]>
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
new_font( GetFont() );
51 if (!new_font
.Ok()) new_font
= *wxSWISS_FONT
;
52 GetTextExtent( "H", (int*)NULL
, &y
, (int*)NULL
, (int*)NULL
, &new_font
);
55 for (size_t pos
= 0; pos
< message
.Len(); pos
++)
57 if (message
[pos
] == wxT('\n'))
61 wxStaticText
*s1
= new wxStaticText( this, -1, line
);
76 // remaining text behind last '\n'
79 wxStaticText
*s2
= new wxStaticText( this, -1, line
);
86 wxSizer
*wxDialogBase::CreateButtonSizer( long flags
)
88 wxBoxSizer
*box
= new wxBoxSizer( wxHORIZONTAL
);
90 #if defined(__WXMSW__) || defined(__WXMAC__)
96 wxButton
*ok
= (wxButton
*) NULL
;
97 wxButton
*cancel
= (wxButton
*) NULL
;
98 wxButton
*yes
= (wxButton
*) NULL
;
99 wxButton
*no
= (wxButton
*) NULL
;
101 // always show an OK button, unless only YES_NO is given
102 if ((flags
& wxYES_NO
) == 0) flags
= flags
| wxOK
;
104 if (flags
& wxYES_NO
)
106 yes
= new wxButton( this, wxID_YES
, _("Yes") );
107 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
108 no
= new wxButton( this, wxID_NO
, _("No") );
109 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
113 yes
= new wxButton( this, wxID_YES
, _("Yes") );
114 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
118 no
= new wxButton( this, wxID_NO
, _("No") );
119 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
124 ok
= new wxButton( this, wxID_OK
, _("OK") );
125 box
->Add( ok
, 0, wxLEFT
|wxRIGHT
, margin
);
128 if (flags
& wxFORWARD
)
129 box
->Add( new wxButton( this, wxID_FORWARD
, _("Forward") ), 0, wxLEFT
|wxRIGHT
, margin
);
131 if (flags
& wxBACKWARD
)
132 box
->Add( new wxButton( this, wxID_BACKWARD
, _("Backward") ), 0, wxLEFT
|wxRIGHT
, margin
);
135 box
->Add( new wxButton( this, wxID_SETUP
, _("Setup") ), 0, wxLEFT
|wxRIGHT
, margin
);
138 box
->Add( new wxButton( this, wxID_MORE
, _("More...") ), 0, wxLEFT
|wxRIGHT
, margin
);
141 box
->Add( new wxButton( this, wxID_HELP
, _("Help") ), 0, wxLEFT
|wxRIGHT
, margin
);
143 if (flags
& wxCANCEL
)
145 cancel
= new wxButton( this, wxID_CANCEL
, _("Cancel") );
146 box
->Add( cancel
, 0, wxLEFT
|wxRIGHT
, margin
);
149 if (flags
& wxNO_DEFAULT
)