Home | History | Annotate | Download | only in include
      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 _FWL_WIDGETMGR_IMP_H
      8 #define _FWL_WIDGETMGR_IMP_H
      9 class CFWL_TargetImp;
     10 class IFWL_Widget;
     11 class IFWL_AdapterWidgetMgr;
     12 class CFWL_WidgetMgrItem;
     13 class CFWL_WidgetMgr;
     14 class CFWL_WidgetMgrDelegate;
     15 class IFWL_AdapterNative;
     16 class CFWL_WidgetMgrItem {
     17  public:
     18   CFWL_WidgetMgrItem()
     19       : pParent(NULL),
     20         pOwner(NULL),
     21         pChild(NULL),
     22         pPrevious(NULL),
     23         pNext(NULL),
     24         pWidget(NULL),
     25         pOffscreen(NULL),
     26         iRedrawCounter(0)
     27 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
     28         ,
     29         bOutsideChanged(FALSE)
     30 #endif
     31   {
     32   }
     33   ~CFWL_WidgetMgrItem() {
     34     if (pOffscreen) {
     35       delete pOffscreen;
     36       pOffscreen = NULL;
     37     }
     38   }
     39   CFWL_WidgetMgrItem* pParent;
     40   CFWL_WidgetMgrItem* pOwner;
     41   CFWL_WidgetMgrItem* pChild;
     42   CFWL_WidgetMgrItem* pPrevious;
     43   CFWL_WidgetMgrItem* pNext;
     44   IFWL_Widget* pWidget;
     45   CFX_Graphics* pOffscreen;
     46   int32_t iRedrawCounter;
     47 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
     48   FX_BOOL bOutsideChanged;
     49 #endif
     50 };
     51 
     52 class CFWL_WidgetMgr : public IFWL_WidgetMgr {
     53  public:
     54   CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative);
     55   ~CFWL_WidgetMgr() override;
     56 
     57   // IFWL_WidgetMgr:
     58   int32_t CountWidgets(IFWL_Widget* pParent = NULL) override;
     59   IFWL_Widget* GetWidget(int32_t nIndex, IFWL_Widget* pParent = NULL) override;
     60   IFWL_Widget* GetWidget(IFWL_Widget* pWidget,
     61                          FWL_WGTRELATION eRelation) override;
     62   int32_t GetWidgetIndex(IFWL_Widget* pWidget) override;
     63   FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) override;
     64   FWL_ERR RepaintWidget(IFWL_Widget* pWidget,
     65                         const CFX_RectF* pRect = NULL) override;
     66   FX_DWORD GetCapability() override { return m_dwCapability; }
     67 
     68   void AddWidget(IFWL_Widget* pWidget);
     69   void InsertWidget(IFWL_Widget* pParent,
     70                     IFWL_Widget* pChild,
     71                     int32_t nIndex = -1);
     72   void RemoveWidget(IFWL_Widget* pWidget);
     73   void SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned);
     74   void SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild);
     75   FX_BOOL IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent);
     76   FWL_ERR CreateWidget_Native(IFWL_Widget* pWidget);
     77   FWL_ERR DestroyWidget_Native(IFWL_Widget* pWidget);
     78   FWL_ERR GetWidgetRect_Native(IFWL_Widget* pWidget, CFX_RectF& rect);
     79   FWL_ERR SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect);
     80   FWL_ERR SetWidgetPosition_Native(IFWL_Widget* pWidget,
     81                                    FX_FLOAT fx,
     82                                    FX_FLOAT fy);
     83   FWL_ERR SetWidgetIcon_Native(IFWL_Widget* pWidget,
     84                                const CFX_DIBitmap* pIcon,
     85                                FX_BOOL bBig);
     86   FWL_ERR SetWidgetCaption_Native(IFWL_Widget* pWidget,
     87                                   const CFX_WideStringC& wsCaption);
     88   FWL_ERR SetBorderRegion_Native(IFWL_Widget* pWidget, CFX_Path* pPath);
     89   FWL_ERR ShowWidget_Native(IFWL_Widget* pWidget);
     90   FWL_ERR HideWidget_Native(IFWL_Widget* pWidget);
     91   FWL_ERR SetNormal_Native(IFWL_Widget* pWidget);
     92   FWL_ERR SetMaximize_Native(IFWL_Widget* pWidget);
     93   FWL_ERR SetMinimize_Native(IFWL_Widget* pWidget);
     94   FX_BOOL CheckMessage_Native();
     95   FWL_ERR DispatchMessage_Native();
     96   FX_BOOL IsIdleMessage_Native();
     97   FWL_ERR Exit_Native(int32_t iExitCode);
     98   FWL_ERR CreateWidgetWithNativeId_Native(IFWL_Widget* pWidget, void* vp);
     99   IFWL_Widget* GetWidgetAtPoint(IFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy);
    100   void NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy);
    101   IFWL_Widget* nextTab(IFWL_Widget* parent, IFWL_Widget* focus, FX_BOOL& bFind);
    102   int32_t CountRadioButtonGroup(IFWL_Widget* pFirst);
    103   IFWL_Widget* GetSiblingRadioButton(IFWL_Widget* pWidget, FX_BOOL bNext);
    104   IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton);
    105   void GetSameGroupRadioButton(IFWL_Widget* pRadioButton, CFX_PtrArray& group);
    106   IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent);
    107   void AddRedrawCounts(IFWL_Widget* pWidget);
    108   void ResetRedrawCounts(IFWL_Widget* pWidget);
    109   IFWL_AdapterWidgetMgr* GetAdapterWidgetMgr() { return m_pAdapter; }
    110   CFWL_WidgetMgrDelegate* GetDelegate() { return m_pDelegate; }
    111   CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget);
    112   FX_BOOL IsThreadEnabled();
    113   FX_BOOL IsFormDisabled();
    114   FX_BOOL GetAdapterPopupPos(IFWL_Widget* pWidget,
    115                              FX_FLOAT fMinHeight,
    116                              FX_FLOAT fMaxHeight,
    117                              const CFX_RectF& rtAnchor,
    118                              CFX_RectF& rtPopup);
    119 
    120  protected:
    121   int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent,
    122                           int32_t* pIndex,
    123                           CFWL_WidgetMgrItem* pItem,
    124                           IFWL_Widget** pWidget = NULL);
    125   FX_BOOL IsAbleNative(IFWL_Widget* pWidget);
    126   CFX_MapPtrToPtr m_mapWidgetItem;
    127   IFWL_AdapterWidgetMgr* m_pAdapter;
    128   CFWL_WidgetMgrDelegate* m_pDelegate;
    129   friend class CFWL_WidgetMgrDelegate;
    130   FX_DWORD m_dwCapability;
    131 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
    132   CFX_RectF m_rtScreen;
    133 #endif
    134 };
    135 
    136 class CFWL_WidgetMgrDelegate : public IFWL_WidgetMgrDelegate {
    137  public:
    138   CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr);
    139   ~CFWL_WidgetMgrDelegate() override {}
    140 
    141   // IFWL_WidgetMgrDelegate:
    142   FWL_ERR OnSetCapability(
    143       FX_DWORD dwCapability = FWL_WGTMGR_DisableThread) override;
    144   int32_t OnProcessMessageToForm(CFWL_Message* pMessage) override;
    145   FWL_ERR OnDrawWidget(IFWL_Widget* pWidget,
    146                        CFX_Graphics* pGraphics,
    147                        const CFX_Matrix* pMatrix) override;
    148 
    149  protected:
    150   void DrawChild(IFWL_Widget* pParent,
    151                  const CFX_RectF& rtClip,
    152                  CFX_Graphics* pGraphics,
    153                  const CFX_Matrix* pMatrix);
    154   CFX_Graphics* DrawWidgetBefore(IFWL_Widget* pWidget,
    155                                  CFX_Graphics* pGraphics,
    156                                  const CFX_Matrix* pMatrix);
    157   void DrawWidgetAfter(IFWL_Widget* pWidget,
    158                        CFX_Graphics* pGraphics,
    159                        CFX_RectF& rtClip,
    160                        const CFX_Matrix* pMatrix);
    161   FX_BOOL IsNeedRepaint(IFWL_Widget* pWidget,
    162                         CFX_Matrix* pMatrix,
    163                         const CFX_RectF& rtDirty);
    164   FX_BOOL bUseOffscreenDirect(IFWL_Widget* pWidget);
    165 
    166   CFWL_WidgetMgr* m_pWidgetMgr;
    167 };
    168 #endif
    169