mirror of https://github.com/fltk/fltk
Fluid: Fix variable naming and a memory leak
This commit is contained in:
parent
410e57d2db
commit
817a97bb65
|
@ -295,16 +295,24 @@ void CodeViewer::draw()
|
|||
Fl::set_color(FL_SELECTION_COLOR, c);
|
||||
}
|
||||
|
||||
// ---- DesignViewer implementation
|
||||
// ---- TextViewer implementation
|
||||
|
||||
/**
|
||||
Create a DesignViewer widget.
|
||||
Create a TextViewer widget.
|
||||
\param[in] X, Y, W, H position and size of the widget
|
||||
\param[in] L optional label
|
||||
*/
|
||||
DesignViewer::DesignViewer(int X, int Y, int W, int H, const char *L)
|
||||
TextViewer::TextViewer(int X, int Y, int W, int H, const char *L)
|
||||
: Fl_Text_Display(X, Y, W, H, L)
|
||||
{
|
||||
buffer(new Fl_Text_Buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
Avoid memory leaks.
|
||||
*/
|
||||
TextViewer::~TextViewer() {
|
||||
Fl_Text_Buffer *buf = mBuffer;
|
||||
buffer(0);
|
||||
delete buf;
|
||||
}
|
||||
|
|
|
@ -68,9 +68,10 @@ protected:
|
|||
|
||||
// ---- DesignViewer declaration
|
||||
|
||||
class DesignViewer : public Fl_Text_Display {
|
||||
class TextViewer : public Fl_Text_Display {
|
||||
public:
|
||||
DesignViewer(int X, int Y, int W, int H, const char *L=0);
|
||||
TextViewer(int X, int Y, int W, int H, const char *L=0);
|
||||
~TextViewer();
|
||||
int top_line() { return get_absolute_top_line_number(); }
|
||||
};
|
||||
|
||||
|
|
|
@ -1794,11 +1794,11 @@ void update_sourceview_cb(Fl_Button*, void*)
|
|||
strlcat(sv_design_filename, "source_view_tmp.fl", FL_PATH_MAX);
|
||||
}
|
||||
|
||||
if (sv_design->visible_r()) {
|
||||
if (sv_project->visible_r()) {
|
||||
write_file(sv_design_filename);
|
||||
int top = sv_design->top_line();
|
||||
sv_design->buffer()->loadfile(sv_design_filename);
|
||||
sv_design->scroll(top, 0);
|
||||
int top = sv_project->top_line();
|
||||
sv_project->buffer()->loadfile(sv_design_filename);
|
||||
sv_project->scroll(top, 0);
|
||||
} else if (sv_strings->visible_r()) {
|
||||
static const char *exts[] = { ".txt", ".po", ".msg" };
|
||||
char fn[FL_PATH_MAX];
|
||||
|
@ -2021,6 +2021,8 @@ int main(int argc,char **argv) {
|
|||
#endif // _WIN32
|
||||
|
||||
undo_clear();
|
||||
if (g_shell_command)
|
||||
::free(g_shell_command);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1484,9 +1484,9 @@ CodeViewer *sv_source=(CodeViewer *)0;
|
|||
|
||||
CodeViewer *sv_header=(CodeViewer *)0;
|
||||
|
||||
DesignViewer *sv_strings=(DesignViewer *)0;
|
||||
TextViewer *sv_strings=(TextViewer *)0;
|
||||
|
||||
DesignViewer *sv_design=(DesignViewer *)0;
|
||||
TextViewer *sv_project=(TextViewer *)0;
|
||||
|
||||
Fl_Light_Button *sv_autorefresh=(Fl_Light_Button *)0;
|
||||
|
||||
|
@ -1545,7 +1545,7 @@ Fl_Double_Window* make_sourceview() {
|
|||
{ Fl_Group* o = new Fl_Group(10, 35, 500, 415, "Strings");
|
||||
o->labelsize(13);
|
||||
o->hide();
|
||||
{ DesignViewer* o = sv_strings = new DesignViewer(20, 50, 480, 390);
|
||||
{ TextViewer* o = sv_strings = new TextViewer(20, 50, 480, 390);
|
||||
sv_strings->box(FL_DOWN_FRAME);
|
||||
sv_strings->color(FL_BACKGROUND2_COLOR);
|
||||
sv_strings->selection_color(FL_SELECTION_COLOR);
|
||||
|
@ -1560,28 +1560,28 @@ Fl_Double_Window* make_sourceview() {
|
|||
Fl_Group::current()->resizable(sv_strings);
|
||||
o->linenumber_width(60);
|
||||
o->linenumber_size(o->Fl_Text_Display::textsize());
|
||||
} // DesignViewer* sv_strings
|
||||
} // TextViewer* sv_strings
|
||||
o->end();
|
||||
} // Fl_Group* o
|
||||
{ Fl_Group* o = new Fl_Group(10, 35, 500, 415, "Design");
|
||||
{ Fl_Group* o = new Fl_Group(10, 35, 500, 415, "Project");
|
||||
o->labelsize(13);
|
||||
o->hide();
|
||||
{ DesignViewer* o = sv_design = new DesignViewer(20, 50, 480, 390);
|
||||
sv_design->box(FL_DOWN_FRAME);
|
||||
sv_design->color(FL_BACKGROUND2_COLOR);
|
||||
sv_design->selection_color(FL_SELECTION_COLOR);
|
||||
sv_design->labeltype(FL_NORMAL_LABEL);
|
||||
sv_design->labelfont(0);
|
||||
sv_design->labelsize(14);
|
||||
sv_design->labelcolor(FL_FOREGROUND_COLOR);
|
||||
sv_design->textfont(4);
|
||||
sv_design->textsize(11);
|
||||
sv_design->align(Fl_Align(FL_ALIGN_TOP));
|
||||
sv_design->when(FL_WHEN_RELEASE);
|
||||
Fl_Group::current()->resizable(sv_design);
|
||||
{ TextViewer* o = sv_project = new TextViewer(20, 50, 480, 390);
|
||||
sv_project->box(FL_DOWN_FRAME);
|
||||
sv_project->color(FL_BACKGROUND2_COLOR);
|
||||
sv_project->selection_color(FL_SELECTION_COLOR);
|
||||
sv_project->labeltype(FL_NORMAL_LABEL);
|
||||
sv_project->labelfont(0);
|
||||
sv_project->labelsize(14);
|
||||
sv_project->labelcolor(FL_FOREGROUND_COLOR);
|
||||
sv_project->textfont(4);
|
||||
sv_project->textsize(11);
|
||||
sv_project->align(Fl_Align(FL_ALIGN_TOP));
|
||||
sv_project->when(FL_WHEN_RELEASE);
|
||||
Fl_Group::current()->resizable(sv_project);
|
||||
o->linenumber_width(60);
|
||||
o->linenumber_size(o->Fl_Text_Display::textsize());
|
||||
} // DesignViewer* sv_design
|
||||
} // TextViewer* sv_project
|
||||
o->end();
|
||||
} // Fl_Group* o
|
||||
sv_tab->end();
|
||||
|
|
|
@ -1017,18 +1017,18 @@ Function {make_sourceview()} {open
|
|||
xywh {20 50 480 390} textfont 4 textsize 11 resizable
|
||||
code1 {o->linenumber_width(60);}
|
||||
code2 {o->linenumber_size(o->Fl_Text_Display::textsize());}
|
||||
class DesignViewer
|
||||
class TextViewer
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label Design open
|
||||
label Project open
|
||||
xywh {10 35 500 415} labelsize 13 hide
|
||||
} {
|
||||
Fl_Text_Display sv_design {
|
||||
Fl_Text_Display sv_project {
|
||||
xywh {20 50 480 390} textfont 4 textsize 11 resizable
|
||||
code1 {o->linenumber_width(60);}
|
||||
code2 {o->linenumber_size(o->Fl_Text_Display::textsize());}
|
||||
class DesignViewer
|
||||
class TextViewer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,8 @@ extern void update_sourceview_position_cb(Fl_Tabs*, void*);
|
|||
extern Fl_Tabs *sv_tab;
|
||||
extern CodeViewer *sv_source;
|
||||
extern CodeViewer *sv_header;
|
||||
extern DesignViewer *sv_strings;
|
||||
extern DesignViewer *sv_design;
|
||||
extern TextViewer *sv_strings;
|
||||
extern TextViewer *sv_project;
|
||||
extern void update_sourceview_cb(Fl_Button*, void*);
|
||||
extern Fl_Light_Button *sv_autorefresh;
|
||||
extern Fl_Light_Button *sv_autoposition;
|
||||
|
|
Loading…
Reference in New Issue