Commit 72c6ee5a66b52cadbd97c9b3d2aa59762a98069e

Authored by Kingsley Stephens
1 parent 3afbefd9

Radio button example

Change-Id: If745c02e307876871cf8cbbdeb97d464cc021fef
build/tizen/examples/Makefile.am
... ... @@ -32,7 +32,8 @@ bin_PROGRAMS = \
32 32 shadow-bone-lighting.example \
33 33 dali-builder \
34 34 builder.example \
35   - image-scaling-irregular-grid.example
  35 + image-scaling-irregular-grid.example \
  36 + buttons.example
36 37  
37 38  
38 39 daliimagedir = $(appdatadir)/images/
... ... @@ -146,3 +147,8 @@ image_scaling_irregular_grid_example_SOURCES = $(examples_src_dir)/image/image-s
146 147 image_scaling_irregular_grid_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS)
147 148 image_scaling_irregular_grid_example_DEPENDENCIES = $(EXAMPLE_DEPS)
148 149 image_scaling_irregular_grid_example_LDADD = $(EXAMPLE_LDADD)
  150 +
  151 +buttons_example_SOURCES = $(examples_src_dir)/buttons/buttons-example.cpp
  152 +buttons_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS)
  153 +buttons_example_DEPENDENCIES = $(EXAMPLE_DEPS)
  154 +buttons_example_LDADD = $(EXAMPLE_LDADD)
... ...
com.samsung.dali-demo.xml
... ... @@ -61,4 +61,7 @@
61 61 <ui-application appid="image-scaling-irregular-grid.example" exec="/usr/apps/com.samsung.dali-demo/bin/image-scaling-irregular-grid.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
62 62 <label>Image Scaling Modes</label>
63 63 </ui-application>
  64 + <ui-application appid="buttons.example" exec="/usr/apps/com.samsung.dali-demo/bin/buttons.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
  65 + <label>Radio Buttons</label>
  66 + </ui-application>
64 67 </manifest>
... ...
demo/images/button-disabled.9.png 0 → 100644

852 Bytes

demo/images/button-down.9.png 0 → 100644

1.01 KB

demo/images/button-up.9.png 0 → 100644

1013 Bytes

demo/images/checkbox-checked.png 0 → 100644

1.94 KB

demo/images/checkbox-unchecked.png 0 → 100644

629 Bytes

