00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(_XRB_DIALOG_HPP_)
00012 #define _XRB_DIALOG_HPP_
00013
00014 #include "xrb.hpp"
00015
00016 #include "xrb_modalwidget.hpp"
00017
00018 namespace Xrb
00019 {
00020
00021 class Layout;
00022 class Button;
00023
00031 class Dialog : public ModalWidget
00032 {
00033 private:
00034
00035 enum
00036 {
00037 BUTTON_OK = 1,
00038 BUTTON_CANCEL = BUTTON_OK << 1
00039 };
00040
00041 public:
00042
00046 enum DialogType
00047 {
00048 DT_OK = BUTTON_OK,
00049 DT_OK_CANCEL = BUTTON_OK|BUTTON_CANCEL,
00050 DT_CANCEL = BUTTON_CANCEL
00051 };
00052
00056 enum ButtonID
00057 {
00058 ID_OK = 0,
00059 ID_CANCEL,
00060 };
00061
00068 Dialog (
00069 DialogType const dialog_type,
00070 ContainerWidget *const parent,
00071 std::string const &name = "Dialog");
00076 virtual ~Dialog () { }
00077
00082 inline Layout *DialogLayout () const { return m_dialog_layout; }
00086 bool HasButton (ButtonID const button_id) const;
00089 inline bool HasOKButton () const
00090 {
00091 return (m_dialog_type & BUTTON_OK) != 0;
00092 }
00095 inline bool HasCancelButton () const
00096 {
00097 return (m_dialog_type & BUTTON_CANCEL) != 0;
00098 }
00099
00103 inline SignalSender1<ButtonID> const *SenderDialogReturned () { return &m_sender_dialog_returned; }
00107 inline SignalSender0 const *SenderDialogReturnedOK ()
00108 {
00109 ASSERT1(HasOKButton());
00110 return &m_sender_dialog_returned_ok;
00111 }
00115 inline SignalSender0 const *SenderDialogReturnedCancel ()
00116 {
00117 ASSERT1(HasCancelButton());
00118 return &m_sender_dialog_returned_cancel;
00119 }
00120
00121 protected:
00122
00126 virtual bool ProcessKeyEvent (EventKey const *e);
00127
00133 virtual void OKButtonActivated ();
00139 virtual void CancelButtonActivated ();
00140
00141 private:
00142
00143 DialogType m_dialog_type;
00144
00145 Layout *m_dialog_layout;
00146 Layout *m_button_layout;
00147 Button *m_ok_button;
00148 Button *m_cancel_button;
00149
00150 SignalSender1<ButtonID> m_sender_dialog_returned;
00151 SignalSender0 m_sender_dialog_returned_ok;
00152 SignalSender0 m_sender_dialog_returned_cancel;
00153
00154 SignalReceiver0 m_internal_receiver_ok_button_activated;
00155 SignalReceiver0 m_internal_receiver_cancel_button_activated;
00156 };
00157
00158 }
00159
00160 #endif // !defined(_XRB_DIALOG_HPP_)
00161