]>
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"
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 const long wxDialogBase::LAYOUT_X_MARGIN
= 5;
46 const long wxDialogBase::LAYOUT_Y_MARGIN
= 5;
48 const long wxDialogBase::MARGIN_BETWEEN_BUTTONS
= 3*LAYOUT_X_MARGIN
;
50 // ============================================================================
52 // ============================================================================
54 // ----------------------------------------------------------------------------
55 // dialog layout functions
56 // ----------------------------------------------------------------------------
58 wxSize
wxDialogBase::SplitTextMessage(const wxString
& message
,
62 dc
.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
65 long height
, width
, heightTextMax
= 0, widthTextMax
= 0;
66 for ( const wxChar
*pc
= message
; ; pc
++ )
68 if ( *pc
== _T('\n') || !*pc
)
70 #if defined(__VISAGECPP__)
71 // have two versions of this in wxWindowDC tp avoid function hiding
72 // since there are two of these in wxDCBase, and in turn in wxDC.
73 // VA cannot resolve this so:
74 dc
.GetTextExtent(curLine
, &width
, &height
, NULL
, NULL
, NULL
, FALSE
);
76 dc
.GetTextExtent(curLine
, &width
, &height
);
78 if ( width
> widthTextMax
)
80 if ( height
> heightTextMax
)
81 heightTextMax
= height
;
99 return wxSize(widthTextMax
, heightTextMax
);
102 long wxDialogBase::CreateTextMessage(const wxArrayString
& lines
,
103 const wxPoint
& posText
,
104 const wxSize
& sizeText
)
108 size_t nLineCount
= lines
.GetCount();
109 for ( size_t nLine
= 0; nLine
< nLineCount
; nLine
++ )
111 text
= new wxStaticText(this, -1, lines
[nLine
],
112 wxPoint(posText
.x
, y
),
114 y
+= sizeText
.GetHeight();
120 wxSize
wxDialogBase::GetStandardButtonSize(bool hasCancel
)
124 GetTextExtent(_("OK"), &wButton
, NULL
);
129 GetTextExtent(_("Cancel"), &width
, NULL
);
130 if ( width
> wButton
)
136 // the minimal acceptable width
141 // the width of the button is not just the width of the label...
142 wButton
+= 2*LAYOUT_X_MARGIN
;
145 // a nice looking proportion
146 int hButton
= (wButton
* 23) / 75;
148 return wxSize(wButton
, hButton
);
150 return wxButton::GetDefaultSize();
154 void wxDialogBase::CreateStandardButtons(long wDialog
,
160 // NB: create [Ok] first to get the right tab order
161 wxButton
*ok
= (wxButton
*) NULL
;
162 wxButton
*cancel
= (wxButton
*) NULL
;
164 long x
= wDialog
/ 2;
166 x
-= MARGIN_BETWEEN_BUTTONS
/ 2 + wButton
;
170 ok
= new wxButton( this, wxID_OK
, _("OK"),
172 wxSize(wButton
, hButton
) );
176 x
+= MARGIN_BETWEEN_BUTTONS
+ wButton
;
177 cancel
= new wxButton( this, wxID_CANCEL
, _("Cancel"),
179 wxSize(wButton
, hButton
) );
186 long wxDialogBase::GetStandardTextHeight()
188 return (3*GetCharHeight()) / 2;