1
//------------------------------------------------------------------------
2
// LOCAL : Unix/FLTK local definitions
3
//------------------------------------------------------------------------
5
// GL-Friendly Node Builder (C) 2000-2005 Andrew Apted
7
// Based on 'BSP 2.3' by Colin Reed, Lee Killough and others.
9
// This program is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
//------------------------------------------------------------------------
21
#ifndef __GLBSP_LOCAL_H__
22
#define __GLBSP_LOCAL_H__
27
#error GLBSP_GUI should be defined when compiling this file
30
// use this for inlining. Usually defined in the makefile.
32
#define INLINE_G /* nothing */
52
#include <FL/Fl_Box.H>
53
#include <FL/Fl_Browser.H>
54
#include <FL/Fl_Button.H>
55
#include <FL/Fl_Check_Button.H>
56
#include <FL/Fl_Counter.H>
57
#include <FL/Fl_File_Icon.H>
58
#include <FL/Fl_Group.H>
59
#include <FL/Fl_Hold_Browser.H>
60
#include <FL/Fl_Image.H>
61
#include <FL/Fl_Input.H>
62
#include <FL/Fl_Menu_Bar.H>
63
#include <FL/Fl_Menu_Item.H>
64
#include <FL/Fl_Multiline_Output.H>
65
#include <FL/Fl_Multi_Browser.H>
66
#include <FL/Fl_Pack.H>
67
#include <FL/Fl_Pixmap.H>
68
#include <FL/Fl_Return_Button.H>
69
#include <FL/Fl_Round_Button.H>
70
#include <FL/Fl_Scrollbar.H>
71
#include <FL/Fl_Slider.H>
73
#include <FL/Fl_Sys_Menu_Bar.H>
75
#include <FL/Fl_Value_Input.H>
76
#include <FL/Fl_Widget.H>
77
#include <FL/Fl_Window.H>
79
#include <FL/fl_ask.H>
80
#include <FL/fl_draw.H>
81
#include <FL/Fl_File_Chooser.H>
88
typedef struct guix_preferences_s
90
// main window position & size
94
// positions & sizes of other windows
95
int progress_x, progress_y;
96
int dialog_x, dialog_y;
99
int manual_x, manual_y;
100
int manual_w, manual_h;
103
// warn about overwriting files
104
boolean_g overwrite_warn;
106
// warn about input file == output file
107
boolean_g same_file_warn;
109
// warn about missing extensions
110
boolean_g lack_ext_warn;
112
// filename for saving the log
113
const char *save_log_file;
117
extern guix_preferences_t guix_prefs;
119
extern nodebuildinfo_t guix_info;
120
extern volatile nodebuildcomms_t guix_comms;
121
extern const nodebuildfuncs_t guix_funcs;
123
void MainSetDefaults(void);
130
extern const unsigned char about_image_pal[256 * 3];
131
extern const unsigned char about_image_data[];
133
#define ABOUT_IMG_W 190
134
#define ABOUT_IMG_H 190
141
typedef struct book_page_s
143
// array of lines, ends with NULL.
144
// Link lines start with '#L' and two decimal digits.
145
// Paragraphcs start with '#P' and two digits, first digit is major
146
// indent level, second digit is minor indent level.
152
class Guix_Book : public Fl_Window
156
virtual ~Guix_Book();
158
// override resize method, reformat text
159
virtual FL_EXPORT void resize(int,int,int,int);
169
Fl_Hold_Browser *browser;
175
// total number of pages ?
178
// load a new page into the browser. Updates 'page_num'. This
179
// routine should be called shortly after construction, to display
180
// the initial page. Zero will get the contents page. Invalid
181
// page numbers will be safely ignored.
183
void LoadPage(int new_num);
185
// take the appropriate action for the given line number.
186
void FollowLink(int line);
188
// handle various internal "to do" items. This is here since
189
// modifying widgets (esp. clearing and adding lines to the hold
190
// browser) from within their callbacks seems like a risky business
191
// to me. Should be called in the Fl::wait() loop.
195
// page to change to, otherwise BOOK_NO_PAGE
200
boolean_g want_reformat;
202
// initial window position and size
206
// -- paragraph code --
208
boolean_g in_paragraph;
209
boolean_g first_line;
220
void ParaAddWord(const char *word);
221
void ParaAddLine(const char *line);
224
#define BOOK_NO_PAGE -50
226
extern const book_page_t book_pages[];
227
extern Guix_Book * guix_book_win;
230
class Guix_License : public Fl_Window
234
virtual ~Guix_License();
245
// initial window position and size
250
extern Guix_License * guix_lic_win;
260
COOKIE_E_NO_FILE = 1,
261
COOKIE_E_PARSE_ERRORS = 2,
262
COOKIE_E_CHECK_ERRORS = 3
266
void CookieSetPath(const char *argv0);
267
cookie_status_t CookieReadAll(void);
268
cookie_status_t CookieWriteAll(void);
275
void DialogLoadImages(void);
276
void DialogFreeImages(void);
278
int DialogShowAndGetChoice(const char *title, Fl_Pixmap *pic,
279
const char *message, const char *left = "OK",
280
const char *middle = NULL, const char *right = NULL);
282
int DialogQueryFilename(const char *message,
283
const char ** name_ptr, const char *guess_name);
285
void GUI_FatalError(const char *str, ...);
292
class Guix_FileBox : public Fl_Group
295
Guix_FileBox(int x, int y, int w, int h);
296
virtual ~Guix_FileBox();
298
// child widgets in File area
304
Fl_Output *out_gwa_file;
306
Fl_Button *in_browse;
307
Fl_Button *out_browse;
308
Fl_Button *out_guess;
310
// filename to produce when in GWA mode.
311
const char *gwa_filename;
313
// group for file boxes, to handle resizing properly.
314
Fl_Group *file_group;
316
// routine to set the input widgets based on the build-info.
319
// routine to change the build-info to match the widgets.
322
// routine to call when GWA mode changes state.
325
// routine to call when the in_file changes. It should compute
326
// a new value for 'gwa_filename', and update the out_gwa_file
329
void InFileChanged();
331
// locking routine (see Guix_MainWin)
332
void LockOut(boolean_g lock_it);
335
class Guix_FactorBox : public Fl_Group
338
Guix_FactorBox(int x, int y, int w, int h);
339
virtual ~Guix_FactorBox();
344
// routine to set the input widget based on the build-info.
347
// routine to change the build-info to match the input.
350
// locking routine (see Guix_MainWin)
351
void LockOut(boolean_g lock_it);
354
class Guix_BuildButton : public Fl_Group
357
Guix_BuildButton(int x, int y, int w, int h);
358
virtual ~Guix_BuildButton();
364
// locking routine (see Guix_MainWin)
365
void LockOut(boolean_g lock_it);
368
#define ALERT_TXT "glBSP Alert"
369
#define MISSING_COMMS "(Not Specified)"
376
int HelperCaseCmp(const char *A, const char *B);
377
int HelperCaseCmpLen(const char *A, const char *B, int len);
379
unsigned int HelperGetMillis();
381
boolean_g HelperFilenameValid(const char *filename);
382
boolean_g HelperHasExt(const char *filename);
383
boolean_g HelperCheckExt(const char *filename, const char *ext);
384
char *HelperReplaceExt(const char *filename, const char *ext);
385
char *HelperGuessOutput(const char *filename);
386
boolean_g HelperFileExists(const char *filename);
393
extern const char * pldie_image_data[];
394
extern const char * skull_image_data[];
396
extern Fl_Image * about_image;
397
extern Fl_Pixmap * pldie_image;
398
extern Fl_Pixmap * skull_image;
405
extern const char *license_text[];
412
#define MANUAL_WINDOW_MIN_W 500
413
#define MANUAL_WINDOW_MIN_H 200
420
* MenuCreate(int x, int y, int w, int h);
427
class Guix_BuildMode : public Fl_Group
430
Guix_BuildMode(int x, int y, int w, int h);
431
virtual ~Guix_BuildMode();
433
// child widgets: a set of radio buttons
435
Fl_Button *maybe_normal;
439
// this routine sets one of the radio buttons on, based on the given
440
// build-information.
444
// this routine does the reverse, setting the 'gwa_mode', 'no_normal'
445
// and 'force_normal' fields based on which radio button is currently
450
// locking routine (see Guix_MainWin)
451
void LockOut(boolean_g lock_it);
454
class Guix_MiscOptions : public Fl_Group
457
Guix_MiscOptions(int x, int y, int w, int h);
458
virtual ~Guix_MiscOptions();
460
// child widgets: a set of toggle buttons
461
Fl_Button *choose_fresh;
463
Fl_Button *no_reject;
464
Fl_Button *pack_sides;
466
// routine to set the buttons based on the build-info.
469
// routine to change the build-info to match the buttons.
472
// routine to call when GWA mode changes state.
475
// locking routine (see Guix_MainWin)
476
void LockOut(boolean_g lock_it);
484
class Guix_PrefWin : public Fl_Window
487
// constructor reads the guix_pref values.
488
// destructor writes them.
491
virtual ~Guix_PrefWin();
498
Fl_Button *overwrite;
499
Fl_Button *same_file;
504
Fl_Button *reset_all;
507
// routine called by "reset all" button
512
// initial window position
516
extern Guix_PrefWin * guix_pref_win;
523
typedef struct guix_bar_s
530
// current string for bar
533
// string buffer for percentage
537
// current percentage shown (avoid updating widget)
541
class Guix_ProgressBox : public Fl_Group
544
Guix_ProgressBox(int x, int y, int w, int h);
545
virtual ~Guix_ProgressBox();
552
// current message strings
553
const char *title_str;
555
// current number of bars (READ ONLY from outside)
558
// sets the number of active bars. Must be 1 or 2.
559
void SetBars(int num);
561
// clear the progress bars (e.g. when stopped by user)
562
void ClearBars(void);
564
// set the short name of the bar
565
void SetBarName(int which, const char *label_short);
569
// initial window position
572
void CreateOneBar(guix_bar_t& bar, int x, int y, int w, int h);
574
void SetupOneBar(guix_bar_t& bar, int y, const char *label_short,
578
void GUI_Ticker(void);
580
boolean_g GUI_DisplayOpen(displaytype_e type);
581
void GUI_DisplaySetTitle(const char *str);
582
void GUI_DisplaySetBar(int barnum, int count);
583
void GUI_DisplaySetBarLimit(int barnum, int limit);
584
void GUI_DisplaySetBarText(int barnum, const char *str);
585
void GUI_DisplayClose(void);
592
class Guix_TextBox : public Fl_Multi_Browser
595
Guix_TextBox(int x, int y, int w, int h);
596
virtual ~Guix_TextBox();
598
// adds the message to the text box. The message may contain
599
// newlines ('\n'). The message doesn't need a trailing '\n', i.e.
602
void AddMsg(const char *msg, Fl_Color col = FL_BLACK,
603
boolean_g bold = FALSE);
605
// add a horizontal dividing bar
608
// routine to clear the text box
611
// routine to save the log to a file. Will overwrite the file if
612
// already exists. Returns TRUE if successful or FALSE on error.
614
boolean_g SaveLog(const char *filename);
616
// locking routine (see Guix_MainWin)
617
void LockOut(boolean_g lock_it);
620
void GUI_PrintMsg(const char *str, ...);
627
#define MAIN_BG_COLOR fl_gray_ramp(FL_NUM_GRAY * 9 / 24)
629
#define MAIN_WINDOW_MIN_W 540
630
#define MAIN_WINDOW_MIN_H 450
632
class Guix_MainWin : public Fl_Window
635
Guix_MainWin(const char *title);
636
virtual ~Guix_MainWin();
638
// main child widgets
641
Fl_Sys_Menu_Bar *menu_bar;
643
Fl_Menu_Bar *menu_bar;
646
Guix_BuildMode *build_mode;
647
Guix_MiscOptions *misc_opts;
648
Guix_FactorBox *factor;
651
Guix_ProgressBox *progress;
652
Guix_BuildButton *builder;
653
Guix_TextBox *text_box;
655
// user closed the window
658
// routine to capture the current main window state into the
659
// guix_preferences_t structure.
663
// this routine is useful if the nodebuildinfo has changed. It
664
// causes all the widgets to update themselves using the new
669
// routine to capture all of the nodebuildinfo state from the
670
// various widgets. Note: don't need to call this before
671
// destructing everything -- the widget destructors will do it
676
// this routine will update the user interface to prevent the user
677
// from modifying most of the widgets (used during building). When
678
// 'lock_it' is FALSE, we are actually unlocking a previous lock.
680
void LockOut(boolean_g lock_it);
684
// initial window size, read after the window manager has had a
685
// chance to move the window somewhere else. If the window is still
686
// there when CaptureState() is called, we don't need to update the
687
// coords in the cookie file.
689
int init_x, init_y, init_w, init_h;
692
extern Guix_MainWin * guix_win;
694
void WindowSmallDelay(void);
697
#endif /* __GLBSP_LOCAL_H__ */