Added callbacks to Fl_Text_Editor.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2824 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2002-11-05 06:45:41 +00:00
parent b9e7232d26
commit 66dabdb8f5
8 changed files with 43 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Text_Editor.H,v 1.1.2.4 2002/08/14 16:49:38 easysw Exp $"
// "$Id: Fl_Text_Editor.H,v 1.1.2.5 2002/11/05 06:45:40 matthiaswm Exp $"
//
// Header file for Fl_Text_Editor class.
//
@@ -91,6 +91,7 @@ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display {
protected:
int handle_key();
void maybe_do_callback();
int insert_mode_;
Key_Binding* key_bindings;
@@ -101,6 +102,6 @@ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display {
#endif
//
// End of "$Id: Fl_Text_Editor.H,v 1.1.2.4 2002/08/14 16:49:38 easysw Exp $".
// End of "$Id: Fl_Text_Editor.H,v 1.1.2.5 2002/11/05 06:45:40 matthiaswm Exp $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.9 2002/11/03 00:01:19 matthiaswm Exp $"
// "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.10 2002/11/05 06:45:40 matthiaswm Exp $"
//
// C function type code for the Fast Light Tool Kit (FLTK).
//
@@ -28,6 +28,7 @@
#include <FL/fl_show_input.H>
#include "../src/flstring.h"
#include <stdio.h>
#include <malloc.h>
extern int i18n_type;
extern const char* i18n_include;
@@ -337,9 +338,10 @@ void Fl_Code_Type::open() {
else if (w == code_panel_ok) break;
else if (!w) Fl::wait();
}
const char*c = code_input->buffer()->text();
char*c = code_input->buffer()->text();
message = c_check(c); if (message) continue;
name(c);
free(c);
break;
}
BREAK2:
@@ -705,5 +707,5 @@ void Fl_Class_Type::write_code2() {
}
//
// End of "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.9 2002/11/03 00:01:19 matthiaswm Exp $".
// End of "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.10 2002/11/05 06:45:40 matthiaswm Exp $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.21 2002/11/03 00:01:19 matthiaswm Exp $"
// "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.22 2002/11/05 06:45:40 matthiaswm Exp $"
//
// Widget type code for the Fast Light Tool Kit (FLTK).
//
@@ -946,12 +946,13 @@ void callback_cb(Fl_Text_Editor* i, void *v) {
const char *cbtext = current_widget->callback();
i->buffer()->text( cbtext ? cbtext : "" );
} else {
const char *c = i->buffer()->text();
char *c = i->buffer()->text();
const char *d = c_check(c);
if (d) {fl_message("Error in callback: %s",d); haderror = 1; return;}
for (Fl_Type *o = Fl_Type::first; o; o = o->next) if (o->selected) {
o->callback(c);
}
free(c);
}
}
@@ -1971,5 +1972,5 @@ int Fl_Widget_Type::read_fdesign(const char* propname, const char* value) {
}
//
// End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.21 2002/11/03 00:01:19 matthiaswm Exp $".
// End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.22 2002/11/05 06:45:40 matthiaswm Exp $".
//

View File

