chiark / gitweb /
Merge branch 'arkkra' into shiny
[mup] / mup / mupmate / Main.H
CommitLineData
69695f33
MW
1/* Copyright (c) 2006 by Arkkra Enterprises */
2/* All rights reserved */
3
4#ifndef _MAIN_H_
5#define _MAIN_H_
6
7// Header file for the main Mupmate window, containing toolbar and editor.
8
9#include <FL/Fl_Widget.H>
10#include <FL/Fl_Double_Window.H>
11#include <FL/Fl_Menu_Bar.H>
12#include <FL/Fl_Menu_Item.H>
13#include <FL/Fl_Text_Buffer.H>
14#include <FL/Fl_Text_Editor.H>
15
16#include "File.H"
17#include "Edit.H"
18#include "Run.H"
19#include "Config.H"
20#include "Help.H"
21
22class Main;
23
24//---------- class to show Mup license and get user's agreement
25
26class License : public Fl_Double_Window {
27public:
28 License(Main * m_p, const char * magic);
29 ~License(void);
30
31 // Callbacks
32 static void IAgree_cb(Fl_Widget *, void * data);
33 static void Cancel_cb(Fl_Widget *, void * data);
34 static void Continue_cb(Fl_Widget *, void * data);
35
36private:
37 // Callbacks
38 void IAgree(void);
39 void Cancel(void);
40 void Continue(void);
41
42 // Widgets
43 Fl_Text_Display * text_p; // The text of the license
44 Fl_Return_Button * i_agree_p;
45 Fl_Button * cancel_p;
46
47 // Name of file that tells us if user has agreed to license
48 const char * magic_file_name;
49
50 // The main window
51 Main * main_p;
52};
53
54
55
56// Class for main window, with editor and toolbar
57
58class Main : public Fl_Double_Window {
59
60friend class License;
61
62public:
63 Main(const char * title);
64 ~Main();
65
66 // Callbacks
67 static void modify_cb(int, int, int, int, const char *, void * data);
68 static void font_change_cb(void * data, Fl_Font font, unsigned char size);
69 static void atclose_cb(Fl_Widget *, void * data);
70
71 // We don't want Escape to cause main window to close,
72 // and need to handle Paste ungraying specially.
73 // This event handler takes care of those things.
74 static int handle_events(int);
75
76 // Show user hints the first time they bring up Mupmate
77 void hints(void);
78
79 // Reset state information when user opens a new file.
80 void begin_new_file();
81
82 // Pointers to the classes for each toolbar menu item widgets
83 File * filemenu_p;
84 Edit * editmenu_p;
85 Config * configmenu_p;
86 Help * helpmenu_p;
87 Run * runmenu_p;
88
89 // Clean up all windows
90 static void clean_exit(int exitval = 0);
91
92private:
93 // called when input text is modified
94 void modify(void);
95
96 // Sets font/size of editor
97 void font_change(Fl_Font font, unsigned char size);
98
99 // Make window manager close like Exit
100 void atclose(void);
101
102 // Cursor blinker
103 static void blinker(void *);
104
105 // Ponters to the top level widgets
106 Fl_Menu_Bar * toolbar_p;
107 Fl_Text_Editor * editor_p;
108
109 // For font/size change notification
110 Font_change_registration * font_change_reg_p;
111
112 // True if there is a selected area in editor window
113 bool have_selection;
114
115 // True if something in clipboard
116 bool can_paste;
117
118 // For knowing when to gray out Undo menu item
119 bool undo_active;
120 bool undo_active_on_next_change;
121 int prev_bufflength;
122
123 // Current cursor on/off state, for blinker
124 int cursor_state;
125
126 // We currently only have one main window, but code is
127 // general to allow multiple windows. We keep a linked list
128 // of all the windows.
129 static Main * list_p;
130 Main * next;
131};
132
133#endif