FX Bool considered harmful, part 3
[pdfium.git] / fpdfsdk / include / pdfwindow / PWL_ComboBox.h
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 FPDFSDK_INCLUDE_PDFWINDOW_PWL_COMBOBOX_H_
8 #define FPDFSDK_INCLUDE_PDFWINDOW_PWL_COMBOBOX_H_
9
10 #include "PWL_Edit.h"
11 #include "PWL_ListBox.h"
12 #include "PWL_Wnd.h"
13
14 class CPWL_CBEdit : public CPWL_Edit
15 {
16 public:
17         CPWL_CBEdit(){};
18         virtual ~CPWL_CBEdit(){};
19 };
20
21 class PWL_CLASS CPWL_CBListBox : public CPWL_ListBox
22 {
23 public:
24         CPWL_CBListBox(){};
25         virtual ~CPWL_CBListBox(){};
26
27 public:
28         virtual bool                            OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag);
29
30         bool                            OnKeyDownWithExit(FX_WORD nChar, bool & bExit, FX_DWORD nFlag);
31         bool                            OnCharWithExit(FX_WORD nChar, bool & bExit, FX_DWORD nFlag);
32 };
33
34 #define PWL_COMBOBOX_BUTTON_WIDTH               13
35
36 class CPWL_CBButton : public CPWL_Wnd
37 {
38 public:
39         CPWL_CBButton(){};
40         virtual ~CPWL_CBButton(){};
41
42 public:
43         virtual void                            GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream);
44         virtual void                            DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device);
45
46         virtual bool                            OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag);
47         virtual bool                            OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag);
48
49 };
50
51 class PWL_CLASS CPWL_ComboBox : public CPWL_Wnd
52 {
53 public:
54         CPWL_ComboBox();
55         operator CPWL_Edit* ()          {return m_pEdit;}
56
57 public:
58         virtual CFX_ByteString          GetClassName() const;
59         virtual void                            OnCreate(PWL_CREATEPARAM & cp);
60
61         virtual bool                            OnKeyDown(FX_WORD nChar, FX_DWORD nFlag);
62         virtual bool                            OnChar(FX_WORD nChar, FX_DWORD nFlag);
63
64         virtual void                            OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0);
65
66         virtual void                            CreateChildWnd(const PWL_CREATEPARAM & cp);
67         virtual void                            RePosChildWnd();
68
69         virtual CPDF_Rect                       GetFocusRect() const;
70
71         virtual void                            SetFocus();
72         virtual void                            KillFocus();
73
74         bool                                            IsModified() const;
75
76 public:
77         void                                            SetFillerNotify(IPWL_Filler_Notify* pNotify);
78
79         CFX_WideString                          GetText() const;
80         void                                            SetText(const FX_WCHAR* text);
81
82         void                                            AddString(const FX_WCHAR* string);
83         int32_t                                 GetSelect() const;
84         void                                            SetSelect(int32_t nItemIndex);
85
86         void                                            SetEditSel(int32_t nStartChar,int32_t nEndChar);
87         void                                            GetEditSel(int32_t & nStartChar, int32_t & nEndChar ) const;
88         void                                            Clear();
89         void                                            SelectAll();
90         bool                                            IsPopup() const;
91
92         void                                            SetSelectText();
93
94 private:
95         void                                            CreateEdit(const PWL_CREATEPARAM & cp);
96         void                                            CreateButton(const PWL_CREATEPARAM & cp);
97         void                                            CreateListBox(const PWL_CREATEPARAM & cp);
98
99         void                                            SetPopup(bool bPopup);
100
101 private:
102         CPWL_CBEdit*                            m_pEdit;
103         CPWL_CBButton*                          m_pButton;
104         CPWL_CBListBox*                         m_pList;
105
106         bool                                            m_bPopup;
107         CPDF_Rect                                       m_rcOldWindow;
108         int32_t                                 m_nPopupWhere;
109         int32_t                                 m_nSelectItem;
110         IPWL_Filler_Notify*                     m_pFillerNotify;
111
112 public:
113         void                                                    AttachFFLData(void* pData) {m_pFormFiller = pData;}
114 private:
115         void*                                                   m_pFormFiller;
116 };
117
118 #endif  // FPDFSDK_INCLUDE_PDFWINDOW_PWL_COMBOBOX_H_