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