Change examples for view class extension instead of using controller class.
Change-Id: I7edad76b8b9f50fb6d4f702c366796ee237ec9d7
* limitations under the License.
*
*/
-class page1: public ui_controller
+
+/** This example create a simple view which is inheritance ui_view.
+ * Then push in viewmgr.
+ */
+class page1: public ui_view
{
private:
appdata_s *ad;
-public:
- page1(appdata_s *ad)
- : ad(ad)
- {
- /* ui_view(controller, identity name).
- Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_view(this, "page1"));
- }
- ~page1()
- {
- }
-
+protected:
void on_load()
{
- //Initialize contents.
- ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
//Create a main content.
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 1",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 1",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
},
this->ad);
- view->set_content(content, "Title");
+ this->set_content(content, "Title");
+ }
+
+public:
+ page1(appdata_s *ad) : ui_view("page1"), ad(ad)
+ {
+ ad->viewmgr->push_view(this);
+ }
+
+ ~page1()
+ {
}
};
* limitations under the License.
*
*/
-class page2: public ui_controller
+
+/** This example create a simple view which is inheritance ui_view.
+ * And add two buttons in view title area. hen push in viewmgr.
+ */
+class page2: public ui_view
{
private:
appdata_s *ad;
-public:
- page2(appdata_s *ad)
- : ad(ad)
- {
- /* ui_view(controller, identity name).
- Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_view(this, "page2"));
- }
-
- ~page2()
- {
- }
-
+protected:
void on_load()
{
- //Initialize contents.
- ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
//Create a main content.
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 2",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 2",
//Prev Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- ad->viewmgr->pop_view();
- },
- //Next Button Callback
- [](void *data, Evas_Object *obj, void *event_info) -> void
- {
- appdata_s *ad = static_cast<appdata_s *>(data);
- create_page3(ad);
- },
- this->ad);
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ ad->viewmgr->pop_view();
+ },
+ //Next Button Callback
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ appdata_s *ad = static_cast<appdata_s *>(data);
+ create_page3(ad);
+ },
+ this->ad);
//Title left button
- Elm_Button *left_title_btn = elm_button_add(view->get_base());
+ Elm_Button *left_title_btn = elm_button_add(this->get_base());
elm_object_text_set(left_title_btn, "Cancel");
//Title right button
- Elm_Button *right_title_btn = elm_button_add(view->get_base());
+ Elm_Button *right_title_btn = elm_button_add(this->get_base());
elm_object_text_set(right_title_btn, "Done");
//Arguments: content, title, subtitle, title left button, title right button
- view->set_content(content, "Title Buttons", NULL, left_title_btn, right_title_btn);
+ this->set_content(content, "Title Buttons", NULL, left_title_btn, right_title_btn);
+ }
+
+public:
+ page2(appdata_s *ad) : ui_view("page2"), ad(ad)
+ {
+ //Push this view in viewmgr.
+ ad->viewmgr->push_view(this);
+ }
+
+ ~page2()
+ {
}
};
* limitations under the License.
*
*/
-class page3: public ui_controller
+
+/** This example create a simple view which is inheritance ui_view.
+ * And set text in view subtitle. then push in viewmgr.
+ */
+class page3: public ui_view
{
private:
appdata_s *ad;
-public:
- page3(appdata_s *ad)
- : ad(ad)
- {
- /* ui_view(controller, identity name).
- Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_view(this, "page3"));
- }
-
- ~page3()
- {
- }
-
+protected:
void on_load()
{
- //Initialize contents.
-
- ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
//Create a main content.
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 3",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 3",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
this->ad);
//Arguments: content, title, subtitle, title left button, title right button
- view->set_content(content, "Title", "Subtitle", NULL, NULL);
+ this->set_content(content, "Title", "Subtitle", NULL, NULL);
+ }
+
+public:
+ page3(appdata_s *ad) : ui_view("page3"), ad(ad)
+ {
+ ad->viewmgr->push_view(this);
+ }
+
+ ~page3()
+ {
}
};
* limitations under the License.
*
*/
-class page4: public ui_controller
+
+/** This example create a simple view which is inheritance ui_view.
+ * And set long text to title, set badge text in view title area.
+ * Then push in viewmgr.
+ */
+class page4: public ui_view
{
private:
appdata_s *ad;
-public:
- page4(appdata_s *ad)
- : ad(ad)
- {
- /* ui_view(controller, identity name).
- Later, you could get the identity name using view->get_name(); */
- ad->viewmgr->push_view(new ui_view(this, "page4"));
- }
-
- ~page4()
- {
- }
-
+protected:
void on_load()
{
- //Initialize contents.
-
- ui_view *view = dynamic_cast<ui_view *>(this->get_view());
-
//Create a main content.
- Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 4",
+ Evas_Object *content = create_content(this->get_base(), "ViewMgr Demo<br>Page 4",
//Prev Button Callback
[](void *data, Evas_Object *obj, void *event_info) -> void
{
this->ad);
//Arguments: content, title
- view->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
- view->set_title_badge("999+");
+ this->set_content(content, "TitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitleTitle");
+ this->set_title_badge("999+");
+ }
+
+public:
+ page4(appdata_s *ad) : ui_view("page4"), ad(ad)
+ {
+ ad->viewmgr->push_view(this);
+ }
+
+ ~page4()
+ {
}
};