]>
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/button.h"
33 #include "wx/dialog.h"
34 #include "wx/dcclient.h"
36 #include "wx/settings.h"
37 #include "wx/stattext.h"
39 #include "wx/button.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
font( GetFont() );
55 GetTextExtent(_T("H"), (int*)NULL
, &y
, (int*)NULL
, (int*)NULL
, &font
);
58 for (size_t pos
= 0; pos
< message
.Len(); pos
++)
60 if (message
[pos
] == wxT('\n'))
64 wxStaticText
*s1
= new wxStaticText( this, -1, line
);
79 // remaining text behind last '\n'
82 wxStaticText
*s2
= new wxStaticText( this, -1, line
);
89 wxSizer
*wxDialogBase::CreateButtonSizer( long flags
)
91 wxBoxSizer
*box
= new wxBoxSizer( wxHORIZONTAL
);
93 #if defined(__WXMSW__) || defined(__WXMAC__)
94 static const int margin
= 6;
96 static const int margin
= 10;
99 wxButton
*ok
= (wxButton
*) NULL
;
100 wxButton
*cancel
= (wxButton
*) NULL
;
101 wxButton
*yes
= (wxButton
*) NULL
;
102 wxButton
*no
= (wxButton
*) NULL
;
104 // always show an OK button, unless only YES_NO is given
105 if ((flags
& wxYES_NO
) == 0) flags
= flags
| wxOK
;
107 if (flags
& wxYES_NO
)
109 yes
= new wxButton( this, wxID_YES
, _("Yes") );
110 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
111 no
= new wxButton( this, wxID_NO
, _("No") );
112 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
116 yes
= new wxButton( this, wxID_YES
, _("Yes") );
117 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
121 no
= new wxButton( this, wxID_NO
, _("No") );
122 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
127 ok
= new wxButton( this, wxID_OK
, _("OK") );
128 box
->Add( ok
, 0, wxLEFT
|wxRIGHT
, margin
);
131 if (flags
& wxFORWARD
)
132 box
->Add( new wxButton( this, wxID_FORWARD
, _("Forward") ), 0, wxLEFT
|wxRIGHT
, margin
);
134 if (flags
& wxBACKWARD
)
135 box
->Add( new wxButton( this, wxID_BACKWARD
, _("Backward") ), 0, wxLEFT
|wxRIGHT
, margin
);
138 box
->Add( new wxButton( this, wxID_SETUP
, _("Setup") ), 0, wxLEFT
|wxRIGHT
, margin
);
141 box
->Add( new wxButton( this, wxID_MORE
, _("More...") ), 0, wxLEFT
|wxRIGHT
, margin
);
144 box
->Add( new wxButton( this, wxID_HELP
, _("Help") ), 0, wxLEFT
|wxRIGHT
, margin
);
146 if (flags
& wxCANCEL
)
148 cancel
= new wxButton( this, wxID_CANCEL
, _("Cancel") );
149 box
->Add( cancel
, 0, wxLEFT
|wxRIGHT
, margin
);
152 if (flags
& wxNO_DEFAULT
)