1 /* Copyright (c) 2006 by Arkkra Enterprises */
2 /* All rights reserved */
8 #include <FL/Fl_Widget.H>
9 #include <FL/Fl_Double_Window.H>
10 #include <FL/Fl_Box.H>
11 #include <FL/Fl_Input.H>
12 #include <FL/Fl_Text_Editor.H>
13 #include <FL/Fl_File_Browser.H>
14 #include <FL/Fl_Button.H>
15 #include <FL/Fl_Return_Button.H>
16 #include <FL/Fl_Choice.H>
17 #include <FL/filename.H>
22 // Class used to ask user if they want to save changes.
23 // The FLTK fl_choice doesn't do quite what we want, so we make our own...
25 class Save_confirm_dialog : Fl_Double_Window {
27 enum Answer { Cancel, No, Yes };
29 // This brings up the dialog
30 static Answer confirm_save(const char * text, bool hide_the_No = false);
33 Save_confirm_dialog(const char * text);
34 ~Save_confirm_dialog(void);
39 Fl_Return_Button * yes_p;
46 // Class for the items off of "File" on the main menu bar
57 static void modify_cb(int, int, int, int, const char *, void * data);
58 static void New_cb(Fl_Widget *, void * data);
59 static void NewFromTemplate_cb(Fl_Widget *, void * data);
60 static void Open_cb(Fl_Widget *, void * data);
61 static void Save_cb(Fl_Widget *, void * data);
62 static void SaveAs_cb(Fl_Widget *, void * data);
63 static void Exit_cb(Fl_Widget *, void * data);
65 // Load a file into the text editor
66 void load_file(const char * name);
68 // Give access to the text editor buffer
69 Fl_Text_Buffer * get_buffer() { return editor_p->buffer(); }
71 // Gives real filename, or "Untitled.mup" if there is none
72 const char * effective_filename();
74 // This class needs access to Main class and its text editor.
75 // Creator should call these to point to the proper instances
76 void set_editor(Fl_Text_Editor * ed_p);
77 void set_parent(Main * main_p);
79 // These show the dialog and return the file name the user enters.
80 const char * open_ask_user(void);
81 const char * save_as_ask_user(void);
83 // Ask user if they want to save the currently unsaved changes.
84 Save_confirm_dialog::Answer save_changes_check(const char * extra_text = "",
85 bool hide_the_No = false);
88 // Make icon for Mup files.
89 static void add_mup_icon(void);
97 void NewFromTemplate(void);
98 void Save(bool honor_auto_display = true);
99 void SaveAs(bool honor_auto_display = true);
102 // Write out the current file
103 void save_file(bool honor_auto_display);
105 // Put current file name in window label
106 void set_window_label(void);
108 // Reset things for starting to edit a different file
109 void begin_new_file(void);
111 // The name of file being edited
114 // If buffer has changed since last being saved
115 bool unsaved_changes;
117 // Pointers to other class instances we need
118 Fl_Text_Editor * editor_p;
119 Main * parent_window_p;