| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef XFA_SRC_FWL_CORE_FWL_FORMIMP_H_ | |
| 8 #define XFA_SRC_FWL_CORE_FWL_FORMIMP_H_ | |
| 9 | |
| 10 #include "xfa/include/fwl/core/fwl_form.h" | |
| 11 #include "xfa/src/fwl/core/fwl_panelimp.h" | |
| 12 #include "xfa/src/fwl/core/fwl_widgetimp.h" | |
| 13 | |
| 14 class CFWL_NoteLoop; | |
| 15 class CFWL_WidgetImpProperties; | |
| 16 class CFWL_MsgMouse; | |
| 17 class IFWL_Widget; | |
| 18 class IFWL_ThemeProvider; | |
| 19 class CFWL_SysBtn; | |
| 20 class CFWL_FormImp; | |
| 21 class CFWL_FormImpDelegate; | |
| 22 | |
| 23 #define FWL_SYSBUTTONSTATE_Hover 0x0001 | |
| 24 #define FWL_SYSBUTTONSTATE_Pressed 0x0002 | |
| 25 #define FWL_SYSBUTTONSTATE_Disabled 0x0010 | |
| 26 class CFWL_SysBtn { | |
| 27 public: | |
| 28 CFWL_SysBtn() { | |
| 29 m_rtBtn.Set(0, 0, 0, 0); | |
| 30 m_dwState = 0; | |
| 31 } | |
| 32 | |
| 33 FX_BOOL IsHover() { return m_dwState & FWL_SYSBUTTONSTATE_Hover; } | |
| 34 FX_BOOL IsPressed() { return m_dwState & FWL_SYSBUTTONSTATE_Pressed; } | |
| 35 FX_BOOL IsDisabled() { return m_dwState & FWL_SYSBUTTONSTATE_Disabled; } | |
| 36 void SetNormal() { m_dwState &= 0xFFF0; } | |
| 37 void SetPressed() { | |
| 38 SetNormal(); | |
| 39 m_dwState |= FWL_SYSBUTTONSTATE_Pressed; | |
| 40 } | |
| 41 void SetHover() { | |
| 42 SetNormal(); | |
| 43 m_dwState |= FWL_SYSBUTTONSTATE_Hover; | |
| 44 } | |
| 45 void SetDisabled(FX_BOOL bDisabled) { | |
| 46 bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled | |
| 47 : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled; | |
| 48 } | |
| 49 int32_t GetPartState() { | |
| 50 return (IsDisabled() ? FWL_PARTSTATE_FRM_Disabled : (m_dwState + 1)); | |
| 51 } | |
| 52 | |
| 53 CFX_RectF m_rtBtn; | |
| 54 FX_DWORD m_dwState; | |
| 55 }; | |
| 56 enum FORM_RESIZETYPE { | |
| 57 FORM_RESIZETYPE_None = 0, | |
| 58 FORM_RESIZETYPE_Cap, | |
| 59 FORM_RESIZETYPE_Left, | |
| 60 FORM_RESIZETYPE_Top, | |
| 61 FORM_RESIZETYPE_Right, | |
| 62 FORM_RESIZETYPE_Bottom, | |
| 63 FORM_RESIZETYPE_LeftTop, | |
| 64 FORM_RESIZETYPE_LeftBottom, | |
| 65 FORM_RESIZETYPE_RightTop, | |
| 66 FORM_RESIZETYPE_RightBottom | |
| 67 }; | |
| 68 typedef struct RestoreResizeInfo { | |
| 69 CFX_PointF m_ptStart; | |
| 70 CFX_SizeF m_szStart; | |
| 71 } RestoreInfo; | |
| 72 class CFWL_FormImp : public CFWL_PanelImp { | |
| 73 public: | |
| 74 CFWL_FormImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); | |
| 75 virtual ~CFWL_FormImp(); | |
| 76 virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const; | |
| 77 virtual FX_DWORD GetClassID() const; | |
| 78 virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; | |
| 79 virtual FWL_ERR Initialize(); | |
| 80 virtual FWL_ERR Finalize(); | |
| 81 | |
| 82 virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); | |
| 83 virtual FWL_ERR GetClientRect(CFX_RectF& rect); | |
| 84 virtual FWL_ERR Update(); | |
| 85 virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy); | |
| 86 virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics, | |
| 87 const CFX_Matrix* pMatrix = NULL); | |
| 88 virtual FWL_FORMSIZE GetFormSize(); | |
| 89 virtual FWL_ERR SetFormSize(FWL_FORMSIZE eFormSize); | |
| 90 virtual IFWL_Widget* DoModal(); | |
| 91 virtual IFWL_Widget* DoModal(FX_DWORD& dwCommandID); | |
| 92 virtual FWL_ERR EndDoModal(); | |
| 93 virtual FWL_ERR SetBorderRegion(CFX_Path* pPath); | |
| 94 virtual void DrawBackground(CFX_Graphics* pGraphics, | |
| 95 IFWL_ThemeProvider* pTheme); | |
| 96 CFWL_WidgetImp* GetSubFocus(); | |
| 97 void SetSubFocus(CFWL_WidgetImp* pWidget); | |
| 98 CFX_MapAccelerators& GetAccelerator(); | |
| 99 void SetAccelerator(CFX_MapAccelerators* pAccelerators); | |
| 100 | |
| 101 protected: | |
| 102 void ShowChildWidget(IFWL_Widget* pParent); | |
| 103 void RemoveSysButtons(); | |
| 104 void CalcContentRect(CFX_RectF& rtContent); | |
| 105 CFWL_SysBtn* GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy); | |
| 106 CFWL_SysBtn* GetSysBtnByState(FX_DWORD dwState); | |
| 107 CFWL_SysBtn* GetSysBtnByIndex(int32_t nIndex); | |
| 108 int32_t GetSysBtnIndex(CFWL_SysBtn* pBtn); | |
| 109 FX_FLOAT GetCaptionHeight(); | |
| 110 void DrawCaptionText(CFX_Graphics* pGs, | |
| 111 IFWL_ThemeProvider* pTheme, | |
| 112 const CFX_Matrix* pMatrix = NULL); | |
| 113 void DrawIconImage(CFX_Graphics* pGs, | |
| 114 IFWL_ThemeProvider* pTheme, | |
| 115 const CFX_Matrix* pMatrix = NULL); | |
| 116 void GetEdgeRect(CFX_RectF& rtEdge); | |
| 117 void SetWorkAreaRect(); | |
| 118 void SetCursor(FX_FLOAT fx, FX_FLOAT fy); | |
| 119 void Layout(); | |
| 120 void ReSetSysBtn(); | |
| 121 void RegisterForm(); | |
| 122 void UnRegisterForm(); | |
| 123 FX_BOOL IsDoModal(); | |
| 124 void SetThemeData(); | |
| 125 FX_BOOL HasIcon(); | |
| 126 void UpdateIcon(); | |
| 127 void UpdateCaption(); | |
| 128 void DoWidthLimit(FX_FLOAT& fLeft, | |
| 129 FX_FLOAT& fWidth, | |
| 130 FX_FLOAT fCurX, | |
| 131 FX_FLOAT fSpace, | |
| 132 FX_FLOAT fLimitMin, | |
| 133 FX_FLOAT fLimitMax, | |
| 134 FX_BOOL bLeft); | |
| 135 void DoHeightLimit(FX_FLOAT& fTop, | |
| 136 FX_FLOAT& fHeight, | |
| 137 FX_FLOAT fCurY, | |
| 138 FX_FLOAT fSpace, | |
| 139 FX_FLOAT fLimitMin, | |
| 140 FX_FLOAT fLimitMax, | |
| 141 FX_BOOL bTop); | |
| 142 CFX_MapAccelerators m_mapAccelerators; | |
| 143 CFX_RectF m_rtRestore; | |
| 144 CFX_RectF m_rtCaptionText; | |
| 145 CFX_RectF m_rtRelative; | |
| 146 CFX_RectF m_rtCaption; | |
| 147 CFX_RectF m_rtIcon; | |
| 148 CFWL_SysBtn* m_pCloseBox; | |
| 149 CFWL_SysBtn* m_pMinBox; | |
| 150 CFWL_SysBtn* m_pMaxBox; | |
| 151 CFWL_SysBtn* m_pCaptionBox; | |
| 152 CFWL_NoteLoop* m_pNoteLoop; | |
| 153 CFWL_WidgetImp* m_pSubFocus; | |
| 154 RestoreInfo m_InfoStart; | |
| 155 FX_FLOAT m_fCXBorder; | |
| 156 FX_FLOAT m_fCYBorder; | |
| 157 int32_t m_iCaptureBtn; | |
| 158 int32_t m_iSysBox; | |
| 159 int32_t m_eResizeType; | |
| 160 FX_BOOL m_bLButtonDown; | |
| 161 FX_BOOL m_bMaximized; | |
| 162 FX_BOOL m_bSetMaximize; | |
| 163 FX_BOOL m_bCustomizeLayout; | |
| 164 FWL_FORMSIZE m_eFormSize; | |
| 165 FX_BOOL m_bDoModalFlag; | |
| 166 FX_FLOAT m_fSmallIconSz; | |
| 167 FX_FLOAT m_fBigIconSz; | |
| 168 CFX_DIBitmap* m_pBigIcon; | |
| 169 CFX_DIBitmap* m_pSmallIcon; | |
| 170 FX_BOOL m_bMouseIn; | |
| 171 friend class CFWL_FormImpDelegate; | |
| 172 }; | |
| 173 class CFWL_FormImpDelegate : public CFWL_WidgetImpDelegate { | |
| 174 public: | |
| 175 CFWL_FormImpDelegate(CFWL_FormImp* pOwner); | |
| 176 int32_t OnProcessMessage(CFWL_Message* pMessage) override; | |
| 177 FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override; | |
| 178 FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics, | |
| 179 const CFX_Matrix* pMatrix = NULL) override; | |
| 180 | |
| 181 protected: | |
| 182 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 183 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
| 184 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
| 185 void OnMouseHover(CFWL_MsgMouse* pMsg); | |
| 186 void OnMouseLeave(CFWL_MsgMouse* pMsg); | |
| 187 void OnLButtonDblClk(CFWL_MsgMouse* pMsg); | |
| 188 void OnWindowMove(CFWL_MsgWindowMove* pMsg); | |
| 189 void OnClose(CFWL_MsgClose* pMsg); | |
| 190 CFWL_FormImp* m_pOwner; | |
| 191 }; | |
| 192 | |
| 193 #endif // XFA_SRC_FWL_CORE_FWL_FORMIMP_H_ | |
| OLD | NEW |