Apply to remove download listener before deleting _WebImpl
[framework/osp/web.git] / src / controls / FWebCtrl_SelectBox.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FWebCtrl_SelectBox.h
20  * @brief               The file contains the declaration of _SelectBox class.
21  *
22  * The file contains the declaration of _SelectBox class.
23  */
24 #ifndef _FWEB_CTRL_INTERNAL_SELECT_BOX_H_
25 #define _FWEB_CTRL_INTERNAL_SELECT_BOX_H_
26
27 #include <Evas.h>
28 #include <FBaseColIList.h>
29 #include <FBaseString.h>
30 #include <FUiCtrlIListViewItemEventListener.h>
31 #include <FUiCtrlIListViewItemProvider.h>
32 #include <FUi_ControlManager.h>
33 #include "FWebCtrl_WebPopup.h"
34
35 namespace Tizen { namespace Graphics
36 {
37 class Rectangle;
38 }} // Tizen::Graphics
39
40 namespace Tizen { namespace Ui
41 {
42 class IActionEventListener;
43 }} // Tizen::Ui
44
45 namespace Tizen { namespace Ui { namespace Controls
46 {
47 class Button;
48 class GroupedList;
49 class ListItemBase;
50 class ListView;
51 }}} // Tizen::Ui::Controls
52
53 namespace Tizen { namespace Web { namespace Controls
54 {
55
56 enum _ButtonFormat
57 {
58         ID_BUTTON_SELECTION = 5,
59         ID_BUTTON_CANCEL
60 };
61
62
63 class _SelectBox
64         : public _WebPopup
65         , public Tizen::Ui::Controls::IListViewItemEventListener
66         , public Tizen::Ui::Controls::IListViewItemProvider
67 {
68 public:
69         /**
70          * Constructor
71          */
72         _SelectBox(void);
73
74         /**
75          * Destructor
76          */
77         virtual ~_SelectBox(void);
78
79         result Construct(bool isMultiSelect, const Tizen::Base::String& title, int listItemCnt, Evas_Object* pWebView = null);
80         Tizen::Base::Collection::IList* GetSelectedListN(void) const;
81
82         //IListViewItemProvider
83         virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth);
84         virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth);
85         virtual int GetItemCount(void);
86
87         // IListViewItemEventListener
88         virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
89         virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
90         virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
91
92         virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
93
94         result AddListItem(const Tizen::Base::String& itemText, int itemType,bool slected);
95         result UpdateList(Eina_List* pItems, int prevIndex, bool clearPrevList, bool isGroupdList);
96
97 private:
98         /**
99          * This is the copy constructor for this class.
100          */
101         _SelectBox(const _SelectBox& source);
102
103         /**
104          * This is the assignment operator for this class.
105          */
106         _SelectBox& operator =(const _SelectBox& source);
107
108         bool IsMultiSelectable(void) const { return __multiSelection; }
109         void UpdateSelectionIndex(int index);
110         result CreateButtons(int btnHeight, int buttonGap);
111
112 public:
113         static const int ID_FORMAT_STRING = 300;
114         static const int LIST_ITEM_TYPE_GROUP = 2;
115         static const int LIST_ITEM_TYPE_NORMAL = 1;
116         static const int LIST_ITEM_TYPE_SUB = 0;
117
118 private:
119         Tizen::Base::Collection::ArrayList __listElementArray;
120         Tizen::Ui::Controls::ListView* __pListView;
121         bool __multiSelection;
122         int __SelectedIndex;
123         int __prevIndex;
124         Tizen::Ui::_ControlOrientation __orientation;
125         Evas_Object* __pWebView;
126         Eina_Inarray* __pToggledArray;
127 }; // _SelectBox
128
129 }}} //Tizen::Web::Controls
130 #endif // _FWEB_CTRL_INTERNAL_SELECT_BOX_H_