Changeset 147 in PSPA for Interface_Web/trunk


Ignore:
Timestamp:
Dec 6, 2012, 4:43:31 PM (12 years ago)
Author:
garnier
Message:

amelioration du dialog

Location:
Interface_Web/trunk/pspaWT
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/include/GWt_dialog.h

    r144 r147  
    1212 public :
    1313
    14   GWt_dialog(WString titre, std::string message, bool modal=false, bool patienter=false, bool ok=false);
    15  
     14  enum  iconType { Warning, Error, Info, Wait, NoIcon };
     15
     16  GWt_dialog(WString titre, std::string message, iconType icon=NoIcon, bool modal=false, bool ok=false);
    1617};
    1718#endif
  • Interface_Web/trunk/pspaWT/src/GWt_dialog.cc

    r145 r147  
    33#include <Wt/WText>
    44#include <Wt/WBreak>
     5#include <Wt/WHBoxLayout>
    56#include <Wt/WPushButton>
    67#include "GWt_dialog.h"
    78
    8 GWt_dialog::GWt_dialog(WString titre, std::string message, bool modal, bool patienter,bool ok):
     9GWt_dialog::GWt_dialog(
     10 WString titre,
     11 std::string message,
     12 iconType icon,
     13 bool modal,
     14 bool ok
     15):
    916  WDialog(titre)
    1017{
    1118
    12   // changement des "\n" par des <br>
    13   size_t pos = message.find("\n", 0);
     19  WContainerWidget* widgt = new WContainerWidget(contents());
     20  WHBoxLayout* hLayout = new WHBoxLayout();
     21 
     22  WImage* tImg = new WImage("icons/error.png");
     23  switch (icon) {
     24  case Warning:
     25    tImg->setImageLink ("icons/warning.png");
     26    tImg->setMaximumSize (70,70);
     27    hLayout->addWidget(tImg);
     28    break;
     29  case Error:
     30    tImg->setImageLink ("icons/error.png");
     31    tImg->setMaximumSize (70,70);
     32    hLayout->addWidget(tImg);
     33    break;
     34  case Info:
     35    tImg->setImageLink ("icons/info.png");
     36    tImg->setMaximumSize (70,70);
     37    hLayout->addWidget(tImg);
     38    break;
     39  case Wait:
     40    tImg->setImageLink ("icons/patienter.gif");
     41    tImg->setMaximumSize (70,70);
     42    hLayout->addWidget(tImg);
     43    break;
     44  case NoIcon:
     45    break;
     46  default:
     47    break;
     48  }
    1449
    15   while(pos != std::string::npos) {
    16     new Wt::WText(message.substr(0,pos),contents());
    17     message = message.substr(pos+1);
    18     pos = message.find("\n");
    19     new Wt::WBreak(contents());
    20   }
    21   new Wt::WText(message,contents());
     50 WContainerWidget* right = new WContainerWidget();
     51 WVBoxLayout* vLayout = new WVBoxLayout();
     52 
     53 // changement des "\n" par des <br>
     54 size_t pos = message.find("\n", 0);
     55 
     56 while(pos != std::string::npos) {
     57   vLayout->addWidget(new Wt::WText(message.substr(0,pos),widgt));
     58   message = message.substr(pos+1);
     59   pos = message.find("\n");
     60   vLayout->addWidget(new Wt::WBreak());
     61 }
     62 vLayout->addWidget(new Wt::WText(message));
     63 
     64 
     65 if (ok) {
     66   vLayout->addWidget(new Wt::WBreak);
     67   
     68   Wt::WPushButton *ok = new Wt::WPushButton("Ok");
     69   vLayout->addWidget(ok);
     70   
     71   // this event will accept() the Dialog
     72   ok->clicked().connect(this, &Wt::WDialog::accept);
     73 }
     74 
     75 right->setLayout(vLayout);
     76 hLayout->addWidget(right);
    2277
    23   if (patienter) {
    24     new WImage("icons/patienter.gif",contents());
    25   }
    26   if (ok) {
    27     new Wt::WBreak(contents());
    28    
    29     Wt::WPushButton *ok = new Wt::WPushButton("Ok", contents());
    30    
    31     // this event will accept() the Dialog
    32     ok->clicked().connect(this, &Wt::WDialog::accept);
    33   }
    34   setModal (modal);
     78 widgt->setLayout(hLayout);
     79
     80 setModal (modal);
    3581}
    3682
  • Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc

    r144 r147  
    318318        {
    319319          addConsoleMessage(" bad section definition !  \n ");
    320           GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", true,false,true);
     320          GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", GWt_dialog::Error,true,true);
    321321          warningDialog.exec();
    322322          return;
     
    332332        {
    333333          addConsoleMessage(" bad section definition !  \n ");
    334           GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", true,false,true);
     334          GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", GWt_dialog::Error, true,true);
    335335          warningDialog.exec();
    336336          return;
     
    343343
    344344  if (!areDataCoherent()) {
    345     GWt_dialog warningDialog("PSPA : Vérification des sections", " données incohérentes !", true,false,true);
     345    GWt_dialog warningDialog("PSPA : Vérification des sections", " données incohérentes !", GWt_dialog::Error,true,true);
    346346    warningDialog.exec();
    347347  }
     
    375375      caMarche = false;
    376376      addConsoleMessage(diagnostic.c_str());
    377       GWt_dialog calculDialog("PSPA : Erreur lors de check execute", diagnostic, true,false,true);
     377      GWt_dialog calculDialog("PSPA : Erreur lors de check execute", diagnostic , GWt_dialog::Error,true,true);
    378378      calculDialog.exec();
    379379    }
     
    396396  static_cast<GWt_globalParameters*>(globalParam_)->updateGlobals();
    397397
    398   GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", false,true);
     398  GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Error, true,false);
    399399  calculDialog.show();
    400400
     
    403403  string resultat;
    404404  if ( !dtmanage_->executeAll(resultat)) {
    405     GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exécution !", true,false,true);
     405    GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exécution !", GWt_dialog::Error, true,true);
    406406    warningDialog.exec();
    407407  }
Note: See TracChangeset for help on using the changeset viewer.