]>
git.saurik.com Git - wxWidgets.git/blob - src/common/dlgcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/dlgcmn.cpp
3 // Purpose: common (to all ports) wxDialog functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "dialogbase.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/dialog.h"
33 #include "wx/dcclient.h"
35 #include "wx/settings.h"
36 #include "wx/stattext.h"
40 //--------------------------------------------------------------------------
42 //--------------------------------------------------------------------------
44 wxSizer
*wxDialogBase::CreateTextSizer( const wxString
&message
)
46 wxBoxSizer
*box
= new wxBoxSizer( wxVERTICAL
);
48 // get line height for empty lines
50 wxFont
font( GetFont() );
53 GetTextExtent(_T("H"), (int*)NULL
, &y
, (int*)NULL
, (int*)NULL
, &font
);
56 for (size_t pos
= 0; pos
< message
.Len(); pos
++)
58 if (message
[pos
] == wxT('\n'))
62 wxStaticText
*s1
= new wxStaticText( this, -1, line
);
77 // remaining text behind last '\n'
80 wxStaticText
*s2
= new wxStaticText( this, -1, line
);
87 wxSizer
*wxDialogBase::CreateButtonSizer( long flags
)
89 wxBoxSizer
*box
= new wxBoxSizer( wxHORIZONTAL
);
91 #if defined(__WXMSW__) || defined(__WXMAC__)
92 static const int margin
= 6;
94 static const int margin
= 10;
97 wxButton
*ok
= (wxButton
*) NULL
;
98 wxButton
*cancel
= (wxButton
*) NULL
;
99 wxButton
*yes
= (wxButton
*) NULL
;
100 wxButton
*no
= (wxButton
*) NULL
;
102 // always show an OK button, unless only YES_NO is given
103 if ((flags
& wxYES_NO
) == 0) flags
= flags
| wxOK
;
105 if (flags
& wxYES_NO
)
107 yes
= new wxButton( this, wxID_YES
, _("Yes") );
108 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
109 no
= new wxButton( this, wxID_NO
, _("No") );
110 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
114 yes
= new wxButton( this, wxID_YES
, _("Yes") );
115 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
119 no
= new wxButton( this, wxID_NO
, _("No") );
120 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
125 ok
= new wxButton( this, wxID_OK
, _("OK") );
126 box
->Add( ok
, 0, wxLEFT
|wxRIGHT
, margin
);
129 if (flags
& wxFORWARD
)
130 box
->Add( new wxButton( this, wxID_FORWARD
, _("Forward") ), 0, wxLEFT
|wxRIGHT
, margin
);
132 if (flags
& wxBACKWARD
)
133 box
->Add( new wxButton( this, wxID_BACKWARD
, _("Backward") ), 0, wxLEFT
|wxRIGHT
, margin
);
136 box
->Add( new wxButton( this, wxID_SETUP
, _("Setup") ), 0, wxLEFT
|wxRIGHT
, margin
);
139 box
->Add( new wxButton( this, wxID_MORE
, _("More...") ), 0, wxLEFT
|wxRIGHT
, margin
);
142 box
->Add( new wxButton( this, wxID_HELP
, _("Help") ), 0, wxLEFT
|wxRIGHT
, margin
);
144 if (flags
& wxCANCEL
)
146 cancel
= new wxButton( this, wxID_CANCEL
, _("Cancel") );
147 box
->Add( cancel
, 0, wxLEFT
|wxRIGHT
, margin
);
150 if (flags
& wxNO_DEFAULT
)