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
|
//
// Fluid Application header for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2025 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
#ifndef FLUID_FLUID_H
#define FLUID_FLUID_H
#include "Project.h"
#include "app/args.h"
#include "app/history.h"
#include "app/Snap_Action.h"
#include "tools/filename.h"
#include <FL/Fl_Preferences.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/filename.H>
#define FLD_BROWSERWIDTH 300
#define FLD_BROWSERHEIGHT 500
#define FLD_WINWIDTH 300
#define FLD_MENUHEIGHT 25
#define FLD_WINHEIGHT (FLD_BROWSERHEIGHT+FLD_MENUHEIGHT)
// ---- types
class Fl_Double_Window;
class Fl_Window;
class Fl_Menu_Bar;
class Node;
class Fl_Choice;
class Fl_Button;
class Fl_Check_Button;
class Fl_Help_Dialog;
class Layout_List;
class App_Menu_Bar;
class Project;
class Application {
/// Currently selected project.
Project *current_project_;
/// Working directory at application launch.
char launch_path_[FL_PATH_MAX];
/// Path to store temporary files during app run.
char tmpdir_path_[FL_PATH_MAX];
/// True if the temporary file path was already created.
int tmpdir_create_called;
// Generate a path to a directory for temporary data storage.
void create_tmpdir();
// Delete the temporary directory and all its contents.
void delete_tmpdir();
public: // Member Variables
/// Application wide preferences
Fl_Preferences preferences;
/// Project history.
History history;
/// Command line arguments
Args args;
/// List of available layouts
Layout_List *layout_list;
/// Set, if Fluid runs in batch mode, and no user interface is activated.
int batch_mode;
// TODO: make this into a class: app::Settings
/// Show guides in the design window when positioning widgets, saved in app preferences.
int show_guides;
/// Show areas of restricted use in overlay plane.
/// Restricted areas are widget that overlap each other, widgets that are outside
/// of their parent's bounds (except children of Scroll groups), and areas
/// within an Fl_Tile that are not covered by children.
int show_restricted;
/// Show a ghosted outline for groups that have very little contrast.
/// This makes groups with NO_BOX or FLAT_BOX better editable.
int show_ghosted_outline;
/// Show widget comments in the browser, saved in app preferences.
int show_comments;
// TODO: make this into a class: app::External_Editor
/// Use external editor for editing Code_Node, saved in app preferences.
int use_external_editor;
/// Debugging help for external Code_Node editor.
int debug_external_editor;
/// Run this command to load an Code_Node into an external editor, save in app preferences.
char external_editor_command[512];
// TODO: make this into a class: app::GUI
Fl_Window *main_window;
static Fl_Menu_Item main_menu[];
App_Menu_Bar *main_menubar;
Fl_Menu_Item *save_item;
Fl_Menu_Item *history_item;
Fl_Menu_Item *widgetbin_item;
Fl_Menu_Item *codeview_item;
Fl_Menu_Item *overlay_item;
Fl_Button *overlay_button;
Fl_Menu_Item *guides_item;
Fl_Menu_Item *restricted_item;
/// Offset in pixels when adding widgets from an .fl file.
int pasteoffset;
int ipasteoffset;
/// FLUID-wide help dialog.
Fl_Help_Dialog *help_dialog;
public: // Methods
// Create the Fluid application.
Application();
/// Destructor.
~Application();
// Launch the application.
int run(int argc, char **argv);
// Quit the application and clean up.
void quit();
/// Quick access to the current project.
Project &proj;
// Return the working directory path at application launch.
const char *launch_path() const;
// Return the path to a temporary directory for this instance of Fluid.
const char *get_tmpdir();
// Return the path and filename of a temporary file for cut or duplicated data.
const char *cutfname(int which = 0);
// Clear the current project and create a new, empty one.
int new_project(int user_must_confirm = 1);
// Open a file chooser and load an exiting project file.
int open_project_file(const char *filename_arg);
// Load a project from the give file name and path.
int merge_project_file(const char *filename_arg);
// Save the current design to the file given by \c filename.
void save_project_file(void *arg);
// Reload the file set by \c filename, replacing the current design.
void revert_project();
// Open the template browser and load a new file from templates.
int new_project_from_template();
// Open the dialog to allow the user to print the current window.
void print_snapshots();
// Generate the C++ source and header filenames and write those files.
int write_code_files(int dont_show_completion_dialog = 0);
// User chose to cut the currently selected widgets.
void cut_selected();
// User chose to copy the currently selected widgets.
void copy_selected();
// User chose to paste the widgets from the cut buffer.
void paste_from_clipboard();
// Duplicate the selected widgets.
void duplicate_selected();
// User chose to delete the currently selected widgets.
void delete_selected();
// Show the editor for the \c current Node.
void edit_selected();
// User wants to sort selected widgets by y coordinate.
void sort_selected();
// Show or hide the widget bin.
void toggle_widget_bin();
// Open a dialog to show the HTML help page form the FLTK documentation folder.
void show_help(const char *name);
// Open the "About" dialog.
void about();
// Build the main app window and create a few other dialogs.
void make_main_window();
// Open a native file chooser to allow choosing a project file for reading.
// Returns path in provided buffer, or empty string if cancelled.
void open_project_filechooser(char *result, int result_size, const char *title);
// Give the user the opportunity to save a project before clearing it.
int confirm_project_clear();
// Ensure that text widgets in the widget panel propagates apply current changes.
void flush_text_widgets();
// Position the given window window based on entries in the app preferences.
char position_window(Fl_Window *w, const char *prefsName, int Visible, int X, int Y, int W = 0, int H = 0);
// Save the position and visibility state of a window to the app preferences.
void save_position(Fl_Window *w, const char *prefsName);
// Change the app's and hence preview the design's scheme.
void set_scheme(const char *new_scheme);
// Read Fluid's scheme preferences and set the app's scheme.
void init_scheme();
#ifdef __APPLE__
static void apple_open_cb(const char *c);
#endif
};
extern Application Fluid;
#endif // FLUID_FLUID_H
|