Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / partner / cpp / Sample / Tizen C++ / LocalContent / LocalContent / project / src / LocalContent.cpp
1 //\r
2 // Tizen C++ SDK\r
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
4 //\r
5 // Licensed under the Flora License, Version 1.0 (the License);\r
6 // you may not use this file except in compliance with the License.\r
7 // You may obtain a copy of the License at\r
8 //\r
9 //      http://www.tizenopensource.org/license\r
10 //\r
11 // Unless required by applicable law or agreed to in writing, software\r
12 // distributed under the License is distributed on an AS IS BASIS,\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 // See the License for the specific language governing permissions and\r
15 // limitations under the License.\r
16 //\r
17 \r
18 #include "LocalContent.h"\r
19 #include "MainForm.h"\r
20 \r
21 using namespace Osp::App;\r
22 using namespace Osp::Base;\r
23 using namespace Osp::System;\r
24 using namespace Osp::Ui::Controls;\r
25 \r
26 LocalContent::LocalContent(void)\r
27 {\r
28 }\r
29 \r
30 LocalContent::~LocalContent(void)\r
31 {\r
32 }\r
33 \r
34 Application*\r
35 LocalContent::CreateInstance(void)\r
36 {\r
37         // Create the instance through the constructor.\r
38         return new (std::nothrow) LocalContent();\r
39 }\r
40 \r
41 bool\r
42 LocalContent::OnAppInitializing(AppRegistry& appRegistry)\r
43 {\r
44         // TODO:\r
45         // Initialize UI resources and application specific data.\r
46         // The application's permanent data and context can be obtained from the appRegistry.\r
47         //\r
48         // If this method is successful, return true; otherwise, return false.\r
49         // If this method returns false, the application will be terminated.\r
50 \r
51         // Create a form\r
52         Frame* pFrame = null;\r
53         MainForm *pForm = null;\r
54 \r
55         pForm = new (std::nothrow) MainForm();\r
56         TryReturn(pForm != null, false, "pForm is null.");\r
57 \r
58         pForm->Initialize();\r
59 \r
60         // Add the form to the frame\r
61         pFrame = GetAppFrame()->GetFrame();\r
62         pFrame->AddControl(*pForm);\r
63 \r
64         // Set the current form\r
65         pFrame->SetCurrentForm(*pForm);\r
66 \r
67         // Draw and Show the form\r
68         pForm->Draw();\r
69         //pForm->Show();\r
70         pForm->SetDefaultContentType();\r
71 \r
72         // Uncomment the following statement to listen to the screen on/off events.\r
73         //PowerManager::SetScreenEventListener(*this);  \r
74 \r
75         return true;\r
76 }\r
77 \r
78 bool\r
79 LocalContent::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)\r
80 {\r
81         // TODO:\r
82         // Deallocate resources allocated by this application for termination.\r
83         // The application's permanent data and context can be saved via appRegistry.\r
84         return true;\r
85 }\r
86 \r
87 void\r
88 LocalContent::OnForeground(void)\r
89 {\r
90         // TODO:\r
91         // Start or resume drawing when the application is moved to the foreground.\r
92 }\r
93 \r
94 void\r
95 LocalContent::OnBackground(void)\r
96 {\r
97         // TODO:\r
98         // Stop drawing when the application is moved to the background.\r
99 }\r
100 \r
101 void\r
102 LocalContent::OnLowMemory(void)\r
103 {\r
104         // TODO:\r
105         // Free unused resources or close the application.\r
106 }\r
107 \r
108 void\r
109 LocalContent::OnBatteryLevelChanged(BatteryLevel batteryLevel)\r
110 {\r
111         // TODO:\r
112         // Handle any changes in battery level here.\r
113         // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL.\r
114 }\r
115 \r
116 void\r
117 LocalContent::OnScreenOn (void)\r
118 {\r
119         // TODO:\r
120         // Get the released resources or resume the operations that were paused or stopped in OnScreenOff().\r
121 }\r
122 \r
123 void\r
124 LocalContent::OnScreenOff (void)\r
125 {\r
126         // TODO:\r
127         //  Unless there is a strong reason to do otherwise, release resources (such as 3D, media, and sensors) to allow the device to enter the sleep mode to save the battery.\r
128         // Invoking a lengthy asynchronous method within this listener method can be risky, because it is not guaranteed to invoke a callback before the device enters the sleep mode.\r
129         // Similarly, do not perform lengthy operations in this listener method. Any operation must be a quick one.\r
130 }\r