-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditorWindow.cpp
More file actions
88 lines (70 loc) · 3.12 KB
/
EditorWindow.cpp
File metadata and controls
88 lines (70 loc) · 3.12 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
#include "EditorWindow.h"
#include<FL/Fl_Sys_Menu_Bar.H>
#include<FL/Fl_Text_Buffer.H>
#include<FL/Fl_PNG_Image.H>
#include"CallbackUtils.h"
int Globals::changed = 0;
std::string Globals::filename = "";
Fl_Text_Buffer* Globals::textbuf = new Fl_Text_Buffer;
void initialization(EditorWindow* window);
EditorWindow::EditorWindow(int width, int height, const char* title)
: Fl_Double_Window(width, height, title)
{
Fl_Menu_Item menuitems[] = {
{ "&File", 0, 0, 0, FL_SUBMENU },
{ "&New File", 0, (Fl_Callback*)new_cb },
{ "&Open File...", FL_CTRL + 'o', (Fl_Callback*)open_cb },
//{ "&Insert File...", FL_CTRL + 'i', (Fl_Callback*)insert_cb, 0, FL_MENU_DIVIDER },
{ "&Save File", FL_CTRL + 's', (Fl_Callback*)save_cb },
{ "Save File &As...", FL_CTRL + FL_SHIFT + 's', (Fl_Callback*)saveas_cb, 0, FL_MENU_DIVIDER },
//{ "New &View", FL_ALT + 'v', (Fl_Callback*)view_cb, 0 },
//{ "&Close View", FL_CTRL + 'w', (Fl_Callback*)close_cb, 0, FL_MENU_DIVIDER },
{ "E&xit", FL_CTRL + 'q', (Fl_Callback*)quit_cb, 0 },
{ 0 },
{ "&Edit", 0, 0, 0, FL_SUBMENU },
{ "&Undo", FL_CTRL + 'z', (Fl_Callback*)undo_cb, 0, FL_MENU_DIVIDER },
{ "Cu&t", FL_CTRL + 'x', (Fl_Callback*)cut_cb, this },
{ "&Copy", FL_CTRL + 'c', (Fl_Callback*)copy_cb, this },
{ "&Paste", FL_CTRL + 'v', (Fl_Callback*)paste_cb, this },
{ "&Delete", 0, (Fl_Callback*)delete_cb, this },
{ 0 },
{ "&Search", 0, 0, 0, FL_SUBMENU },
{ "&Find...", FL_CTRL + 'f', (Fl_Callback*)find_cb, this },
{ "F&ind Again", FL_CTRL + 'g', (Fl_Callback*)find2_cb, this },
{ "&Replace...", FL_CTRL + 'r', (Fl_Callback*)replace_cb, this },
{ "Re&place Again", FL_CTRL + 't', (Fl_Callback*)replace2_cb, this },
{ 0 },
{ 0 }
};
Fl_Menu_Bar* m = new Fl_Menu_Bar(0, 0, 800, 30);
m->copy(menuitems);
editor = new Fl_Text_Editor(0, 30, 800, 570);
editor->buffer(Globals::textbuf );
editor->textfont(FL_COURIER);
Globals::textbuf->canUndo(1);
Globals::textbuf->add_modify_callback(changed_cb, this);
Globals::textbuf->call_modify_callbacks();
initialization(this);
/* const char* icon_name = "icon_main.png";
Fl_PNG_Image* icon = new Fl_PNG_Image(icon_name);
int c_width = icon->w();
int c_height = icon->h();
*/
this->callback(quit_cb, 0);
}
void initialization(EditorWindow* window)
{
window->replace_dlg = new Fl_Window(300, 105, "Replace");
window->replace_find = new Fl_Input(70, 10, 200, 25, "Find:");
window->replace_with = new Fl_Input(70, 40, 200, 25, "Replace:");
window->replace_all = new Fl_Button(10, 70, 90, 25, "Replace All");
window->replace_all->callback(replall_cb, window);
window->replace_next = new Fl_Return_Button(105, 70, 120, 25, "Replace Next");
window->replace_next->callback(replace2_cb, window);
window->replace_cancel = new Fl_Button(230, 70, 60, 25, "Cancel");
window->replace_cancel->callback(replcan_cb, window);
}
EditorWindow::~EditorWindow()
{
//TODO
}