Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ListQuestionDialog Class Reference

#include <modaldialog.h>

Inheritance diagram for ListQuestionDialog:
QuestionDialog ModalDialog WindowController UpgradeOperationMountDialog

Public Member Functions

virtual void initControls (void)
 
virtual bool processWindowCommand (const EventCommandId &command, Control *control)
 
class SimplePickergetPicker ()
 
- Public Member Functions inherited from QuestionDialog
virtual void init (const std::string &title)
 
virtual void run (void)
 
 QuestionDialog ()
 
virtual ~QuestionDialog (void)
 
- Public Member Functions inherited from ModalDialog
virtual void setCallback (ModalDialogCallback *cb, const std::string &id)
 
virtual void init (void)
 
void modalFinished (void)
 
 ModalDialog ()
 
virtual ~ModalDialog (void)
 
- Public Member Functions inherited from WindowController
virtual void draw (void)
 
virtual Windowwindow (void)
 
virtual void setWindow (Window *w)
 
 WindowController ()
 
virtual ~WindowController (void)
 

Static Protected Member Functions

static void CreateControlsForListWindow (Window *w)
 

Additional Inherited Members

- Protected Attributes inherited from QuestionDialog
bool m_deleteWindow
 

Detailed Description

Definition at line 129 of file modaldialog.h.

Member Function Documentation

void ListQuestionDialog::CreateControlsForListWindow ( Window w)
staticprotected

Definition at line 160 of file modaldialog.cpp.

References Window::addControl(), BOLD_STROKE, CENTER_JUSTIFY, GUI_CLEAR(), GUI_OPAQUE_BLACK(), GUI_OPAQUE_MEDIUM_GRAY(), GUI_OPAQUE_WHITE(), SaturatedColor(), Scroller::setButtonColor(), Scroller::setColor(), Window::setColor(), Control::setColor(), NewButton::setCommand(), NewButton::setDownColor(), NewButton::setDownTextColor(), StaticDisplay::setFont(), Control::setFont(), NewButton::setHighlightColor(), Picker::setHighlightColor(), Picker::setHighlightTextColor(), Control::setId(), StaticDisplay::setJustification(), NewButton::setLabel(), StaticDisplay::setMultiLine(), Control::setOutlineColor(), Window::setOutlineColor(), Window::setOutlineWidth(), Control::setRect(), Scroller::setRect(), StaticDisplay::setRect(), Picker::setScroller(), Picker::setSelectionColor(), Window::setSizeAndCenter(), Scroller::setTextColor(), StaticDisplay::setTextColor(), Control::setTextColor(), Picker::setTextMargins(), Window::setTexture(), and Scroller::setThumbColor().

Referenced by initControls().

