1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_EMBEDSERV_SOURCE_INC_SYSWINWRAPPER_HXX 21 #define INCLUDED_EMBEDSERV_SOURCE_INC_SYSWINWRAPPER_HXX 22 23 #if !defined WIN32_LEAN_AND_MEAN 24 # define WIN32_LEAN_AND_MEAN 25 #endif 26 #include <windows.h> 27 28 /** 29 ** CWindow: Our basic window class. 30 **/ 31 32 33 class DocumentHolder; 34 35 36 namespace winwrap { 37 38 39 void TransformRect(LPRECT rect,HWND pWnd,HWND pWndClipTo); 40 41 42 LRESULT APIENTRY HatchWndProc( 43 HWND hWnd, UINT iMsg 44 , WPARAM wParam, LPARAM lParam); 45 46 47 BOOL HatchWindowRegister(HINSTANCE hInst); 48 49 class CWindow 50 { 51 protected: 52 HINSTANCE m_hInst; //Task instance 53 HWND m_hWnd; //Window handle of the window 54 55 public: 56 //Standard Class Functions 57 CWindow(HINSTANCE); 58 ~CWindow(); 59 60 //Just returns members. No need to modify 61 HWND Window(); 62 HINSTANCE Instance(); 63 }; 64 65 66 class Tracker { 67 public: 68 // Constructors 69 Tracker(); 70 Tracker(LPCRECT lpSrcRect, UINT nStyle); 71 72 // Style Flags 73 enum StyleFlags 74 { 75 solidLine = 1, dottedLine = 2, hatchedBorder = 4, 76 resizeInside = 8, resizeOutside = 16, hatchInside = 32, 77 }; 78 79 // Hit-Test codes 80 enum TrackerHit 81 { 82 hitNothing = -1, 83 hitTopLeft = 0, hitTopRight = 1, 84 hitBottomRight = 2, hitBottomLeft = 3, 85 hitTop = 4, hitRight = 5, hitBottom = 6, 86 hitLeft = 7, hitMiddle = 8 87 }; 88 89 // Attributes 90 UINT m_nStyle; // current state 91 RECT m_rect; // current position (always in pixels) 92 SIZE m_sizeMin; // minimum X and Y size during track operation 93 int m_nHandleSize; // size of resize handles (default from WIN.INI) 94 95 // Operations 96 void Draw(HDC hDC) const; 97 void GetTrueRect(LPRECT lpTrueRect) const; 98 BOOL SetCursor(HWND hWnd,UINT nHitTest) const; 99 BOOL Track(HWND hWnd,POINT point,BOOL bAllowInvert = FALSE, 100 HWND hWndClipTo = nullptr); 101 // BOOL TrackRubberBand(HWND hWnd,POINT point,BOOL bAllowInvert = TRUE); 102 int HitTest(POINT point) const; 103 int NormalizeHit(int nHandle) const; 104 105 // Overridables 106 virtual void DrawTrackerRect( 107 LPRECT lpRect, HWND hWndClipTo, 108 HDC hDC, HWND hWnd); 109 virtual void AdjustRect(int nHandle, LPRECT lpRect); 110 virtual void OnChangedRect(const RECT& rectOld); 111 virtual UINT GetHandleMask() const; 112 113 // Implementation 114 public: 115 virtual ~Tracker(); 116 117 protected: 118 BOOL m_bAllowInvert; // flag passed to Track or TrackRubberBand 119 RECT m_rectLast; 120 SIZE m_sizeLast; 121 BOOL m_bErase; // TRUE if DrawTrackerRect is called for erasing 122 BOOL m_bFinalErase; // TRUE if DragTrackerRect called for final erase 123 124 // implementation helpers 125 int HitTestHandles(POINT point) const; 126 void GetHandleRect(int nHandle,RECT* pHandleRect) const; 127 void GetModifyPointers( 128 int nHandle,int**ppx, int**ppy, int* px, int*py); 129 virtual int GetHandleSize(LPRECT lpRect = nullptr) const; 130 BOOL TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo); 131 void Construct(); 132 }; 133 134 135 //Width of the border 136 #define HATCHWIN_BORDERWIDTHDEFAULT 4 137 138 139 class CHatchWin : public CWindow 140 { 141 friend LRESULT APIENTRY HatchWndProc(HWND, UINT, WPARAM, LPARAM); 142 143 public: 144 145 const DocumentHolder* m_pDocHolder; 146 Tracker m_aTracker; 147 148 int m_dBorder; 149 int m_dBorderOrg; 150 WORD m_uID; 151 HWND m_hWndParent; 152 HWND m_hWndKid; 153 HWND m_hWndAssociate; 154 RECT m_rcPos; 155 RECT m_rcClip; 156 157 public: 158 CHatchWin(HINSTANCE,const DocumentHolder*); 159 ~CHatchWin(); 160 161 BOOL Init(HWND, WORD, HWND); 162 163 HWND HwndAssociateSet(HWND); 164 HWND HwndAssociateGet(); 165 166 void RectsSet(LPRECT, LPRECT); 167 void ChildSet(HWND); 168 void ShowHatch(BOOL); 169 void SetTrans(); 170 }; 171 172 } 173 174 #endif // INCLUDED_EMBEDSERV_SOURCE_INC_SYSWINWRAPPER_HXX 175 176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 177