- m_dialogStyle = style;
- m_selection = 0;
- m_clientData = NULL;
-
- // dialog layout constants
- static const int LAYOUT_X_MARGIN = 5;
- static const int LAYOUT_Y_MARGIN = 5;
- static const int MARGIN_BETWEEN_BUTTONS = 3*LAYOUT_X_MARGIN;
-
- // calc the message size
- // ---------------------
-
- // TODO this should be factored out to a common function (also used in
- // msgdlgg.cpp)
- wxClientDC dc(this);
- dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
-
- wxArrayString lines;
- wxString curLine;
- long height, width, heightTextMax = 0, widthTextMax = 0;
- for ( const char *pc = message; ; pc++ ) {
- if ( *pc == '\n' || *pc == '\0' ) {
- dc.GetTextExtent(curLine, &width, &height);
- if ( width > widthTextMax )
- widthTextMax = width;
- if ( height > heightTextMax )
- heightTextMax = height;
-
- lines.Add(curLine);
-
- if ( *pc == '\n' ) {
- curLine.Empty();
- }
- else {
- // the end of string
- break;
- }
- }
- else {
- curLine += *pc;
- }
- }
-
- size_t nLineCount = lines.Count();
- long hTotalMsg = heightTextMax*nLineCount;
-
- // calc the button size
- // --------------------
-
- bool hasCancel = FALSE;
-
- // always create the OK button - the code below supposes we do have buttons
- // and besides the user should have some way to close this dialog
- wxASSERT_MSG( style & wxOK, _T("this dialog should have OK button") );
-
- wxString labelOk(_("OK"));
- long wButton = 0;
- dc.GetTextExtent(labelOk, &width, NULL);
- if ( width > wButton )
- wButton = width;
-
- wxString labelCancel;
- if ( style & wxCANCEL )
- {
- labelCancel = _("Cancel");
- dc.GetTextExtent(labelCancel, &width, NULL);
- if ( width > wButton )
- wButton = width;
-
- hasCancel = TRUE;
- }