* Returns pair (retType,string) * retType: 0 if cancelled, 1 otherwise */
| 3183 | * retType: 0 if cancelled, 1 otherwise |
| 3184 | */ |
| 3185 | std::pair<int,std::string> CsvApplication::myFlAskString(std::string title, std::string buttonText, int buttonWidth) { |
| 3186 | My_Fl_Small_Window *askWin; |
| 3187 | Fl_Input *input; |
| 3188 | My_Fl_Button *okButton; |
| 3189 | std::string retStr = ""; |
| 3190 | int retInt = 1; |
| 3191 | app.myFlAskStringOk = false; |
| 3192 | |
| 3193 | const int winWidth = 400; |
| 3194 | const int winHeight = 120; |
| 3195 | const int gridMargin = 20; |
| 3196 | |
| 3197 | struct My_Fl_Button::buttonColorStruct colorsHighlightButton; |
| 3198 | colorsHighlightButton.background = ColorThemes::getColor(app.getTheme(), "hightlight_button_bg"); |
| 3199 | colorsHighlightButton.label = ColorThemes::getColor(app.getTheme(), "hightlight_button_text"); |
| 3200 | colorsHighlightButton.border = ColorThemes::getColor(app.getTheme(), "hightlight_button_border"); |
| 3201 | colorsHighlightButton.windowBg = ColorThemes::getColor(app.getTheme(), "win_bg"); |
| 3202 | colorsHighlightButton.borderWidth = ColorThemes::getColor(app.getTheme(), "highlight_button_border_width"); |
| 3203 | |
| 3204 | |
| 3205 | askWin = new My_Fl_Small_Window(winWidth,winHeight); |
| 3206 | askWin->copy_label(title.c_str()); |
| 3207 | askWin->color(ColorThemes::getColor(app.getTheme(), "win_bg")); |
| 3208 | askWin->callback(myFlAskStringCB); |
| 3209 | |
| 3210 | input = new Fl_Input(gridMargin,gridMargin,winWidth-2*gridMargin,24); |
| 3211 | input->box(FL_FLAT_BOX); |
| 3212 | |
| 3213 | okButton = new My_Fl_Button(winWidth-gridMargin-buttonWidth,winHeight-gridMargin-24,buttonWidth,24,buttonText.c_str()); |
| 3214 | okButton->colors = colorsHighlightButton; |
| 3215 | okButton->shortcut(FL_Enter); |
| 3216 | okButton->callback(myFlAskStringOkCB, NULL); |
| 3217 | |
| 3218 | askWin->set_modal(); |
| 3219 | askWin->show(); |
| 3220 | while( askWin->shown() ) { |
| 3221 | Fl::wait(); |
| 3222 | } |
| 3223 | askWin->hide(); |
| 3224 | Fl::check(); |
| 3225 | |
| 3226 | if( app.myFlAskStringOk ) { |
| 3227 | retStr = input->value(); |
| 3228 | retInt = 1; |
| 3229 | } else { |
| 3230 | retInt = 0; |
| 3231 | } |
| 3232 | |
| 3233 | delete okButton; |
| 3234 | delete input; |
| 3235 | delete askWin; |
| 3236 | |
| 3237 | return std::make_pair(retInt, retStr); |
| 3238 | } |
| 3239 | void CsvApplication::myFlAskStringCB(Fl_Widget *widget, long data) { |
| 3240 | if( data > 0 ) { |
| 3241 | app.myFlAskStringOk = true; |