161 {
162  window->setSizeAndCenter( Size( 1.2, 1.2 ) );
163  window->setTexture( "basecomputer.png" );
164  window->setColor( SaturatedColor( 0, 0, 1, .1 ) );
165  window->setOutlineColor( SaturatedColor( .7, .7, .7 ) );
166  window->setOutlineWidth( 2.0 );
167 
168  //Title text display.
169  StaticDisplay *title = new StaticDisplay;
170  title->setRect( Rect( -.57, .42, 1.14, .15 ) );
171  title->setMultiLine( true );
173  title->setTextColor( GUI_OPAQUE_WHITE() );
174  title->setColor( GUI_CLEAR );
175  title->setFont( Font( .08, BOLD_STROKE ) );
176  title->setId( "Title" );
177  //Put it on the window.
178  window->addControl( title );
179 
180  //OK button.
181  NewButton *ok = new NewButton;
182  ok->setRect( Rect( -.27, -.57, .22, .1 ) );
183  ok->setLabel( "OK" );
184  ok->setCommand( "OK" );
185  ok->setColor( GFXColor( 0, 0, 1, .25 ) );
187  ok->setDownColor( GFXColor( 0, 0, 1, .6 ) );
189  ok->setHighlightColor( GFXColor( 0, 0, 1, .4 ) );
190  ok->setFont( Font( .08, BOLD_STROKE ) );
191  ok->setId( "OK" );
192  //Put the button on the window.
193  window->addControl( ok );
194 
195  //Cancel button.
196  NewButton *cancel = new NewButton;
197  cancel->setRect( Rect( .05, -.57, .22, .1 ) );
198  cancel->setLabel( "Cancel" );
199  cancel->setCommand( "Cancel" );
200  cancel->setColor( GFXColor( 0, 0, 1, .25 ) );
201  cancel->setTextColor( GUI_OPAQUE_WHITE() );
202  cancel->setDownColor( GFXColor( 0, 0, 1, .6 ) );
203  cancel->setDownTextColor( GUI_OPAQUE_BLACK() );
204  cancel->setHighlightColor( GFXColor( 0, 0, 1, .4 ) );
205  cancel->setFont( Font( .08, BOLD_STROKE ) );
206  cancel->setId( "Cancel" );
207  //Put the button on the window.
208  window->addControl( cancel );
209 
210  //Scroller for description.
211  Scroller *pickScroller = new Scroller;
212  pickScroller->setRect( Rect( .52, -.4, .05, .85 ) );
213  pickScroller->setColor( SaturatedColor( 0, 0, 1, .1 ) );
214  pickScroller->setThumbColor( SaturatedColor( 0, 0, .4 ), GUI_OPAQUE_WHITE() );
215  pickScroller->setButtonColor( SaturatedColor( 0, 0, .4 ) );
216  pickScroller->setTextColor( GUI_OPAQUE_WHITE() );
217  pickScroller->setOutlineColor( GUI_OPAQUE_MEDIUM_GRAY() );
218 
219  //List picker.
220  SimplePicker *pick = new SimplePicker;
221  pick->setRect( Rect( -.57, -.4, 1.09, .85 ) );
222  pick->setColor( SaturatedColor( 0, 0, 1, .1 ) );
224  pick->setTextColor( GUI_OPAQUE_WHITE() );
225  pick->setSelectionColor( SaturatedColor( .2, .2, .7, .8 ) );
226  pick->setHighlightColor( SaturatedColor( 0, 0, .6, .35 ) );
228  pick->setFont( Font( .065 ) );
229  pick->setTextMargins( Size( 0.02, 0.01 ) );
230  pick->setId( "Picker" );
231  pick->setScroller( pickScroller );
232  //Put the picker on the window.
233  window->addControl( pick );
234 
235  window->addControl( pickScroller ); //Want scroller "over" picker.
236 }
SimplePicker * ListQuestionDialog::getPicker ( )

Definition at line 355 of file modaldialog.cpp.

References Window::findControlById(), and WindowController::window().

Referenced by showListQuestion().

356 {
357  return static_cast< SimplePicker* > ( window()->findControlById( "Picker" ) );
358 }
virtual void ListQuestionDialog::initControls ( void  )
inlinevirtual

Implements QuestionDialog.

Definition at line 133 of file modaldialog.h.

References CreateControlsForListWindow(), and WindowController::window().

134  {
136  }
bool ListQuestionDialog::processWindowCommand ( const EventCommandId command,
Control control 
)
virtual

Reimplemented from ModalDialog.

Reimplemented in UpgradeOperationMountDialog.

Definition at line 328 of file modaldialog.cpp.

References Window::findControlById(), ModalDialog::m_result, ModalDialog::modalFinished(), ModalDialog::processWindowCommand(), Picker::selectedItem(), and WindowController::window().

Referenced by UpgradeOperationMountDialog::processWindowCommand().

329 {
330  if (command == "Cancel") {
331  //Just close down, with the result unknown.
332  m_result = (-1);
333  modalFinished();
334  return true;
335  } else if (command == "OK") {
336  //The OK button was clicked.
337  Picker *picker = static_cast< Picker* > ( window()->findControlById( "Picker" ) );
338  assert( picker != NULL );
339  m_result = picker->selectedItem();
340  if (m_result >= 0) {
341  //We have a selection. We are done.
342  modalFinished();
343  } else {
344  //Ignore OK button until we have a selection.
345  //Do nothing here.
346  }
347  return true;
348  } else {
349  //We only care about buttons clicked.
350  return QuestionDialog::processWindowCommand( command, control );
351  }
352  assert( false ); //Should never get here.
353 }

The documentation for this class was generated from the following files: