~om26er/ubuntu/oneiric/nux/sru-888039

« back to all changes in this revision

Viewing changes to examples/button.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-08-11 18:29:22 UTC
  • mfrom: (1.1.25 upstream)
  • Revision ID: james.westby@ubuntu.com-20110811182922-lbfkhxvubg5z59pb
Tags: 1.2.0-0ubuntu1
* New upstream release.
* debian/rules:
  - bump shlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "Nux/Nux.h"
22
22
#include "Nux/VLayout.h"
23
23
#include "Nux/WindowThread.h"
24
 
#include "Nux/PushButton.h"
25
 
 
 
24
#include "Nux/CheckBox.h"
 
25
#include "Nux/ToggleButton.h"
 
26
#include "Nux/Button.h"
 
27
#include "Nux/TextureArea.h"
26
28
 
27
29
void UserInterfaceInitialization(nux::NThread* thread, void* init_data)
28
30
{
29
31
  // Create a vertical Layout
30
32
  nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
31
 
  
32
 
  //Create a button of type PushButton
33
 
  nux::PushButton* button = new nux::PushButton(
34
 
    TEXT ("Hello World!"),
35
 
    NUX_TRACKER_LOCATION);
36
33
 
37
 
  // Set the button maximum width/height
38
 
  button->SetMaximumWidth (80);
39
 
  button->SetMaximumHeight (40);
40
 
  button->SetTextColor (nux::color::Black);
 
34
  //Create a button of type Button
 
35
  nux::Button* button = new nux::Button ("Party on Garth", NUX_TRACKER_LOCATION);
41
36
 
42
37
  // Add the button to the layout
43
38
  layout->AddView (
44
39
    button,
45
 
    1,
46
 
    nux::MINOR_POSITION_CENTER,
47
 
    nux::MINOR_SIZE_FULL);
 
40
    0,
 
41
    nux::MINOR_POSITION_CENTER,
 
42
    nux::MINOR_SIZE_MATCHCONTENT);
 
43
 
 
44
  // Create a button with an image
 
45
  nux::ColorLayer color (nux::Color (0.6, 0.4, 0.7, 1.0));
 
46
  nux::TextureArea* texture_area = new nux::TextureArea ();
 
47
  texture_area->SetPaintLayer (&color);
 
48
 
 
49
  nux::Button* button_with_image = new nux::Button("Party on Wayne", texture_area, NUX_TRACKER_LOCATION);
 
50
  //button_with_image->image_position = nux::NUX_POSITION_BOTTOM;
 
51
 
 
52
  // Add the button to the layout
 
53
  layout->AddView (
 
54
    button_with_image,
 
55
    0,
 
56
    nux::MINOR_POSITION_CENTER,
 
57
    nux::MINOR_SIZE_MATCHCONTENT);
 
58
 
 
59
  color = nux::Color (0.6, 0.4, 0.7, 1.0);
 
60
  texture_area = new nux::TextureArea ();
 
61
  texture_area->SetPaintLayer (&color);
 
62
 
 
63
  nux::Button* button_without_image = new nux::Button(texture_area, NUX_TRACKER_LOCATION);
 
64
 
 
65
  // Add the button to the layout
 
66
  layout->AddView (
 
67
    button_without_image,
 
68
    0,
 
69
    nux::MINOR_POSITION_CENTER,
 
70
    nux::MINOR_SIZE_MATCHCONTENT);
 
71
 
 
72
  nux::ToggleButton *toggle_button = new nux::ToggleButton ("This is a Toggle button, nux just doesn't have a theme for that", NUX_TRACKER_LOCATION);
 
73
  layout->AddView (
 
74
    toggle_button,
 
75
    0,
 
76
    nux::MINOR_POSITION_CENTER,
 
77
    nux::MINOR_SIZE_MATCHCONTENT);
 
78
 
 
79
  nux::CheckBox *check_button = new nux::CheckBox ("Check box widget? Check!", NUX_TRACKER_LOCATION);
 
80
  layout->AddView (
 
81
    check_button,
 
82
    0,
 
83
    nux::MINOR_POSITION_CENTER,
 
84
    nux::MINOR_SIZE_MATCHCONTENT);
48
85
 
49
86
  // Control the position of elements inside the layout
50
87
  layout->SetContentDistribution (nux::MAJOR_POSITION_CENTER);
64
101
 
65
102
  // Create a Window thread
66
103
  nux::WindowThread* wt = nux::CreateGUIThread(
67
 
    TEXT("Push Button"),
68
 
    200,
69
 
    150,
 
104
    TEXT("Button"),
 
105
    800,
 
106
    600,
70
107
    0,
71
108
    &UserInterfaceInitialization,
72
109
    0);