1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir #include <windows.h>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir /**
32*cdf0e10cSrcweir  ** CWindow:  Our basic window class.
33*cdf0e10cSrcweir  **/
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir class DocumentHolder;
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir namespace winwrap {
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir     void TransformRect(LPRECT rect,HWND pWnd,HWND pWndClipTo);
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 	LRESULT APIENTRY HatchWndProc(
46*cdf0e10cSrcweir 		HWND hWnd, UINT iMsg
47*cdf0e10cSrcweir 		, WPARAM wParam, LPARAM lParam);
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 	BOOL HatchWindowRegister(HINSTANCE hInst);
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir     class CWindow
53*cdf0e10cSrcweir     {
54*cdf0e10cSrcweir     protected:
55*cdf0e10cSrcweir         HINSTANCE   m_hInst;            //Task instance
56*cdf0e10cSrcweir         HWND        m_hWnd;             //Window handle of the window
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir     public:
59*cdf0e10cSrcweir         //Standard Class Functions
60*cdf0e10cSrcweir         CWindow(HINSTANCE);
61*cdf0e10cSrcweir         ~CWindow(void);
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir         //Just returns members.  No need to modify
64*cdf0e10cSrcweir         HWND        Window(void);
65*cdf0e10cSrcweir         HINSTANCE   Instance(void);
66*cdf0e10cSrcweir     };
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     class Tracker {
71*cdf0e10cSrcweir     public:
72*cdf0e10cSrcweir         // Constructors
73*cdf0e10cSrcweir         Tracker();
74*cdf0e10cSrcweir         Tracker(LPCRECT lpSrcRect, UINT nStyle);
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         // Style Flags
77*cdf0e10cSrcweir         enum StyleFlags
78*cdf0e10cSrcweir         {
79*cdf0e10cSrcweir             solidLine = 1, dottedLine = 2, hatchedBorder = 4,
80*cdf0e10cSrcweir             resizeInside = 8, resizeOutside = 16, hatchInside = 32,
81*cdf0e10cSrcweir         };
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir         // Hit-Test codes
84*cdf0e10cSrcweir         enum TrackerHit
85*cdf0e10cSrcweir         {
86*cdf0e10cSrcweir             hitNothing = -1,
87*cdf0e10cSrcweir             hitTopLeft = 0, hitTopRight = 1,
88*cdf0e10cSrcweir             hitBottomRight = 2, hitBottomLeft = 3,
89*cdf0e10cSrcweir             hitTop = 4, hitRight = 5, hitBottom = 6,
90*cdf0e10cSrcweir             hitLeft = 7, hitMiddle = 8
91*cdf0e10cSrcweir         };
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir         // Attributes
94*cdf0e10cSrcweir         UINT m_nStyle;      // current state
95*cdf0e10cSrcweir         RECT m_rect;       // current position (always in pixels)
96*cdf0e10cSrcweir         SIZE m_sizeMin;    // minimum X and Y size during track operation
97*cdf0e10cSrcweir         int m_nHandleSize;  // size of resize handles (default from WIN.INI)
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir         // Operations
100*cdf0e10cSrcweir         void Draw(HDC hDC) const;
101*cdf0e10cSrcweir         void GetTrueRect(LPRECT lpTrueRect) const;
102*cdf0e10cSrcweir         BOOL SetCursor(HWND hWnd,UINT nHitTest) const;
103*cdf0e10cSrcweir         BOOL Track(HWND hWnd,POINT point,BOOL bAllowInvert = FALSE,
104*cdf0e10cSrcweir                    HWND hWndClipTo = NULL);
105*cdf0e10cSrcweir //         BOOL TrackRubberBand(HWND hWnd,POINT point,BOOL bAllowInvert = TRUE);
106*cdf0e10cSrcweir         int HitTest(POINT point) const;
107*cdf0e10cSrcweir         int NormalizeHit(int nHandle) const;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir         // Overridables
110*cdf0e10cSrcweir         virtual void DrawTrackerRect(
111*cdf0e10cSrcweir             LPRECT lpRect, HWND hWndClipTo,
112*cdf0e10cSrcweir             HDC hDC, HWND hWnd);
113*cdf0e10cSrcweir         virtual void AdjustRect(int nHandle, LPRECT lpRect);
114*cdf0e10cSrcweir         virtual void OnChangedRect(const RECT& rectOld);
115*cdf0e10cSrcweir         virtual UINT GetHandleMask() const;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir // Implementation
118*cdf0e10cSrcweir     public:
119*cdf0e10cSrcweir         virtual ~Tracker();
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir protected:
122*cdf0e10cSrcweir         BOOL m_bAllowInvert; // flag passed to Track or TrackRubberBand
123*cdf0e10cSrcweir         RECT m_rectLast;
124*cdf0e10cSrcweir         SIZE m_sizeLast;
125*cdf0e10cSrcweir         BOOL m_bErase;       // TRUE if DrawTrackerRect is called for erasing
126*cdf0e10cSrcweir         BOOL m_bFinalErase;  // TRUE if DragTrackerRect called for final erase
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         // implementation helpers
129*cdf0e10cSrcweir         int HitTestHandles(POINT point) const;
130*cdf0e10cSrcweir         void GetHandleRect(int nHandle,RECT* pHandleRect) const;
131*cdf0e10cSrcweir         void GetModifyPointers(
132*cdf0e10cSrcweir             int nHandle,int**ppx, int**ppy, int* px, int*py);
133*cdf0e10cSrcweir         virtual int GetHandleSize(LPRECT lpRect = NULL) const;
134*cdf0e10cSrcweir         BOOL TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo);
135*cdf0e10cSrcweir         void Construct();
136*cdf0e10cSrcweir     };
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir //Width of the border
141*cdf0e10cSrcweir #define HATCHWIN_BORDERWIDTHDEFAULT     4
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     class CHatchWin : public CWindow
145*cdf0e10cSrcweir     {
146*cdf0e10cSrcweir         friend LRESULT APIENTRY HatchWndProc(HWND, UINT, WPARAM, LPARAM);
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     public:
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir         const DocumentHolder* m_pDocHolder;
151*cdf0e10cSrcweir         Tracker               m_aTracker;
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir         int         m_dBorder;
154*cdf0e10cSrcweir         int         m_dBorderOrg;
155*cdf0e10cSrcweir         UINT        m_uID;
156*cdf0e10cSrcweir         HWND        m_hWndParent;
157*cdf0e10cSrcweir         HWND        m_hWndKid;
158*cdf0e10cSrcweir         HWND        m_hWndAssociate;
159*cdf0e10cSrcweir         RECT        m_rcPos;
160*cdf0e10cSrcweir         RECT        m_rcClip;
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     public:
163*cdf0e10cSrcweir         CHatchWin(HINSTANCE,const DocumentHolder*);
164*cdf0e10cSrcweir         ~CHatchWin(void);
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir         BOOL        Init(HWND, UINT, HWND);
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir         HWND        HwndAssociateSet(HWND);
169*cdf0e10cSrcweir         HWND        HwndAssociateGet(void);
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir         void        RectsSet(LPRECT, LPRECT);
172*cdf0e10cSrcweir         void        ChildSet(HWND);
173*cdf0e10cSrcweir         void        ShowHatch(BOOL);
174*cdf0e10cSrcweir         void        SetTrans();
175*cdf0e10cSrcweir     };
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir }
178