From: Jinkun Jang Date: Tue, 12 Mar 2013 17:11:47 +0000 (+0900) Subject: Tizen 2.1 base X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f84a1f3fed05af3360c01bf4533e7f0d59723208;p=apps%2Fnative%2Fsample%2FBasicApp.git Tizen 2.1 base --- diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9c95663 --- /dev/null +++ b/LICENSE @@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Compatibility Definition Document +and passes the Compatibility Test Suite as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. + +You may add Your own attribution notices within Derivative Works +that You distribute, alongside or as an addendum to the NOTICE text +from the Work, provided that such additional attribution notices +cannot be construed as modifying the License. You may add Your own +copyright statement to Your modifications and may provide additional or +different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works +as a whole, provided Your use, reproduction, and distribution of +the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..3997999 --- /dev/null +++ b/NOTICE @@ -0,0 +1,4 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE file for Flora License terms and conditions. + diff --git a/description.xml b/description.xml new file mode 100644 index 0000000..f19dd57 --- /dev/null +++ b/description.xml @@ -0,0 +1,11 @@ + + + + + BasicApp + 1.0 + screenshot.png + +The BasicApp sample application demonstrates how you can construct forms to implement basic UI and application functionalities. + + diff --git a/project/data/nofile.dummy b/project/data/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/project/inc/BasicApp.h b/project/inc/BasicApp.h new file mode 100644 index 0000000..56295ab --- /dev/null +++ b/project/inc/BasicApp.h @@ -0,0 +1,65 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _BASIC_APP_H_ +#define _BASIC_APP_H_ + +#include +#include +#include + +//application must inherit from Application class +//which provides basic features necessary to define an application. + +class BasicApp + : public Tizen::App::Application + , public Tizen::System::IScreenEventListener +{ +public: + //[HelloWorld] application must have a factory method that creates an instance of itself. + static Tizen::App::Application* CreateInstance(void); + +public: + BasicApp(void); + virtual ~BasicApp(void); + + // Called when the application is initializing. + virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry); + + //Called when the application is terminating. + virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false); + + //Called when the application's frame moves to the top of the screen. + virtual void OnForeground(void); + + //Called when this application's frame is moved from top of the screen to the background. + virtual void OnBackground(void); + + //Called when the system memory is not sufficient to run the application any further. + virtual void OnLowMemory(void); + + // Called when the battery level changes. + virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel); + + // Called when the screen turns on. + virtual void OnScreenOn (void); + + // Called when the screen turns off. + virtual void OnScreenOff (void); +}; + +#endif diff --git a/project/inc/BasicAppFrame.h b/project/inc/BasicAppFrame.h new file mode 100644 index 0000000..2356edf --- /dev/null +++ b/project/inc/BasicAppFrame.h @@ -0,0 +1,40 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _BASIC_APP_FRAME_H_ +#define _BASIC_APP_FRAME_H_ + +#include +#include + +class BasicAppFrame + : public Tizen::Ui::Controls::Frame +{ +public: + BasicAppFrame(void); + virtual ~BasicAppFrame(void); + + result Initialize(int panelId); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + +private: + int __panelId; +}; + +#endif //_BASIC_APP_FRAME_H_ \ No newline at end of file diff --git a/project/inc/ButtonPanel.h b/project/inc/ButtonPanel.h new file mode 100644 index 0000000..a97852b --- /dev/null +++ b/project/inc/ButtonPanel.h @@ -0,0 +1,43 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _BUTTON_PANEL_H_ +#define _BUTTON_PANEL_H_ + +#include +#include + +class ButtonPanel + : public Tizen::Ui::Controls::Panel + , public Tizen::Ui::IActionEventListener +{ +public: + ButtonPanel(void); + virtual ~ButtonPanel(void); + + result Initialize(const Tizen::Graphics::Rectangle& Rect); + + virtual result OnInitializing(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + static const int ID_BUTTON = 101; + + Tizen::Ui::Controls::Label *__pLabel; +}; + +#endif diff --git a/project/inc/ImagePanel.h b/project/inc/ImagePanel.h new file mode 100644 index 0000000..74f2fa4 --- /dev/null +++ b/project/inc/ImagePanel.h @@ -0,0 +1,43 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _IMAGE_PANEL_H_ +#define _IMAGE_PANEL_H_ + +#include +#include + +class ImagePanel + : public Tizen::Ui::Controls::Panel + , public Tizen::Ui::IOrientationEventListener +{ +public: + ImagePanel(void); + virtual ~ImagePanel(void); + + result Initialize(Tizen::Graphics::Rectangle rect); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual result OnDraw(void); + virtual void OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus); + +private: + Tizen::Graphics::Bitmap *__pTizenBitmap; +}; + +#endif diff --git a/project/inc/MainForm.h b/project/inc/MainForm.h new file mode 100644 index 0000000..8e1182e --- /dev/null +++ b/project/inc/MainForm.h @@ -0,0 +1,52 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _MAIN_FORM_H_ +#define _MAIN_FORM_H_ + +#include + +class MainForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Controls::IFormBackEventListener +{ +public: + MainForm(void); + virtual ~MainForm(void); + + result Initialize(int panelId); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + +private: + static const int ID_HEADER_ITEM1 = 101; + static const int ID_HEADER_ITEM2 = 102; + static const int ID_HEADER_ITEM3 = 103; + static const int ID_ORIENTATION = 200; + + Tizen::Ui::Controls::Panel* __pPanel[3]; + Tizen::Ui::Controls::Button* __pButtonOrientation; + Tizen::Ui::Orientation __status; + + int __panelId; +}; + +#endif diff --git a/project/manifest.xml b/project/manifest.xml new file mode 100644 index 0000000..bba9580 --- /dev/null +++ b/project/manifest.xml @@ -0,0 +1,21 @@ + + + $(manifestAppId) + 1.0.0 + C++App + + + 2.0 + + + + + + $(projectName) + + + mainmenu.png + + + + diff --git a/project/res/eng-GB.xml b/project/res/eng-GB.xml new file mode 100644 index 0000000..6ae6172 --- /dev/null +++ b/project/res/eng-GB.xml @@ -0,0 +1,7 @@ + + + + Change Orientation + diff --git a/project/res/screen-density-xhigh/tizen.png b/project/res/screen-density-xhigh/tizen.png new file mode 100644 index 0000000..56040da Binary files /dev/null and b/project/res/screen-density-xhigh/tizen.png differ diff --git a/project/res/screen-size-normal/IDF_MAINFORM.xml b/project/res/screen-size-normal/IDF_MAINFORM.xml new file mode 100755 index 0000000..9e910eb --- /dev/null +++ b/project/res/screen-size-normal/IDF_MAINFORM.xml @@ -0,0 +1,32 @@ + + + + + +720 +
+ + + + +
+ + +
+
+ + +
+ + + + + + +
diff --git a/project/shared/data/nofile.dummy b/project/shared/data/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/project/shared/res/screen-density-xhigh/mainmenu.png b/project/shared/res/screen-density-xhigh/mainmenu.png new file mode 100755 index 0000000..983c883 Binary files /dev/null and b/project/shared/res/screen-density-xhigh/mainmenu.png differ diff --git a/project/shared/trusted/nofile.dummy b/project/shared/trusted/nofile.dummy new file mode 100644 index 0000000..e69de29 diff --git a/project/src/BasicApp.cpp b/project/src/BasicApp.cpp new file mode 100644 index 0000000..9269e88 --- /dev/null +++ b/project/src/BasicApp.cpp @@ -0,0 +1,107 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include + +#include "BasicApp.h" +#include "BasicAppFrame.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::System; +using namespace Tizen::Ui::Controls; + +BasicApp::BasicApp(void) +{ +} + +BasicApp::~BasicApp(void) +{ +} + +Application* +BasicApp::CreateInstance(void) +{ + // Create the instance through the constructor. + return new (std::nothrow) BasicApp(); +} + +bool +BasicApp::OnAppInitializing(AppRegistry& appRegistry) +{ + int lastPanelId = 0; + String lastPanelName(L""); + String panelIDkey(L"AppLastPanelId"); + String panelNamekey(L"AppLastPanelName"); + + result r = appRegistry.Get(panelIDkey, lastPanelId); + if (r == E_KEY_NOT_FOUND) + { + lastPanelId = 0; + appRegistry.Add(panelIDkey, lastPanelId); + } + + r = appRegistry.Get(panelNamekey, lastPanelName); + if (r == E_KEY_NOT_FOUND) + { + appRegistry.Add(panelNamekey, L"Panel1"); + } + + // Create a Frame + BasicAppFrame* pBasicAppFrame = new (std::nothrow) BasicAppFrame(); + pBasicAppFrame->Initialize(lastPanelId); + pBasicAppFrame->SetName(L"BasicApp"); + AddFrame(*pBasicAppFrame); + + return true; +} + +bool +BasicApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + return true; +} + +void +BasicApp::OnForeground(void) +{ +} + +void +BasicApp::OnBackground(void) +{ +} + +void +BasicApp::OnLowMemory(void) +{ +} + +void +BasicApp::OnBatteryLevelChanged(BatteryLevel batteryLevel) +{ +} + +void +BasicApp::OnScreenOn (void) +{ +} + +void +BasicApp::OnScreenOff (void) +{ +} \ No newline at end of file diff --git a/project/src/BasicAppEntry.cpp b/project/src/BasicAppEntry.cpp new file mode 100644 index 0000000..5e3737a --- /dev/null +++ b/project/src/BasicAppEntry.cpp @@ -0,0 +1,61 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * This file contains the Tizen application entry point. + */ + +#include + +#include "BasicApp.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +_EXPORT_ int OspMain(int argc, char* pArgv[]); + +/** + * The entry function of Tizen application called by the operating system. + */ +int +OspMain(int argc, char* pArgv[]) +{ + AppLog("Application started."); + ArrayList args; + args.Construct(); + for (int i = 0; i < argc; i++) + { + args.Add(*(new (std::nothrow) String(pArgv[i]))); + } + + result r = Tizen::App::Application::Execute(BasicApp::CreateInstance, &args); + + TryLog(r == E_SUCCESS, "[%s] Application execution failed", GetErrorMessage(r)); + + args.RemoveAll(true); + AppLog("Application finished."); + + return static_cast(r); +} +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/project/src/BasicAppFrame.cpp b/project/src/BasicAppFrame.cpp new file mode 100644 index 0000000..538974e --- /dev/null +++ b/project/src/BasicAppFrame.cpp @@ -0,0 +1,70 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include + +#include "BasicAppFrame.h" +#include "MainForm.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +BasicAppFrame::BasicAppFrame(void) + : __panelId(0) +{ +} + +BasicAppFrame::~BasicAppFrame(void) +{ +} + +result +BasicAppFrame::Initialize(int panelId) +{ + result r = Frame::Construct(); + __panelId = panelId; + + return r; +} + +result +BasicAppFrame::OnInitializing(void) +{ + // Create a form + MainForm* pMainForm = new (std::nothrow) MainForm(); + result r = pMainForm->Initialize(__panelId); + + // Add the form to the frame + AddControl(*pMainForm); + + // Set the current form + SetCurrentForm(*pMainForm); + + // Draw the form + pMainForm->Invalidate(true); + + return r; +} + +result +BasicAppFrame::OnTerminating(void) +{ + result r = E_SUCCESS; + + return r; +} diff --git a/project/src/ButtonPanel.cpp b/project/src/ButtonPanel.cpp new file mode 100644 index 0000000..48c41ae --- /dev/null +++ b/project/src/ButtonPanel.cpp @@ -0,0 +1,78 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include +#include + +#include "ButtonPanel.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +ButtonPanel::ButtonPanel(void) + : __pLabel(null) +{ +} + +ButtonPanel::~ButtonPanel(void) +{ +} + +result +ButtonPanel::Initialize(const Tizen::Graphics::Rectangle& rect) +{ + return Panel::Construct(rect); +} + +result +ButtonPanel::OnInitializing(void) +{ + // Create a Label + __pLabel = new (std::nothrow) Label(); + __pLabel->Construct(Rectangle(45, 190, 600, 80), L"Button"); + __pLabel->SetName(L"Label1"); + __pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + __pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + result r = AddControl(*__pLabel); + + // Create a Button + Button *pButton = new (std::nothrow) Button(); + pButton->Construct(Rectangle(20, 290, 680, 160)); + pButton->SetText(L"Change Text"); + pButton->SetActionId(ID_BUTTON); + pButton->AddActionEventListener(*this); + r = AddControl(*pButton); + + return r; +} + +void +ButtonPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + switch(actionId) + { + case ID_BUTTON: + { + __pLabel->SetText(L"Button is clicked!"); + AppLog("Button is pressed! \n"); + } + break; + } + Invalidate(true); +} + diff --git a/project/src/ImagePanel.cpp b/project/src/ImagePanel.cpp new file mode 100644 index 0000000..1e669b6 --- /dev/null +++ b/project/src/ImagePanel.cpp @@ -0,0 +1,106 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include +#include + +#include "ImagePanel.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Io; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Media; +using namespace Tizen::Graphics; + +ImagePanel::ImagePanel(void) + : __pTizenBitmap(null) +{ +} + +ImagePanel::~ImagePanel(void) +{ +} + +result +ImagePanel::Initialize(Tizen::Graphics::Rectangle rect) +{ + return Panel::Construct(rect); +} + +result +ImagePanel::OnInitializing(void) +{ + Image image; + result r = image.Construct(); + String filepath = App::GetInstance()->GetAppResourcePath() + L"screen-density-xhigh/tizen.png"; + + __pTizenBitmap = image.DecodeN(filepath, BITMAP_PIXEL_FORMAT_ARGB8888); + + return r; +} + +result +ImagePanel::OnTerminating(void) +{ + result r = E_SUCCESS; + + delete __pTizenBitmap; + return r; +} + +result +ImagePanel::OnDraw(void) +{ + result r = E_SUCCESS; + + Canvas* pCanvas = GetCanvasN(); + + if (pCanvas != null && __pTizenBitmap != null) + { + Rectangle rect = GetBounds(); + + float widthRatio = float(rect.width) / __pTizenBitmap->GetWidth(); + float heightRatio = float(rect.height) / __pTizenBitmap->GetHeight(); + float ratio = (widthRatio > heightRatio) ? heightRatio : widthRatio; + + int height = int(__pTizenBitmap->GetHeight() * ratio); + int width = int(__pTizenBitmap->GetWidth() * ratio); + + r = pCanvas->DrawBitmap(Rectangle((rect.width - width) / 2, (rect.height - height) / 2, width, height), *__pTizenBitmap); + } + + delete pCanvas; + + return r; +} + +void +ImagePanel::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus) +{ + Form *pForm = static_cast
(GetParent()); + + if (pForm != null) + { + Rectangle clientRect = pForm->GetClientAreaBounds(); + Rectangle rect(0, 0, clientRect.width, clientRect.height); + + SetBounds(rect); + } + Invalidate(true); +} diff --git a/project/src/MainForm.cpp b/project/src/MainForm.cpp new file mode 100644 index 0000000..0837e08 --- /dev/null +++ b/project/src/MainForm.cpp @@ -0,0 +1,241 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include +#include + +#include "ButtonPanel.h" +#include "ImagePanel.h" +#include "MainForm.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +MainForm::MainForm(void) + : __pButtonOrientation(null) + , __status(ORIENTATION_PORTRAIT) + , __panelId(0) +{ +} + +MainForm::~MainForm(void) +{ +} + +result +MainForm::Initialize(int panelId) +{ + result r = Form::Construct(L"IDF_MAINFORM"); + + if (panelId >= 0 && panelId <= 2) + { + __panelId = panelId; + } + else + { + __panelId = 0; + } + + return r; +} + +result +MainForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + Rectangle clientRect = GetClientAreaBounds(); + Rectangle rect(0, 0, clientRect.width, clientRect.height); + + // Create header + Header* pHeader = GetHeader(); + if (pHeader != null) + { + pHeader->SetStyle(HEADER_STYLE_TAB); + + HeaderItem headerItem1; + headerItem1.Construct(ID_HEADER_ITEM1); + headerItem1.SetText(L"BUTTON"); + pHeader->AddItem(headerItem1); + + HeaderItem headerItem2; + headerItem2.Construct(ID_HEADER_ITEM2); + headerItem2.SetText(L"ORIENTATION"); + pHeader->AddItem(headerItem2); + + HeaderItem headerItem3; + headerItem3.Construct(ID_HEADER_ITEM3); + headerItem3.SetText(L"IMAGE"); + pHeader->AddItem(headerItem3); + + pHeader->AddActionEventListener(*this); + } + + // Create footer + Footer * pFooter = GetFooter(); + if (pFooter != null) + { + pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON); + pFooter->SetBackButton(); + SetFormBackEventListener(this); + } + + // Create the Button panel + ButtonPanel* pButtonPanel = new (std::nothrow) ButtonPanel(); + pButtonPanel->Initialize(rect); + AddControl(*pButtonPanel); + __pPanel[0] = pButtonPanel; + + // Orientation panel was created with UI Builder, + // so only its button events must be defined here + __pPanel[1] = static_cast(GetControl(L"IDC_ORIENTATIONPANEL")); + if (__pPanel[1] != null) + { + __pButtonOrientation = static_cast