Init Tizen 2.2.1
[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 <FUiIPropagatedKeyEventListener.h>
33 #include <FUi_ControlManager.h>
34 #include "FWebCtrl_WebPopup.h"
35 #include "FWebCtrl_WebImpl.h"
36
37 namespace Tizen { namespace Graphics
38 {
39 class Rectangle;
40 }} // Tizen::Graphics
41
42 namespace Tizen { namespace Ui
43 {
44 class IActionEventListener;
45 }} // Tizen::Ui
46
47 namespace Tizen { namespace Ui { namespace Controls
48 {
49 class Button;
50 class GroupedList;
51 class ListItemBase;
52 class ListView;
53 }}} // Tizen::Ui::Controls
54
55 namespace Tizen { namespace Web { namespace Controls
56 {
57
58 enum _ButtonFormat
59 {
60         ID_BUTTON_SELECTION = 5,
61         ID_BUTTON_CANCEL
62 };
63
64 class _SelectBox
65         : public _WebPopup
66         , public Tizen::Ui::Controls::IListViewItemEventListener
67         , public Tizen::Ui::Controls::IListViewItemProvider
68         , public Tizen::Ui::IPropagatedKeyEventListener
69 {
70 public:
71         /**
72          * Constructor
73          */
74         _SelectBox(void);
75
76         /**
77          * Destructor
78          */
79         virtual ~_SelectBox(void);
80
81         result Construct(Tizen::Web::Controls::_WebImpl* pImpl, bool isMultiSelect, const Tizen::Base::String& title, int listItemCnt, Evas_Object* pWebView = null, const Tizen::Base::String& url = L"");
82         Tizen::Base::Collection::IList* GetSelectedListN(void) const;
83
84         //IListViewItemProvider
85         virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth);
86         virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth);
87         virtual int GetItemCount(void);
88
89         // IListViewItemEventListener
90         virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
91         virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
92         virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
93
94         virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
95
96         virtual bool  OnKeyPressed (Tizen::Ui::Control &source, const Tizen::Ui::KeyEventInfo &keyEventInfo);
97         virtual bool  OnKeyReleased (Tizen::Ui::Control &source, const Tizen::Ui::KeyEventInfo &keyEventInfo);
98         virtual bool  OnPreviewKeyPressed (Tizen::Ui::Control &source, const Tizen::Ui::KeyEventInfo &keyEventInfo);
99         virtual bool  OnPreviewKeyReleased (Tizen::Ui::Control &source, const Tizen::Ui::KeyEventInfo &keyEventInfo);
100         virtual bool  TranslateKeyEventInfo (Tizen::Ui::Control &source, Tizen::Ui::KeyEventInfo &keyEventInfo);
101
102         result AddListItem(const Tizen::Base::String& itemText, int itemType,bool slected);
103         result UpdateList(Eina_List* pItems, int prevIndex, bool clearPrevList, bool isGroupdList);
104
105 private:
106         /**
107          * This is the copy constructor for this class.
108          */
109         _SelectBox(const _SelectBox& source);
110
111         /**
112          * This is the assignment operator for this class.
113          */
114         _SelectBox& operator =(const _SelectBox& source);
115
116         bool IsMultiSelectable(void) const { return __multiSelection; }
117         void UpdateSelectionIndex(int index);
118         result CreateButtons(int btnHeight, int buttonGap);
119
120 public:
121         static const int ID_FORMAT_STRING = 300;
122         static const int LIST_ITEM_TYPE_GROUP = 2;
123         static const int LIST_ITEM_TYPE_NORMAL = 1;
124         static const int LIST_ITEM_TYPE_SUB = 0;
125
126 private:
127         Tizen::Base::Collection::ArrayList __listElementArray;
128         Tizen::Ui::Controls::ListView* __pListView;
129         Tizen::Web::Controls::_WebImpl* __pImpl;
130         bool __multiSelection;
131         int __SelectedIndex;
132         int __prevIndex;
133         Tizen::Ui::_ControlOrientation __orientation;
134         Evas_Object* __pWebView;
135         Eina_Inarray* __pToggledArray;
136         Tizen::Base::String __url;
137 }; // _SelectBox
138
139 }}} //Tizen::Web::Controls
140 #endif // _FWEB_CTRL_INTERNAL_SELECT_BOX_H_