examples/buttons/buttons-example.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2014 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 +#include "../shared/view.h"
  19 +#include <dali/dali.h>
  20 +#include <dali-toolkit/dali-toolkit.h>
  21 +
  22 +using namespace Dali;
  23 +
  24 +namespace
  25 +{
  26 +// Used to produce visually same dimensions on desktop and device builds
  27 +float ScalePointSize( int pointSize )
  28 +{
  29 + Dali::Vector2 dpi = Dali::Stage::GetCurrent().GetDpi();
  30 + float meanDpi = (dpi.height + dpi.width) * 0.5f;
  31 + return pointSize * meanDpi / 220.0f;
  32 +}
  33 +
  34 +} // namespace
  35 +
  36 +// Define this so that it is interchangeable
  37 +// "DP" stands for Device independent Pixels
  38 +#define DP(x) ScalePointSize(x)
  39 +
  40 +
  41 +namespace
  42 +{
  43 +
  44 +const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "background-gradient.jpg";
  45 +const char* const TOOLBAR_IMAGE = DALI_IMAGE_DIR "top-bar.png";
  46 +
  47 +const char* const TOOLBAR_TITLE = "Buttons";
  48 +
  49 +const char* const SMALL_IMAGE_1 = DALI_IMAGE_DIR "gallery-small-14.jpg";
  50 +const char* const BIG_IMAGE_1 = DALI_IMAGE_DIR "gallery-large-4.jpg";
  51 +
  52 +const char* const SMALL_IMAGE_2 = DALI_IMAGE_DIR "gallery-small-20.jpg";
  53 +const char* const BIG_IMAGE_2 = DALI_IMAGE_DIR "gallery-large-11.jpg";
  54 +
  55 +const char* const SMALL_IMAGE_3 = DALI_IMAGE_DIR "gallery-small-25.jpg";
  56 +const char* const BIG_IMAGE_3 = DALI_IMAGE_DIR "gallery-large-13.jpg";
  57 +
  58 +const char* const ENABLED_IMAGE = DALI_IMAGE_DIR "item-select-check.png";
  59 +
  60 +const char* const PUSHBUTTON_PRESS_IMAGE = DALI_IMAGE_DIR "button-down.9.png";
  61 +const char* const PUSHBUTTON_DIM_IMAGE = DALI_IMAGE_DIR "button-disabled.9.png";
  62 +const char* const PUSHBUTTON_BUTTON_IMAGE = DALI_IMAGE_DIR "button-up.9.png";
  63 +
  64 +const char* const CHECKBOX_UNCHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-unchecked.png";
  65 +const char* const CHECKBOX_CHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-checked.png";
  66 +
  67 +const Vector4 BACKGROUND_COLOUR( 1.0f, 1.0f, 1.0f, 0.15f );
  68 +
  69 +// Layout sizes
  70 +const int RADIO_LABEL_THUMBNAIL_SIZE = 48;
  71 +const int RADIO_IMAGE_SPACING = 8;
  72 +const int BUTTON_HEIGHT = 48;
  73 +
  74 +const int MARGIN_SIZE = 10;
  75 +const int TOP_MARGIN = 85;
  76 +const int GROUP2_HEIGHT = 238;
  77 +const int GROUP1_HEIGHT = 120;
  78 +const int GROUP3_HEIGHT = 190;
  79 +const int GROUP4_HEIGHT = BUTTON_HEIGHT + MARGIN_SIZE * 2;
  80 +
  81 +} // namespace
  82 +
  83 +/** This example shows how to create and use different buttons.
  84 + *
  85 + * 1. First group of radio buttons with image actor labels selects an image to load
  86 + * 2. A push button loads the selected thumbnail image into the larger image pane
  87 + * 3. Second group of radio buttons with a table view label containing a text view and image view, and a normal text view.
  88 + * Selecting one of these will enable/disable the image loading push button
  89 + * 4. A group of check boxes
  90 + */
  91 +class ButtonsController: public ConnectionTracker
  92 +{
  93 + public:
  94 +
  95 + ButtonsController( Application& application )
  96 + : mApplication( application )
  97 + {
  98 + // Connect to the Application's Init signal
  99 + mApplication.InitSignal().Connect( this, &ButtonsController::Create );
  100 + }
  101 +
  102 + ~ButtonsController()
  103 + {
  104 + // Nothing to do here
  105 + }
  106 +
  107 + void Create( Application& application )
  108 + {
  109 + // The Init signal is received once (only) during the Application lifetime
  110 +
  111 + // Respond to key events
  112 + Stage::GetCurrent().KeyEventSignal().Connect(this, &ButtonsController::OnKeyEvent);
  113 +
  114 + // Creates a default view with a default tool bar.
  115 + // The view is added to the stage.
  116 + mContentLayer = DemoHelper::CreateView( application,
  117 + mView,
  118 + mToolBar,
  119 + BACKGROUND_IMAGE,
  120 + TOOLBAR_IMAGE,
  121 + TOOLBAR_TITLE );
  122 +
  123 + int yPos = TOP_MARGIN + MARGIN_SIZE;
  124 +
  125 + // Image selector radio group
  126 + Actor radioGroup2Background = Toolkit::CreateSolidColorActor( BACKGROUND_COLOUR );
  127 + radioGroup2Background.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  128 + radioGroup2Background.SetParentOrigin( ParentOrigin::TOP_LEFT );
  129 + radioGroup2Background.SetPosition( DP(MARGIN_SIZE), DP(yPos) );
  130 + radioGroup2Background.SetSize( DP(348), DP(GROUP2_HEIGHT) );
  131 + mContentLayer.Add( radioGroup2Background );
  132 +
  133 + Actor radioButtonsGroup2 = Actor::New();
  134 + radioButtonsGroup2.SetParentOrigin( ParentOrigin::TOP_LEFT );
  135 + radioButtonsGroup2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  136 + radioButtonsGroup2.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) );
  137 + radioButtonsGroup2.SetSize( DP(100), DP(160) );
  138 +
  139 + radioGroup2Background.Add( radioButtonsGroup2 );
  140 +
  141 + int radioY = 0;
  142 +
  143 + // Radio 1
  144 + {
  145 + ImageActor imageActor = ImageActor::New( Image::New( SMALL_IMAGE_1 ) );
  146 + imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
  147 + mRadioButtonImage1 = Dali::Toolkit::RadioButton::New( imageActor );
  148 + mRadioButtonImage1.SetParentOrigin( ParentOrigin::TOP_LEFT );
  149 + mRadioButtonImage1.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  150 + mRadioButtonImage1.SetPosition( 0, DP(radioY) );
  151 + mRadioButtonImage1.SetActive( true );
  152 +
  153 + radioButtonsGroup2.Add( mRadioButtonImage1 );
  154 + }
  155 +
  156 + // Radio 2
  157 + {
  158 + radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING;
  159 +
  160 + ImageActor imageActor = ImageActor::New( Image::New( SMALL_IMAGE_2 ) );
  161 + imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
  162 +
  163 + mRadioButtonImage2 = Dali::Toolkit::RadioButton::New( imageActor );
  164 + mRadioButtonImage2.SetParentOrigin( ParentOrigin::TOP_LEFT );
  165 + mRadioButtonImage2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  166 + mRadioButtonImage2.SetPosition( 0, DP(radioY) );
  167 +
  168 + radioButtonsGroup2.Add( mRadioButtonImage2 );
  169 + }
  170 +
  171 + // Radio 3
  172 + {
  173 + radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING;
  174 +
  175 + ImageActor imageActor = ImageActor::New( Image::New( SMALL_IMAGE_3 ) );
  176 + imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
  177 +
  178 + mRadioButtonImage3 = Dali::Toolkit::RadioButton::New( imageActor );
  179 + mRadioButtonImage3.SetParentOrigin( ParentOrigin::TOP_LEFT );
  180 + mRadioButtonImage3.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  181 + mRadioButtonImage3.SetPosition( 0, DP(radioY) );
  182 +
  183 + radioButtonsGroup2.Add( mRadioButtonImage3 );
  184 + }
  185 +
  186 + // Create select button
  187 + mUpdateButton = Toolkit::PushButton::New();
  188 + mUpdateButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
  189 + mUpdateButton.SetAnchorPoint( AnchorPoint::TOP_CENTER );
  190 + mUpdateButton.SetPosition( 0, DP(MARGIN_SIZE) );
  191 + mUpdateButton.SetLabelText("Select");
  192 + mUpdateButton.SetSize( DP(100), DP(BUTTON_HEIGHT) );
  193 +
  194 + mUpdateButton.SetPressedImage( Dali::Image::New( PUSHBUTTON_PRESS_IMAGE ) );
  195 + mUpdateButton.SetDimmedImage( Dali::Image::New( PUSHBUTTON_DIM_IMAGE ) );
  196 + mUpdateButton.SetButtonImage( Dali::Image::New( PUSHBUTTON_BUTTON_IMAGE ) );
  197 +
  198 + mUpdateButton.ClickedSignal().Connect( this, &ButtonsController::OnButtonClicked );
  199 +
  200 + radioButtonsGroup2.Add(mUpdateButton);
  201 +
  202 + // ImageActor to display selected image
  203 + mBigImage1 = Image::New( BIG_IMAGE_1 );
  204 + mBigImage2 = Image::New( BIG_IMAGE_2 );
  205 + mBigImage3 = Image::New( BIG_IMAGE_3 );
  206 +
  207 + mImage = ImageActor::New( mBigImage1 );
  208 + mImage.SetParentOrigin( ParentOrigin::TOP_RIGHT );
  209 + mImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  210 + mImage.SetPosition( DP(MARGIN_SIZE), 0 );
  211 + mImage.SetSize( DP(218), DP(218) );
  212 + radioButtonsGroup2.Add( mImage );
  213 +
  214 + // The enable/disable radio group
  215 + yPos += GROUP2_HEIGHT + MARGIN_SIZE;
  216 +
  217 + Actor radioGroup1Background = Toolkit::CreateSolidColorActor( BACKGROUND_COLOUR );
  218 + radioGroup1Background.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  219 + radioGroup1Background.SetParentOrigin( ParentOrigin::TOP_LEFT );
  220 + radioGroup1Background.SetPosition( DP(MARGIN_SIZE), DP(yPos) );
  221 + radioGroup1Background.SetSize( DP(348), DP(GROUP1_HEIGHT) );
  222 + mContentLayer.Add( radioGroup1Background );
  223 +
  224 + // Radio group
  225 + Actor radioButtonsGroup1 = Actor::New();
  226 + radioButtonsGroup1.SetParentOrigin( ParentOrigin::TOP_LEFT );
  227 + radioButtonsGroup1.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  228 + radioButtonsGroup1.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) );
  229 +
  230 + radioGroup1Background.Add( radioButtonsGroup1 );
  231 +
  232 + // First radio button
  233 + {
  234 + Toolkit::TableView tableView = Toolkit::TableView::New( 1, 2 );
  235 + tableView.SetSize( DP(260), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
  236 +
  237 + Toolkit::TextView textView = Toolkit::TextView::New( "Select enabled" );
  238 + Toolkit::Alignment alignment = Toolkit::Alignment::New( Toolkit::Alignment::HorizontalLeft );
  239 + alignment.Add( textView );
  240 + tableView.AddChild( alignment, Toolkit::TableView::CellPosition( 0, 0 ) );
  241 +
  242 + ImageActor imageActor = ImageActor::New( Image::New( ENABLED_IMAGE ) );
  243 + imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
  244 + tableView.AddChild( imageActor, Toolkit::TableView::CellPosition( 0, 1 ) );
  245 + tableView.SetFixedWidth( 1, DP(RADIO_LABEL_THUMBNAIL_SIZE) );
  246 +
  247 + Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( tableView );
  248 + radioButton.SetName( "radio-select-enable" );
  249 + radioButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
  250 + radioButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  251 + radioButton.SetPosition( 0, 0 );
  252 + radioButton.SetActive( true );
  253 +
  254 + radioButton.ToggledSignal().Connect( this, &ButtonsController::EnableSelectButtonToggle );
  255 +
  256 + radioButtonsGroup1.Add( radioButton );
  257 + }
  258 +
  259 + // Second radio button
  260 + {
  261 + Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( "Select disabled" );
  262 + radioButton.SetName( "radio-select-disable" );
  263 + radioButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
  264 + radioButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  265 + radioButton.SetPosition( 0, DP(50) );
  266 +
  267 + radioButton.ToggledSignal().Connect( this, &ButtonsController::EnableSelectButtonToggle );
  268 +
  269 + radioButtonsGroup1.Add( radioButton );
  270 + }
  271 +
  272 + // CheckBoxes
  273 + yPos += GROUP1_HEIGHT + MARGIN_SIZE;
  274 +
  275 + Actor checkBoxBackground = Toolkit::CreateSolidColorActor( BACKGROUND_COLOUR );
  276 + checkBoxBackground.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  277 + checkBoxBackground.SetParentOrigin( ParentOrigin::TOP_LEFT );
  278 + checkBoxBackground.SetPosition( DP(MARGIN_SIZE), DP(yPos) );
  279 + checkBoxBackground.SetSize( DP(430), DP(GROUP3_HEIGHT) );
  280 + mContentLayer.Add( checkBoxBackground );
  281 +
  282 + Dali::Image unchecked = Dali::Image::New( CHECKBOX_UNCHECKED_IMAGE );
  283 + Dali::Image checked = Dali::Image::New( CHECKBOX_CHECKED_IMAGE );
  284 +
  285 + int checkYPos = MARGIN_SIZE;
  286 +
  287 + {
  288 + Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
  289 + checkBox.SetName( "checkbox1" );
  290 + checkBox.SetPosition( DP(MARGIN_SIZE), DP(checkYPos) );
  291 + checkBox.SetParentOrigin( ParentOrigin::TOP_LEFT );
  292 + checkBox.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  293 + checkBox.SetBackgroundImage( unchecked );
  294 + checkBox.SetCheckedImage( checked );
  295 + checkBox.SetSize( DP(48), DP(48) );
  296 + checkBox.ToggledSignal().Connect( this, &ButtonsController::OnCheckBoxesToggled );
  297 +
  298 + checkBoxBackground.Add( checkBox );
  299 + }
  300 +
  301 + mCheckBox1State = Toolkit::TextView::New( "CheckBox1 is unchecked" );
  302 +
  303 + mCheckBox1State.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  304 + mCheckBox1State.SetPosition( DP(80), DP(checkYPos) );
  305 +
  306 + checkBoxBackground.Add( mCheckBox1State );
  307 +
  308 + checkYPos += 60;
  309 +
  310 + {
  311 + Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
  312 + checkBox.SetName( "checkbox2" );
  313 + checkBox.SetPosition( DP(MARGIN_SIZE), DP(checkYPos) );
  314 + checkBox.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  315 + checkBox.SetBackgroundImage( unchecked );
  316 + checkBox.SetCheckedImage( checked );
  317 + checkBox.SetSize( DP(48), DP(48) );
  318 + checkBox.SetChecked( true );
  319 + checkBox.ToggledSignal().Connect( this, &ButtonsController::OnCheckBoxesToggled );
  320 +
  321 + checkBoxBackground.Add( checkBox );
  322 + }
  323 +
  324 + mCheckBox2State = Toolkit::TextView::New( "CheckBox2 is checked" );
  325 + mCheckBox2State.SetParentOrigin( ParentOrigin::TOP_LEFT );
  326 + mCheckBox2State.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  327 + mCheckBox2State.SetPosition( DP(80), DP(checkYPos) );
  328 +
  329 + checkBoxBackground.Add( mCheckBox2State );
  330 +
  331 + checkYPos += 60;
  332 +
  333 + {
  334 + Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
  335 + checkBox.SetName( "checkbox3" );
  336 + checkBox.SetPosition( DP(MARGIN_SIZE), DP(checkYPos) );
  337 + checkBox.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  338 + checkBox.SetBackgroundImage( unchecked );
  339 + checkBox.SetCheckedImage( checked );
  340 + checkBox.SetSize( DP(48), DP(48) );
  341 + checkBox.ToggledSignal().Connect( this, &ButtonsController::OnCheckBoxesToggled );
  342 +
  343 + checkBoxBackground.Add( checkBox );
  344 + }
  345 +
  346 + mCheckBox3State = Toolkit::TextView::New( "CheckBox3 is unchecked" );
  347 +
  348 + mCheckBox3State.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  349 + mCheckBox3State.SetPosition( DP(80), DP(checkYPos) );
  350 +
  351 + checkBoxBackground.Add( mCheckBox3State );
  352 +
  353 + // Create toggle button
  354 + yPos += GROUP3_HEIGHT + MARGIN_SIZE;
  355 +
  356 + Actor toggleBackground = Toolkit::CreateSolidColorActor( BACKGROUND_COLOUR );
  357 + toggleBackground.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  358 + toggleBackground.SetParentOrigin( ParentOrigin::TOP_LEFT );
  359 + toggleBackground.SetPosition( DP(MARGIN_SIZE), DP(yPos) );
  360 + toggleBackground.SetSize( DP(150 + MARGIN_SIZE * 2), DP(GROUP4_HEIGHT) );
  361 + mContentLayer.Add( toggleBackground );
  362 +
  363 + Toolkit::PushButton toggleButton = Toolkit::PushButton::New();
  364 + toggleButton.SetToggleButton( true );
  365 + toggleButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
  366 + toggleButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  367 + toggleButton.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) );
  368 + toggleButton.SetLabelText( "Toggle OFF" );
  369 + toggleButton.SetSize( DP(150), DP(BUTTON_HEIGHT) );
  370 +
  371 + toggleButton.SetPressedImage( Dali::Image::New( PUSHBUTTON_PRESS_IMAGE ) );
  372 + toggleButton.SetDimmedImage( Dali::Image::New( PUSHBUTTON_DIM_IMAGE ) );
  373 + toggleButton.SetButtonImage( Dali::Image::New( PUSHBUTTON_BUTTON_IMAGE ) );
  374 +
  375 + toggleButton.ToggledSignal().Connect( this, &ButtonsController::OnButtonToggled );
  376 +
  377 + toggleBackground.Add( toggleButton );
  378 + }
  379 +
  380 + void OnKeyEvent( const KeyEvent& event )
  381 + {
  382 + if( event.state == KeyEvent::Down )
  383 + {
  384 + if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
  385 + {
  386 + // Exit application when click back or escape.
  387 + mApplication.Quit();
  388 + }
  389 + }
  390 + }
  391 +
  392 + bool OnButtonToggled( Toolkit::Button button, bool state )
  393 + {
  394 + Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( button );
  395 + if( pushButton )
  396 + {
  397 + if( state )
  398 + {
  399 + pushButton.SetLabelText( "Toggle ON" );
  400 + }
  401 + else
  402 + {
  403 + pushButton.SetLabelText( "Toggle OFF" );
  404 + }
  405 + }
  406 +
  407 + return true;
  408 + }
  409 +
  410 + bool EnableSelectButtonToggle( Toolkit::Button button, bool state )
  411 + {
  412 + if( button.GetName() == "radio-select-enable" && state == true )
  413 + {
  414 + mUpdateButton.SetDimmed( false );
  415 + }
  416 + else if( button.GetName() == "radio-select-disable" && state == true )
  417 + {
  418 + mUpdateButton.SetDimmed( true );
  419 + }
  420 +
  421 + return true;
  422 + }
  423 +
  424 + bool OnButtonClicked(Toolkit::Button button)
  425 + {
  426 + if( mRadioButtonImage1.IsActive() )
  427 + {
  428 + mImage.SetImage( mBigImage1 );
  429 + }
  430 + else if( mRadioButtonImage2.IsActive() )
  431 + {
  432 + mImage.SetImage( mBigImage2 );
  433 + }
  434 + else if( mRadioButtonImage3.IsActive() )
  435 + {
  436 + mImage.SetImage( mBigImage3 );
  437 + }
  438 + return true;
  439 + }
  440 +
  441 + bool OnCheckBoxesToggled( Toolkit::Button button, bool state )
  442 + {
  443 + if( button.GetName() == "checkbox1" )
  444 + {
  445 + if( state )
  446 + {
  447 + mCheckBox1State.SetText("CheckBox1 is checked");
  448 + }
  449 + else
  450 + {
  451 + mCheckBox1State.SetText("CheckBox1 is unchecked");
  452 + }
  453 + }
  454 +
  455 + if( button.GetName() == "checkbox2" )
  456 + {
  457 + if( state )
  458 + {
  459 + mCheckBox2State.SetText("CheckBox2 is checked");
  460 + }
  461 + else
  462 + {
  463 + mCheckBox2State.SetText("CheckBox2 is unchecked");
  464 + }
  465 + }
  466 +
  467 + if( button.GetName() == "checkbox3" )
  468 + {
  469 + if( state )
  470 + {
  471 + mCheckBox3State.SetText("CheckBox3 is checked");
  472 + }
  473 + else
  474 + {
  475 + mCheckBox3State.SetText("CheckBox3 is unchecked");
  476 + }
  477 + }
  478 +
  479 + return true;
  480 + }
  481 +
  482 + private:
  483 +
  484 + Application& mApplication;
  485 + Toolkit::View mView; ///< The View instance.
  486 + Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
  487 + Layer mContentLayer; ///< Content layer
  488 +
  489 + Toolkit::RadioButton mRadioButtonImage1;
  490 + Toolkit::RadioButton mRadioButtonImage2;
  491 + Toolkit::RadioButton mRadioButtonImage3;
  492 +
  493 + Toolkit::PushButton mUpdateButton;
  494 +
  495 + Image mBigImage1;
  496 + Image mBigImage2;
  497 + Image mBigImage3;
  498 + ImageActor mImage;
  499 +
  500 + Toolkit::TextView mCheckBox1State;
  501 + Toolkit::TextView mCheckBox2State;
  502 + Toolkit::TextView mCheckBox3State;
  503 +};
  504 +
  505 +void RunTest( Application& application )
  506 +{
  507 + ButtonsController test( application );
  508 +
  509 + application.MainLoop();
  510 +}
  511 +
  512 +// Entry point for Linux & SLP applications
  513 +//
  514 +int main( int argc, char **argv )
  515 +{
  516 + Application application = Application::New( &argc, &argv );
  517 +
  518 + RunTest( application );
  519 +
  520 + return 0;
  521 +}
... ...