• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 _PWL_IconList_H_
8 #define _PWL_IconList_H_
9 
10 class IPWL_IconList_Notify;
11 class CPWL_IconList_Item;
12 class CPWL_IconList_Content;
13 class CPWL_IconList;
14 class CPWL_Label;
15 
16 class IPWL_IconList_Notify
17 {
18 public:
19 	virtual void						OnNoteListSelChanged(FX_INT32 nItemIndex) = 0;
20 };
21 
22 class CPWL_IconList_Item : public CPWL_Wnd
23 {
24 public:
25 	CPWL_IconList_Item();
26 	virtual ~CPWL_IconList_Item();
27 
28 	virtual CFX_ByteString				GetClassName() const;
29 	virtual void						CreateChildWnd(const PWL_CREATEPARAM & cp);
30 	virtual void						RePosChildWnd();
31 
32 	void								SetSelect(FX_BOOL bSelected);
33 	FX_BOOL								IsSelected() const;
34 	void								SetData(void* pData);
35 	void								SetIcon(FX_INT32 nIconIndex);
36 	void								SetText(const CFX_WideString& str);
37 	void								SetIconFillColor(const CPWL_Color& color);
38 	CFX_WideString						GetText() const;
39 
40 protected:
41 	virtual FX_FLOAT					GetItemHeight(FX_FLOAT fLimitWidth);
42 	virtual void						DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device);
43 
44 	virtual void						OnEnabled();
45 	virtual void						OnDisabled();
46 
47 private:
48 	FX_INT32							m_nIconIndex;
49 	void*								m_pData;
50 	FX_BOOL								m_bSelected;
51 	CPWL_Label*							m_pText;
52 	CPWL_Color							m_crIcon;
53 };
54 
55 class CPWL_IconList_Content : public CPWL_ListCtrl
56 {
57 public:
58 	CPWL_IconList_Content(FX_INT32 nListCount);
59 	virtual ~CPWL_IconList_Content();
60 
61 	void								SetSelect(FX_INT32 nIndex);
62 	FX_INT32							GetSelect() const;
63 	void								SetNotify(IPWL_IconList_Notify* pNotify);
64 	void								EnableNotify(FX_BOOL bNotify);
65 	void								SetListData(FX_INT32 nItemIndex, void* pData);
66 	void								SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex);
67 	void								SetListString(FX_INT32 nItemIndex, const CFX_WideString& str);
68 	void								SetIconFillColor(const CPWL_Color& color);
69 	CFX_WideString						GetListString(FX_INT32 nItemIndex) const;
70 	IPWL_IconList_Notify*				GetNotify() const;
71 	void								ScrollToItem(FX_INT32 nItemIndex);
72 
73 protected:
74 	virtual void						CreateChildWnd(const PWL_CREATEPARAM & cp);
75 	virtual FX_BOOL						OnLButtonDown(const CPDF_Point & point);
76 	virtual FX_BOOL						OnLButtonUp(const CPDF_Point & point);
77 	virtual FX_BOOL						OnMouseMove(const CPDF_Point & point);
78 	virtual FX_BOOL						OnKeyDown(FX_WORD nChar);
79 
80 private:
81 	CPWL_IconList_Item*					GetListItem(FX_INT32 nItemIndex) const;
82 	void								SelectItem(FX_INT32 nItemIndex, FX_BOOL bSelect);
83 	FX_INT32							FindItemIndex(const CPDF_Point& point);
84 
85 	FX_BOOL								m_nSelectIndex;
86 	IPWL_IconList_Notify*				m_pNotify;
87 	FX_BOOL								m_bEnableNotify;
88 	FX_BOOL								m_bMouseDown;
89 	FX_INT32							m_nListCount;
90 };
91 
92 class PWL_CLASS CPWL_IconList : public CPWL_Wnd
93 {
94 public:
95 	CPWL_IconList(FX_INT32 nListCount);
96 	virtual ~CPWL_IconList();
97 
98 	virtual FX_BOOL						OnMouseWheel(short zDelta, const CPDF_Point & point);
99 
100 	void								SetSelect(FX_INT32 nIndex);
101 	void								SetTopItem(FX_INT32 nIndex);
102 	FX_INT32							GetSelect() const;
103 	void								SetNotify(IPWL_IconList_Notify* pNotify);
104 	void								EnableNotify(FX_BOOL bNotify);
105 	void								SetListData(FX_INT32 nItemIndex, void* pData);
106 	void								SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex);
107 	void								SetListString(FX_INT32 nItemIndex, const CFX_WideString& str);
108 	void								SetIconFillColor(const CPWL_Color& color);
109 	CFX_WideString						GetListString(FX_INT32 nItemIndex) const;
110 
111 protected:
112 	virtual void						OnCreated();
113 	virtual void						RePosChildWnd();
114 	virtual void						CreateChildWnd(const PWL_CREATEPARAM & cp);
115 
116 	virtual void						OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0);
117 
118 private:
119 	CPWL_IconList_Content*				m_pListContent;
120 	FX_INT32							m_nListCount;
121 };
122 
123 #endif //_PWL_IconList_H_
124 
125 
126