- wxSizer *topSizer = new wxSizer(this, wxSizerShrink);
- topSizer->SetBorder(10, 10);
-
- // message sizer at the top
- wxRowColSizer *messageSizer = new wxRowColSizer(topSizer, wxSIZER_COLS, 100);
- messageSizer->SetName(_T("messageSizer"));
-
-// bool centre = ((style & wxCENTRE) == wxCENTRE);
-
- wxList messageList;
- wxSplitMessage2(message, &messageList, this, messageSizer);
-
- // spacer size in the middle
- wxSpacingSizer *spacingSizer = new wxSpacingSizer(topSizer, wxBelow, messageSizer, 20);
-
- // row size at the bottom
- wxRowColSizer *buttonSizer = new wxRowColSizer(topSizer, wxSIZER_ROWS );
- buttonSizer->SetName(_T("buttonSizer"));
- buttonSizer->SetSpacing(12,0);
-
- // Specify constraints for the button sizer
- wxLayoutConstraints *c = new wxLayoutConstraints;
- c->width.AsIs ();
- c->height.AsIs ();
- c->top.Below (spacingSizer);
- c->left.Absolute (10);
-// c->centreX.SameAs (spacingSizer, wxCentreX);
- buttonSizer->SetConstraints(c);
-
- wxButton *ok = (wxButton *) NULL;
- wxButton *cancel = (wxButton *) NULL;
- wxButton *yes = (wxButton *) NULL;
- wxButton *no = (wxButton *) NULL;
-
- if (style & wxYES_NO) {
- yes = new wxButton(this, wxID_YES, _("Yes"), wxDefaultPosition, wxSize(75,-1) );
- no = new wxButton(this, wxID_NO, _("No"), wxDefaultPosition, wxSize(75,-1) );
-
- buttonSizer->AddSizerChild(yes);
- buttonSizer->AddSizerChild(no);
+ wxLayoutConstraints *c;
+ SetAutoLayout(TRUE);
+
+ wxStaticBitmap *icon = new wxStaticBitmap(this, -1,
+ wxTheApp->GetStdIcon(style & wxICON_MASK));
+ const int iconSize = icon->GetBitmap().GetWidth();
+
+ // split the message in lines
+ // --------------------------
+
+ wxArrayString lines;
+ wxSize sizeText = SplitTextMessage(message, &lines);
+ long widthTextMax = sizeText.GetWidth(),
+ heightTextMax = sizeText.GetHeight();
+ size_t nLineCount = lines.GetCount();
+
+ // calculate the total dialog size
+ enum
+ {
+ Btn_Ok,
+ Btn_Yes,
+ Btn_No,
+ Btn_Cancel,
+ Btn_Max
+ };
+ wxButton *buttons[Btn_Max] = { NULL, NULL, NULL, NULL };
+ int nDefaultBtn = -1;
+
+ // some checks are in order...
+ wxASSERT_MSG( !(style & wxOK) || !(style & wxYES_NO),
+ "don't create dialog with both Yes/No and Ok buttons!" );
+
+ wxASSERT_MSG( (style & wxOK ) || (style & wxYES_NO),
+ "don't create dialog with only the Cancel button!" );
+
+ if ( style & wxYES_NO ) {
+ buttons[Btn_Yes] = new wxButton(this, wxID_YES, _("Yes"));
+ buttons[Btn_No] = new wxButton(this, wxID_NO, _("No"));
+
+
+ if(style & wxNO_DEFAULT)
+ nDefaultBtn = Btn_No;
+ else
+ nDefaultBtn = Btn_Yes;