Replaced old wxSizer,

Converted two of wxGTK's standard dialogs to use them,
  Applied two fixes to wxDC code,
  Made wxRadiobox a little smaller,
  Added sizer.h to wx.h


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3325 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-08-09 17:00:51 +00:00
parent d597fcb781
commit 3417c2cd3d
19 changed files with 303 additions and 1346 deletions

View File

@@ -92,9 +92,13 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
SetLabel(label);
int x = 0; int y = 0;
wxFont new_font( parent->GetFont() );
GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font );
wxSize newSize = size;
if (newSize.x == -1) newSize.x = 15+gdk_string_measure( m_widget->style->font, label.mbc_str() );
if (newSize.y == -1) newSize.y = 26;
if (newSize.x == -1) newSize.x = 12+x;
if (newSize.y == -1) newSize.y = 11+y;
SetSize( newSize.x, newSize.y );
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",

View File

@@ -28,6 +28,7 @@
#include "wx/listbox.h"
#include "wx/stattext.h"
#include "wx/intl.h"
#include "wx/sizer.h"
#endif
#if wxUSE_STATLINE
@@ -36,24 +37,19 @@
#include "wx/gtk/choicdlg.h"
/* Split message, using constraints to position controls */
static wxSize wxSplitMessage2( const wxString &message, wxWindow *parent )
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
{
int y = 10;
int w = 50;
wxString line( _T("") );
wxString line;
for (size_t pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
{
if (!line.IsEmpty())
{
wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(15,y) );
wxSize size1( s1->GetSize() );
if (size1.x > w) w = size1.x;
wxStaticText *s1 = new wxStaticText( parent, -1, line );
sizer->Add( s1 );
line = _T("");
}
y += 18;
}
else
{
@@ -61,16 +57,12 @@ static wxSize wxSplitMessage2( const wxString &message, wxWindow *parent )
}
}
// remaining text behind last '\n'
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(15,y) );
wxSize size2( s2->GetSize() );
if (size2.x > w) w = size2.x;
wxStaticText *s2 = new wxStaticText( parent, -1, line );
sizer->Add( s2 );
}
y += 18;
return wxSize(w+30,y);
}
@@ -202,7 +194,7 @@ IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
int n, const wxString *choices, char **clientData, long style, const wxPoint& pos):
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
{
Create(parent, message, caption, n, choices, clientData, style);
}
@@ -240,17 +232,15 @@ bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& m
wxBeginBusyCursor();
wxSize message_size( wxSplitMessage2( message, this ) );
wxBox *topsizer = new wxBox( wxVERTICAL );
wxButton *ok = (wxButton *) NULL;
wxButton *cancel = (wxButton *) NULL;
wxList m_buttons;
int y = message_size.y + 15;
int listbox_height = 150;
wxListBox *listBox = new wxListBox( this, wxID_LISTBOX, wxPoint(10, y), wxSize(360, listbox_height),
// 1) text message
wxBox *textsizer = new wxBox( wxVERTICAL );
wxSplitMessage2( message, this, textsizer );
topsizer->Add( textsizer, 0, wxALL, 10 );
// 2) list box
wxListBox *listBox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) ,
n, choices, wxLB_ALWAYS_SB );
listBox->SetSelection( m_selection );
if (clientData)
@@ -258,53 +248,46 @@ bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& m
for (int i = 0; i < n; i++)
listBox->SetClientData(i, clientData[i]);
}
y += listbox_height + 35;
topsizer->Add( listBox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
if (style & wxOK)
#if wxUSE_STATLINE
// 3) static line
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 3 );
#endif
// 4) buttons
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
wxButton *ok = (wxButton *) NULL;
if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( ok );
ok = new wxButton( this, wxID_OK, _("OK") );
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
}
wxButton *cancel = (wxButton *) NULL;
if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( cancel );
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
}
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
if (ok)
{
ok->SetDefault();
ok->SetFocus();
}
int w = m_buttons.GetCount() * 100;
if (message_size.x > w) w = message_size.x;
int space = w / (m_buttons.GetCount()*2);
listBox->SetSize( 20, -1, w-10, listbox_height );
int m = 0;
wxNode *node = m_buttons.First();
while (node)
{
wxWindow *win = (wxWindow*)node->Data();
int x = (m*2+1)*space - 40 + 15;
win->Move( x, -1 );
node = node->Next();
m++;
}
#if wxUSE_STATLINE
int edge_margin = 7;
(void) new wxStaticLine( this, -1, wxPoint(edge_margin,y-20), wxSize(w+30-2*edge_margin, 5) );
#endif
SetSize( w+30, y+40 );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
SetSizer( topsizer );
SetAutoLayout( TRUE );
Centre( wxBOTH );
if (ok)
ok->SetDefault();
listBox->SetFocus();
wxEndBusyCursor();
return TRUE;

View File

