Commit c9b498ac0a2a0688fd787aed3577d963a885b95c

Authored by Paul Wisbey
1 parent 058b80f9

Skeleton TextField demo

Change-Id: I3ca1324727d7cc2f6c60a6c5879732cda41b8010
build/tizen/examples/CMakeLists.txt
... ... @@ -114,3 +114,8 @@ SET(TEXT_LABEL_MULTI_LANGUAGE_SRCS ${EXAMPLES_SRC_DIR}/text/text-label-multi-lan
114 114 ADD_EXECUTABLE(text-label-multi-language.example ${TEXT_LABEL_MULTI_LANGUAGE_SRCS})
115 115 TARGET_LINK_LIBRARIES(text-label-multi-language.example ${REQUIRED_PKGS_LDFLAGS})
116 116 INSTALL(TARGETS text-label-multi-language.example DESTINATION ${BINDIR})
  117 +
  118 +SET(TEXT_FIELD_SRCS ${EXAMPLES_SRC_DIR}/text/text-field-example.cpp)
  119 +ADD_EXECUTABLE(text-field.example ${TEXT_FIELD_SRCS})
  120 +TARGET_LINK_LIBRARIES(text-field.example ${REQUIRED_PKGS_LDFLAGS})
  121 +INSTALL(TARGETS text-field.example DESTINATION ${BINDIR})
... ...
examples/text/text-field-example.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2015 Samsung Electronics Co., Ltd.
  3 + *
  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
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  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.
  15 + *
  16 + */
  17 +
  18 +/**
  19 + * @file text-field-example.cpp
  20 + * @brief Basic usage of TextField control
  21 + */
  22 +
  23 +// EXTERNAL INCLUDES
  24 +#include <dali-toolkit/dali-toolkit.h>
  25 +#include <dali/public-api/text-abstraction/text-abstraction.h>
  26 +
  27 +using namespace Dali;
  28 +using namespace Dali::Toolkit;
  29 +
  30 +/**
  31 + * @brief The main class of the demo.
  32 + */
  33 +class TextFieldExample : public ConnectionTracker
  34 +{
  35 +public:
  36 +
  37 + TextFieldExample( Application& application )
  38 + : mApplication( application )
  39 + {
  40 + // Connect to the Application's Init signal
  41 + mApplication.InitSignal().Connect( this, &TextFieldExample::Create );
  42 + }
  43 +
  44 + ~TextFieldExample()
  45 + {
  46 + // Nothing to do here.
  47 + }
  48 +
  49 + /**
  50 + * One-time setup in response to Application InitSignal.
  51 + */
  52 + void Create( Application& application )
  53 + {
  54 + Stage stage = Stage::GetCurrent();
  55 +
  56 + stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent);
  57 +
  58 + TextField field = TextField::New();
  59 + field.SetParentOrigin( ParentOrigin::CENTER );
  60 + stage.Add( field );
  61 +
  62 + field.SetProperty( TextField::PROPERTY_TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog" );
  63 +
  64 + // TODO
  65 + //Property::Value fieldText = field.GetProperty( TextField::PROPERTY_TEXT );
  66 + //std::cout << "Got text from field: " << fieldText.Get< std::string >() << std::endl;
  67 + }
  68 +
  69 + /**
  70 + * Main key event handler
  71 + */
  72 + void OnKeyEvent(const KeyEvent& event)
  73 + {
  74 + if(event.state == KeyEvent::Down)
  75 + {
  76 + if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) )
  77 + {
  78 + mApplication.Quit();
  79 + }
  80 + }
  81 + }
  82 +
  83 +private:
  84 +
  85 + Application& mApplication;
  86 +};
  87 +
  88 +void RunTest( Application& application )
  89 +{
  90 + TextFieldExample test( application );
  91 +
  92 + application.MainLoop();
  93 +}
  94 +
  95 +/** Entry point for Linux & Tizen applications */
  96 +int main( int argc, char **argv )
  97 +{
  98 + Application application = Application::New( &argc, &argv );
  99 +
  100 + RunTest( application );
  101 +
  102 + return 0;
  103 +}
... ...