116 lines
2.9 KiB
C++
116 lines
2.9 KiB
C++
#ifndef GUI_HPP
|
|
#define GUI_HPP
|
|
|
|
#include <FL/fl_ask.H>
|
|
#include <FL/filename.H>
|
|
|
|
#include <FL/Fl_Window.H>
|
|
#include <FL/Fl_Menu_Bar.H>
|
|
#include <FL/Fl_Pack.H>
|
|
#include <FL/Fl_Button.H>
|
|
#include <FL/Fl_Box.H>
|
|
#include <FL/Fl_Output.H>
|
|
#include <FL/Fl_Text_Editor.H>
|
|
|
|
const int WIN_W = 800;
|
|
const int WIN_H = 600;
|
|
const int ROW_H = 40;
|
|
const int BOX_W = 96;
|
|
const int BOX_H = 32;
|
|
|
|
const char *window_title = "ToyEd text editor";
|
|
const char *empty_status = "Built " __DATE__ " " __TIME__;
|
|
|
|
struct MainWindow {
|
|
Fl_Window *window;
|
|
|
|
Fl_Menu_Bar *main_menu;
|
|
|
|
Fl_Pack *toolbar;
|
|
Fl_Button *cmd_new;
|
|
Fl_Button *cmd_open;
|
|
Fl_Button *cmd_save;
|
|
Fl_Button *cmd_reload;
|
|
Fl_Button *cmd_stats;
|
|
Fl_Box *spacer;
|
|
Fl_Button *cmd_undo;
|
|
Fl_Button *cmd_find;
|
|
Fl_Button *cmd_next;
|
|
|
|
Fl_Text_Editor *editor;
|
|
|
|
Fl_Output *status1;
|
|
Fl_Output *status2;
|
|
Fl_Output *status3;
|
|
|
|
MainWindow() {
|
|
window = new Fl_Window(WIN_W, WIN_H, window_title);
|
|
|
|
main_menu = new Fl_Menu_Bar(4, 4, WIN_W-8, BOX_H);
|
|
|
|
toolbar = new Fl_Pack(4, ROW_H+4, WIN_W-8, BOX_H);
|
|
toolbar->type(Fl_Pack::HORIZONTAL);
|
|
|
|
cmd_new = new Fl_Button(
|
|
0, 0, BOX_W, BOX_H, "@filenew New");
|
|
cmd_open = new Fl_Button(
|
|
0, 0, BOX_W, BOX_H, "@fileopen Open");
|
|
cmd_save = new Fl_Button(
|
|
0, 0, BOX_W, BOX_H, "@filesave Save");
|
|
cmd_reload = new Fl_Button(
|
|
0, 0, BOX_W, BOX_H, "@reload Reload");
|
|
cmd_stats = new Fl_Button(
|
|
0, 0, BOX_W, BOX_H, "@menu Stats");
|
|
spacer = new Fl_Box(0, 0, BOX_W/6+6, BOX_H);
|
|
cmd_undo = new Fl_Button(0, 0, BOX_W, BOX_H, "@undo Undo");
|
|
cmd_find = new Fl_Button(0, 0, BOX_W, BOX_H, "@search Find");
|
|
cmd_next = new Fl_Button(0, 0, BOX_W, BOX_H, "@>> Next");
|
|
|
|
toolbar->resizable(spacer);
|
|
toolbar->end();
|
|
|
|
editor = new Fl_Text_Editor(
|
|
4, ROW_H*2, WIN_W-8, WIN_H - ROW_H * 3);
|
|
|
|
status1 = new Fl_Output(
|
|
4, WIN_H-ROW_H+4, WIN_W/2-8, BOX_H, "");
|
|
status2 = new Fl_Output(
|
|
WIN_W/2+4, WIN_H-ROW_H+4, WIN_W/4-8, BOX_H, "");
|
|
status3 = new Fl_Output(
|
|
WIN_W*3/4+4, WIN_H-ROW_H+4, WIN_W/4-8, BOX_H, "");
|
|
|
|
status1->value(empty_status);
|
|
|
|
window->resizable(editor);
|
|
window->end();
|
|
|
|
editor->wrap_mode(Fl_Text_Editor::WRAP_AT_BOUNDS, 80);
|
|
editor->textfont(FL_COURIER);
|
|
}
|
|
|
|
~MainWindow() {
|
|
delete window;
|
|
}
|
|
};
|
|
|
|
inline void show_about(Fl_Widget *w, void *data) {
|
|
fl_message_title("About ToyEd Native");
|
|
fl_message("A toy text editor\nv1.1 (5 Feb 2024)\nBoost License");
|
|
}
|
|
|
|
inline void show_credits(Fl_Widget *w, void *data) {
|
|
fl_message_title("ToyEd Native credits");
|
|
fl_message("Made by No Time To Play\nWith the FLTK library");
|
|
}
|
|
|
|
inline void show_website(Fl_Widget *w, void *data) {
|
|
fl_open_uri("https://ctrl-c.club/~nttp/toys/toyed/native.html");
|
|
}
|
|
|
|
inline void scheme_base(Fl_Widget *w, void *data) { Fl::scheme("base"); }
|
|
inline void scheme_gtk(Fl_Widget *w, void *data) { Fl::scheme("gtk+"); }
|
|
inline void scheme_plastic(Fl_Widget *w, void *data) { Fl::scheme("plastic"); }
|
|
inline void scheme_gleam(Fl_Widget *w, void *data) { Fl::scheme("gleam"); }
|
|
|
|
#endif
|