Changeset 195 in PSPA for Interface_Web/branches/insertionsElements
- Timestamp:
- Dec 17, 2012, 3:22:03 PM (12 years ago)
- Location:
- Interface_Web/branches/insertionsElements
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/branches/insertionsElements/include/GWt_LigneFaisceau.h
r187 r195 12 12 #include <Wt/WHBoxLayout> 13 13 #include <Wt/WContainerWidget> 14 #include <Wt/WImage>15 14 16 15 using namespace Wt; … … 29 28 PspaApplication* pspa_; 30 29 Compteur *nObjets_; 31 32 string createLabel(nomdElements el,int n);33 30 34 31 public : -
Interface_Web/branches/insertionsElements/include/GWt_dropZoneLigneFaiseau.h
r192 r195 2 2 #define GWT_DROPZONELIGNEFAISEAU_SEEN 3 3 4 #include "GWt_LigneFaisceau.h" 4 #include "GWt_dialog.h" 5 #include "GWt_pspaApplication.h" 6 #include "abstractElement.h" 7 #include "GWt_abstractElement.h" 8 5 9 #include <Wt/WContainerWidget> 6 #include "GWt_dialog.h"7 10 8 11 using namespace Wt; … … 13 16 public : 14 17 15 GWt_dropZoneLigneFaiseau(PspaApplication* );18 GWt_dropZoneLigneFaiseau(PspaApplication*,bool linkImage = true); 16 19 ~GWt_dropZoneLigneFaiseau(); 20 17 21 18 22 private: … … 26 30 void onClick(GWt_abstractElement*); 27 31 void removeDone(GWt_abstractElement*); 32 std::string getElementNumberInBeamLine(nomdElements el); 28 33 29 34 PspaApplication* pspa_; 30 GWt_LigneFaisceau* ligneFaiseau_;31 35 GWt_dialog* messageDropZone_; 32 36 WText* insertMessage_; 33 WWidget* HR_;37 WWidget* linkImage_; 34 38 35 39 WContainerWidget* abstractElement_; -
Interface_Web/branches/insertionsElements/src/GWt_LigneFaisceau.cc
r192 r195 35 35 36 36 // add the first drop zone 37 hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_ ));37 hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false)); 38 38 39 39 // add a strech element at the end … … 41 41 } 42 42 43 string GWt_LigneFaisceau::createLabel(nomdElements el,int n)44 {45 cout<<"GWt_LigneFaisceau::createLabel()"<<endl;46 47 string str;48 if(n < 10) {49 str= el.getElementLabel()+"0"+mixedTools::intToString(n);50 } else {51 str= el.getElementLabel()+mixedTools::intToString(n);52 }53 return str;54 }55 56 43 57 44 -
Interface_Web/branches/insertionsElements/src/GWt_abstractElement.cc
r192 r195 24 24 dropped_->setObjectName("aPushButton"); 25 25 dropped_->setIcon(element_->getName().getElementImage()); 26 dropped_->setMaximumSize( 45,37);26 dropped_->setMaximumSize(50,37); 27 27 dropped_->clicked().connect(this,&GWt_abstractElement::clicked); 28 28 -
Interface_Web/branches/insertionsElements/src/GWt_dropZoneLigneFaiseau.cc
r192 r195 6 6 #include <Wt/WSignalMapper> 7 7 #include <Wt/WText> 8 9 GWt_dropZoneLigneFaiseau::GWt_dropZoneLigneFaiseau(PspaApplication* ps) 8 #include <Wt/WImage> 9 #include <Wt/WHBoxLayout> 10 11 12 GWt_dropZoneLigneFaiseau::GWt_dropZoneLigneFaiseau(PspaApplication* ps,bool linkImageOk) 10 13 : WContainerWidget(), 11 14 pspa_(ps), 15 insertMessage_(NULL), 16 linkImage_(NULL), 12 17 abstractElement_(NULL) 13 18 { … … 24 29 mouseDragged().connect(this, &GWt_dropZoneLigneFaiseau::mouseIsDragged); 25 30 26 insertMessage_ = new WText("Insert an element..."); 27 HR_ = new WImage("icons/link.jpg"); 28 HR_->setMargin(4, Top | Bottom); // add margin vertically 29 31 insertMessage_ = new WText("Drag an element here"); 30 32 addWidget(insertMessage_); 31 addWidget(HR_); 33 if (linkImageOk) { 34 linkImage_ = new WImage("icons/link.jpg"); 35 linkImage_->setMargin(4, Top | Bottom); // add margin vertically 36 addWidget(linkImage_); 37 } 38 32 39 insertMessage_->hide(); 33 40 … … 57 64 } 58 65 } 59 if ( HR_) {60 HR_->hide();66 if (linkImage_) { 67 linkImage_->hide(); 61 68 } 62 69 … … 70 77 { 71 78 if (!abstractElement_) { 72 resize(5,5); 79 if (linkImage_) { 80 resize(linkImage_->width(),linkImage_->height()); 81 } else { 82 resize(10,10); 83 } 73 84 } 74 85 if (insertMessage_) { 75 86 insertMessage_->hide(); 76 87 } 77 if ( HR_) {78 HR_->show();79 } 80 decorationStyle().setBorder (WBorder (WBorder:: None));88 if (linkImage_) { 89 linkImage_->show(); 90 } 91 decorationStyle().setBorder (WBorder (WBorder::Dashed, WBorder::Medium,WColor(255,255,255,255))); 81 92 pspa_->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOut"); 82 93 } … … 116 127 // FIXME 117 128 // ptr->setLabel(createLabel(e,nObjets_[eType].incr())); 129 ptr->setLabel(getElementNumberInBeamLine(e)); 118 130 119 131 cout << " je vais ajouter l'element " << ptr->getName().getElementName() << " de type " << ptr->getName().getElementType() << endl; … … 151 163 // do not insert new element if some element is already present 152 164 153 // insert one before154 165 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 155 166 bool replaceElement = false; … … 159 170 } 160 171 172 // insert one before 161 173 if (!replaceElement) { 162 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_)); 174 // if it the first element of the beam line 175 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))) == 0) { 176 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_,false)); 177 178 } else { 179 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_,true)); 180 } 163 181 } 164 182 … … 166 184 clear(); 167 185 insertMessage_ = NULL; 168 HR_ = NULL;186 linkImage_ = NULL; 169 187 abstractElement_ = gw->getWidget(); 170 188 addWidget(abstractElement_); … … 174 192 175 193 // insert after 176 // if it is the last, add a strech factor 194 // if it is the last, add a strech factor and no link image 177 195 cout<<" nb elem:"<< layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 << " COUNT:"<< wc->count () <<"<---------------"<< endl; 178 196 if (!replaceElement) { 179 197 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 == wc->count()) { 180 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_ ),1);198 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_,false),1); 181 199 } else { 182 200 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_)); … … 247 265 } 248 266 267 268 269 std::string GWt_dropZoneLigneFaiseau::getElementNumberInBeamLine(nomdElements el){ 270 string str = ""; 271 272 if (static_cast <WContainerWidget*> (parent())) { 273 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 274 for (int a=0; a<wc->count(); a++) { 275 if (static_cast <GWt_abstractElement*> (wc->widget (a))) { 276 pspa_->addConsoleMessage("type trouvé"); 277 } 278 } 279 280 int n = 999999; 281 282 std::stringstream stream; 283 stream << n ; 284 std::string number(stream.str()); 285 286 if(n < 10) { 287 str= el.getElementLabel()+"0"+number; 288 } else { 289 str= el.getElementLabel()+" "+number; 290 } 291 } 292 293 return str; 294 295 } -
Interface_Web/branches/insertionsElements/src/GWt_pspaApplication.cc
r192 r195 82 82 83 83 console_ = new WContainerWidget(); 84 console_->decorationStyle().setBackgroundColor (WColor(" gray"));84 console_->decorationStyle().setBackgroundColor (WColor("lightgray")); 85 85 console_->setMaximumSize(600,200); 86 86 layout->addWidget(console_, 3, 1);
Note: See TracChangeset
for help on using the changeset viewer.