@@ -54,7 +54,7 @@ Function {make_code_panel()} {open
Fl_Group {} {open
xywh {10 10 525 120} box DOWN_FRAME resizable
} {
Fl_Text_Editor code_input {selected
Fl_Text_Editor code_input {
xywh {12 12 521 116} box NO_BOX resizable
code0 {o->buffer(new Fl_Text_Buffer);}
code1 {o->textfont(FL_COURIER);}
@@ -399,7 +399,7 @@ Function {make_widgetbin()} {open
}
Fl_Button {} {
user_data {"Fl_Output"}
callback type_make_cb
callback type_make_cb selected
tooltip Output xywh {284 4 24 24} box THIN_UP_BOX
code0 {o->image(pixmap[27]);}
}

View File

@@ -19,6 +19,7 @@ Fl_Double_Window* make_widget_panel() {
{ Fl_Group* o = new Fl_Group(10, 30, 395, 295, "GUI");
o->callback((Fl_Callback*)propagate_load);
o->when(FL_WHEN_NEVER);
o->hide();
{ Fl_Group* o = new Fl_Group(95, 40, 301, 280);
o->callback((Fl_Callback*)propagate_load);
{ Fl_Group* o = new Fl_Group(95, 40, 300, 20);
@@ -383,7 +384,6 @@ Fl_Double_Window* make_widget_panel() {
{ Fl_Group* o = new Fl_Group(10, 30, 395, 295, "C++");
o->callback((Fl_Callback*)propagate_load);
o->when(FL_WHEN_NEVER);
o->hide();
{ Fl_Group* o = new Fl_Group(100, 40, 295, 132);
o->callback((Fl_Callback*)propagate_load);
{ Fl_Group* o = new Fl_Group(100, 40, 295, 20);
@@ -449,6 +449,7 @@ Fl_Double_Window* make_widget_panel() {
o->textfont(4);
o->callback((Fl_Callback*)callback_cb);
o->align(FL_ALIGN_LEFT);
o->when(FL_WHEN_RELEASE_ALWAYS);
Fl_Group::current()->resizable(o);
o->buffer(new Fl_Text_Buffer());
o->textfont(FL_COURIER);

View File

@@ -13,8 +13,8 @@ Function {make_widget_panel()} {open
} {
Fl_Group {} {
label GUI
callback propagate_load selected
xywh {10 30 395 295} when 0 resizable
callback propagate_load
xywh {10 30 395 295} when 0 hide resizable
} {
Fl_Group {} {
callback propagate_load open
@@ -349,7 +349,7 @@ image}
Fl_Group {} {
label {C++}
callback propagate_load
xywh {10 30 395 295} when 0 hide
xywh {10 30 395 295} when 0
} {
Fl_Group {} {
callback propagate_load
@@ -413,8 +413,8 @@ image}
} {
Fl_Text_Editor {} {
label {Callback:}
callback callback_cb
tooltip {The callback function or code for the widget.} xywh {102 177 291 86} box NO_BOX align 4 textfont 4 resizable
callback callback_cb selected
tooltip {The callback function or code for the widget.} xywh {102 177 291 86} box NO_BOX align 4 when 6 textfont 4 resizable
code0 {o->buffer(new Fl_Text_Buffer());}
code1 {o->textfont(FL_COURIER);}
}

View File

@@ -1,5 +1,5 @@
//
// "$Id: Fl_Text_Editor.cxx,v 1.9.2.10 2002/10/30 14:23:16 easysw Exp $"
// "$Id: Fl_Text_Editor.cxx,v 1.9.2.11 2002/11/05 06:45:40 matthiaswm Exp $"
//
// Copyright 2001-2002 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under
@@ -185,6 +185,7 @@ int Fl_Text_Editor::kf_default(int c, Fl_Text_Editor* e) {
if (e->insert_mode()) e->insert(s);
else e->overstrike(s);
e->show_insert_position();
if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
return 1;
}
@@ -197,6 +198,7 @@ int Fl_Text_Editor::kf_backspace(int, Fl_Text_Editor* e) {
e->buffer()->select(e->insert_position(), e->insert_position()+1);
kill_selection(e);
e->show_insert_position();
if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
return 1;
}
@@ -204,6 +206,7 @@ int Fl_Text_Editor::kf_enter(int, Fl_Text_Editor* e) {
kill_selection(e);
e->insert("\n");
e->show_insert_position();
if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
return 1;
}
@@ -350,6 +353,7 @@ int Fl_Text_Editor::kf_delete(int, Fl_Text_Editor* e) {
e->buffer()->select(e->insert_position(), e->insert_position()+1);
kill_selection(e);
e->show_insert_position();
if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
return 1;
}
@@ -365,6 +369,7 @@ int Fl_Text_Editor::kf_copy(int, Fl_Text_Editor* e) {
int Fl_Text_Editor::kf_cut(int c, Fl_Text_Editor* e) {
kf_copy(c, e);
kill_selection(e);
if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
return 1;
}
@@ -372,6 +377,7 @@ int Fl_Text_Editor::kf_paste(int, Fl_Text_Editor* e) {
kill_selection(e);
Fl::paste(*e, 1);
e->show_insert_position();
if (e->when()&FL_WHEN_CHANGED) e->do_callback(); else e->set_changed();
return 1;
}
@@ -409,6 +415,11 @@ int Fl_Text_Editor::handle_key() {
return 0;
}
void Fl_Text_Editor::maybe_do_callback() {
if (changed() || (when()&FL_WHEN_NOT_CHANGED)) {
clear_changed(); do_callback();}
}
int Fl_Text_Editor::handle(int event) {
if (!buffer()) return 0;
@@ -416,6 +427,7 @@ int Fl_Text_Editor::handle(int event) {
dragType = -1;
Fl::paste(*this, 0);
Fl::focus(this);
if (when()&FL_WHEN_CHANGED) do_callback(); else set_changed();
return 1;
}
@@ -427,6 +439,8 @@ int Fl_Text_Editor::handle(int event) {
case FL_UNFOCUS:
show_cursor(mCursorOn); // redraws the cursor
case FL_HIDE:
if (when() & FL_WHEN_RELEASE) maybe_do_callback();
return 1;
case FL_KEYBOARD:
@@ -437,6 +451,7 @@ int Fl_Text_Editor::handle(int event) {
if (insert_mode()) insert(Fl::event_text());
else overstrike(Fl::event_text());
show_insert_position();
if (when()&FL_WHEN_CHANGED) do_callback(); else set_changed();
return 1;
// CET - FIXME - this will clobber the window's current cursor state!
@@ -451,5 +466,5 @@ int Fl_Text_Editor::handle(int event) {
}
//
// End of "$Id: Fl_Text_Editor.cxx,v 1.9.2.10 2002/10/30 14:23:16 easysw Exp $".
// End of "$Id: Fl_Text_Editor.cxx,v 1.9.2.11 2002/11/05 06:45:40 matthiaswm Exp $".
//

View File

@@ -1,5 +1,5 @@
# data file for the Fltk User Interface Designer (fluid)
version 1.0100
version 1.0102
header_name {.h}
code_name {.cxx}
decl {\#include <FL/Fl_Preferences.H>} {public
@@ -28,7 +28,8 @@ Function {closeWindowCB( Fl_Widget*, void* )} {open private return_type void
Function {saveAndCloseWindowCB( Fl_Widget*, void* )} {open private return_type void
} {
code {writePrefs();
delete myWindow;} {}
delete myWindow;} {selected
}
}
Function {} {open return_type int
@@ -173,7 +174,7 @@ Function {} {open return_type int
xywh {175 185 70 20} type Horizontal align 8 minimum 2 maximum 6 value 3.1
}
Fl_Input wPaper {
label {Newspaper:} selected
label {Newspaper:}
xywh {165 225 105 20} align 5
}
}
@@ -316,6 +317,5 @@ Function {writePrefs()} {open return_type void
/* sample code only: */
unsigned int hex = 0x2387efcd;
eat.set( "binFoo", (void*)&hex, sizeof( unsigned int ) );
eat.set( "binFoo2", (void*)&writePrefs, 256 );
} {}
eat.set( "binFoo2", (void*)&writePrefs, 256 );} {}
}