@@ -304,6 +304,7 @@ void wxWindowDC::DoDrawLines( int n, wxPoint points[], long xoffset, long yoffse
long x2 = XLOG2DEV(points[i+1].x + xoffset);
long y1 = YLOG2DEV(points[i].y + yoffset); // oh, what a waste
long y2 = YLOG2DEV(points[i+1].y + yoffset);
if (m_window)
gdk_draw_line( m_window, m_penGC, x1, y1, x2, y2 );
@@ -327,7 +328,7 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], long xoffset, long yoff
CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset );
}
if (m_brush.GetStyle() != wxTRANSPARENT)
if ((m_brush.GetStyle() != wxTRANSPARENT) && m_window)
gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
// To do: Fillstyle
@@ -1039,29 +1040,26 @@ void wxWindowDC::SetBackground( const wxBrush &brush )
gdk_gc_set_background( m_penGC, m_backgroundBrush.GetColour().GetColor() );
gdk_gc_set_background( m_bgGC, m_backgroundBrush.GetColour().GetColor() );
gdk_gc_set_foreground( m_bgGC, m_backgroundBrush.GetColour().GetColor() );
GdkFill fillStyle = GDK_SOLID;
switch (m_backgroundBrush.GetStyle())
{
case wxSOLID:
case wxTRANSPARENT:
break;
default:
fillStyle = GDK_STIPPLED;
}
gdk_gc_set_fill( m_bgGC, fillStyle );
gdk_gc_set_fill( m_bgGC, GDK_SOLID );
if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->Ok()))
{
if (m_backgroundBrush.GetStipple()->GetPixmap())
{
gdk_gc_set_fill( m_bgGC, GDK_TILED );
gdk_gc_set_tile( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() );
}
else
{
gdk_gc_set_fill( m_bgGC, GDK_STIPPLED );
gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetBitmap() );
}
}
if (IS_HATCH(m_backgroundBrush.GetStyle()))
{
gdk_gc_set_fill( m_bgGC, GDK_STIPPLED );
int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH;
gdk_gc_set_stipple( m_bgGC, hatches[num] );
}

View File

@@ -271,7 +271,7 @@ wxSize wxRadioBox::LayoutItems()
node = node->Next();
}
res.x = x+4;
res.y = 42;
res.y = 40;
}
return res;

View File

@@ -28,6 +28,7 @@
#include "wx/stattext.h"
#include "wx/textctrl.h"
#include "wx/intl.h"
#include "wx/sizer.h"
#endif
#if wxUSE_STATLINE
@@ -36,24 +37,19 @@
#include "wx/gtk/textdlg.h"
/* Split message, using constraints to position controls */
static wxSize wxSplitMessage2( const wxString &message, wxWindow *parent )
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
{
int y = 10;
int w = 50;
wxString line( _T("") );
wxString line;
for (size_t pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
{
if (!line.IsEmpty())
{
wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(15,y) );
wxSize size1( s1->GetSize() );
if (size1.x > w) w = size1.x;
wxStaticText *s1 = new wxStaticText( parent, -1, line );
sizer->Add( s1 );
line = _T("");
}
y += 18;
}
else
{
@@ -61,16 +57,12 @@ static wxSize wxSplitMessage2( const wxString &message, wxWindow *parent )
}
}
// remaining text behind last '\n'
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(15,y) );
wxSize size2( s2->GetSize() );
if (size2.x > w) w = size2.x;
wxStaticText *s2 = new wxStaticText( parent, -1, line );
sizer->Add( s2 );
}
y += 18;
return wxSize(w+30,y);
}
// wxTextEntryDialog
@@ -92,64 +84,55 @@ wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, const wxString& message,
wxBeginBusyCursor();
wxSize message_size( wxSplitMessage2( message, this ) );
wxBox *topsizer = new wxBox( wxVERTICAL );
// 1) text message
wxBox *textsizer = new wxBox( wxVERTICAL );
wxSplitMessage2( message, this, textsizer );
topsizer->Add( textsizer, 0, wxALL, 10 );
// 2) text ctrl
wxTextCtrl *textCtrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1));
topsizer->Add( textCtrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
#if wxUSE_STATLINE
// 3) static line
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 3 );
#endif
// 4) buttons
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
wxButton *ok = (wxButton *) NULL;
wxButton *cancel = (wxButton *) NULL;
wxList m_buttons;
int y = message_size.y + 15;
wxTextCtrl *textCtrl = new wxTextCtrl(this, wxID_TEXT, value, wxPoint(-1, y), wxSize(350, -1));
y += 65;
if (style & wxOK)
if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( ok );
ok = new wxButton( this, wxID_OK, _("OK") );
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
}
wxButton *cancel = (wxButton *) NULL;
if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( cancel );
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
}
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
if (ok)
{
ok->SetDefault();
ok->SetFocus();
}
int w = wxMax( 350, m_buttons.GetCount() * 100 );
w = wxMax( w, message_size.x );
int space = w / (m_buttons.GetCount()*2);
textCtrl->SetSize( 20, -1, w-10, -1 );
int m = 0;
wxNode *node = m_buttons.First();
while (node)
{
wxWindow *win = (wxWindow*)node->Data();
int x = (m*2+1)*space - 40 + 15;
win->Move( x, -1 );
node = node->Next();
m++;
}
#if wxUSE_STATLINE
int edge_margin = 7;
(void) new wxStaticLine( this, -1, wxPoint(edge_margin,y-20), wxSize(w+30-2*edge_margin, 5) );
#endif
SetSize( w+30, y+40 );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
SetSizer( topsizer );
SetAutoLayout( TRUE );
Centre( wxBOTH );
if (ok)
ok->SetDefault();
wxEndBusyCursor();
textCtrl->SetFocus();
wxEndBusyCursor();
}
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )