Home | History | Annotate | Download | only in fwl
      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_FWL_CFWL_FORM_H_
      8 #define XFA_FWL_CFWL_FORM_H_
      9 
     10 #include <memory>
     11 
     12 #include "core/fxcrt/fx_system.h"
     13 #include "xfa/fwl/cfwl_widget.h"
     14 #include "xfa/fwl/cfwl_widgetproperties.h"
     15 
     16 #define FWL_CLASS_Form L"FWL_FORM"
     17 #define FWL_CLASS_FormProxy L"FWL_FORMPROXY"
     18 
     19 #if (_FX_OS_ == _FX_MACOSX_)
     20 #define FWL_UseMacSystemBorder
     21 #endif
     22 
     23 class CFWL_MessageMouse;
     24 class CFWL_NoteLoop;
     25 class CFWL_Widget;
     26 class IFWL_ThemeProvider;
     27 
     28 class CFWL_Form : public CFWL_Widget {
     29  public:
     30   CFWL_Form(const CFWL_App* app,
     31             std::unique_ptr<CFWL_WidgetProperties> properties,
     32             CFWL_Widget* pOuter);
     33   ~CFWL_Form() override;
     34 
     35   // CFWL_Widget
     36   FWL_Type GetClassID() const override;
     37   bool IsInstance(const CFX_WideStringC& wsClass) const override;
     38   CFX_RectF GetClientRect() override;
     39   void Update() override;
     40   FWL_WidgetHit HitTest(const CFX_PointF& point) override;
     41   void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
     42   void OnProcessMessage(CFWL_Message* pMessage) override;
     43   void OnDrawWidget(CFX_Graphics* pGraphics,
     44                     const CFX_Matrix* pMatrix) override;
     45 
     46   CFWL_Widget* DoModal();
     47   void EndDoModal();
     48 
     49   CFWL_Widget* GetSubFocus() const { return m_pSubFocus; }
     50   void SetSubFocus(CFWL_Widget* pWidget) { m_pSubFocus = pWidget; }
     51 
     52  private:
     53   void DrawBackground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme);
     54   CFX_RectF GetEdgeRect();
     55   void SetWorkAreaRect();
     56   void Layout();
     57   void RegisterForm();
     58   void UnRegisterForm();
     59   void OnLButtonDown(CFWL_MessageMouse* pMsg);
     60   void OnLButtonUp(CFWL_MessageMouse* pMsg);
     61 
     62   CFX_RectF m_rtRestore;
     63   CFX_RectF m_rtRelative;
     64   std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop;
     65   CFWL_Widget* m_pSubFocus;
     66   FX_FLOAT m_fCXBorder;
     67   FX_FLOAT m_fCYBorder;
     68 };
     69 
     70 #endif  // XFA_FWL_CFWL_FORM_H_
     71