⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpdlg.cxx

📁 windows mobile phone source code
💻 CXX
📖 第 1 页 / 共 2 页
字号:
  if (dlgdim.Width() < titledim.Width())
    dlgdim.SetWidth(titledim.Width());

  // Now clip to the screen size
  PDim sdim(FromPixels(owner->GetScreenRect().Dimensions()));
  if (dlgdim.Width() > sdim.Width()) {
    dlgdim.SetWidth(sdim.Width());
    tdim.SetWidth(dlgdim.Width() - 20 - idim.Width());
  }
  if (dlgdim.Height() > sdim.Height())
    dlgdim.SetHeight(sdim.Height());

  // Make sure it doesn't get smaller than 1/4 screen width either.
  sdim.SetWidth(sdim.Width()/4);
  if (dlgdim.Width() < sdim.Width())
    dlgdim.SetWidth(sdim.Width());

  // Size and position the dialog
  SetDimensions(dlgdim, LocalCoords);
  SetPosition(0, 0, CentreScreen, CentreScreen);
  
  // Now position all the child windows
  if (icon != NULL) {
    PDIMENSION ty = dlgdim.Height() - bzonedim.Height() - 10;
    icon->SetPosition(10, 10 + (ty - idim.Height())/2);
    text->SetPosition(10 + idim.Width(), 10);
    text->SetDimensions(dlgdim.Width()-20-idim.Width(), ty, LocalCoords);
  }
  else {
    text->SetPosition(10, 10);
    text->SetDimensions(dlgdim.Width()-20,
                        dlgdim.Height() - bzonedim.Height() - 10,
                        LocalCoords);
  }
  
  PORDINATE bpos = dlgdim.Height() - bzonedim.Height() + bdim.Height()/2;
  if (btn2 != NULL && btn3 != NULL) {
    PORDINATE gap = (dlgdim.Width() - bdim.Width()*3)/4;
    btn1->SetPosition(gap, bpos);
    btn2->SetPosition(gap*2 + bdim.Width(), bpos);
    btn3->SetPosition(gap*3 + bdim.Width()*2, bpos);
  }
  else if (btn2 != NULL) {
    PORDINATE gap = (dlgdim.Width() - bdim.Width()*2)/3;
    btn1->SetPosition(gap, bpos);
    btn2->SetPosition(gap*2 + bdim.Width(), bpos);
  }
  else
    btn1->SetPosition((dlgdim.Width()-bdim.Width())/2, bpos);

  // Show all the the children
  text->Show();
  btn1->SetNotifier(PCREATE_NOTIFIER(DoButtonPress));
  btn1->Show();
  if (btn2 != NULL) {
    btn2->Show();
    btn2->SetNotifier(btn1->GetNotifier());
  }
  if (btn3 != NULL) {
    btn3->Show();
    btn3->SetNotifier(btn1->GetNotifier());
  }
  if (icon != NULL)
    icon->Show();
}


void PSimpleDialog::DoButtonPress(PPushButton & button, INT)
{
  if (&button == btn1)
    EndModal(btn1val);
  else if (&button == btn2)
    EndModal(btn2val);
  else if (&button == btn3)
    EndModal(btn3val);
}


PSimpleDialog::ButtonType PSimpleDialog::DoSimple(PInteractor * parent,
         PRESOURCE_ID resID, ButtonsToHave btns, IconToShow icn, va_list args)
{
  PResourceString str(resID);
  return DoSimple(parent, str, btns, icn, args);
}


void PSimpleDialog::Info(PInteractor * parent, PRESOURCE_ID resID, ...)
{
  va_list args;
  va_start(args, resID);
  DoSimple(parent, resID, OkBtn, InformationIcon, args);
}


void PSimpleDialog::Error(PInteractor * parent, PRESOURCE_ID resID, ...)
{
  va_list args;
  va_start(args, resID);
  DoSimple(parent, resID, OkBtn, ExclamationIcon, args);
}


void PSimpleDialog::FatalError(PInteractor * parent, PRESOURCE_ID resID, ...)
{
  va_list args;
  va_start(args, resID);
  DoSimple(parent, resID, OkBtn, StopSignIcon, args);
}


BOOL PSimpleDialog::OkCancel(PInteractor * parent, PRESOURCE_ID resID, ...)
{
  va_list args;
  va_start(args, resID);
  return DoSimple(parent, resID, OkCancelBtn, QuestionIcon, args) == WasOk;
}


