]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dialog.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/dialog.cpp
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #include "wx/dialog.h"
18 #include "wx/cursor.h"
21 #include "wx/evtloop.h"
25 #include <gdk/gdkkeysyms.h>
27 #include "wx/gtk/win_gtk.h"
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 extern int g_openDialogs
;
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 IMPLEMENT_DYNAMIC_CLASS(wxDialog
,wxTopLevelWindow
)
45 m_modalShowing
= false;
46 m_themeEnabled
= true;
49 wxDialog::wxDialog( wxWindow
*parent
,
50 wxWindowID id
, const wxString
&title
,
51 const wxPoint
&pos
, const wxSize
&size
,
52 long style
, const wxString
&name
)
56 (void)Create( parent
, id
, title
, pos
, size
, style
, name
);
59 bool wxDialog::Create( wxWindow
*parent
,
60 wxWindowID id
, const wxString
&title
,
61 const wxPoint
&pos
, const wxSize
&size
,
62 long style
, const wxString
&name
)
64 SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG
);
66 // all dialogs should have tab traversal enabled
67 style
|= wxTAB_TRAVERSAL
;
69 return wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
);
72 bool wxDialog::Show( bool show
)
74 if (!show
&& IsModal())
76 EndModal( wxID_CANCEL
);
79 if (show
&& !m_sizeSet
)
81 /* by calling GtkOnSize here, we don't have to call
82 either after showing the frame, which would entail
83 much ugly flicker nor from within the size_allocate
84 handler, because GTK 1.1.X forbids that. */
86 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
89 bool ret
= wxWindow::Show( show
);
91 if (show
) InitDialog();
96 bool wxDialog::IsModal() const
98 return m_modalShowing
;
101 void wxDialog::SetModal( bool WXUNUSED(flag
) )
103 wxFAIL_MSG( wxT("wxDialog:SetModal obsolete now") );
106 int wxDialog::ShowModal()
110 wxFAIL_MSG( wxT("wxDialog:ShowModal called twice") );
111 return GetReturnCode();
114 // use the apps top level window as parent if none given unless explicitly
116 if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT
) )
118 wxWindow
*parent
= wxTheApp
->GetTopWindow();
121 parent
->IsBeingDeleted() &&
122 !(parent
->GetExtraStyle() & wxWS_EX_TRANSIENT
) )
125 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(parent
->m_widget
) );
129 wxBusyCursorSuspender cs
; // temporarily suppress the busy cursor
133 m_modalShowing
= true;
137 // NOTE: gtk_window_set_modal internally calls gtk_grab_add() !
138 gtk_window_set_modal(GTK_WINDOW(m_widget
), TRUE
);
142 gtk_window_set_modal(GTK_WINDOW(m_widget
), FALSE
);
146 return GetReturnCode();
149 void wxDialog::EndModal( int retCode
)
151 SetReturnCode( retCode
);
155 wxFAIL_MSG( wxT("wxDialog:EndModal called twice") );
159 m_modalShowing
= false;