2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file simple-text-label-example.cpp
20 * @brief Basic usage of SimpleTextLabel control
24 #include <dali-toolkit/dali-toolkit.h>
27 using namespace Dali::Toolkit;
30 * @brief The main class of the demo.
32 class SimpleTextLabelExample : public ConnectionTracker
35 SimpleTextLabelExample(Application& application)
36 : mApplication(application)
38 // Connect to the Application's Init signal
39 mApplication.InitSignal().Connect(this, &SimpleTextLabelExample::Create);
42 ~SimpleTextLabelExample()
44 // Nothing to do here.
48 * One-time setup in response to Application InitSignal.
50 void Create(Application& application)
52 Window window = application.GetWindow();
54 window.KeyEventSignal().Connect(this, &SimpleTextLabelExample::OnKeyEvent);
56 mLabel = TextLabel::New("A Quick Brown Fox Jumps Over The Lazy Dog");
57 mLabel.SetProperty(Dali::Actor::Property::NAME, "SimpleTextLabel");
58 mLabel.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
59 mLabel.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
60 mLabel.SetProperty(Actor::Property::SIZE, Vector2(400.f, 400.f));
61 mLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
62 mLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLACK);
63 mLabel.SetBackgroundColor(Color::WHITE);
69 * Main key event handler
71 void OnKeyEvent(const KeyEvent& event)
73 if(event.GetState() == KeyEvent::DOWN)
75 if(IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK))
83 Application& mApplication;
88 void RunTest(Application& application)
90 SimpleTextLabelExample test(application);
92 application.MainLoop();
95 /** Entry point for Linux & Tizen applications */
96 int DALI_EXPORT_API main(int argc, char** argv)
98 Application application = Application::New(&argc, &argv);
100 RunTest(application);