BOOL PSimpleDialog::YesNo(PInteractor * parent, PRESOURCE_ID resID, ...)
{
  va_list args;
  va_start(args, resID);
  return DoSimple(parent, resID, YesNoBtn, QuestionIcon, args) == WasYes;
}


PSimpleDialog::ButtonType 
      PSimpleDialog::YesNoCancel(PInteractor * parent, PRESOURCE_ID resID, ...)
{
  va_list args;
  va_start(args, resID);
  return DoSimple(parent, resID, YesNoCancelBtn, QuestionIcon, args);
}


PSimpleDialog::ButtonType PSimpleDialog::AbortRetryIgnore(
                                 PInteractor * parent, PRESOURCE_ID resID, ...)
{
  va_list args;
  va_start(args, resID);
  return DoSimple(parent, resID, AbortRetryIgnoreBtn, ExclamationIcon, args);
}


PSimpleDialog::ButtonType PSimpleDialog::DoSimple(PInteractor * parent,
        const char * fmt, ButtonsToHave btns, IconToShow icn, va_list args)
{
  PString str;
  str.vsprintf(fmt, args);
  return DoSimple(parent, str, btns, icn);
}


void PSimpleDialog::Info(PInteractor * parent, const char * str, ...)
{
  va_list args;
  va_start(args, str);
  DoSimple(parent, str, OkBtn, InformationIcon, args);
}


void PSimpleDialog::Error(PInteractor * parent, const char * str, ...)
{
  va_list args;
  va_start(args, str);
  DoSimple(parent, str, OkBtn, ExclamationIcon, args);
}


void PSimpleDialog::FatalError(PInteractor * parent, const char * str, ...)
{
  va_list args;
  va_start(args, str);
  DoSimple(parent, str, OkBtn, StopSignIcon, args);
}


BOOL PSimpleDialog::OkCancel(PInteractor * parent, const char * str, ...)
{
  va_list args;
  va_start(args, str);
  return DoSimple(parent, str, OkCancelBtn, QuestionIcon, args) == WasOk;
}


BOOL PSimpleDialog::YesNo(PInteractor * parent, const char * str, ...)
{
  va_list args;
  va_start(args, str);
  return DoSimple(parent, str, YesNoBtn, QuestionIcon, args) == WasYes;
}


PSimpleDialog::ButtonType
     PSimpleDialog::YesNoCancel(PInteractor * parent, const char * str, ...)
{
  va_list args;
  va_start(args, str);
  return DoSimple(parent, str, YesNoCancelBtn, QuestionIcon, args);
}


PSimpleDialog::ButtonType PSimpleDialog::AbortRetryIgnore(
                                  PInteractor * parent, const char * str, ...)
{
  va_list args;
  va_start(args, str);
  return DoSimple(parent, str, AbortRetryIgnoreBtn, ExclamationIcon, args);
}



PSimpleDialog::ButtonType PSimpleDialog::DoSimple(PInteractor * parent,
                      const PString & str, ButtonsToHave btns, IconToShow icn)
{
  PSimpleDialog dlg(parent, str, btns, icn);
  return (ButtonType)dlg.RunModal();
}


void PSimpleDialog::Info(PInteractor * parent, const PString & str)
{
  DoSimple(parent, str, OkBtn, InformationIcon);
}


void PSimpleDialog::Error(PInteractor * parent, const PString & str)
{
  DoSimple(parent, str, OkBtn, ExclamationIcon);
}


void PSimpleDialog::FatalError(PInteractor * parent, const PString & str)
{
  DoSimple(parent, str, OkBtn, StopSignIcon);
}


BOOL PSimpleDialog::OkCancel(PInteractor * parent, const PString & str)
{
  return DoSimple(parent, str, OkCancelBtn, QuestionIcon) == WasOk;
}


BOOL PSimpleDialog::YesNo(PInteractor * parent, const PString & str)
{
  return DoSimple(parent, str, YesNoBtn, QuestionIcon) == WasYes;
}


PSimpleDialog::ButtonType 
          PSimpleDialog::YesNoCancel(PInteractor * parent, const PString & str)
{
  return DoSimple(parent, str, YesNoCancelBtn, QuestionIcon);
}


PSimpleDialog::ButtonType PSimpleDialog::AbortRetryIgnore(
                                     PInteractor * parent, const PString & str)
{
  return DoSimple(parent, str, AbortRetryIgnoreBtn, ExclamationIcon);
}


#endif

#undef new


// End Of File ///////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -