Layout things in wxMessageBox

Positioning of frames and dialogs


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2286 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-04-26 13:10:49 +00:00
parent a89ae1e485
commit 227e5e99cd
9 changed files with 119 additions and 39 deletions

View File

@@ -190,9 +190,13 @@ void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) )
"Message box text", wxYES_NO|wxCANCEL); "Message box text", wxYES_NO|wxCANCEL);
dialog.ShowModal(); dialog.ShowModal();
#endif
::wxMessageBox("MsgBox with a really long long string", ::wxMessageBox("MsgBox with a really long long string",
"this is the text", wxYES_NO|wxICON_EXCLAMATION); "this is the text", wxYES_NO|wxICON_EXCLAMATION);
#endif
::wxMessageBox("Short",
"This is the text", wxYES_NO|wxICON_EXCLAMATION);
} }
void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event) ) void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event) )

View File

@@ -1363,6 +1363,7 @@ bool wxSizer::LayoutPhase1(int *noChanges)
// Find the bounding box and set own size // Find the bounding box and set own size
int maxX = 0; int maxX = 0;
int maxY = 0; int maxY = 0;
wxNode *node = GetChildren().First(); wxNode *node = GetChildren().First();
while (node) while (node)
{ {
@@ -1374,10 +1375,11 @@ bool wxSizer::LayoutPhase1(int *noChanges)
maxX = (x + width); maxX = (x + width);
if ((y+height) > maxY) if ((y+height) > maxY)
maxY = (y + height); maxY = (y + height);
node = node->Next(); node = node->Next();
} }
SetSize(GetBorderX(), GetBorderY(), maxX, maxY); SetSize(GetBorderX(), GetBorderY(), maxX, maxY);
// If this is the only sizer for the parent, size the parent to this sizer. // If this is the only sizer for the parent, size the parent to this sizer.
if ( m_sizerParent && (m_sizerParent->GetSizer() == this) ) if ( m_sizerParent && (m_sizerParent->GetSizer() == this) )
m_sizerParent->SetClientSize(maxX + 2*GetBorderX(), maxY + 2*GetBorderY()); m_sizerParent->SetClientSize(maxX + 2*GetBorderX(), maxY + 2*GetBorderY());
@@ -1555,7 +1557,7 @@ bool wxRowColSizer::LayoutPhase1(int *noChanges)
int currentY = borderY; int currentY = borderY;
int maxX = currentX; int maxX = currentX;
int maxY = currentY; int maxY = currentY;
wxNode *node = GetChildren().First(); wxNode *node = GetChildren().First();
while (node) while (node)
{ {

View File

@@ -98,6 +98,7 @@ wxGenericMessageDialog::wxGenericMessageDialog(wxWindow *parent, const wxString&
wxSizer *topSizer = new wxSizer(this, wxSizerShrink); wxSizer *topSizer = new wxSizer(this, wxSizerShrink);
topSizer->SetBorder(10, 10); topSizer->SetBorder(10, 10);
// message sizer at the top
wxRowColSizer *messageSizer = new wxRowColSizer(topSizer, wxSIZER_COLS, 100); wxRowColSizer *messageSizer = new wxRowColSizer(topSizer, wxSIZER_COLS, 100);
messageSizer->SetName(_T("messageSizer")); messageSizer->SetName(_T("messageSizer"));
@@ -106,10 +107,11 @@ wxGenericMessageDialog::wxGenericMessageDialog(wxWindow *parent, const wxString&
wxList messageList; wxList messageList;
wxSplitMessage2(message, &messageList, this, messageSizer); wxSplitMessage2(message, &messageList, this, messageSizer);
// Insert a spacer // spacer size in the middle
wxSpacingSizer *spacingSizer = new wxSpacingSizer(topSizer, wxBelow, messageSizer, 20); wxSpacingSizer *spacingSizer = new wxSpacingSizer(topSizer, wxBelow, messageSizer, 20);
wxRowColSizer *buttonSizer = new wxRowColSizer(topSizer, wxSIZER_ROWS); // row size at the bottom
wxRowColSizer *buttonSizer = new wxRowColSizer(topSizer, wxSIZER_ROWS );
buttonSizer->SetName(_T("buttonSizer")); buttonSizer->SetName(_T("buttonSizer"));
buttonSizer->SetSpacing(12,0); buttonSizer->SetSpacing(12,0);
@@ -118,9 +120,10 @@ wxGenericMessageDialog::wxGenericMessageDialog(wxWindow *parent, const wxString&
c->width.AsIs (); c->width.AsIs ();
c->height.AsIs (); c->height.AsIs ();
c->top.Below (spacingSizer); c->top.Below (spacingSizer);
c->centreX.SameAs (spacingSizer, wxCentreX); c->left.Absolute (10);
// c->centreX.SameAs (spacingSizer, wxCentreX);
buttonSizer->SetConstraints(c); buttonSizer->SetConstraints(c);
wxButton *ok = (wxButton *) NULL; wxButton *ok = (wxButton *) NULL;
wxButton *cancel = (wxButton *) NULL; wxButton *cancel = (wxButton *) NULL;
wxButton *yes = (wxButton *) NULL; wxButton *yes = (wxButton *) NULL;
@@ -156,6 +159,7 @@ wxGenericMessageDialog::wxGenericMessageDialog(wxWindow *parent, const wxString&
} }
Layout(); Layout();
Centre(wxBOTH); Centre(wxBOTH);
wxEndBusyCursor(); wxEndBusyCursor();

View File

@@ -132,6 +132,18 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
return FALSE; return FALSE;
} }
//-----------------------------------------------------------------------------
// "map" from m_widget
//-----------------------------------------------------------------------------
static gint
gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win )
{
gtk_widget_set_uposition( widget, win->m_x, win->m_y );
return FALSE;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxDialog // wxDialog
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -197,7 +209,12 @@ bool wxDialog::Create( wxWindow *parent,
been realized, so we do this directly after realization */ been realized, so we do this directly after realization */
gtk_signal_connect( GTK_OBJECT(m_widget), "realize", gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this ); GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
/* we set the position of the window after the map event. setting it
before has no effect (with KWM) */
gtk_signal_connect( GTK_OBJECT(m_widget), "map",
GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this );
/* the user resized the frame by dragging etc. */ /* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );
@@ -390,13 +407,16 @@ void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{ {
if ((m_x != old_x) || (m_y != old_y)) if ((m_x != old_x) || (m_y != old_y))
{ {
/* m_sizeSet = FALSE; */ /* we set the position here and when showing the dialog
for the first time in idle time */
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
} }
} }
if ((m_width != old_width) || (m_height != old_height)) if ((m_width != old_width) || (m_height != old_height))
{ {
/* actual resizing is deferred to GtkOnSize in idle time and
when showing the dialog */
m_sizeSet = FALSE; m_sizeSet = FALSE;
} }
@@ -466,7 +486,17 @@ bool wxDialog::Show( bool show )
GtkOnSize( m_x, m_y, m_width, m_height ); GtkOnSize( m_x, m_y, m_width, m_height );
} }
wxWindow::Show( show ); if (show != m_isShown)
{
if (show)
{
gtk_widget_show( m_widget );
}
else
gtk_widget_hide( m_widget );
m_isShown = show;
}
if (show) InitDialog(); if (show) InitDialog();

View File

@@ -193,15 +193,17 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
win->SetIcon( icon ); win->SetIcon( icon );
} }
if (!win->m_sizeSet) return FALSE;
{ }
/* by calling GtkOnSize here, we don't have to call
either after showing the frame, which would entail //-----------------------------------------------------------------------------
much ugly flicker or from within the size_allocate // "map" from m_widget
handler, because GTK 1.1.X forbids that. */ //-----------------------------------------------------------------------------
win->GtkOnSize( win->m_x, win->m_y, win->m_width, win->m_height ); static gint
} gtk_frame_map_callback( GtkWidget *widget, wxFrame *win )
{
gtk_widget_set_uposition( widget, win->m_x, win->m_y );
return FALSE; return FALSE;
} }
@@ -356,6 +358,11 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_signal_connect( GTK_OBJECT(m_widget), "realize", gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this ); GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
/* we set the position of the window after the map event. setting it
before has no effect (with KWM) */
gtk_signal_connect( GTK_OBJECT(m_widget), "map",
GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer) this );
/* the user resized the frame by dragging etc. */ /* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
@@ -391,7 +398,6 @@ bool wxFrame::Show( bool show )
{ {
wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
#if 0
if (show && !m_sizeSet) if (show && !m_sizeSet)
{ {
/* by calling GtkOnSize here, we don't have to call /* by calling GtkOnSize here, we don't have to call
@@ -401,7 +407,6 @@ bool wxFrame::Show( bool show )
GtkOnSize( m_x, m_y, m_width, m_height ); GtkOnSize( m_x, m_y, m_width, m_height );
} }
#endif
return wxWindow::Show( show ); return wxWindow::Show( show );
} }
@@ -465,8 +470,8 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{ {
if ((m_x != old_x) || (m_y != old_y)) if ((m_x != old_x) || (m_y != old_y))
{ {
/* m_sizeSet = FALSE; */ /* we set the size here and in gtk_frame_map_callback */
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
} }
} }

View File

