summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2005-03-17 21:57:17 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2005-03-17 21:57:17 +0000
commit1e742cc41f169d97790bba4f63b7a56db8a66455 (patch)
tree0c6d40593dedc9351dd89de24df5311c381d7d7f
parent8fcd08ffaac998385489dc202bba379280612990 (diff)
Use check items for overlays and the widget bin, and track their state.
Add Edit/Duplicate to duplicate the current selection; this functions independently of the cut/copy/paste buffer. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4126 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES6
-rw-r--r--fluid/Fl_Window_Type.cxx4
-rw-r--r--fluid/fluid.cxx68
3 files changed, 62 insertions, 16 deletions
diff --git a/CHANGES b/CHANGES
index 102d0c454..a49535846 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,12 @@
CHANGES IN FLTK 1.1.7
- - fixed frame drawing of Fl_Text_Display (STR #762.2)
- Documentation fixes (STR #648, STR #692, STR #730, STR
#744, STR #745)
+ - Added Edit/Duplicate command to FLUID to duplicate the
+ current selection.
+ - FLUID now tracks the current state of the widget bin
+ and overlay using menu item checks.
+ - Fixed frame drawing of Fl_Text_Display (STR #762)
- Fl_Clock_Output::value() did not return the previously
set value (STR #748)
- Added comment type to FLUID. This is useful for
diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx
index 230b52b05..f77a0ffd7 100644
--- a/fluid/Fl_Window_Type.cxx
+++ b/fluid/Fl_Window_Type.cxx
@@ -893,8 +893,12 @@ void Fl_Window_Type::draw_overlay() {
fl_rectf(mybx,mybt-5,5,5);
}
+extern Fl_Menu_Bar *main_menubar;
+
// Calculate new bounding box of selected widgets:
void Fl_Window_Type::fix_overlay() {
+ Fl_Menu_Item *item = (Fl_Menu_Item *)main_menubar->find_item("&Edit/O&verlays");
+ if (item) item->set();
overlays_invisible = 0;
recalc = 1;
((Overlay_Window *)(this->o))->redraw_overlay();
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx
index 1aaff3815..9c11f77b8 100644
--- a/fluid/fluid.cxx
+++ b/fluid/fluid.cxx
@@ -140,6 +140,7 @@ void save_position(Fl_Window *w, const char *prefsName) {
}
Fl_Window *main_window;
+Fl_Menu_Bar *main_menubar;
void save_cb(Fl_Widget *, void *v) {
const char *c = filename;
@@ -348,22 +349,26 @@ void ungroup_cb(Fl_Widget *, void *);
extern int pasteoffset;
static int ipasteoffset;
-static char* cutfname() {
- static char name[1024];
+static char* cutfname(int which = 0) {
+ static char name[2][1024];
static char beenhere = 0;
if (!beenhere) {
beenhere = 1;
- fluid_prefs.getUserdataPath(name, sizeof(name));
- strlcat(name, "cut_buffer", sizeof(name));
- // getUserdataPath zeros the "name" buffer...
+ fluid_prefs.getUserdataPath(name[0], sizeof(name[0]));
+ strlcat(name[0], "cut_buffer", sizeof(name[0]));
+ fluid_prefs.getUserdataPath(name[1], sizeof(name[1]));
+ strlcat(name[1], "dup_buffer", sizeof(name[1]));
}
- return name;
+ return name[which];
}
void copy_cb(Fl_Widget*, void*) {
- if (!Fl_Type::current) return;
+ if (!Fl_Type::current) {
+ fl_beep();
+ return;
+ }
ipasteoffset = 10;
if (!write_file(cutfname(),1)) {
fl_message("Can't write %s: %s", cutfname(), strerror(errno));
@@ -373,7 +378,10 @@ void copy_cb(Fl_Widget*, void*) {
extern void select_only(Fl_Type *);
void cut_cb(Fl_Widget *, void *) {
- if (!Fl_Type::current) return;
+ if (!Fl_Type::current) {
+ fl_beep();
+ return;
+ }
ipasteoffset = 0;
Fl_Type *p = Fl_Type::current->parent;
while (p && p->selected) p = p->parent;
@@ -400,6 +408,28 @@ void paste_cb(Fl_Widget*, void*) {
force_parent = 0;
}
+// Duplicate the selected widgets...
+void duplicate_cb(Fl_Widget*, void*) {
+ if (!Fl_Type::current) {
+ fl_beep();
+ return;
+ }
+
+ if (!write_file(cutfname(1),1)) {
+ fl_message("Can't write %s: %s", cutfname(1), strerror(errno));
+ return;
+ }
+
+ pasteoffset = 0;
+ force_parent = 1;
+
+ if (!read_file(cutfname(1), 1)) {
+ fl_message("Can't read %s: %s", cutfname(1), strerror(errno));
+ }
+
+ force_parent = 0;
+}
+
void earlier_cb(Fl_Widget*,void*);
void later_cb(Fl_Widget*,void*);
@@ -455,14 +485,21 @@ void manual_cb(Fl_Widget *, void *) {
}
void toggle_widgetbin_cb(Fl_Widget *, void *) {
+ Fl_Menu_Item *item = (Fl_Menu_Item *)main_menubar->find_item("&Edit/Widget &Bin");
+
if ( !widgetbin_panel ) {
make_widgetbin();
+ widgetbin_panel->callback(toggle_widgetbin_cb);
if (!position_window(widgetbin_panel,"widgetbin_pos", 1, 320, 30)) return;
+
}
- if ( widgetbin_panel->visible() )
+ if ( widgetbin_panel->visible() ) {
widgetbin_panel->hide();
- else
+ if (item) item->clear();
+ } else {
widgetbin_panel->show();
+ if (item) item->set();
+ }
}
////////////////////////////////////////////////////////////////
@@ -496,6 +533,7 @@ Fl_Menu_Item Main_Menu[] = {
{"&Undo", FL_CTRL+'z', nyi},
{"C&ut", FL_CTRL+'x', cut_cb},
{"&Copy", FL_CTRL+'c', copy_cb},
+ {"&Duplicate", FL_CTRL+'d', duplicate_cb},
{"&Paste", FL_CTRL+'v', paste_cb},
{"Select &All", FL_CTRL+'a', select_all_cb, 0, FL_MENU_DIVIDER},
{"&Open...", FL_F+1, openwidget_cb},
@@ -508,8 +546,8 @@ Fl_Menu_Item Main_Menu[] = {
{"U&ngroup", FL_F+8, ungroup_cb,0, FL_MENU_DIVIDER},
//{"Deactivate", 0, nyi},
//{"Activate", 0, nyi, 0, FL_MENU_DIVIDER},
- {"Toggle O&verlays",FL_CTRL+FL_SHIFT+'o',toggle_overlays},
- {"Toggle Widget &Bin",FL_ALT+'b',toggle_widgetbin_cb, 0, FL_MENU_DIVIDER},
+ {"O&verlays",FL_CTRL+FL_SHIFT+'o',toggle_overlays, 0, FL_MENU_TOGGLE | FL_MENU_VALUE},
+ {"Widget &Bin",FL_ALT+'b',toggle_widgetbin_cb, 0, FL_MENU_TOGGLE | FL_MENU_DIVIDER},
{"Pro&ject Settings...",FL_CTRL+'p',show_project_cb},
{"&GUI Settings...",FL_CTRL+FL_SHIFT+'p',show_settings_cb},
{0},
@@ -578,9 +616,9 @@ void make_main_window() {
o->box(FL_FLAT_BOX);
o->tooltip("Double-click to view or change an item.");
main_window->resizable(o);
- Fl_Menu_Bar *m = new Fl_Menu_Bar(0,0,BROWSERWIDTH,MENUHEIGHT);
- m->menu(Main_Menu);
- m->global();
+ main_menubar = new Fl_Menu_Bar(0,0,BROWSERWIDTH,MENUHEIGHT);
+ main_menubar->menu(Main_Menu);
+ main_menubar->global();
fill_in_New_Menu();
main_window->end();
}