]>
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 // ----------------------------------------------------------------------------
22 #pragma implementation
26 // For compilers that support precompilation, includes "wx.h".
27 #include "wx/wxprec.h"
34 #include "wx/dialog.h"
35 #include "wx/dcclient.h"
37 #include "wx/settings.h"
38 #include "wx/stattext.h"
42 //--------------------------------------------------------------------------
44 //--------------------------------------------------------------------------
46 wxSizer
*wxDialogBase::CreateTextSizer( const wxString
&message
)
48 wxBoxSizer
*box
= new wxBoxSizer( wxVERTICAL
);
50 // get line height for empty lines
52 wxFont
new_font( GetFont() );
53 if (!new_font
.Ok()) new_font
= *wxSWISS_FONT
;
54 GetTextExtent( "H", (int*)NULL
, &y
, (int*)NULL
, (int*)NULL
, &new_font
);
57 for (size_t pos
= 0; pos
< message
.Len(); pos
++)
59 if (message
[pos
] == _T('\n'))
63 wxStaticText
*s1
= new wxStaticText( this, -1, line
);
78 // remaining text behind last '\n'
81 wxStaticText
*s2
= new wxStaticText( this, -1, line
);
88 wxSizer
*wxDialogBase::CreateButtonSizer( long flags
)
90 wxBoxSizer
*box
= new wxBoxSizer( wxHORIZONTAL
);
92 #if defined(__WXMSW__) || defined(__WXMAC__)
98 wxButton
*ok
= (wxButton
*) NULL
;
99 wxButton
*cancel
= (wxButton
*) NULL
;
100 wxButton
*yes
= (wxButton
*) NULL
;
101 wxButton
*no
= (wxButton
*) NULL
;
103 // always show an OK button, unless only YES_NO is given
104 if ((flags
& wxYES_NO
) == 0) flags
= flags
| wxOK
;
106 if (flags
& wxYES_NO
)
108 yes
= new wxButton( this, wxID_YES
, _("Yes") );
109 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
110 no
= new wxButton( this, wxID_NO
, _("No") );
111 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
115 yes
= new wxButton( this, wxID_YES
, _("Yes") );
116 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
120 no
= new wxButton( this, wxID_NO
, _("No") );
121 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
126 ok
= new wxButton( this, wxID_OK
, _("OK") );
127 box
->Add( ok
, 0, wxLEFT
|wxRIGHT
, margin
);
130 if (flags
& wxFORWARD
)
131 box
->Add( new wxButton( this, wxID_FORWARD
, _("Forward") ), 0, wxLEFT
|wxRIGHT
, margin
);
133 if (flags
& wxBACKWARD
)
134 box
->Add( new wxButton( this, wxID_BACKWARD
, _("Backward") ), 0, wxLEFT
|wxRIGHT
, margin
);
137 box
->Add( new wxButton( this, wxID_SETUP
, _("Setup") ), 0, wxLEFT
|wxRIGHT
, margin
);
140 box
->Add( new wxButton( this, wxID_MORE
, _("More...") ), 0, wxLEFT
|wxRIGHT
, margin
);
143 box
->Add( new wxButton( this, wxID_HELP
, _("Help") ), 0, wxLEFT
|wxRIGHT
, margin
);
145 if (flags
& wxCANCEL
)
147 cancel
= new wxButton( this, wxID_CANCEL
, _("Cancel") );
148 box
->Add( cancel
, 0, wxLEFT
|wxRIGHT
, margin
);
151 if (flags
& wxNO_DEFAULT
)