ALBA
albaGUIDialog.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaGUIDialog
5 Authors: Silvano Imboden
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16#ifndef __albaGUIDialog_H__
17#define __albaGUIDialog_H__
18//----------------------------------------------------------------------------
19// Include:
20//----------------------------------------------------------------------------
21#include "wx/dialog.h"
22#include "albaEvent.h"
23#include "albaObserver.h"
24#include "albaGUI.h"
25#include "albaServiceClient.h"
26#include "albaAbsLogicManager.h"
27
28//----------------------------------------------------------------------------
29// Const:
30//----------------------------------------------------------------------------
32{
33 albaRESIZABLE = 1, // make the Dialog Resizable
34 albaCLOSEWINDOW = 2, // to enable the close button on the window frame
35 albaOK = 4, // to create an ok button
36 albaCANCEL = 8, // to create a cancel button
37 albaCLOSE = 16, // to create a close button
38};
39//----------------------------------------------------------------------------
40// albaGUIDialog :
41//----------------------------------------------------------------------------
75class ALBA_EXPORT albaGUIDialog : public wxDialog, public albaObserver, public albaServiceClient
76{
77public:
78 albaGUIDialog (const wxString& title, long style = albaCLOSEWINDOW | albaRESIZABLE | albaCLOSE);
79 virtual ~albaGUIDialog ();
80 void SetListener(albaObserver *Listener) {m_Listener = Listener;};
81 void OnEvent(albaEventBase *alba_event);
82
84 void Add(wxWindow* window,int option = 0, int flag = wxEXPAND, int border = 0) {window->Reparent(this); m_GuiSizer->Add(window,option,flag,border);};
85
87 void Add(albaGUI* window,int option = 0, int flag = wxEXPAND, int border = 0) {window->Reparent(this); window->FitGui(); m_GuiSizer->Add(window,option,flag,border);};
88
90 void Add(wxSizer* sizer, int option = 0, int flag = wxEXPAND, int border = 0) {m_GuiSizer->Add(sizer, option,flag,border);};
91
93 bool Remove(wxWindow* window) {return m_GuiSizer->Detach(window);};
94
96 bool Remove(wxSizer* sizer ) {return m_GuiSizer->Detach(sizer);};
97
98 int ShowModal();
99
101 void EnableOk(bool enable) {if(m_OkButton) m_OkButton->Enable(enable);};
102 void EnableCancel(bool enable) {if(m_CancelButton) m_CancelButton->Enable(enable);};
103 void EnableClose(bool enable) {if(m_CloseButton) m_CloseButton->Enable(enable);};
104
105
106 virtual void WXSetInitialFittingClientSize(int flags, wxSizer* sizer = NULL);
107
108
112 virtual void OnOK(wxCommandEvent &event);
116 virtual void OnCancel(wxCommandEvent &event);
121 virtual void OnCloseWindow(wxCloseEvent &event);
122
124 virtual void OnSize(wxSizeEvent &event){DoLayout();};
125
126 wxBoxSizer *m_GuiSizer;
127 wxBoxSizer *m_ButtonsSizer;
128 wxBoxSizer *m_DialogSizer;
129 wxButton *m_OkButton;
130 wxButton *m_CancelButton;
131 wxButton *m_CloseButton;
132
134
135private:
137 void nvOnCloseWindow(wxCloseEvent &event) {OnCloseWindow(event);};
138 void nvOnOK(wxCommandEvent &event) {OnOK(event);};
139 void nvOnCancel(wxCommandEvent &event) {OnCancel(event);};
140 void nvOnClose(wxCommandEvent &event) {wxDialog::Close();}; //calls nvOnCloseWindow
141
142 bool m_DialogInitialized;
143 DECLARE_EVENT_TABLE()
144};
145#endif
DIALOG_STYLES
Definition: albaGUIDialog.h:32
@ albaRESIZABLE
Definition: albaGUIDialog.h:33
@ albaCLOSE
Definition: albaGUIDialog.h:37
@ albaCANCEL
Definition: albaGUIDialog.h:36
@ albaOK
Definition: albaGUIDialog.h:35
@ albaCLOSEWINDOW
Definition: albaGUIDialog.h:34
Implementation of the message object for the Subject/Observer design pattern.
Definition: albaEventBase.h:49
albaGUIDialog is the base class for albaDialogs.
Definition: albaGUIDialog.h:76
wxBoxSizer * m_DialogSizer
Dialog sizer – manage the Dialog initial Size, and the other sizers.
void Add(albaGUI *window, int option=0, int flag=wxEXPAND, int border=0)
Add a albaGUI to the dialog.
Definition: albaGUIDialog.h:87
virtual void OnCloseWindow(wxCloseEvent &event)
Virtual functions called to terminate ShowModal - these can be redefined without providing the Event ...
bool Remove(wxSizer *sizer)
Remove a sizer from the dialog.
Definition: albaGUIDialog.h:96
void EnableOk(bool enable)
Enable/Disable the default buttons – doesn't apply to user created buttons.
virtual void WXSetInitialFittingClientSize(int flags, wxSizer *sizer=NULL)
void SetListener(albaObserver *Listener)
Definition: albaGUIDialog.h:80
bool Remove(wxWindow *window)
Remove a widget from the dialog.
Definition: albaGUIDialog.h:93
virtual void OnCancel(wxCommandEvent &event)
Virtual functions called to terminate ShowModal - these can be redefined without providing the Event ...
wxButton * m_CloseButton
Button used to close the dialog with wxID_CLOSE.
albaObserver * m_Listener
wxBoxSizer * m_GuiSizer
Sizer for user widgets – Calling Add() insert a widget in this sizer.
void OnEvent(albaEventBase *alba_event)
process the events sent by subjects
void Add(wxSizer *sizer, int option=0, int flag=wxEXPAND, int border=0)
Add a sizer to the dialog.
Definition: albaGUIDialog.h:90
albaGUIDialog(const wxString &title, long style=albaCLOSEWINDOW|albaRESIZABLE|albaCLOSE)
void Add(wxWindow *window, int option=0, int flag=wxEXPAND, int border=0)
Add a widget to the dialog.
Definition: albaGUIDialog.h:84
void EnableCancel(bool enable)
wxButton * m_OkButton
Button used to close the dialog with wxID_OK.
virtual void OnSize(wxSizeEvent &event)
Handle on size event.
virtual void OnOK(wxCommandEvent &event)
Virtual functions called to terminate ShowModal - these can be redefined without providing the Event ...
wxBoxSizer * m_ButtonsSizer
Sizer holding the ok,cancel,close button (if any)
wxButton * m_CancelButton
Button used to close the dialog with wxID_CANCEL.
virtual ~albaGUIDialog()
void EnableClose(bool enable)
albaGUI is a panel with function to easily create GUI.
Definition: albaGUI.h:110
void FitGui()
Recalculate 'this' Gui Size and MinSize considering the space required by the children widgets.
void Reparent(wxWindow *parent)
place the GUI on a different parent, and perform the required Resize/Stretch/ and Show
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36