ba80c4f51fc4d9ab4bf649000e2e4b73b7fc4274
[platform/framework/web/crosswalk-tizen.git] /
1 // Copyright 2016 Samsung Electronics. 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 #ifndef EWK_EFL_INTEGRATION_BROWSER_SELECT_PICKER_SELECT_PICKER_BASE_H_
6 #define EWK_EFL_INTEGRATION_BROWSER_SELECT_PICKER_SELECT_PICKER_BASE_H_
7
8 #include <Elementary.h>
9 #include <vector>
10
11 #include "content/public/common/menu_item.h"
12 #include "ui/gfx/geometry/rect.h"
13
14 class EWebView;
15 class GenlistCallbackData;
16
17 class SelectPickerBase {
18  public:
19   virtual ~SelectPickerBase();
20   static SelectPickerBase* Create(EWebView* web_view,
21                                   int selected_index,
22                                   const std::vector<content::MenuItem>& items,
23                                   bool is_multiple_selection,
24                                   const gfx::Rect& bounds);
25   virtual void UpdateFormNavigation(int form_element_count,
26                                     int current_node_index) {}
27   virtual void UpdatePickerData(int selected_index,
28                                 const std::vector<content::MenuItem>& items,
29                                 bool is_multiple_selection);
30   virtual gfx::Rect GetGeometryDIP() const;
31
32   void Show();
33   void Hide();
34   bool IsVisible() const;
35
36  protected:
37   explicit SelectPickerBase(EWebView* web_view,
38                             int selected_index,
39                             bool is_multiple_selection);
40   virtual const char* GetItemStyle() const;
41   virtual void Init(const std::vector<content::MenuItem>& items,
42                     const gfx::Rect& bounds) = 0;
43   virtual void ClearData();
44   virtual void CreateAndPopulatePopupList(
45       const std::vector<content::MenuItem>& items) = 0;
46   virtual void ItemSelected(GenlistCallbackData* data, void* event_info);
47   void InitializeSelectedPickerData(
48       const std::vector<content::MenuItem>& items);
49   void DidSelectPopupMenuItem();
50   void DidMultipleSelectPopupMenuItem();
51
52   EWebView* web_view_;
53   Evas_Object* popup_list_;
54   Evas_Object* layout_;
55   Evas_Object* window_;
56   int selected_index_;
57   bool is_multiple_selection_;
58   Elm_Genlist_Item_Class* item_class_;
59 #if defined(TIZEN_ATK_SUPPORT)
60   Elm_Object_Item* first_item_;
61   Elm_Object_Item* selected_item_;
62 #endif
63
64  private:
65   static void ItemSelectedCallback(void*, Evas_Object*, void*);
66   static void MenuItemActivatedCallback(void*, Evas_Object*, void*);
67   static void MenuItemDeactivatedCallback(void*, Evas_Object*, void*);
68   void InitializeItemClass();
69   void InitializeGroupClass();
70   void DestroyPopupList();
71
72   Elm_Genlist_Item_Class* group_class_;
73   std::vector<GenlistCallbackData*> select_picker_data_;
74   std::vector<int> selected_indexes_;
75 };
76
77 #endif  // EWK_EFL_INTEGRATION_BROWSER_SELECT_PICKER_SELECT_PICKER_BASE_H_