source: PSPA/Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface/src/GWt_dialog.cc @ 399

Last change on this file since 399 was 399, checked in by garnier, 11 years ago

Mise en place des comboBox et changement de l'aspect visuel

File size: 3.2 KB
Line 
1#include <Wt/WVBoxLayout>
2#include <Wt/WImage>
3#include <Wt/WText>
4#include <Wt/WBreak>
5#include <Wt/WVBoxLayout>
6#include <Wt/WHBoxLayout>
7#include <Wt/WPushButton>
8#include <Wt/WCssDecorationStyle>
9#include "GWt_dialog.h"
10
11GWt_dialog::GWt_dialog(
12                       WString titre,
13                       WContainerWidget* wc,
14                       bool modal
15                       ):
16WDialog(titre+"   ")
17{
18   
19    // change the title bar style
20    titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220));
21   
22    WContainerWidget* widgt = new WContainerWidget(contents());
23    vDialogLayout_ = new WVBoxLayout();
24    widgt->setLayout(vDialogLayout_);
25   
26    setClosable(true);
27    setModal (modal);
28    setResizable(true);
29    show();
30   
31    if (wc != NULL) {
32        addVContent(wc);
33    }
34}
35
36
37
38GWt_dialog::GWt_dialog(
39                       WString titre,
40                       WString message,
41                       iconType icon,
42                       bool modal,
43                       bool ok
44                       ):
45WDialog(titre)
46{
47   
48    // change the title bar style
49    titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220));
50   
51    WContainerWidget* widgt = new WContainerWidget(contents());
52    WHBoxLayout* hLayout = new WHBoxLayout();
53   
54    WImage* tImg = new WImage("icons/error.png");
55    switch (icon) {
56        case Warning:
57            tImg->setImageLink ("icons/warning.png");
58            tImg->setMaximumSize (70,70);
59            hLayout->addWidget(tImg);
60            break;
61        case Error:
62            tImg->setImageLink ("icons/error.png");
63            tImg->setMaximumSize (70,70);
64            hLayout->addWidget(tImg);
65            break;
66        case Info:
67            tImg->setImageLink ("icons/info.png");
68            tImg->setMaximumSize (70,70);
69            hLayout->addWidget(tImg);
70            break;
71        case Wait:
72            tImg->setImageLink ("icons/patientez.gif");
73            tImg->setMaximumSize (70,70);
74            hLayout->addWidget(tImg);
75            break;
76        case NoIcon:
77            break;
78        default:
79            break;
80    }
81   
82    WContainerWidget* right = new WContainerWidget();
83    WVBoxLayout* vLayout = new WVBoxLayout();
84   
85    // changement des "\n" par des <br>
86    size_t pos = message.toUTF8().find("\n", 0);
87   
88    while(pos != std::string::npos) {
89        vLayout->addWidget(new Wt::WText(WString::fromUTF8(message.toUTF8 ().substr(0,pos))));
90        message = message.toUTF8 ().substr(pos+1);
91        pos = message.toUTF8 ().find("\n");
92        vLayout->addWidget(new Wt::WBreak());
93    }
94    vLayout->addWidget(new Wt::WText(message));
95   
96   
97    if (ok) {
98        vLayout->addWidget(new Wt::WBreak);
99       
100        Wt::WPushButton *ok = new Wt::WPushButton("Ok");
101        vLayout->addWidget(ok);
102       
103        // this event will accept() the Dialog
104        ok->clicked().connect(this, &Wt::WDialog::accept);
105    }
106   
107    right->setLayout(vLayout);
108    hLayout->addWidget(right);
109   
110    widgt->setLayout(hLayout);
111   
112    setClosable(true);
113    setModal (modal);
114}
115
116
117void GWt_dialog::addVContent(WContainerWidget* wc) {
118
119    if (vDialogLayout_) {
120        vDialogLayout_->addWidget(wc);
121    }
122}
123
124
Note: See TracBrowser for help on using the repository browser.