Using UrlHistoryList do display history list (on urientry edition).
[profile/tv/apps/web/browser.git] / services / WebPageUI / URIEntry.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef URIENTRY_H
18 #define URIENTRY_H
19
20 #include <Evas.h>
21 #include <boost/signals2/signal.hpp>
22 #include "memory.h"
23
24 #include "BasicUI/Action.h"
25 #include "BrowserImage.h"
26 #include "EflTools.h"
27
28
29 namespace tizen_browser {
30 namespace base_ui {
31
32 class URIEntry {
33 public:
34     enum IconType {
35         IconTypeSearch
36         , IconTypeDoc
37         , IconTypeFav
38     };
39     URIEntry();
40     ~URIEntry();
41     void init(Evas_Object* parent);
42     Evas_Object* getContent();
43
44
45     void changeUri(const std::string&);
46     boost::signals2::signal<void (const std::string&)> uriChanged;
47
48     // uri edition change
49     boost::signals2::signal<void ()> uriEntryEditingChanged;
50     // uri edition change (by a user)
51     boost::signals2::signal<void (const std::shared_ptr<std::string>)> uriEntryEditingChangedByUser;
52
53     void setFavIcon(std::shared_ptr<tizen_browser::tools::BrowserImage> favicon);
54     void setCurrentFavIcon();
55     void setSearchIcon();
56     void setDocIcon();
57     void setPageTitle(const std::string& title);
58     void setURI(const std::string& uri);
59     void showPageTitle();
60     IconType getCurrentIconTyep();
61     /**
62      * \brief Adds Action to URI bar.
63      *
64      * All Actions will be displayed before URI entry.
65      */
66     void AddAction(sharedAction action);
67
68     /**
69      * \brief returns list of stored actions
70      */
71     std::list<sharedAction> actions() const;
72
73     /**
74      * \brief Sets Focus to URI entry.
75      */
76     void setFocus();
77
78     /**
79      * @brief Remove focus form URI
80      */
81     void clearFocus();
82
83     /**
84      * @brief check if URI is focused
85      */
86     bool hasFocus() const;
87
88     void setDisabled(bool disabled);
89     void editingCanceled();
90
91 private:
92     static void activated(void* data, Evas_Object* obj, void* event_info);
93     static void aborted(void* data, Evas_Object* obj, void* event_info);
94     static void preeditChange(void* data, Evas_Object* obj, void* event_info);
95     static void focused(void* data, Evas_Object* obj, void* event_info);
96     static void unfocused(void* data, Evas_Object* obj, void* event_info);
97
98     void editingCompleted();
99     void selectWholeText();
100     void setUrlGuideText(const char* txt) const;
101
102     /**
103      * \brief Rewrites URI to support search and prefixing http:// if needed
104      */
105     std::string rewriteURI(const std::string& url);
106
107     static void _fixed_entry_key_down_handler(void* data, Evas* e, Evas_Object* obj, void* event_info);
108     static void _uri_entry_btn_clicked(void* data, Evas_Object* obj, void* event_info);
109     static void _uri_entry_clicked(void* data, Evas_Object* obj, void* event_info);
110     static void _uri_entry_editing_changed(void* data, Evas_Object* obj, void* event_info);
111     static void _uri_entry_editing_changed_user(void* data, Evas_Object* obj, void* event_info);
112
113     static void focusedBtn(void* data, Evas_Object* obj, void* event_info);
114     static void unfocusedBtn(void* data, Evas_Object* obj, void* event_info);
115
116 private:
117     Evas_Object* m_parent;
118     IconType m_currentIconType;
119     std::list<sharedAction> m_actions;
120     Evas_Object* m_entry;
121     Evas_Object* m_favicon;
122     Evas_Object* m_entry_layout;
123     Evas_Object* m_entryBtn;
124     bool m_entrySelectedAllFirst;
125     std::string m_oryginalEntryText;
126     std::string m_pageTitle;
127     std::string m_URI;
128     bool m_searchTextEntered;
129 };
130
131
132 }
133 }
134
135 #endif // URIENTRY_H