Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / basewidget / include / fwl_listboximp.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FWL_LISTBOX_IMP_H\r
8 #define _FWL_LISTBOX_IMP_H\r
9 class CFWL_WidgetImp;\r
10 class CFWL_WidgetImpProperties;\r
11 class CFWL_WidgetImpDelegate;\r
12 class CFWL_ScrollBarImp;\r
13 class IFWL_Widget;\r
14 class CFWL_ListBoxImp;\r
15 class CFWL_ListBoxImpDelegate;\r
16 class CFWL_ListBoxImp : public CFWL_WidgetImp\r
17 {\r
18 public:\r
19     CFWL_ListBoxImp(IFWL_Widget *pOuter = NULL);\r
20     CFWL_ListBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
21     ~CFWL_ListBoxImp();\r
22     virtual FWL_ERR             GetClassName(CFX_WideString &wsClass) const;\r
23     virtual FX_DWORD    GetClassID() const;\r
24     virtual FWL_ERR             Initialize();\r
25     virtual FWL_ERR             Finalize();\r
26     virtual FWL_ERR             GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);\r
27     virtual     FWL_ERR         Update();\r
28     virtual FX_DWORD    HitTest(FX_FLOAT fx, FX_FLOAT fy);\r
29     virtual FWL_ERR             DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
30     virtual FWL_ERR             SetThemeProvider(IFWL_ThemeProvider *pThemeProvider);\r
31     virtual FX_INT32    CountSelItems();\r
32     virtual FWL_HLISTITEM       GetSelItem(FX_INT32 nIndexSel);\r
33     virtual FX_INT32    GetSelIndex(FX_INT32 nIndex);\r
34     virtual FWL_ERR             SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);\r
35     virtual FWL_ERR             GetItemText(FWL_HLISTITEM hItem, CFX_WideString &wsText);\r
36     virtual FWL_ERR             GetScrollPos(FX_FLOAT &fPos, FX_BOOL bVert = TRUE);\r
37     virtual FWL_ERR*    Sort(IFWL_ListBoxCompare *pCom);\r
38 protected:\r
39     FWL_HLISTITEM GetItem(FWL_HLISTITEM hItem, FX_DWORD dwKeyCode);\r
40     void                SetSelection(FWL_HLISTITEM hStart, FWL_HLISTITEM hEnd, FX_BOOL bSelected);\r
41     void                SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect);\r
42     FX_BOOL             IsItemSelected(FWL_HLISTITEM hItem);\r
43     void                ClearSelection();\r
44     void                SelectAll();\r
45     FWL_HLISTITEM GetFocusedItem();\r
46     void                SetFocusItem(FWL_HLISTITEM hItem);\r
47     FWL_HLISTITEM       GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);\r
48     FX_BOOL                     GetItemCheckRect(FWL_HLISTITEM hItem, CFX_RectF &rtCheck);\r
49     FX_BOOL                     SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked);\r
50     FX_BOOL                     GetItemChecked(FWL_HLISTITEM hItem);\r
51     FX_BOOL             ScrollToVisible(FWL_HLISTITEM hItem);\r
52     void                DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);\r
53     void                DrawItems(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);\r
54     void                DrawItem(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, FWL_HLISTITEM hItem, FX_INT32 Index, const CFX_RectF &rtItem, const CFX_Matrix *pMatrix = NULL);\r
55     void                DrawStatic(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme);\r
56     CFX_SizeF   CalcSize(FX_BOOL bAutoSize = FALSE);\r
57     void                GetItemSize(CFX_SizeF &size, FWL_HLISTITEM hItem, FX_FLOAT fWidth, FX_FLOAT fHeight, FX_BOOL bAutoSize = FALSE);\r
58     FX_FLOAT    GetMaxTextWidth();\r
59     FX_FLOAT    GetScrollWidth();\r
60     FX_FLOAT    GetItemHeigt();\r
61     void                InitScrollBar(FX_BOOL bVert = TRUE);\r
62     void                SortItem();\r
63     FX_BOOL             IsShowScrollBar(FX_BOOL bVert);\r
64     void                ProcessSelChanged();\r
65 protected:\r
66     CFX_RectF                   m_rtClient;\r
67     CFX_RectF                   m_rtStatic;\r
68     CFX_RectF                   m_rtConent;\r
69     IFWL_ScrollBar*             m_pHorzScrollBar;\r
70     IFWL_ScrollBar*             m_pVertScrollBar;\r
71     FX_DWORD                    m_dwTTOStyles;\r
72     FX_INT32                    m_iTTOAligns;\r
73     FWL_HLISTITEM               m_hAnchor;\r
74     FX_FLOAT                    m_fItemHeight;\r
75     FX_FLOAT                    m_fScorllBarWidth;\r
76     FX_BOOL                             m_bLButtonDown;\r
77     IFWL_ThemeProvider *m_pScrollBarTP;\r
78     friend class CFWL_ListBoxImpDelegate;\r
79 };\r
80 class CFWL_ListBoxImpDelegate : public CFWL_WidgetImpDelegate\r
81 {\r
82 public:\r
83     CFWL_ListBoxImpDelegate(CFWL_ListBoxImp *pOwner);\r
84     virtual FX_INT32    OnProcessMessage(CFWL_Message *pMessage);\r
85     virtual FWL_ERR             OnProcessEvent(CFWL_Event *pEvent);\r
86     virtual FWL_ERR             OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
87 protected:\r
88     void        OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);\r
89     void        OnLButtonDown(CFWL_MsgMouse *pMsg);\r
90     void        OnLButtonUp(CFWL_MsgMouse *pMsg);\r
91     void        OnMouseWheel(CFWL_MsgMouseWheel *pMsg);\r
92     void        OnKeyDown(CFWL_MsgKey *pMsg);\r
93     void        OnVK(FWL_HLISTITEM hItem, FX_BOOL bShift, FX_BOOL bCtrl);\r
94     FX_BOOL     OnScroll(IFWL_ScrollBar *pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos);\r
95     void        DispatchSelChangedEv();\r
96     CFWL_ListBoxImp     *m_pOwner;\r
97 };\r
98 #endif\r