]>
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
)
123 GetTextExtent(_("OK"), &wButton
, NULL
);
128 GetTextExtent(_("Cancel"), &width
, NULL
);
129 if ( width
> wButton
)
135 // the minimal acceptable width
140 // the width of the button is not just the width of the label...
141 wButton
+= 2*LAYOUT_X_MARGIN
;
144 // a nice looking proportion
145 int hButton
= (wButton
* 23) / 75;
147 return wxSize(wButton
, hButton
);
150 void wxDialogBase::CreateStandardButtons(long wDialog
,
156 // NB: create [Ok] first to get the right tab order
157 wxButton
*ok
= (wxButton
*) NULL
;
158 wxButton
*cancel
= (wxButton
*) NULL
;
160 long x
= wDialog
/ 2;
162 x
-= MARGIN_BETWEEN_BUTTONS
/ 2 + wButton
;
166 ok
= new wxButton( this, wxID_OK
, _("OK"),
168 wxSize(wButton
, hButton
) );
172 x
+= MARGIN_BETWEEN_BUTTONS
+ wButton
;
173 cancel
= new wxButton( this, wxID_CANCEL
, _("Cancel"),
175 wxSize(wButton
, hButton
) );
182 long wxDialogBase::GetStandardTextHeight()
184 return (3*GetCharHeight()) / 2;