Menu

[b84aab]: / src / platform / fltk / MainWindow.h  Maximize  Restore  History

Download this file

182 lines (155 with data), 4.9 kB

  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
// This file is part of SmallBASIC
//
// Copyright(C) 2001-2013 Chris Warren-Smith.
//
// This program is distributed under the terms of the GPL v2.0 or later
// Download the GNU Public License (GPL) from www.gnu.org
//
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include <fltk/Window.h>
#include <fltk/TabGroup.h>
#include <fltk/ValueInput.h>
#include <stdint.h>
#include "platform/fltk/display.h"
#include "platform/fltk/EditorWidget.h"
#include "platform/fltk/HelpWidget.h"
#include "platform/fltk/Profile.h"
#include "platform/fltk/utils.h"
#define MNU_HEIGHT 22
#define DEF_FONT_SIZE 12
#define NUM_RECENT_ITEMS 9
#define MAX_DESCENT 8 // filter to avoid non-text fonts
#ifndef MAX_PATH
#define MAX_PATH 256
#endif
enum ExecState {
init_state,
edit_state,
run_state,
modal_state,
break_state,
quit_state
};
enum GroupWidget {
gw_editor,
gw_output,
gw_help,
gw_file
};
struct LineInput : public fltk::Input {
LineInput(int x, int y, int w, int h);
bool replace(int b, int e, const char *text, int ilen);
void layout();
int handle(int event);
private:
int orig_x, orig_y, orig_w, orig_h;
};
struct MainWindow;
extern MainWindow *wnd;
extern ExecState runMode;
#ifdef CALLBACK_METHOD
#undef CALLBACK_METHOD
#endif
#define CALLBACK_METHOD(FN) \
void FN(Widget *w=0, void *v=0); \
static void FN ## _cb(Widget *w, void *v) { \
wnd->FN(w, v); \
}
struct BaseWindow : public Window {
BaseWindow(int w, int h) : Window(w, h, "SmallBASIC") {}
virtual ~BaseWindow() {};
int handle(int e);
bool handleKeyEvent();
int _penDownX;
int _penDownY;
int _penMode; // PEN ON/OFF
};
struct MainWindow : public BaseWindow {
MainWindow(int w, int h);
virtual ~MainWindow() {};
bool basicMain(EditorWidget *editWidget, const char *filename, bool toolExec);
bool isBreakExec(void); // whether BREAK mode has been entered
bool isRunning(void); // whether a program is running
bool isEdit(); // whether a program is currently being edited
bool isIdeHidden(); // whether to run without the IDE displayed
bool isInteractive(); // whether to run without an interface
bool isModal(); // whether a modal gui loop is active
void addPlugin(Menu *menu, const char *label, const char *filename);
void busyMessage();
bool execHelp();
void execLink(strlib::String &file);
void loadIcon(const char *prefix, int resourceId);
void pathMessage(const char *file);
void resetPen();
void saveEditConfig(EditorWidget *editWidget);
void scanPlugIns(Menu *menu);
void scanRecentFiles(Menu *menu);
void setBreak();
void setModal(bool modal);
void setTitle(Window *widget, const char *filename);
void showEditTab(EditorWidget *editWidget);
void showHelpPage();
void statusMsg(RunMessage runMessage, const char *filename);
void updateConfig(EditorWidget *current);
void updateEditTabName(EditorWidget *editWidget);
Group *createEditor(const char *title);
EditorWidget *getEditor(Group *group);
EditorWidget *getEditor(const char *fullPath);
EditorWidget *getEditor(bool select = false);
void editFile(const char *filePath);
Group *getSelectedTab();
Group *getNextTab(Group *current);
Group *getPrevTab(Group *current);
Group *selectTab(const char *label);
Group *findTab(const char *label);
Group *findTab(GroupWidget groupWidget);
GroupWidget getGroupWidget(Group *group) {
return (GroupWidget) (intptr_t) group->user_data();
}
bool logPrint();
FILE *openConfig(const char *fileName, const char *flags = "w");
TtyWidget *tty();
CALLBACK_METHOD(close_tab);
CALLBACK_METHOD(close_other_tabs);
CALLBACK_METHOD(copy_text);
CALLBACK_METHOD(cut_text);
CALLBACK_METHOD(editor_plugin);
CALLBACK_METHOD(export_file);
CALLBACK_METHOD(font_size_decr);
CALLBACK_METHOD(font_size_incr);
CALLBACK_METHOD(font_cache_clear);
CALLBACK_METHOD(help_about);
CALLBACK_METHOD(help_app);
CALLBACK_METHOD(help_contents);
CALLBACK_METHOD(help_contents_anchor);
CALLBACK_METHOD(help_home);
CALLBACK_METHOD(hide_ide);
CALLBACK_METHOD(load_file);
CALLBACK_METHOD(new_file);
CALLBACK_METHOD(next_tab);
CALLBACK_METHOD(open_file);
CALLBACK_METHOD(paste_text);
CALLBACK_METHOD(prev_tab);
CALLBACK_METHOD(quit);
CALLBACK_METHOD(restart_run);
CALLBACK_METHOD(run);
CALLBACK_METHOD(run_break);
CALLBACK_METHOD(run_selection);
CALLBACK_METHOD(save_file_as);
CALLBACK_METHOD(set_flag);
CALLBACK_METHOD(set_options);
CALLBACK_METHOD(tool_plugin);
HelpWidget *getHelp();
strlib::String _siteHome;
strlib::String _exportFile;
// main output
DisplayWidget *_out;
Group *_outputGroup;
EditorWidget *_runEditWidget;
// tab parent
TabGroup *_tabGroup;
// configuration
Profile *_profile;
};
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.