summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlji Seo <ijclaire.seo@samsung.com>2013-11-11 15:30:28 +0900
committerIlji Seo <ijclaire.seo@samsung.com>2013-11-11 15:30:28 +0900
commit0ffd941efc9a3accd48226fa4959e58d789d2c54 (patch)
treef8aeb958e80609e3aa9c47a8e9cf1828cb19fc92
parent7787fcc4953619986a54d7d0441f85fd94f93282 (diff)
downloadDrawingBoard-tizen.tar.gz
DrawingBoard-tizen.tar.bz2
DrawingBoard-tizen.zip
Merged code with RSAtizen
Change-Id: I13cd3bd477553e0278bbcaf70c4eac94e228fc3a Signed-off-by: Ilji Seo <ijclaire.seo@samsung.com>
-rwxr-xr-xLICENSE.Flora206
-rw-r--r--NOTICE3
-rw-r--r--description.xml9
-rw-r--r--project/data/nofile.dummy0
-rw-r--r--project/inc/DrawingBoard.h68
-rw-r--r--project/manifest.xml25
-rw-r--r--project/res/tizen.pngbin0 -> 21322 bytes
-rw-r--r--project/shared/data/nofile.dummy0
-rw-r--r--project/shared/res/screen-density-xhigh/mainmenu.pngbin0 -> 57662 bytes
-rw-r--r--project/shared/trusted/nofile.dummy0
-rw-r--r--project/src/DrawingBoard.cpp1278
-rw-r--r--project/src/DrawingBoardEntry.cpp65
-rw-r--r--sample.xml34
-rw-r--r--screenshot.pngbin0 -> 48201 bytes
14 files changed, 1688 insertions, 0 deletions
diff --git a/LICENSE.Flora b/LICENSE.Flora
new file mode 100755
index 0000000..571fe79
--- /dev/null
+++ b/LICENSE.Flora
@@ -0,0 +1,206 @@
+Flora License
+
+Version 1.1, April, 2013
+
+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 Tizen Compliance Specification
+and passes the Tizen Compliance Tests 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
+ and your own copyright statement or terms and conditions do not conflict
+ the conditions stated in the License including section 3.
+
+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.1 (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..94d56df
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Flora License, Version 1.1
+Please, see the LICENSE.Flora file for Flora License, Version 1.1 terms and conditions.
diff --git a/description.xml b/description.xml
new file mode 100644
index 0000000..4453cd9
--- /dev/null
+++ b/description.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/xsl" href="../../../../description.xsl"?>
+
+<Overview version="0.17.1">
+ <SampleName> DrawingBoard </SampleName>
+ <SampleVersion>1.0</SampleVersion>
+ <Preview>screenshot.png</Preview>
+ <Description>The Purpose of this application, Drawingboard, is to demonstrate the functionalities of 2D graphics.</Description>
+</Overview>
diff --git a/project/data/nofile.dummy b/project/data/nofile.dummy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/data/nofile.dummy
diff --git a/project/inc/DrawingBoard.h b/project/inc/DrawingBoard.h
new file mode 100644
index 0000000..b6303fe
--- /dev/null
+++ b/project/inc/DrawingBoard.h
@@ -0,0 +1,68 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (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 _DRAWING_BOARD_H_
+#define _DRAWING_BOARD_H_
+
+
+#include <FBase.h>
+#include <FGraphics.h>
+#include <FMedia.h>
+#include <FApp.h>
+#include <FUi.h>
+#include <FSystem.h>
+
+class Painter;
+
+class DrawingBoard
+ : public Tizen::App::Application
+ , public Tizen::System::IScreenEventListener
+ , public Tizen::Base::Runtime::ITimerEventListener
+ , public Tizen::Ui::IKeyEventListener
+{
+public:
+ static Tizen::App::Application* CreateInstance(void);
+
+ DrawingBoard();
+ ~DrawingBoard();
+
+ virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
+ virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
+ virtual void OnForeground(void);
+ virtual void OnBackground(void);
+ virtual void OnLowMemory(void);
+ virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
+ virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+ virtual void OnScreenOn(void);
+ virtual void OnScreenOff(void);
+
+ virtual void OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode);
+ virtual void OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode);
+ virtual void OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode);
+
+ void ChangePainter(void);
+ void Draw(void);
+
+private:
+ Tizen::Ui::Controls::Form* __pForm;
+ Painter* __pPainter;
+ Tizen::Base::Runtime::Timer* __pTimer;
+ int __scenarioIndex;
+};
+
+#endif
+
diff --git a/project/manifest.xml b/project/manifest.xml
new file mode 100644
index 0000000..3cdb4dc
--- /dev/null
+++ b/project/manifest.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest">
+ <Id>$(manifestAppId)</Id>
+ <Version>2.2.0</Version>
+ <Type>C++App</Type>
+ <Requirements>
+ <Feature Name="http://tizen.org/feature/screen.size.all">true</Feature>
+ </Requirements>
+ <Apps>
+ <ApiVersion>2.2</ApiVersion>
+ <Privileges/>
+ <UiApp Main="True" MenuIconVisible="True" Name="$(projectName)">
+ <UiScalability BaseScreenSize="Normal" CoordinateSystem="Logical" LogicalCoordinate="720"/>
+ <UiTheme SystemTheme="Black"/>
+ <DisplayNames>
+ <DisplayName Locale="eng-GB">$(projectName)</DisplayName>
+ </DisplayNames>
+ <Icons>
+ <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon>
+ </Icons>
+ <LaunchConditions/>
+ <Notifications/>
+ </UiApp>
+ </Apps>
+</Manifest>
diff --git a/project/res/tizen.png b/project/res/tizen.png
new file mode 100644
index 0000000..d72552f
--- /dev/null
+++ b/project/res/tizen.png
Binary files differ
diff --git a/project/shared/data/nofile.dummy b/project/shared/data/nofile.dummy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/shared/data/nofile.dummy
diff --git a/project/shared/res/screen-density-xhigh/mainmenu.png b/project/shared/res/screen-density-xhigh/mainmenu.png
new file mode 100644
index 0000000..9765b1b
--- /dev/null
+++ b/project/shared/res/screen-density-xhigh/mainmenu.png
Binary files differ
diff --git a/project/shared/trusted/nofile.dummy b/project/shared/trusted/nofile.dummy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/shared/trusted/nofile.dummy
diff --git a/project/src/DrawingBoard.cpp b/project/src/DrawingBoard.cpp
new file mode 100644
index 0000000..462cb2e
--- /dev/null
+++ b/project/src/DrawingBoard.cpp
@@ -0,0 +1,1278 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (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 "DrawingBoard.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Graphics;
+using namespace Tizen::Media;
+using namespace Tizen::System;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+
+
+#define RED32(color32) static_cast<byte>(0x00F8 & ((color32) >> 16))
+#define GREEN32(color32) static_cast<byte>(0x00FC & ((color32) >> 8))
+#define BLUE32(color32) static_cast<byte>(0x00F8 & (color32))
+
+#define RGB888ToCOLOR16(red, green, blue) (static_cast<unsigned short>((static_cast<byte>((blue) >> 3)) | (static_cast<unsigned short>(static_cast<byte>((green) >> 2)) << 5)) | ((static_cast<unsigned short>(static_cast<byte>((red) >> 3)) << 11)))
+#define COLOR32ToCOLOR16(color32) RGB888ToCOLOR16(RED32(color32), GREEN32(color32), BLUE32(color32))
+
+
+const int REPEAT_COUNT = 100;
+const int TIME_OUT = 50;
+const int MAX_LINE_WIDTH = 10;
+const int MAX_FONT_SIZE = 50;
+
+
+class DrawingForm
+ : public Tizen::Ui::Controls::Form
+{
+public:
+ DrawingForm(DrawingBoard* pApp)
+ : __pApp(pApp)
+ {
+ }
+
+ virtual ~DrawingForm(void)
+ {
+ }
+
+public:
+ virtual result OnDraw(void)
+ {
+ if (__pApp)
+ {
+ __pApp->Draw();
+ }
+
+ return E_SUCCESS;
+ }
+
+private:
+ DrawingBoard* __pApp;
+};
+
+
+class Painter
+{
+public:
+ Painter(const Control& control)
+ {
+ _count = 0;
+ _pCanvas = control.GetCanvasN();
+ _pCanvas->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK));
+ _pCanvas->Clear();
+ _pCanvas->Show();
+
+ _bounds = _pCanvas->GetBounds();
+ }
+
+ virtual ~Painter()
+ {
+ delete _pCanvas;
+ }
+
+ virtual bool Draw(void) = 0;
+
+protected:
+ Canvas* _pCanvas;
+ int _count;
+ Rectangle _bounds;
+};
+
+class PixelPainter
+ : public Painter
+{
+public:
+ PixelPainter(const Control& control)
+ : Painter(control)
+ {
+ }
+
+ virtual bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+
+ _pCanvas->SetForegroundColor(color);
+
+ int x = (Math::Rand() % (_bounds.width -2)) + 1;
+ int y = (Math::Rand() % (_bounds.height-2)) + 1;
+
+ _pCanvas->SetPixel(Point(x - 1, y - 1));
+ _pCanvas->SetPixel(Point(x + 1, y - 1));
+ _pCanvas->SetPixel(Point(x, y - 1));
+ _pCanvas->SetPixel(Point(x, y));
+ _pCanvas->SetPixel(Point(x - 1, y + 1));
+ _pCanvas->SetPixel(Point(x, y + 1));
+ _pCanvas->SetPixel(Point(x + 1, y + 1));
+
+ _pCanvas->Show();
+
+ return true;
+ }
+};
+
+
+class LinePainter
+ : public Painter
+{
+public:
+ LinePainter(const Control& control)
+ : Painter(control)
+ {
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ int lineWidth = (Math::Rand() % MAX_LINE_WIDTH) + 1;
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+ _pCanvas->SetForegroundColor(color);
+
+ Point point1(Math::Rand() % _bounds.width, Math::Rand() % _bounds.height);
+ Point point2(Math::Rand() % _bounds.width, Math::Rand() % _bounds.height);
+
+ _pCanvas->SetLineWidth(lineWidth);
+ _pCanvas->DrawLine(point1, point2);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+};
+
+
+class TrianglePainter
+ : public Painter
+{
+public:
+ TrianglePainter(const Control& control)
+ : Painter(control)
+ {
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ int lineWidth = (Math::Rand() % MAX_LINE_WIDTH) + 1;
+
+ _pCanvas->SetLineWidth(lineWidth);
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+
+ _pCanvas->SetForegroundColor(color);
+
+ Point point1;
+ Point point2;
+ Point point3;
+
+ point1.x = Math::Rand() % _bounds.width;
+ point1.y = Math::Rand() % _bounds.height;
+ point2.x = Math::Rand() % _bounds.width;
+ point2.y = Math::Rand() % _bounds.height;
+ point3.x = Math::Rand() % _bounds.width;
+ point3.y = Math::Rand() % _bounds.height;
+
+ _pCanvas->DrawTriangle(point1, point2, point3);
+
+ point1.x = Math::Rand() % _bounds.width;
+ point1.y = Math::Rand() % _bounds.height;
+ point2.x = Math::Rand() % _bounds.width;
+ point2.y = Math::Rand() % _bounds.height;
+ point3.x = Math::Rand() % _bounds.width;
+ point3.y = Math::Rand() % _bounds.height;
+
+ _pCanvas->FillTriangle(color, point1, point2, point3);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+};
+
+
+class RectanglePainter
+ : public Painter
+{
+public:
+ RectanglePainter(const Control& control)
+ : Painter(control)
+ {
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ int lineWidth = (Math::Rand() % MAX_LINE_WIDTH) + 1;
+
+ _pCanvas->SetLineWidth(lineWidth);
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+
+ _pCanvas->SetForegroundColor(color);
+
+ Rectangle rect;
+
+ rect.x = Math::Rand() % _bounds.width;
+ rect.y = Math::Rand() % _bounds.height;
+ rect.width = Math::Rand() % _bounds.width;
+ rect.height = Math::Rand() % _bounds.height;
+
+ _pCanvas->DrawRectangle(rect);
+
+ rect.x = Math::Rand() % _bounds.width;
+ rect.y = Math::Rand() % _bounds.height;
+ rect.width = Math::Rand() % _bounds.width;
+ rect.height = Math::Rand() % _bounds.height;
+
+ _pCanvas->FillRectangle(color, rect);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+};
+
+
+class RoundRectanglePainter
+ : public Painter
+{
+public:
+ RoundRectanglePainter(const Control& control)
+ : Painter(control)
+ {
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ int lineWidth = (Math::Rand() % MAX_LINE_WIDTH) + 1;
+
+ _pCanvas->SetLineWidth(lineWidth);
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+
+ _pCanvas->SetForegroundColor(color);
+
+ Rectangle rect;
+ Dimension round;
+
+ rect.x = Math::Rand() % _bounds.width;
+ rect.y = Math::Rand() % _bounds.height;
+ rect.width = Math::Rand() % _bounds.width;
+ rect.height = Math::Rand() % _bounds.height;
+
+ round.width = rect.width / MAX_LINE_WIDTH;
+ round.height = rect.height / MAX_LINE_WIDTH;
+
+ _pCanvas->DrawRoundRectangle(rect, round);
+
+ rect.x = Math::Rand() % _bounds.width;
+ rect.y = Math::Rand() % _bounds.height;
+ rect.width = Math::Rand() % _bounds.width;
+ rect.height = Math::Rand() % _bounds.height;
+
+ round.width = rect.width / MAX_LINE_WIDTH;
+ round.height = rect.height / MAX_LINE_WIDTH;
+
+ _pCanvas->FillRoundRectangle(color, rect, round);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+};
+
+
+class EllipsePainter
+ : public Painter
+{
+public:
+ EllipsePainter(const Control& control)
+ : Painter(control)
+ {
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ int lineWidth = (Math::Rand() % MAX_LINE_WIDTH) + 1;
+
+ _pCanvas->SetLineWidth(lineWidth);
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+
+ _pCanvas->SetForegroundColor(color);
+
+ Rectangle rect;
+
+ rect.x = Math::Rand() % _bounds.width;
+ rect.y = Math::Rand() % _bounds.height;
+ rect.width = Math::Rand() % _bounds.width;
+ rect.height = Math::Rand() % _bounds.height;
+
+ _pCanvas->DrawEllipse(rect);
+
+ rect.x = Math::Rand() % _bounds.width;
+ rect.y = Math::Rand() % _bounds.height;
+ rect.width = Math::Rand() % _bounds.width;
+ rect.height = Math::Rand() % _bounds.height;
+
+ _pCanvas->FillEllipse(color, rect);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+};
+
+
+class ArcPainter
+ : public Painter
+{
+public:
+ ArcPainter(const Control& control)
+ : Painter(control)
+ {
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ int lineWidth = (Math::Rand() % MAX_LINE_WIDTH) + 1;
+
+ _pCanvas->SetLineWidth(lineWidth);
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+ _pCanvas->SetForegroundColor(color);
+
+ Rectangle rect(Math::Rand() % _bounds.width, Math::Rand() % _bounds.height, Math::Rand() % _bounds.width, Math::Rand() % _bounds.height);
+
+ int startAngle = Math::Rand() % 360;
+ int endAngle = Math::Rand() % 360;
+
+ ArcStyle arcStyle = ARC_STYLE_ONLY;
+
+ switch (Math::Rand() % 3)
+ {
+ case 0:
+ arcStyle = ARC_STYLE_ONLY;
+ break;
+ case 1:
+ arcStyle = ARC_STYLE_CHORD;
+ break;
+ default:
+ arcStyle = ARC_STYLE_PIE;
+ break;
+ }
+
+ _pCanvas->DrawArc(rect, startAngle, endAngle, arcStyle);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+};
+
+
+class PolylinePainter
+ : public Painter
+{
+public:
+ PolylinePainter(const Control& control)
+ : Painter(control)
+ {
+ for (int i = 0; i < 6; i++)
+ {
+ __pointList.Add(*(new (std::nothrow) Point));
+ }
+ }
+
+ virtual ~PolylinePainter()
+ {
+ __pointList.RemoveAll(true);
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ int lineWidth = (Math::Rand() % MAX_LINE_WIDTH) + 1;
+
+ _pCanvas->SetLineWidth(lineWidth);
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+
+ _pCanvas->SetForegroundColor(color);
+
+ for (int i = 0; i < __pointList.GetCount(); i++)
+ {
+ Point* pPoint = dynamic_cast<Point*>(__pointList.GetAt(i));
+
+ if (pPoint)
+ {
+ pPoint->x = Math::Rand() % _bounds.width;
+ pPoint->y = Math::Rand() % _bounds.height;
+ }
+ }
+
+ _pCanvas->DrawPolyline(__pointList);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+
+private:
+ Tizen::Base::Collection::ArrayList __pointList;
+};
+
+
+class PolygonPainter
+ : public Painter
+{
+public:
+ PolygonPainter(const Control& control)
+ : Painter(control)
+ {
+ for (int i = 0; i < 6; i++)
+ {
+ __pointList.Add(*(new (std::nothrow) Point));
+ }
+ }
+
+ virtual ~PolygonPainter()
+ {
+ __pointList.RemoveAll(true);
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ int lineWidth = (Math::Rand() % MAX_LINE_WIDTH) + 1;
+
+ _pCanvas->SetLineWidth(lineWidth);
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+
+ _pCanvas->SetForegroundColor(color);
+
+ for (int i = 0; i < __pointList.GetCount(); i++)
+ {
+ Point* pPoint = dynamic_cast<Point*>(__pointList.GetAt(i));
+
+ if (pPoint)
+ {
+ pPoint->x = Math::Rand() % _bounds.width;
+ pPoint->y = Math::Rand() % _bounds.height;
+ }
+ }
+
+ _pCanvas->DrawPolygon(__pointList);
+
+ for (int i = 0; i < __pointList.GetCount(); i++)
+ {
+ Point* pPoint = dynamic_cast<Point*>(__pointList.GetAt(i));
+
+ if (pPoint)
+ {
+ pPoint->x = Math::Rand() % _bounds.width;
+ pPoint->y = Math::Rand() % _bounds.height;
+ }
+ }
+
+ _pCanvas->FillPolygon(color, __pointList);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+
+private:
+ Tizen::Base::Collection::ArrayList __pointList;
+};
+
+
+class TextPainter
+ : public Painter
+{
+public:
+ TextPainter(const Control& control)
+ : Painter(control)
+ {
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ int fontStyle = FONT_STYLE_PLAIN;
+
+ switch (Math::Rand() % 3)
+ {
+ case 0:
+ fontStyle = FONT_STYLE_PLAIN;
+ break;
+ case 1:
+ fontStyle = FONT_STYLE_BOLD;
+ break;
+ default:
+ fontStyle = FONT_STYLE_ITALIC;
+ break;
+ }
+
+ int fontSize = Math::Rand() % MAX_FONT_SIZE;
+
+ if (fontSize < 10)
+ {
+ fontSize = 10;
+ }
+
+ Font font;
+
+ result r = font.Construct(fontStyle, fontSize);
+
+ if (IsFailed(r))
+ {
+ AppLog("Fails to construct font.\n");
+ return false;
+ }
+
+ _pCanvas->SetFont(font);
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+
+ _pCanvas->SetForegroundColor(color);
+
+ Point point(Math::Rand() % _bounds.width, Math::Rand() % _bounds.height);
+
+ Tizen::Base::String text(L"DrawingBoard Sample");
+
+ _pCanvas->DrawText(point, text);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+};
+
+
+class BitmapPainter
+ : public Painter
+{
+public:
+ BitmapPainter(const Control& control)
+ : Painter(control)
+ , __pBitmap16(null)
+ , __pBitmap32(null)
+ {
+ Image imageDecoder;
+
+ imageDecoder.Construct();
+
+ __pBitmap16 = imageDecoder.DecodeN(App::GetInstance()->GetAppRootPath() + L"res/tizen.png", BITMAP_PIXEL_FORMAT_RGB565);
+ __pBitmap32 = imageDecoder.DecodeN(App::GetInstance()->GetAppRootPath() + L"res/tizen.png", BITMAP_PIXEL_FORMAT_ARGB8888);
+ }
+
+ virtual ~BitmapPainter()
+ {
+ delete __pBitmap16;
+ delete __pBitmap32;
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ Point pos(Math::Rand() % _bounds.width, Math::Rand() % _bounds.height);
+
+ _pCanvas->DrawBitmap(pos, *__pBitmap16);
+
+ pos.x = Math::Rand() % _bounds.width;
+ pos.y = Math::Rand() % _bounds.height;
+
+ _pCanvas->DrawBitmap(pos, *__pBitmap32);
+
+ Rectangle rect;
+
+ rect.x = Math::Rand() % _bounds.width;
+ rect.y = Math::Rand() % _bounds.height;
+ rect.width = (Math::Rand() % (_bounds.width - 1)) + 1;
+ rect.height = (Math::Rand() % (_bounds.height- 1)) + 1;
+
+
+ _pCanvas->DrawBitmap(rect, *__pBitmap16);
+
+ rect.x = Math::Rand() % _bounds.width;
+ rect.y = Math::Rand() % _bounds.height;
+ rect.width = (Math::Rand() % (_bounds.width - 1)) + 1;
+ rect.height = (Math::Rand() % (_bounds.height- 1)) + 1;
+
+ _pCanvas->DrawBitmap(rect, *__pBitmap32);
+
+ rect.x = Math::Rand() % __pBitmap16->GetWidth();
+ rect.y = Math::Rand() % __pBitmap16->GetHeight();
+ rect.width = (Math::Rand() % (__pBitmap16->GetWidth() - 1)) + 1;
+ rect.height = (Math::Rand() % (__pBitmap16->GetHeight() - 1)) + 1;
+
+ if (rect.x + rect.width > __pBitmap16->GetWidth())
+ {
+ rect.width = __pBitmap16->GetWidth() - rect.x;
+ }
+
+ if (rect.y + rect.height > __pBitmap16->GetHeight())
+ {
+ rect.height = __pBitmap16->GetHeight() - rect.y;
+ }
+
+ Rectangle destRect;
+
+ destRect.x = Math::Rand() % _bounds.width;
+ destRect.y = Math::Rand() % _bounds.height;
+ destRect.width = (Math::Rand() % (_bounds.width - 1)) + 1;
+ destRect.height = (Math::Rand() % (_bounds.height- 1)) + 1;
+
+ _pCanvas->DrawBitmap(destRect, *__pBitmap16, rect);
+
+ rect.x = Math::Rand() % __pBitmap32->GetWidth();
+ rect.y = Math::Rand() % __pBitmap32->GetHeight();
+ rect.width = (Math::Rand() % (__pBitmap32->GetWidth() - 1)) + 1;
+ rect.height = (Math::Rand() % (__pBitmap32->GetHeight()- 1)) + 1;
+
+ if (rect.x + rect.width > __pBitmap32->GetWidth())
+ {
+ rect.width = __pBitmap32->GetWidth() - rect.x;
+ }
+
+ if (rect.y + rect.height > __pBitmap32->GetHeight())
+ {
+ rect.height = __pBitmap32->GetHeight() - rect.y;
+ }
+
+ destRect.x = Math::Rand() % _bounds.width;
+ destRect.y = Math::Rand() % _bounds.height;
+ destRect.width = (Math::Rand() % (_bounds.width - 1)) + 1;
+ destRect.height = (Math::Rand() % (_bounds.height- 1)) + 1;
+
+ _pCanvas->DrawBitmap(destRect, *__pBitmap32, rect);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+
+private:
+ Bitmap* __pBitmap16;
+ Bitmap* __pBitmap32;
+};
+
+
+class DirectBufferPainter
+ : public Painter
+{
+public:
+ DirectBufferPainter(const Control& control)
+ : Painter(control)
+ {
+ }
+
+ bool Draw(void)
+ {
+ if (REPEAT_COUNT < _count++)
+ {
+ return false;
+ }
+
+ byte red = Math::Rand() % 0xFF;
+ byte green = Math::Rand() % 0xFF;
+ byte blue = Math::Rand() % 0xFF;
+ byte alpha = Math::Rand() % 0xFF;
+
+ Color color(red, green, blue, alpha);
+
+ _pCanvas->SetForegroundColor(color);
+
+ Rectangle rect(Math::Rand() % _bounds.width, Math::Rand() % _bounds.height, Math::Rand() % _bounds.width, Math::Rand() % _bounds.height);
+
+ FillRectangle(*_pCanvas, color, rect);
+
+ _pCanvas->Show();
+
+ return true;
+ }
+
+ void FillRectangle(Canvas& canvas, const Color &color, const Rectangle &rect)
+ {
+ BufferInfo bufferInfo;
+ int x;
+ int y;
+ int offset;
+ byte srcR;
+ byte srcG;
+ byte srcB;
+ byte destR;
+ byte destG;
+ byte destB;
+ int alphaLevel;
+ int srcLevel;
+ int destLevel;
+ int r;
+ int g;
+ int b;
+ unsigned short color16;
+ unsigned short* pBuffer16;
+ unsigned long* pBuffer32;
+ int bufferWidth;
+ int bufferX1;
+ int bufferY1;
+ int bufferX2;
+ int bufferY2;
+ int x1;
+ int y1;
+ int x2;
+ int y2;
+ int width;
+ int height;
+
+ _pCanvas->Lock(bufferInfo);
+
+ x1 = rect.x;
+ y1 = rect.y;
+ width = rect.width;
+ height = rect.height;
+
+ x2 = x1 + width - 1;
+ y2 = y1 + height - 1;
+
+ bufferX1 = 0;
+ bufferY1 = 0;
+ bufferX2 = bufferX1 + bufferInfo.width - 1;
+ bufferY2 = bufferY1 + bufferInfo.height - 1;
+
+ if (x1 > bufferX2 || x2 < bufferX1)
+ {
+ return;
+ }
+
+ if (y1 > bufferY2 || y2 < bufferY1)
+ {
+ return;
+ }
+
+ if (x1 < bufferX1)
+ {
+ x1 = bufferX1;
+ }
+
+ if (x2 > bufferX2)
+ {
+ x2 = bufferX2;
+ }
+
+ if (y1 < bufferY1)
+ {
+ y1 = bufferY1;
+ }
+
+ if (y2 > bufferY2)
+ {
+ y2 = bufferY2;
+ }
+
+ width = x2 - x1 + 1;
+ height = y2 - y1 + 1;
+
+ bufferWidth = bufferInfo.width;
+
+ if (bufferInfo.bitsPerPixel == 16)
+ {
+
+ color16 = static_cast<unsigned short>(COLOR32ToCOLOR16(color.GetRGB32()));
+ pBuffer16 = static_cast<unsigned short*>(bufferInfo.pPixels);
+
+ alphaLevel = 100 - static_cast<int>(static_cast<float>(color.GetAlpha() / 2.56));
+ srcLevel = alphaLevel;
+ destLevel = 100 - alphaLevel;
+
+ srcR = static_cast<byte>(color16 >> 11);
+ srcG = static_cast<byte>((color16 >> 6) & 0x001F);
+ srcB = static_cast<byte>(color16 & 0x001F);
+
+ for (y = y1; y < y1 + height; y++)
+ {
+ for (x = x1; x < x1 + width; x++)
+ {
+ offset = bufferWidth * y + x;
+ destR = static_cast<byte>(pBuffer16[offset] >> 11);
+ destG = static_cast<byte>((pBuffer16[offset] >> 6) & 0x001F);
+ destB = static_cast<byte>(pBuffer16[offset] & 0x001F);
+
+ r = (destR * destLevel + srcR * srcLevel) / 100;
+ g = (destG * destLevel + srcG * srcLevel) / 100;
+ b = (destB * destLevel + srcB * srcLevel) / 100;
+
+ destR = static_cast<byte>(r);
+ destG = static_cast<byte>(g);
+ destB = static_cast<byte>(b);
+ pBuffer16[offset] = static_cast<unsigned short>((destR << 11) | (destG << 6) | (destB));
+ }
+ }
+ }
+ else if (bufferInfo.bitsPerPixel == 32)
+ {
+ pBuffer32 = static_cast<unsigned long*>(bufferInfo.pPixels);
+
+ for (y = y1; y < y1 + height; y++)
+ {
+ for (x = x1; x < x1 + width; x++)
+ {
+ offset = bufferWidth * y + x;
+ pBuffer32[offset] = color.GetRGB32();
+ }
+ }
+ }
+
+ _pCanvas->Unlock();
+ }
+};
+
+
+class ColorTablePainter
+ : public Painter
+{
+public:
+ ColorTablePainter(const Control& control)
+ : Painter(control)
+ , __x(0)
+ , __y(0)
+ , __width(25)
+ , __height(25)
+ , __red(0)
+ , __green(0)
+ , __blue(0)
+ , __alpha(0xFF)
+ {
+ }
+
+ bool Draw(void)
+ {
+ if (__y >= _bounds.height)
+ {
+ return false;
+ }
+
+ Color color(__red, __green, __blue, __alpha);
+
+ _pCanvas->FillRectangle(color, Rectangle(__x, __y, __width, __height));
+
+ _pCanvas->Show();
+
+ if (__red < 0xFF)
+ {
+ __red++;
+ }
+
+ if (__red >= 0xFF && __green < 0xFF)
+ {
+ __green++;
+ }
+
+ if (__green >= 0xFF && __blue < 0xFF)
+ {
+ __blue++;
+ }
+
+ __x += __width;
+
+ if (__x >= _bounds.width)
+ {
+ __x = 0;
+ __y += __height;
+ }
+
+ return true;
+ }
+
+private:
+ int __x;
+ int __y;
+ int __width;
+ int __height;
+ byte __red;
+ byte __green;
+ byte __blue;
+ byte __alpha;
+};
+
+
+DrawingBoard::DrawingBoard()
+ : __pForm(null)
+ , __pPainter(null)
+ , __pTimer(null)
+ , __scenarioIndex(0)
+{
+}
+
+
+DrawingBoard::~DrawingBoard()
+{
+}
+
+
+Application*
+DrawingBoard::CreateInstance(void)
+{
+ // You can create the instance through another constructor.
+ return new (std::nothrow) DrawingBoard();
+}
+
+bool
+DrawingBoard::OnAppInitializing(AppRegistry& appRegistry)
+{
+ Frame* pAppFrame = new (std::nothrow) Frame();
+
+ pAppFrame->Construct();
+
+ this->AddFrame(*pAppFrame);
+
+ result r = E_SUCCESS;
+
+ __pForm = new (std::nothrow) DrawingForm(this);
+ TryCatch(__pForm != null, , "Failed to allocate memory.");
+
+ r = __pForm->Construct(FORM_STYLE_NORMAL);
+ TryCatch(!IsFailed(r), , "__pForm->Construct(FORM_STYLE_NORMAL) failed.");
+
+ __pForm->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK));
+ r = this->GetAppFrame()->GetFrame()->AddControl(__pForm);
+ TryCatch(!IsFailed(r), , "__pForm->Construct(FORM_STYLE_NORMAL) failed.");
+
+ __pForm->AddKeyEventListener(*this);
+
+ __pTimer = new (std::nothrow) Timer;
+ TryCatch(__pTimer != null, , "Failed to allocate memory.");
+
+ r = __pTimer->Construct(*this);
+ TryCatch(!IsFailed(r), , "Failed to construct timer.");
+
+ return true;
+
+CATCH:
+ delete __pForm;
+ __pForm = null;
+
+ if (__pTimer != null)
+ {
+ __pTimer->Cancel();
+
+ delete __pTimer;
+ __pTimer = null;
+ }
+
+ return false;
+}
+
+
+bool
+DrawingBoard::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+ if (__pTimer != null)
+ {
+ __pTimer->Cancel();
+
+ delete __pTimer;
+ __pTimer = null;
+ }
+
+ if (__pPainter != null)
+ {
+ delete __pPainter;
+ __pPainter = null;
+ }
+
+ return true;
+}
+
+
+void
+DrawingBoard::OnForeground(void)
+{
+ if (__pTimer != null)
+ {
+ __pTimer->Start(TIME_OUT);
+ }
+}
+
+
+void
+DrawingBoard::OnBackground(void)
+{
+ if (__pTimer != null)
+ {
+ __pTimer->Cancel();
+ }
+
+ if (__pForm != null)
+ {
+ Canvas* pCanvas = __pForm->GetCanvasN();
+
+ pCanvas->SetBackgroundColor(Color(0x00000000));
+ pCanvas->Clear();
+
+ pCanvas->Show();
+
+ delete pCanvas;
+ }
+}
+
+
+void
+DrawingBoard::OnLowMemory(void)
+{
+}
+
+
+void
+DrawingBoard::OnBatteryLevelChanged(BatteryLevel batteryLevel)
+{
+}
+
+
+void
+DrawingBoard::OnTimerExpired(Timer& timer)
+{
+ if (__pTimer == null)
+ {
+ return;
+ }
+
+ if (__pPainter == null)
+ {
+ ChangePainter();
+ }
+ else
+ {
+ bool result = __pPainter->Draw();
+
+ if (!result)
+ {
+ ChangePainter();
+ }
+ }
+
+ __pTimer->Start(TIME_OUT);
+}
+
+void
+DrawingBoard::ChangePainter()
+{
+ if (__pForm == null)
+ {
+ return;
+ }
+
+ delete __pPainter;
+ __pPainter = null;
+
+ switch (__scenarioIndex)
+ {
+ case 0:
+ __pPainter = new (std::nothrow) PixelPainter(*__pForm);
+ break;
+ case 1:
+ __pPainter = new (std::nothrow) LinePainter(*__pForm);
+ break;
+ case 2:
+ __pPainter = new (std::nothrow) TrianglePainter(*__pForm);
+ break;
+ case 3:
+ __pPainter = new (std::nothrow) RectanglePainter(*__pForm);
+ break;
+ case 4:
+ __pPainter = new (std::nothrow) RoundRectanglePainter(*__pForm);
+ break;
+ case 5:
+ __pPainter = new (std::nothrow) EllipsePainter(*__pForm);
+ break;
+ case 6:
+ __pPainter = new (std::nothrow) ArcPainter(*__pForm);
+ break;
+ case 7:
+ __pPainter = new (std::nothrow) TextPainter(*__pForm);
+ break;
+ case 8:
+ __pPainter = new (std::nothrow) BitmapPainter(*__pForm);
+ break;
+ case 9:
+ __pPainter = new (std::nothrow) DirectBufferPainter(*__pForm);
+ break;
+ case 10:
+ __pPainter = new (std::nothrow) ColorTablePainter(*__pForm);
+ break;
+ case 11:
+ __pPainter = new (std::nothrow) PolylinePainter(*__pForm);
+ break;
+ case 12:
+ __pPainter = new (std::nothrow) PolygonPainter(*__pForm);
+ break;
+ default:
+ __scenarioIndex = 0;
+ break;
+ }
+
+ __scenarioIndex++;
+
+ if (__scenarioIndex > 12)
+ {
+ __scenarioIndex = 0;
+ }
+}
+
+void
+DrawingBoard::Draw(void)
+{
+ if (__pPainter != null)
+ {
+ __pPainter->Draw();
+ }
+}
+
+void
+DrawingBoard::OnScreenOn (void)
+{
+}
+
+void
+DrawingBoard::OnScreenOff (void)
+{
+}
+
+void
+DrawingBoard::OnKeyPressed(const Control& source, Tizen::Ui::KeyCode keyCode)
+{
+}
+
+void
+DrawingBoard::OnKeyReleased(const Control& source, Tizen::Ui::KeyCode keyCode)
+{
+ if (keyCode == Tizen::Ui::KEY_BACK || keyCode == Tizen::Ui::KEY_ESC)
+ {
+ Terminate();
+ }
+}
+
+void
+DrawingBoard::OnKeyLongPressed(const Control& source, Tizen::Ui::KeyCode keyCode)
+{
+}
diff --git a/project/src/DrawingBoardEntry.cpp b/project/src/DrawingBoardEntry.cpp
new file mode 100644
index 0000000..0b1438a
--- /dev/null
+++ b/project/src/DrawingBoardEntry.cpp
@@ -0,0 +1,65 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (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 C++ application entry point.
+ */
+#include <new>
+#include "DrawingBoard.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 C++ 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(DrawingBoard::CreateInstance, &args);
+
+ if (IsFailed(r))
+ {
+ AppLogException("Application execution failed-[%s].", GetErrorMessage(r));
+ }
+
+ args.RemoveAll(true);
+ AppLog("Application finished.");
+
+ return static_cast<int>(r);
+}
+#ifdef __cplusplus
+}
+#endif // __cplusplus
diff --git a/sample.xml b/sample.xml
new file mode 100644
index 0000000..14ce85c
--- /dev/null
+++ b/sample.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<template>
+
+ <slp-property>
+ <property-group>
+ <sample-name>DrawingBoard</sample-name>
+ <category>Sample</category>
+ <sdk-version>1.00</sdk-version>
+ <project-type>org.tizen.nativecpp.buildArtefactType.app</project-type>
+ <sample-description>description.xml</sample-description>
+ </property-group>
+ </slp-property>
+
+ <process type="org.tizen.nativeappcommon.TizenCopyFolder">
+ <simple name="projectName" value="$(projectName)"/>
+ <simple name="folderPath" value="project"/>
+ <complex-array name="replaceableFiles">
+ <element>
+ <simple name="sourcePath" value="manifest.xml"/>
+ <simple name="targetPath" value="manifest.xml"/>
+ <simple name="replaceable" value = "true"/>
+ </element>
+ </complex-array>
+ </process>
+ <process type="org.tizen.nativecpp.SetDefaultFrameworks">
+ <simple name="projectName" value="$(projectName)"/>
+ <complex-array name="frameworkList">
+ <element>
+ <simple name="framework" value="osp"/>
+ </element>
+ </complex-array>
+ </process>
+
+</template>
diff --git a/screenshot.png b/screenshot.png
new file mode 100644
index 0000000..2e2409f
--- /dev/null
+++ b/screenshot.png
Binary files differ