#include <xrb_dialog.hpp>
Public Types | |
enum | DialogType { DT_OK = BUTTON_OK, DT_OK_CANCEL = BUTTON_OK|BUTTON_CANCEL, DT_CANCEL = BUTTON_CANCEL } |
All the possible button combinations. More... | |
enum | ButtonID { ID_OK = 0, ID_CANCEL } |
Used to signal when a button has been pressed. More... | |
Public Member Functions | |
Dialog (DialogType const dialog_type, ContainerWidget *const parent, std::string const &name="Dialog") | |
Constructs a Dialog using the given button combination. | |
virtual | ~Dialog () |
Destructor. | |
Layout * | DialogLayout () const |
Returns the Layout for the dialog's controls. | |
bool | HasButton (ButtonID const button_id) const |
Returns true iff the specified button exists in this dialog. | |
bool | HasOKButton () const |
Explicitly checks for an OK button. | |
bool | HasCancelButton () const |
Explicitly checks for a Cancel button. | |
SignalSender1< ButtonID > const * | SenderDialogReturned () |
Accessor for the SignalSender which signals the ID of a button when a button has been pressed. | |
SignalSender0 const * | SenderDialogReturnedOK () |
Accessor for the SignalSender which signals that the OK button has been pressed. | |
SignalSender0 const * | SenderDialogReturnedCancel () |
Accessor for the SignalSender which signals that the Cancel button has been pressed. | |
Protected Member Functions | |
virtual bool | ProcessKeyEvent (EventKey const *e) |
Handles the default dialog keypresses. | |
virtual void | OKButtonActivated () |
Called when the OK button is pressed. | |
virtual void | CancelButtonActivated () |
Called when the Cancel button is pressed. |
Child widgets are added to a Layout inside of the Dialog, not to the Dialog itself. The button controls are inside the Layout as well, but they are set to use SP_STAY_ON_TOP so that they will remain at the end of the Layout.
Definition at line 31 of file xrb_dialog.hpp.
All the possible button combinations.
These are used to specify which buttons should be added to the dialog.
Definition at line 46 of file xrb_dialog.hpp.
Used to signal when a button has been pressed.
Used by m_sender_dialog_returned.
Definition at line 56 of file xrb_dialog.hpp.
Xrb::Dialog::Dialog | ( | DialogType const | dialog_type, | |
ContainerWidget *const | parent, | |||
std::string const & | name = "Dialog" | |||
) |
Constructs a Dialog using the given button combination.
dialog_type | Indicates which buttons to add to the dialog. | |
parent | The parent of this widget (see Widget::Widget). | |
name | The name of this widget (see Widget::Widget). |
Definition at line 21 of file xrb_dialog.cpp.
References Xrb::SignalHandler::Connect0(), HasCancelButton(), HasOKButton(), Xrb::SP_STAY_ON_TOP, and Xrb::ModalWidget::UpdateRenderBackground().
virtual Xrb::Dialog::~Dialog | ( | ) | [inline, virtual] |
Destructor.
Doesn't do anything special. The child widgets are deleted by Widget's destructor.
Definition at line 76 of file xrb_dialog.hpp.
Layout* Xrb::Dialog::DialogLayout | ( | ) | const [inline] |
Returns the Layout for the dialog's controls.
When adding widgets to a Dialog, this Layout should be used as the parent widget, not the dialog itself.
Definition at line 82 of file xrb_dialog.hpp.
bool Xrb::Dialog::HasButton | ( | ButtonID const | button_id | ) | const |
Returns true iff the specified button exists in this dialog.
button_id | The button type to check for existence. |
Definition at line 81 of file xrb_dialog.cpp.
References HasCancelButton(), and HasOKButton().
bool Xrb::Dialog::ProcessKeyEvent | ( | EventKey const * | e | ) | [protected, virtual] |
Handles the default dialog keypresses.
Ctrl+Enter is a shortcut for OK, escape is a shortcut for Cancel.
Reimplemented from Xrb::Widget.
Definition at line 96 of file xrb_dialog.cpp.
References CancelButtonActivated(), HasCancelButton(), HasOKButton(), Xrb::EventKey::IsEitherControlKeyPressed(), Xrb::EventKey::IsKeyDownEvent(), Xrb::EventKey::KeyCode(), and OKButtonActivated().
void Xrb::Dialog::OKButtonActivated | ( | ) | [protected, virtual] |
Called when the OK button is pressed.
Shuts down the dialog, and emits the appropriate signals. This function can be called directly to simulate the OK button being pressed.
Definition at line 124 of file xrb_dialog.cpp.
References Xrb::ModalWidget::Shutdown().
Referenced by ProcessKeyEvent().
void Xrb::Dialog::CancelButtonActivated | ( | ) | [protected, virtual] |
Called when the Cancel button is pressed.
Shuts down the dialog, and emits the appropriate signals. This function can be called directly to simulate the Cancel button being pressed.
Definition at line 131 of file xrb_dialog.cpp.
References Xrb::ModalWidget::Shutdown().
Referenced by ProcessKeyEvent().