]>
git.saurik.com Git - wxWidgets.git/blob - src/common/dlgcmn.cpp
c708a96e2591af62ef89334f537f53c9cdc31068
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"
36 #include "wx/settings.h"
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 const long wxDialogBase::LAYOUT_X_MARGIN
= 5;
44 const long wxDialogBase::LAYOUT_Y_MARGIN
= 5;
46 const long wxDialogBase::MARGIN_BETWEEN_BUTTONS
= 3*LAYOUT_X_MARGIN
;
48 // ============================================================================
50 // ============================================================================
52 // ----------------------------------------------------------------------------
53 // dialog layout functions
54 // ----------------------------------------------------------------------------
56 wxSize
wxDialogBase::SplitTextMessage(const wxString
& message
,
60 dc
.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
63 long height
, width
, heightTextMax
= 0, widthTextMax
= 0;
64 for ( const wxChar
*pc
= message
; ; pc
++ )
66 if ( *pc
== _T('\n') || !*pc
)
68 dc
.GetTextExtent(curLine
, &width
, &height
);
69 if ( width
> widthTextMax
)
71 if ( height
> heightTextMax
)
72 heightTextMax
= height
;
90 return wxSize(widthTextMax
, heightTextMax
);
93 long wxDialogBase::CreateTextMessage(const wxArrayString
& lines
,
94 const wxPoint
& posText
,
95 const wxSize
& sizeText
)
99 size_t nLineCount
= lines
.GetCount();
100 for ( size_t nLine
= 0; nLine
< nLineCount
; nLine
++ )
102 text
= new wxStaticText(this, -1, lines
[nLine
],
103 wxPoint(posText
.x
, y
),
105 y
+= sizeText
.GetHeight();
111 wxSize
wxDialogBase::GetStandardButtonSize(bool hasCancel
)
114 GetTextExtent(_("OK"), &wButton
, NULL
);
119 GetTextExtent(_("Cancel"), &width
, NULL
);
120 if ( width
> wButton
)
126 // the minimal acceptable width
131 // the width of the button is not just the width of the label...
132 wButton
+= 2*LAYOUT_X_MARGIN
;
135 // a nice looking proportion
136 int hButton
= (wButton
* 23) / 75;
138 return wxSize(wButton
, hButton
);
141 void wxDialogBase::CreateStandardButtons(long wDialog
,
147 // NB: create [Ok] first to get the right tab order
148 wxButton
*ok
= (wxButton
*) NULL
;
149 wxButton
*cancel
= (wxButton
*) NULL
;
151 long x
= wDialog
/ 2;
153 x
-= MARGIN_BETWEEN_BUTTONS
/ 2 + wButton
;
157 ok
= new wxButton( this, wxID_OK
, _("OK"),
159 wxSize(wButton
, hButton
) );
163 x
+= MARGIN_BETWEEN_BUTTONS
+ wButton
;
164 cancel
= new wxButton( this, wxID_CANCEL
, _("Cancel"),
166 wxSize(wButton
, hButton
) );
173 long wxDialogBase::GetStandardTextHeight()
175 return (3*GetCharHeight()) / 2;