/usr/include/relion-1.3/src/gui_entries.h is in librelion-dev-common 1.3+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | /*
* gui_entries.h
*
* Created on: Oct 7, 2013
* Author: "Sjors H.W. Scheres"
*/
#ifndef GUI_ENTRIES_H_
#define GUI_ENTRIES_H_
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Text_Buffer.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Float_Input.H>
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Slider.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Hold_Browser.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Choice.H>
#include <FL/Fl_Toggle_Button.H>
#include <FL/Fl_Widget.H>
#include <FL/Fl_Wizard.H>
#include "src/macros.h"
#include "src/strings.h"
#include <string>
#include <sstream>
#include <iomanip>
#include <math.h>
#include <fstream>
#include <cstdio>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// Gui layout
//#define XCOL1 10
//#define XCOL2 260
//#define XCOL3 460
//#define XCOL4 475
//#define XCOL5 535
#define GUIWIDTH 800
#define GUIHEIGHT 400
#define XCOL0 200
#define WCOL0 200
#define XCOL1 ( (XCOL0) + 10 )
#define XCOL2 ( (XCOL0) + 260 )
#define XCOL3 ( (XCOL0) + 460 )
#define XCOL4 ( (XCOL0) + 475 )
#define XCOL5 ( (XCOL0) + 535 )
#define STEPY 22
#define COLUMN_SEPARATION 3
#define WCOL1 ( (XCOL2) - (XCOL1) - (COLUMN_SEPARATION) )
#define WCOL2 ( (XCOL3) - (XCOL2) - (COLUMN_SEPARATION) )
#define WCOL3 ( (XCOL4) - (XCOL3) - (COLUMN_SEPARATION) )
#define WCOL4 ( (XCOL5) - (XCOL4) - (COLUMN_SEPARATION) )
//version-1.0 #define GUI_BUTTON_COLOR (fl_rgb_color(200,255,100))
//version-1.1 #define GUI_BUTTON_COLOR (fl_rgb_color(50,150,250))
//version-1.2 #define GUI_BUTTON_COLOR (fl_rgb_color(155,150,255))
//devel-version
#define GUI_BUTTON_COLOR (fl_rgb_color(50, 200, 50))
#define GUI_BUTTON_DARK_COLOR (fl_rgb_color(0, 155, 0))
//possible?#define GUI_BUTTON_COLOR (fl_rgb_color(50, 200, 255))
//version-1.0 #define GUI_RUNBUTTON_COLOR (fl_rgb_color(255,155,0))
//version-1.1 #define GUI_RUNBUTTON_COLOR (fl_rgb_color(255,50,50))
//version-1.2 #define GUI_RUNBUTTON_COLOR (fl_rgb_color(205,53,100))
//devel-version
#define GUI_RUNBUTTON_COLOR (fl_rgb_color(255,80,80))
//possible?#define GUI_RUNBUTTON_COLOR (fl_rgb_color(205,0,155))
#
#define GUI_BACKGROUND_COLOR (fl_rgb_color(240,240,240))
#define GUI_BACKGROUND_COLOR2 (fl_rgb_color(200,200,200))
#define GUI_INPUT_COLOR (fl_rgb_color(255,255,230))
// Replace a single instance of text in a buffer. Return true if replaced, false otherwise
bool replaceStringOnce(Fl_Text_Buffer *textbuf, std::string replacethis, std::string replaceby);
// General utility to replace strings in a text buffer.
void replaceStringAll(Fl_Text_Buffer *textbuf, std::string replacethis, std::string replaceby);
void appendLineString(Fl_Text_Buffer *textbuf, std::string copylinewiththis, int times);
/** This class displays opens an additional window with (help) text
*
*/
class ShowHelpText{
public:
// Constructor that opens and displays the window
ShowHelpText(const char* help = NULL);
// Empty destructor
~ShowHelpText();
};
static Fl_Menu_Item bool_options[] = {
{"Yes"},
{"No"},
{0} // this should be the last entry
};
class textOnlyEntry{
public:
Fl_Text_Display* mydisp;
Fl_Text_Buffer *textbuff;
bool has_been_set;
textOnlyEntry()
{
has_been_set=false;
}
~textOnlyEntry(){};
void initialise(int x, int y, int width, int height, const char* text)
{
mydisp = new Fl_Text_Display(XCOL1, y, width, height);
textbuff = new Fl_Text_Buffer();
textbuff->text(text);
mydisp->buffer(textbuff);
mydisp->color(GUI_BACKGROUND_COLOR);
has_been_set=true;
}
void place(int &y,
const char* text,
int width= WCOL1 + WCOL2 + WCOL3, int height = STEPY + 6, int x = XCOL1)
{
// Clear if existing
clear();
// Add the entry to the window
// Add 3 to step_y, otherwise the text may not fit...
initialise(x, y, width, height, text);
// Update the Y-coordinate
y += height + 2;
}
void clear()
{
if (has_been_set)
{
delete mydisp;
delete textbuff;
has_been_set = false;
}
}
};
/** This is the main class to generate input entry-lines in the Gui windows.
* It implements three columns to be displayed:
* 1. box with the label
* 2. Input field with the input value
* 3. Help button that pops up a window with additional help text
*
* All specific entries (e.g. to get FileName, Boolean, etc. inherit from this class)
*
*
*/
class AnyEntry{
public:
// Input value storage
Fl_Input* inp;
// Label
std::string label;
// Button to show additional help text
Fl_Button* help;
// The additional help text
const char *myhelptext;
/** Constructor with x,y-position from top left
* wcol1, wcol2 and wcol3 are the widths of the three columns described above
* title is the value displayed in the first column
* defaultvalue is what will appear by default in the input value
* help is the additional help text. If it is set to NULL, no help button will be displayed
*/
AnyEntry(){};
/** Empty destructor
*/
~AnyEntry(){};
/** Here really start the entry
*/
void initialise(int x, int y, int height, int wcol2, int wcol3, const char* title, const char* defaultvalue = NULL, const char* help = NULL);
/** Place an entry on a window
*/
void place(int &y,
const char * title,
const char* defaultvalue = NULL,
const char* helptext = NULL,
int x = XCOL1, int h = STEPY, int wcol2 = WCOL2, int wcol3 = WCOL3 );
// Get the value
std::string getValue();
// Set the value
void setValue(const char* inp);
// Clear this entry
void clear();
// Deactivate this entry if the input boolean is true
void deactivate(bool do_deactivate = true);
// Save the value to a file
void writeValue(std::ostream& out);
// Read the value from a file
void readValue(std::ifstream& in);
/** Call-back functions for the help button
* The method of using two functions of static void and inline void was copied from:
* http://www3.telus.net/public/robark/
*/
static void cb_help(Fl_Widget*, void*);
void cb_help_i();
};
// Get a FileName value from the user (with browse button).
class FileNameEntry: public AnyEntry
{
public:
// Browse button
Fl_Button* browse;
const char* pattern;
// Constructor (with 4 column widths)
FileNameEntry() {};
// Destructor
~FileNameEntry(){};
void initialise(int x, int y, int height,
int wcol2, int wcol3, int wcol4,
const char* title,
const char* defaultvalue,
const char* _pattern = "",
const char* help = NULL);
// places on one the window
void place(int &y,
const char * title,
const char* defaultvalue = NULL,
const char* pattern = "",
const char* helptext = NULL,
int x = XCOL1, int h = STEPY, int wcol2 = WCOL2, int wcol3 = WCOL3, int wcol4 = WCOL4 );
// Clear this entry
void clear();
// Deactivate this entry if the input boolean is true
void deactivate(bool do_deactivate = true);
private:
// Call-back functions for the browse button
static void cb_browse(Fl_Widget*, void*);
void cb_browse_i();
};
// Get an entry from a list of possible values from the user.
class RadioEntry: public AnyEntry
{
public:
// The choices
Fl_Choice * choice;
// The menu
Fl_Menu_* menu;
// Deactivate this group
Fl_Group * my_deactivate_group;
// Constructor
RadioEntry(){};
// Destructor
~RadioEntry(){};
void initialise(int x, int y, int height,
int wcol2, int wcol3, int wcol4,
const char* title,
Fl_Menu_Item *options,
Fl_Menu_Item* defaultvalue,
const char* help = NULL,
Fl_Group * deactivate_this_group = NULL);
void place(int &y,
const char * title,
Fl_Menu_Item *options,
Fl_Menu_Item* defaultvalue,
const char* helptext = NULL,
int x = XCOL1, int h = STEPY, int wcol2 = WCOL2, int wcol3 = WCOL3, int wcol4 = WCOL4 );
// Clear this entry
void clear();
// Deactivate this entry if the input boolean is true
void deactivate(bool do_deactivate = true);
// Get the value
std::string getValue();
// Read the value from a file
void readValue(std::ifstream& in);
void call_menu_i()
{
cb_menu_i();
}
public: // this one is public so that it can be called in mainwindow to deactivate default groups
static void cb_menu(Fl_Widget*, void*);
void cb_menu_i();
};
class BooleanEntry: public RadioEntry
{
public:
// Constructor
BooleanEntry(){};
// Destructor
~BooleanEntry(){};
void initialise(int x, int y, int height,
int wcol2, int wcol3, int wcol4,
const char* title,
bool defaultvalue,
const char* help = NULL,
Fl_Group * deactivate_this_group = NULL);
void place(int &y,
const char * title,
bool defaultvalue = true,
const char* help = NULL,
Fl_Group * deactivate_this_group = NULL,
int x = XCOL1, int h = STEPY, int wcol2 = WCOL2, int wcol3 = WCOL3, int wcol4 = WCOL4 );
// Get the value
bool getValue();
};
class SliderEntry: public RadioEntry
{
public:
// The slider
Fl_Slider * slider;
// Constructor
SliderEntry(){};
// Destructor
~SliderEntry(){};
void initialise(int x, int y, int height,
int wcol2, int wcol3, int wcol4,
const char* title,
float defaultvalue,
float minvalue,
float maxvalue,
float valuestep,
const char* help = NULL);
void place(int &y,
const char* title,
float defaultvalue,
float minvalue,
float maxvalue,
float valuestep,
const char* help,
int x = XCOL1, int h = STEPY, int wcol2 = WCOL2, int wcol3 = WCOL3, int wcol4 = WCOL4 );
// Clear this entry
void clear();
// Deactivate this entry if the input boolean is true
void deactivate(bool do_deactivate = true);
// Get the value
float getValue();
// Read the value from a file
void readValue(std::ifstream& in);
private:
static void cb_slider(Fl_Widget*, void*);
void cb_slider_i();
static void cb_input(Fl_Widget*, void*);
void cb_input_i();
};
#endif /* GUI_ENTRIES_H_ */
|