X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/de8113d9a3b19159fe06e1f3321c799085c8d47d..031bc97f4629f95d445f9716a9d4d61665a19dc9:/src/gtk/dialog.cpp diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 2c7594587c..7edb2940c8 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -96,9 +96,8 @@ END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel) -wxDialog::wxDialog() +void wxDialog::Init() { - m_title = ""; m_sizeSet = FALSE; m_modalShowing = FALSE; } @@ -108,8 +107,8 @@ wxDialog::wxDialog( wxWindow *parent, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { - m_modalShowing = FALSE; - m_sizeSet = FALSE; + Init(); + Create( parent, id, title, pos, size, style, name ); } @@ -143,9 +142,38 @@ bool wxDialog::Create( wxWindow *parent, if (m_parent) m_parent->AddChild( this ); PostCreation(); - + gtk_widget_realize( m_widget ); + /* all this is for Motif Window Manager "hints" and is supposed to be + recognized by other WM as well. not tested. */ + long decor = (long) GDK_DECOR_ALL; + long func = (long) GDK_FUNC_ALL; + + if ((m_windowStyle & wxCAPTION) == 0) + decor |= GDK_DECOR_TITLE; +/* if ((m_windowStyle & wxMINIMIZE) == 0) + func |= GDK_FUNC_MINIMIZE; + if ((m_windowStyle & wxMAXIMIZE) == 0) + func |= GDK_FUNC_MAXIMIZE; */ + if ((m_windowStyle & wxSYSTEM_MENU) == 0) + decor |= GDK_DECOR_MENU; + if ((m_windowStyle & wxMINIMIZE_BOX) == 0) + decor |= GDK_DECOR_MINIMIZE; + if ((m_windowStyle & wxMAXIMIZE_BOX) == 0) + decor |= GDK_DECOR_MAXIMIZE; + if ((m_windowStyle & wxRESIZE_BORDER) == 0) + func |= GDK_FUNC_RESIZE; + + gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor); + gdk_window_set_functions(m_widget->window, (GdkWMFunction)func); + + /* GTK's shrinking/growing policy */ + if ((m_windowStyle & wxRESIZE_BORDER) == 0) + gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1); + else + gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1); + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); @@ -173,8 +201,8 @@ wxDialog::~wxDialog() void wxDialog::SetTitle( const wxString& title ) { m_title = title; - if (m_title.IsNull()) m_title = ""; - gtk_window_set_title( GTK_WINDOW(m_widget), m_title ); + if (m_title.IsNull()) m_title = _T(""); + gtk_window_set_title( GTK_WINDOW(m_widget), m_title.mbc_str() ); } wxString wxDialog::GetTitle() const @@ -237,17 +265,17 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event) // sure to destroy the dialog. // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. - static wxList closing; + static wxList s_closing; - if (closing.Member(this)) + if (s_closing.Member(this)) return; // no loops - closing.Append(this); + s_closing.Append(this); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); cancelEvent.SetEventObject( this ); GetEventHandler()->ProcessEvent(cancelEvent); - closing.DeleteObject(this); + s_closing.DeleteObject(this); } bool wxDialog::Destroy() @@ -259,7 +287,7 @@ bool wxDialog::Destroy() void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) { - wxASSERT_MSG( (m_widget != NULL), "invalid dialog" ); + wxASSERT_MSG( (m_widget != NULL), _T("invalid dialog") ); if (GetAutoLayout()) { @@ -290,10 +318,10 @@ void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) } } -void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) +void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { - wxASSERT_MSG( (m_widget != NULL), "invalid dialog" ); - wxASSERT_MSG( (m_wxwindow != NULL), "invalid dialog" ); + wxASSERT_MSG( (m_widget != NULL), _T("invalid dialog") ); + wxASSERT_MSG( (m_wxwindow != NULL), _T("invalid dialog") ); if (m_resizing) return; /* I don't like recursions */ m_resizing = TRUE; @@ -338,7 +366,7 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) if ((m_x != old_x) || (m_y != old_y)) { /* m_sizeSet = FALSE; */ - gtk_widget_set_uposition( m_widget, m_x, m_y ); + gtk_widget_set_uposition( m_widget, m_x, m_y ); } } @@ -350,11 +378,6 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } -void wxDialog::SetSize( int width, int height ) -{ - SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); -} - void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) { // due to a bug in gtk, x,y are always 0 @@ -384,7 +407,7 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh void wxDialog::Centre( int direction ) { - wxASSERT_MSG( (m_widget != NULL), "invalid dialog" ); + wxASSERT_MSG( (m_widget != NULL), _T("invalid dialog") ); int x = 0; int y = 0; @@ -419,7 +442,7 @@ bool wxDialog::Show( bool show ) } wxWindow::Show( show ); - + if (show) InitDialog(); return TRUE; @@ -438,17 +461,17 @@ void wxDialog::SetModal( bool WXUNUSED(flag) ) else if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL; */ - wxFAIL_MSG( "wxDialog:SetModal obsolete now" ); + wxFAIL_MSG( _T("wxDialog:SetModal obsolete now") ); } int wxDialog::ShowModal() { if (IsModal()) { - wxFAIL_MSG( "wxDialog:ShowModal called twice" ); + wxFAIL_MSG( _T("wxDialog:ShowModal called twice") ); return GetReturnCode(); } - + Show( TRUE ); m_modalShowing = TRUE; @@ -466,7 +489,7 @@ void wxDialog::EndModal( int retCode ) if (!IsModal()) { - wxFAIL_MSG( "wxDialog:EndModal called twice" ); + wxFAIL_MSG( _T("wxDialog:EndModal called twice") ); return; }