@@ -416,6 +416,7 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
myfixed = GTK_MYFIXED (widget); myfixed = GTK_MYFIXED (widget);
widget->allocation = *allocation;
#if (GTK_MINOR_VERSION > 0) #if (GTK_MINOR_VERSION > 0)
if (myfixed->shadow_type == GTK_SHADOW_NONE) if (myfixed->shadow_type == GTK_SHADOW_NONE)
border = 0; border = 0;
@@ -425,7 +426,6 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
border = 0; border = 0;
#endif #endif
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget)) if (GTK_WIDGET_REALIZED (widget))
{ {
gdk_window_move_resize( widget->window, gdk_window_move_resize( widget->window,

View File

@@ -132,6 +132,18 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
return FALSE; return FALSE;
} }
//-----------------------------------------------------------------------------
// "map" from m_widget
//-----------------------------------------------------------------------------
static gint
gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win )
{
gtk_widget_set_uposition( widget, win->m_x, win->m_y );
return FALSE;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxDialog // wxDialog
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -197,7 +209,12 @@ bool wxDialog::Create( wxWindow *parent,
been realized, so we do this directly after realization */ been realized, so we do this directly after realization */
gtk_signal_connect( GTK_OBJECT(m_widget), "realize", gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this ); GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
/* we set the position of the window after the map event. setting it
before has no effect (with KWM) */
gtk_signal_connect( GTK_OBJECT(m_widget), "map",
GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this );
/* the user resized the frame by dragging etc. */ /* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );
@@ -390,13 +407,16 @@ void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{ {
if ((m_x != old_x) || (m_y != old_y)) if ((m_x != old_x) || (m_y != old_y))
{ {
/* m_sizeSet = FALSE; */ /* we set the position here and when showing the dialog
for the first time in idle time */
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
} }
} }
if ((m_width != old_width) || (m_height != old_height)) if ((m_width != old_width) || (m_height != old_height))
{ {
/* actual resizing is deferred to GtkOnSize in idle time and
when showing the dialog */
m_sizeSet = FALSE; m_sizeSet = FALSE;
} }
@@ -466,7 +486,17 @@ bool wxDialog::Show( bool show )
GtkOnSize( m_x, m_y, m_width, m_height ); GtkOnSize( m_x, m_y, m_width, m_height );
} }
wxWindow::Show( show ); if (show != m_isShown)
{
if (show)
{
gtk_widget_show( m_widget );
}
else
gtk_widget_hide( m_widget );
m_isShown = show;
}
if (show) InitDialog(); if (show) InitDialog();

View File

@@ -193,15 +193,17 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
win->SetIcon( icon ); win->SetIcon( icon );
} }
if (!win->m_sizeSet) return FALSE;
{ }
/* by calling GtkOnSize here, we don't have to call
either after showing the frame, which would entail //-----------------------------------------------------------------------------
much ugly flicker or from within the size_allocate // "map" from m_widget
handler, because GTK 1.1.X forbids that. */ //-----------------------------------------------------------------------------
win->GtkOnSize( win->m_x, win->m_y, win->m_width, win->m_height ); static gint
} gtk_frame_map_callback( GtkWidget *widget, wxFrame *win )
{
gtk_widget_set_uposition( widget, win->m_x, win->m_y );
return FALSE; return FALSE;
} }
@@ -356,6 +358,11 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_signal_connect( GTK_OBJECT(m_widget), "realize", gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this ); GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
/* we set the position of the window after the map event. setting it
before has no effect (with KWM) */
gtk_signal_connect( GTK_OBJECT(m_widget), "map",
GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer) this );
/* the user resized the frame by dragging etc. */ /* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
@@ -391,7 +398,6 @@ bool wxFrame::Show( bool show )
{ {
wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
#if 0
if (show && !m_sizeSet) if (show && !m_sizeSet)
{ {
/* by calling GtkOnSize here, we don't have to call /* by calling GtkOnSize here, we don't have to call
@@ -401,7 +407,6 @@ bool wxFrame::Show( bool show )
GtkOnSize( m_x, m_y, m_width, m_height ); GtkOnSize( m_x, m_y, m_width, m_height );
} }
#endif
return wxWindow::Show( show ); return wxWindow::Show( show );
} }
@@ -465,8 +470,8 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{ {
if ((m_x != old_x) || (m_y != old_y)) if ((m_x != old_x) || (m_y != old_y))
{ {
/* m_sizeSet = FALSE; */ /* we set the size here and in gtk_frame_map_callback */
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
} }
} }

View File

@@ -416,6 +416,7 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
myfixed = GTK_MYFIXED (widget); myfixed = GTK_MYFIXED (widget);
widget->allocation = *allocation;
#if (GTK_MINOR_VERSION > 0) #if (GTK_MINOR_VERSION > 0)
if (myfixed->shadow_type == GTK_SHADOW_NONE) if (myfixed->shadow_type == GTK_SHADOW_NONE)
border = 0; border = 0;
@@ -425,7 +426,6 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
border = 0; border = 0;
#endif #endif
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget)) if (GTK_WIDGET_REALIZED (widget))
{ {
gdk_window_move_resize( widget->window, gdk_window_move_resize( widget->window,