|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 // 00002 // "$Id: Fl_Widget_Type.cxx 8172 2011-01-03 08:28:38Z matt $" 00003 // 00004 // Widget type code for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 #include <FL/Fl.H> 00029 #include <FL/Fl_Group.H> 00030 #include <FL/Fl_Table.H> 00031 #include <FL/Fl_Input.H> 00032 #include "Fl_Widget_Type.h" 00033 #include "alignment_panel.h" 00034 #include <FL/fl_message.H> 00035 #include <FL/Fl_Slider.H> 00036 #include <FL/Fl_Spinner.H> 00037 #include <FL/Fl_Window.H> 00038 #include "../src/flstring.h" 00039 #include <stdio.h> 00040 #include <stdlib.h> 00041 00042 // Make an Fl_Widget_Type subclass instance. 00043 // It figures out the automatic size and parent of the new widget, 00044 // creates the Fl_Widget (by calling the virtual function _make), 00045 // adds it to the Fl_Widget hierarchy, creates a new Fl_Type 00046 // instance, sets the widget pointers, and makes all the display 00047 // update correctly... 00048 00049 extern int reading_file; 00050 int force_parent; 00051 extern int gridx; 00052 extern int gridy; 00053 extern int i18n_type; 00054 extern const char* i18n_include; 00055 extern const char* i18n_function; 00056 extern const char* i18n_file; 00057 extern const char* i18n_set; 00058 00059 int Fl_Widget_Type::default_size = FL_NORMAL_SIZE; 00060 00061 int Fl_Widget_Type::is_widget() const {return 1;} 00062 int Fl_Widget_Type::is_public() const {return public_;} 00063 00064 const char* subclassname(Fl_Type* l) { 00065 if (l->is_widget()) { 00066 Fl_Widget_Type* p = (Fl_Widget_Type*)l; 00067 const char* c = p->subclass(); 00068 if (c) return c; 00069 if (l->is_class()) return "Fl_Group"; 00070 if (p->o->type() == FL_WINDOW+1) return "Fl_Double_Window"; 00071 if (strcmp(p->type_name(), "Fl_Input") == 0) { 00072 if (p->o->type() == FL_FLOAT_INPUT) return "Fl_Float_Input"; 00073 if (p->o->type() == FL_INT_INPUT) return "Fl_Int_Input"; 00074 } 00075 } 00076 return l->type_name(); 00077 } 00078 00079 // Return the ideal widget size... 00080 void 00081 Fl_Widget_Type::ideal_size(int &w, int &h) { 00082 h = o->labelsize(); 00083 o->measure_label(w, h); 00084 00085 w += Fl::box_dw(o->box()); 00086 h += Fl::box_dh(o->box()); 00087 00088 if (w < 15) w = 15; 00089 if (h < 15) h = 15; 00090 } 00091 00092 // Return the ideal widget spacing... 00093 void 00094 Fl_Widget_Type::ideal_spacing(int &x, int &y) { 00095 if (o->labelsize() < 10) 00096 x = y = 0; 00097 else if (o->labelsize() < 14) 00098 x = y = 5; 00099 else 00100 x = y = 10; 00101 } 00102 00103 Fl_Type *Fl_Widget_Type::make() { 00104 // Find the current widget, or widget to copy: 00105 Fl_Type *qq = Fl_Type::current; 00106 while (qq && (!qq->is_widget() || qq->is_menu_item())) qq = qq->parent; 00107 if (!qq) { 00108 fl_message("Please select a widget"); 00109 return 0; 00110 } 00111 Fl_Widget_Type* q = (Fl_Widget_Type*)qq; 00112 // find the parent widget: 00113 Fl_Widget_Type* p = q; 00114 if ((force_parent || !p->is_group()) && p->parent->is_widget()) 00115 p = (Fl_Widget_Type*)(p->parent); 00116 force_parent = 0; 00117 00118 // Figure out a border between widget and window: 00119 int B = p->o->w()/2; if (p->o->h()/2 < B) B = p->o->h()/2; if (B>25) B = 25; 00120 00121 int ULX,ULY; // parent's origin in window 00122 if (!p->is_window()) { // if it is a group, add corner 00123 ULX = p->o->x(); ULY = p->o->y(); 00124 } else { 00125 ULX = ULY = 0; 00126 } 00127 00128 // Figure out a position and size for the widget 00129 int X,Y,W,H; 00130 if (is_group()) { // fill the parent with the widget 00131 X = ULX+B; 00132 W = p->o->w()-B; 00133 Y = ULY+B; 00134 H = p->o->h()-B; 00135 } else if (q != p) { // copy position and size of current widget 00136 W = q->o->w(); 00137 H = q->o->h(); 00138 X = q->o->x()+W; 00139 Y = q->o->y(); 00140 if (X+W > ULX+p->o->w()) { 00141 X = q->o->x(); 00142 Y = q->o->y()+H; 00143 if (Y+H > ULY+p->o->h()) Y = ULY+B; 00144 } 00145 } else { // just make it small and square... 00146 X = ULX+B; 00147 Y = ULY+B; 00148 W = H = B; 00149 } 00150 00151 // satisfy the grid requirements (otherwise it edits really strangely): 00152 if (gridx>1) { 00153 X = (X/gridx)*gridx; 00154 W = ((W-1)/gridx+1)*gridx; 00155 } 00156 if (gridy>1) { 00157 Y = (Y/gridy)*gridy; 00158 H = ((H-1)/gridy+1)*gridy; 00159 } 00160 00161 // Construct the Fl_Type: 00162 Fl_Widget_Type *t = _make(); 00163 if (!o) o = widget(0,0,100,100); // create template widget 00164 t->factory = this; 00165 // Construct the Fl_Widget: 00166 t->o = widget(X,Y,W,H); 00167 if (reading_file) t->o->label(0); 00168 else if (t->o->label()) t->label(t->o->label()); // allow editing 00169 t->o->user_data((void*)t); 00170 // Put it in the parent: 00171 // ((Fl_Group *)(p->o))->add(t->o); (done by Fl_Type::add()) 00172 // add to browser: 00173 t->add(p); 00174 t->redraw(); 00175 return t; 00176 } 00177 00178 #include "Fluid_Image.h" 00179 00180 void Fl_Widget_Type::setimage(Fluid_Image *i) { 00181 if (i == image || is_window()) return; 00182 if (image) image->decrement(); 00183 if (i) i->increment(); 00184 image = i; 00185 if (i) i->image(o); 00186 else o->image(0); 00187 redraw(); 00188 } 00189 00190 void Fl_Widget_Type::setinactive(Fluid_Image *i) { 00191 if (i == inactive || is_window()) return; 00192 if (inactive) inactive->decrement(); 00193 if (i) i->increment(); 00194 inactive = i; 00195 if (i) i->deimage(o); 00196 else o->deimage(0); 00197 redraw(); 00198 } 00199 00200 void Fl_Widget_Type::setlabel(const char *n) { 00201 o->label(n); 00202 redraw(); 00203 } 00204 00205 Fl_Widget_Type::Fl_Widget_Type() { 00206 for (int n=0; n<NUM_EXTRA_CODE; n++) {extra_code_[n] = 0; } 00207 subclass_ = 0; 00208 hotspot_ = 0; 00209 tooltip_ = 0; 00210 image_name_ = 0; 00211 inactive_name_ = 0; 00212 image = 0; 00213 inactive = 0; 00214 xclass = 0; 00215 o = 0; 00216 public_ = 1; 00217 } 00218 00219 Fl_Widget_Type::~Fl_Widget_Type() { 00220 if (o) { 00221 o->hide(); 00222 if (o->parent()) ((Fl_Group*)o->parent())->remove(*o); 00223 delete o; 00224 } 00225 if (subclass_) free((void*)subclass_); 00226 if (tooltip_) free((void*)tooltip_); 00227 if (image_name_) free((void*)image_name_); 00228 if (inactive_name_) free((void*)inactive_name_); 00229 for (int n=0; n<NUM_EXTRA_CODE; n++) { 00230 if (extra_code_[n]) free((void*) extra_code_[n]); 00231 } 00232 } 00233 00234 void Fl_Widget_Type::extra_code(int m,const char *n) { 00235 storestring(n,extra_code_[m]); 00236 } 00237 00238 extern void redraw_browser(); 00239 void Fl_Widget_Type::subclass(const char *n) { 00240 if (storestring(n,subclass_) && visible) 00241 redraw_browser(); 00242 } 00243 00244 void Fl_Widget_Type::tooltip(const char *n) { 00245 storestring(n,tooltip_); 00246 o->tooltip(n); 00247 } 00248 00249 void Fl_Widget_Type::image_name(const char *n) { 00250 setimage(Fluid_Image::find(n)); 00251 storestring(n,image_name_); 00252 } 00253 00254 void Fl_Widget_Type::inactive_name(const char *n) { 00255 setinactive(Fluid_Image::find(n)); 00256 storestring(n,inactive_name_); 00257 } 00258 00259 void Fl_Widget_Type::redraw() { 00260 Fl_Type *t = this; 00261 if (is_menu_item()) { 00262 // find the menu button that parents this menu: 00263 do t = t->parent; while (t && t->is_menu_item()); 00264 // kludge to cause build_menu to be called again: 00265 t->add_child(0,0); 00266 } else { 00267 while (t->parent && t->parent->is_widget()) t = t->parent; 00268 ((Fl_Widget_Type*)t)->o->redraw(); 00269 } 00270 } 00271 00272 // the recursive part sorts all children, returns pointer to next: 00273 Fl_Type *sort(Fl_Type *parent) { 00274 Fl_Type *f,*n=0; 00275 for (f = parent ? parent->next : Fl_Type::first; ; f = n) { 00276 if (!f || (parent && f->level <= parent->level)) return f; 00277 n = sort(f); 00278 if (!f->selected || (!f->is_widget() || f->is_menu_item())) continue; 00279 Fl_Widget* fw = ((Fl_Widget_Type*)f)->o; 00280 Fl_Type *g; // we will insert before this 00281 for (g = parent->next; g != f; g = g->next) { 00282 if (!g->selected || g->level > f->level) continue; 00283 Fl_Widget* gw = ((Fl_Widget_Type*)g)->o; 00284 if (gw->y() > fw->y()) break; 00285 if (gw->y() == fw->y() && gw->x() > fw->x()) break; 00286 } 00287 if (g != f) f->move_before(g); 00288 } 00289 } 00290 00292 // The control panels! 00293 00294 #include "widget_panel.h" 00295 #include <FL/fl_show_colormap.H> 00296 00297 static Fl_Window *the_panel; 00298 00299 // All the callbacks use the argument to indicate whether to load or store. 00300 // This avoids the need for pointers to all the widgets, and keeps the 00301 // code localized in the callbacks. 00302 // A value of LOAD means to load. The hope is that this will not collide 00303 // with any actual useful values for the argument. I also use this to 00304 // initialized parts of the widget that are nyi by fluid. 00305 00306 Fl_Widget_Type *current_widget; // one of the selected ones 00307 void* const LOAD = (void *)"LOAD"; // "magic" pointer to indicate that we need to load values into the dialog 00308 static int numselected; // number selected 00309 static int haderror; 00310 00311 void name_cb(Fl_Input* o, void *v) { 00312 if (v == LOAD) { 00313 static char buf[1024]; 00314 if (numselected != 1) { 00315 snprintf(buf, sizeof(buf), "Widget Properties (%d widgets)", numselected); 00316 o->hide(); 00317 } else { 00318 o->static_value(current_widget->name()); 00319 o->show(); 00320 snprintf(buf, sizeof(buf), "%s Properties", current_widget->title()); 00321 } 00322 00323 the_panel->label(buf); 00324 } else { 00325 if (numselected == 1) { 00326 current_widget->name(o->value()); 00327 // I don't update window title, as it probably is being closed 00328 // and wm2 (a window manager) barfs if you retitle and then 00329 // hide a window: 00330 // ((Fl_Window*)(o->parent()->parent()->parent()))->label(current_widget->title()); 00331 } 00332 } 00333 } 00334 00335 void name_public_member_cb(Fl_Choice* i, void* v) { 00336 if (v == LOAD) { 00337 i->value(current_widget->public_); 00338 if (current_widget->is_in_class()) i->show(); else i->hide(); 00339 } else { 00340 int mod = 0; 00341 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00342 if (o->selected && o->is_widget()) { 00343 Fl_Widget_Type *w = ((Fl_Widget_Type*)o); 00344 if (w->is_in_class()) { 00345 w->public_ = i->value(); 00346 } else { 00347 // if this is not in a class, it can be only private or public 00348 w->public_ = (i->value()>0); 00349 } 00350 mod = 1; 00351 } 00352 } 00353 if (mod) { 00354 set_modflag(1); 00355 redraw_browser(); 00356 } 00357 } 00358 } 00359 00360 void name_public_cb(Fl_Choice* i, void* v) { 00361 if (v == LOAD) { 00362 i->value(current_widget->public_>0); 00363 if (current_widget->is_in_class()) i->hide(); else i->show(); 00364 } else { 00365 int mod = 0; 00366 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00367 if (o->selected && o->is_widget()) { 00368 ((Fl_Widget_Type*)o)->public_ = i->value(); 00369 mod = 1; 00370 } 00371 } 00372 if (mod) { 00373 set_modflag(1); 00374 redraw_browser(); 00375 } 00376 } 00377 } 00378 00379 static char* oldlabel; 00380 static unsigned oldlabellen; 00381 00382 void label_cb(Fl_Input* i, void *v) { 00383 if (v == LOAD) { 00384 i->static_value(current_widget->label()); 00385 if (strlen(i->value()) >= oldlabellen) { 00386 oldlabellen = strlen(i->value())+128; 00387 oldlabel = (char*)realloc(oldlabel,oldlabellen); 00388 } 00389 strcpy(oldlabel,i->value()); 00390 } else { 00391 int mod = 0; 00392 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00393 if (o->selected && o->is_widget()) { 00394 o->label(i->value()); 00395 mod = 1; 00396 } 00397 } 00398 if (mod) set_modflag(1); 00399 } 00400 } 00401 00402 static Fl_Input *image_input; 00403 00404 void image_cb(Fl_Input* i, void *v) { 00405 if (v == LOAD) { 00406 image_input = i; 00407 if (current_widget->is_widget() && !current_widget->is_window()) { 00408 i->activate(); 00409 i->static_value(((Fl_Widget_Type*)current_widget)->image_name()); 00410 } else i->deactivate(); 00411 } else { 00412 int mod = 0; 00413 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00414 if (o->selected && o->is_widget()) { 00415 ((Fl_Widget_Type*)o)->image_name(i->value()); 00416 mod = 1; 00417 } 00418 } 00419 if (mod) set_modflag(1); 00420 } 00421 } 00422 00423 void image_browse_cb(Fl_Button* b, void *v) { 00424 if (v == LOAD) { 00425 if (current_widget->is_widget() && !current_widget->is_window()) 00426 b->activate(); 00427 else 00428 b->deactivate(); 00429 } else { 00430 int mod = 0; 00431 if (ui_find_image(image_input->value())) { 00432 image_input->value(ui_find_image_name); 00433 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00434 if (o->selected && o->is_widget()) { 00435 ((Fl_Widget_Type*)o)->image_name(ui_find_image_name); 00436 mod = 1; 00437 } 00438 } 00439 if (mod) set_modflag(1); 00440 } 00441 } 00442 } 00443 00444 static Fl_Input *inactive_input; 00445 00446 void inactive_cb(Fl_Input* i, void *v) { 00447 if (v == LOAD) { 00448 inactive_input = i; 00449 if (current_widget->is_widget() && !current_widget->is_window()) { 00450 i->activate(); 00451 i->static_value(((Fl_Widget_Type*)current_widget)->inactive_name()); 00452 } else i->deactivate(); 00453 } else { 00454 int mod = 0; 00455 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00456 if (o->selected && o->is_widget()) { 00457 ((Fl_Widget_Type*)o)->inactive_name(i->value()); 00458 mod = 1; 00459 } 00460 } 00461 if (mod) set_modflag(1); 00462 } 00463 } 00464 00465 void inactive_browse_cb(Fl_Button* b, void *v) { 00466 if (v == LOAD) { 00467 if (current_widget->is_widget() && !current_widget->is_window()) 00468 b->activate(); 00469 else 00470 b->deactivate(); 00471 } else { 00472 int mod = 0; 00473 if (ui_find_image(inactive_input->value())) { 00474 inactive_input->value(ui_find_image_name); 00475 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00476 if (o->selected && o->is_widget()) { 00477 ((Fl_Widget_Type*)o)->inactive_name(ui_find_image_name); 00478 mod = 1; 00479 } 00480 } 00481 if (mod) set_modflag(1); 00482 } 00483 } 00484 } 00485 00486 void tooltip_cb(Fl_Input* i, void *v) { 00487 if (v == LOAD) { 00488 if (current_widget->is_widget()) { 00489 i->activate(); 00490 i->static_value(((Fl_Widget_Type*)current_widget)->tooltip()); 00491 } else i->deactivate(); 00492 } else { 00493 int mod = 0; 00494 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00495 if (o->selected && o->is_widget()) { 00496 ((Fl_Widget_Type*)o)->tooltip(i->value()); 00497 mod = 1; 00498 } 00499 } 00500 if (mod) set_modflag(1); 00501 } 00502 } 00503 00504 Fl_Value_Input *x_input, *y_input, *w_input, *h_input; 00505 00506 void x_cb(Fl_Value_Input *i, void *v) { 00507 if (v == LOAD) { 00508 x_input = i; 00509 if (current_widget->is_widget()) { 00510 i->value(((Fl_Widget_Type *)current_widget)->o->x()); 00511 x_input->activate(); 00512 } else x_input->deactivate(); 00513 } else { 00514 int mod = 0; 00515 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00516 if (o->selected && o->is_widget()) { 00517 Fl_Widget *w = ((Fl_Widget_Type *)o)->o; 00518 w->resize((int)i->value(), w->y(), w->w(), w->h()); 00519 if (w->window()) w->window()->redraw(); 00520 if (o->is_window()) { 00521 ((Fl_Window *)w)->size_range(gridx, gridy, Fl::w(), Fl::h(), 00522 gridx, gridy, 0); 00523 } 00524 mod = 1; 00525 } 00526 } 00527 if (mod) set_modflag(1); 00528 } 00529 } 00530 00531 void y_cb(Fl_Value_Input *i, void *v) { 00532 if (v == LOAD) { 00533 y_input = i; 00534 if (current_widget->is_widget()) { 00535 i->value(((Fl_Widget_Type *)current_widget)->o->y()); 00536 y_input->activate(); 00537 } else y_input->deactivate(); 00538 } else { 00539 int mod = 0; 00540 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00541 if (o->selected && o->is_widget()) { 00542 Fl_Widget *w = ((Fl_Widget_Type *)o)->o; 00543 w->resize(w->x(), (int)i->value(), w->w(), w->h()); 00544 if (w->window()) w->window()->redraw(); 00545 if (o->is_window()) { 00546 ((Fl_Window *)w)->size_range(gridx, gridy, Fl::w(), Fl::h(), 00547 gridx, gridy, 0); 00548 } 00549 mod = 1; 00550 } 00551 } 00552 if (mod) set_modflag(1); 00553 } 00554 } 00555 00556 void w_cb(Fl_Value_Input *i, void *v) { 00557 if (v == LOAD) { 00558 w_input = i; 00559 if (current_widget->is_widget()) { 00560 i->value(((Fl_Widget_Type *)current_widget)->o->w()); 00561 w_input->activate(); 00562 } else w_input->deactivate(); 00563 } else { 00564 int mod = 0; 00565 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00566 if (o->selected && o->is_widget()) { 00567 Fl_Widget *w = ((Fl_Widget_Type *)o)->o; 00568 w->resize(w->x(), w->y(), (int)i->value(), w->h()); 00569 if (w->window()) w->window()->redraw(); 00570 if (o->is_window()) { 00571 ((Fl_Window *)w)->size_range(gridx, gridy, Fl::w(), Fl::h(), 00572 gridx, gridy, 0); 00573 } 00574 mod = 1; 00575 } 00576 } 00577 if (mod) set_modflag(1); 00578 } 00579 } 00580 00581 void h_cb(Fl_Value_Input *i, void *v) { 00582 if (v == LOAD) { 00583 h_input = i; 00584 if (current_widget->is_widget()) { 00585 i->value(((Fl_Widget_Type *)current_widget)->o->h()); 00586 h_input->activate(); 00587 } else h_input->deactivate(); 00588 } else { 00589 int mod = 0; 00590 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00591 if (o->selected && o->is_widget()) { 00592 Fl_Widget *w = ((Fl_Widget_Type *)o)->o; 00593 w->resize(w->x(), w->y(), w->w(), (int)i->value()); 00594 if (w->window()) w->window()->redraw(); 00595 if (o->is_window()) { 00596 ((Fl_Window *)w)->size_range(gridx, gridy, Fl::w(), Fl::h(), 00597 gridx, gridy, 0); 00598 } 00599 mod = 1; 00600 } 00601 } 00602 if (mod) set_modflag(1); 00603 } 00604 } 00605 00606 void wc_relative_cb(Fl_Light_Button *i, void *v) { 00607 if (v == LOAD) { 00608 if (!strcmp(current_widget->type_name(), "widget_class")) { 00609 i->show(); 00610 i->value(((Fl_Widget_Class_Type *)current_widget)->wc_relative); 00611 } else { 00612 i->hide(); 00613 } 00614 } else { 00615 int mod = 0; 00616 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00617 if (o->selected && !strcmp(current_widget->type_name(), "widget_class")) { 00618 Fl_Widget_Class_Type *t = (Fl_Widget_Class_Type *)o; 00619 t->wc_relative = i->value(); 00620 mod = 1; 00621 } 00622 } 00623 if (mod) set_modflag(1); 00624 } 00625 } 00626 00628 00629 // turn number to string or string to number for saving to file: 00630 // does not work for hierarchial menus! 00631 00632 const char *item_name(Fl_Menu_Item* m, int i) { 00633 if (m) { 00634 while (m->label()) { 00635 if (m->argument() == i) return m->label(); 00636 m++; 00637 } 00638 } 00639 static char buffer[20]; 00640 sprintf(buffer, "%d", i); 00641 return buffer; 00642 } 00643 int item_number(Fl_Menu_Item* m, const char* i) { 00644 if (m && i) { 00645 if (i[0]=='F' && i[1]=='L' && i[2]=='_') i += 3; 00646 while (m->label()) { 00647 if (!strcmp(m->label(), i)) return int(m->argument()); 00648 m++; 00649 } 00650 } 00651 return atoi(i); 00652 } 00653 00654 #define ZERO_ENTRY 1000 00655 00656 Fl_Menu_Item boxmenu[] = { 00657 {"NO_BOX",0,0,(void *)ZERO_ENTRY}, 00658 {"boxes",0,0,0,FL_SUBMENU}, 00659 {"UP_BOX",0,0,(void *)FL_UP_BOX}, 00660 {"DOWN_BOX",0,0,(void *)FL_DOWN_BOX}, 00661 {"FLAT_BOX",0,0,(void *)FL_FLAT_BOX}, 00662 {"BORDER_BOX",0,0,(void *)FL_BORDER_BOX}, 00663 {"THIN_UP_BOX",0,0,(void *)FL_THIN_UP_BOX}, 00664 {"THIN_DOWN_BOX",0,0,(void *)FL_THIN_DOWN_BOX}, 00665 {"ENGRAVED_BOX",0,0,(void *)FL_ENGRAVED_BOX}, 00666 {"EMBOSSED_BOX",0,0,(void *)FL_EMBOSSED_BOX}, 00667 {"ROUND_UP_BOX",0,0,(void *)FL_ROUND_UP_BOX}, 00668 {"ROUND_DOWN_BOX",0,0,(void *)FL_ROUND_DOWN_BOX}, 00669 {"DIAMOND_UP_BOX",0,0,(void *)FL_DIAMOND_UP_BOX}, 00670 {"DIAMOND_DOWN_BOX",0,0,(void *)FL_DIAMOND_DOWN_BOX}, 00671 {"SHADOW_BOX",0,0,(void *)FL_SHADOW_BOX}, 00672 {"ROUNDED_BOX",0,0,(void *)FL_ROUNDED_BOX}, 00673 {"RSHADOW_BOX",0,0,(void *)FL_RSHADOW_BOX}, 00674 {"RFLAT_BOX",0,0,(void *)FL_RFLAT_BOX}, 00675 {"OVAL_BOX",0,0,(void *)FL_OVAL_BOX}, 00676 {"OSHADOW_BOX",0,0,(void *)FL_OSHADOW_BOX}, 00677 {"OFLAT_BOX",0,0,(void *)FL_OFLAT_BOX}, 00678 {"PLASTIC_UP_BOX",0,0,(void *)FL_PLASTIC_UP_BOX}, 00679 {"PLASTIC_DOWN_BOX",0,0,(void *)FL_PLASTIC_DOWN_BOX}, 00680 {"PLASTIC_THIN_UP_BOX",0,0,(void *)FL_PLASTIC_THIN_UP_BOX}, 00681 {"PLASTIC_THIN_DOWN_BOX",0,0,(void *)FL_PLASTIC_THIN_DOWN_BOX}, 00682 {"PLASTIC_ROUND_UP_BOX",0,0,(void *)FL_PLASTIC_ROUND_UP_BOX}, 00683 {"PLASTIC_ROUND_DOWN_BOX",0,0,(void *)FL_PLASTIC_ROUND_DOWN_BOX}, 00684 {"GTK_UP_BOX",0,0,(void *)FL_GTK_UP_BOX}, 00685 {"GTK_DOWN_BOX",0,0,(void *)FL_GTK_DOWN_BOX}, 00686 {"GTK_THIN_UP_BOX",0,0,(void *)FL_GTK_THIN_UP_BOX}, 00687 {"GTK_THIN_DOWN_BOX",0,0,(void *)FL_GTK_THIN_DOWN_BOX}, 00688 {"GTK_ROUND_UP_BOX",0,0,(void *)FL_GTK_ROUND_UP_BOX}, 00689 {"GTK_ROUND_DOWN_BOX",0,0,(void *)FL_GTK_ROUND_DOWN_BOX}, 00690 {0}, 00691 {"frames",0,0,0,FL_SUBMENU}, 00692 {"UP_FRAME",0,0,(void *)FL_UP_FRAME}, 00693 {"DOWN_FRAME",0,0,(void *)FL_DOWN_FRAME}, 00694 {"THIN_UP_FRAME",0,0,(void *)FL_THIN_UP_FRAME}, 00695 {"THIN_DOWN_FRAME",0,0,(void *)FL_THIN_DOWN_FRAME}, 00696 {"ENGRAVED_FRAME",0,0,(void *)FL_ENGRAVED_FRAME}, 00697 {"EMBOSSED_FRAME",0,0,(void *)FL_EMBOSSED_FRAME}, 00698 {"BORDER_FRAME",0,0,(void *)FL_BORDER_FRAME}, 00699 {"SHADOW_FRAME",0,0,(void *)FL_SHADOW_FRAME}, 00700 {"ROUNDED_FRAME",0,0,(void *)FL_ROUNDED_FRAME}, 00701 {"OVAL_FRAME",0,0,(void *)FL_OVAL_FRAME}, 00702 {"PLASTIC_UP_FRAME",0,0,(void *)FL_PLASTIC_UP_FRAME}, 00703 {"PLASTIC_DOWN_FRAME",0,0,(void *)FL_PLASTIC_DOWN_FRAME}, 00704 {"GTK_UP_FRAME",0,0,(void *)FL_GTK_UP_FRAME}, 00705 {"GTK_DOWN_FRAME",0,0,(void *)FL_GTK_DOWN_FRAME}, 00706 {"GTK_THIN_UP_FRAME",0,0,(void *)FL_GTK_THIN_UP_FRAME}, 00707 {"GTK_THIN_DOWN_FRAME",0,0,(void *)FL_GTK_THIN_DOWN_FRAME}, 00708 {0}, 00709 {0}}; 00710 00711 const char *boxname(int i) { 00712 if (!i) i = ZERO_ENTRY; 00713 for (int j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) 00714 if (boxmenu[j].argument() == i) return boxmenu[j].label(); 00715 return 0; 00716 } 00717 00718 int boxnumber(const char *i) { 00719 if (i[0]=='F' && i[1]=='L' && i[2]=='_') i += 3; 00720 for (int j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) 00721 if (boxmenu[j].label() && !strcmp(boxmenu[j].label(), i)) { 00722 return int(boxmenu[j].argument()); 00723 } 00724 return 0; 00725 } 00726 00727 void box_cb(Fl_Choice* i, void *v) { 00728 if (v == LOAD) { 00729 if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); 00730 int n = current_widget->o->box(); if (!n) n = ZERO_ENTRY; 00731 for (int j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) 00732 if (boxmenu[j].argument() == n) {i->value(j); break;} 00733 } else { 00734 int mod = 0; 00735 int m = i->value(); 00736 int n = int(boxmenu[m].argument()); 00737 if (!n) return; // should not happen 00738 if (n == ZERO_ENTRY) n = 0; 00739 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00740 if (o->selected && o->is_widget()) { 00741 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 00742 q->o->box((Fl_Boxtype)n); 00743 q->redraw(); 00744 mod = 1; 00745 } 00746 } 00747 if (mod) set_modflag(1); 00748 } 00749 } 00750 00751 void down_box_cb(Fl_Choice* i, void *v) { 00752 if (v == LOAD) { 00753 int n; 00754 if (current_widget->is_button() && !current_widget->is_menu_item()) 00755 n = ((Fl_Button*)(current_widget->o))->down_box(); 00756 else if (!strcmp(current_widget->type_name(), "Fl_Input_Choice")) 00757 n = ((Fl_Input_Choice*)(current_widget->o))->down_box(); 00758 else if (current_widget->is_menu_button()) 00759 n = ((Fl_Menu_*)(current_widget->o))->down_box(); 00760 else { 00761 i->deactivate(); return; 00762 } 00763 i->activate(); 00764 if (!n) n = ZERO_ENTRY; 00765 for (int j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) 00766 if (boxmenu[j].argument() == n) {i->value(j); break;} 00767 } else { 00768 int mod = 0; 00769 int m = i->value(); 00770 int n = int(boxmenu[m].argument()); 00771 if (!n) return; // should not happen 00772 if (n == ZERO_ENTRY) n = 0; 00773 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00774 if (o->selected) { 00775 if (o->is_button() && !o->is_menu_item()) { 00776 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 00777 ((Fl_Button*)(q->o))->down_box((Fl_Boxtype)n); 00778 if (((Fl_Button*)(q->o))->value()) q->redraw(); 00779 } else if (!strcmp(o->type_name(), "Fl_Input_Choice")) { 00780 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 00781 ((Fl_Input_Choice*)(q->o))->down_box((Fl_Boxtype)n); 00782 } else if (o->is_menu_button()) { 00783 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 00784 ((Fl_Menu_*)(q->o))->down_box((Fl_Boxtype)n); 00785 } 00786 mod = 1; 00787 } 00788 } 00789 if (mod) set_modflag(1); 00790 } 00791 } 00792 00794 00795 Fl_Menu_Item whenmenu[] = { 00796 {"Never",0,0,(void*)ZERO_ENTRY}, 00797 {"Release",0,0,(void*)FL_WHEN_RELEASE}, 00798 {"Changed",0,0,(void*)FL_WHEN_CHANGED}, 00799 {"Enter key",0,0,(void*)FL_WHEN_ENTER_KEY}, 00800 //{"Release or Enter",0,0,(void*)(FL_WHEN_ENTER_KEY|FL_WHEN_RELEASE)}, 00801 {0}}; 00802 00803 static Fl_Menu_Item whensymbolmenu[] = { 00804 {"FL_WHEN_NEVER",0,0,(void*)(FL_WHEN_NEVER)}, 00805 {"FL_WHEN_CHANGED",0,0,(void*)(FL_WHEN_CHANGED)}, 00806 {"FL_WHEN_RELEASE",0,0,(void*)(FL_WHEN_RELEASE)}, 00807 {"FL_WHEN_RELEASE_ALWAYS",0,0,(void*)(FL_WHEN_RELEASE_ALWAYS)}, 00808 {"FL_WHEN_ENTER_KEY",0,0,(void*)(FL_WHEN_ENTER_KEY)}, 00809 {"FL_WHEN_ENTER_KEY_ALWAYS",0,0,(void*)(FL_WHEN_ENTER_KEY_ALWAYS)}, 00810 {0}}; 00811 00812 void when_cb(Fl_Choice* i, void *v) { 00813 if (v == LOAD) { 00814 if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); 00815 int n = current_widget->o->when() & (~FL_WHEN_NOT_CHANGED); 00816 if (!n) n = ZERO_ENTRY; 00817 for (int j = 0; j < int(sizeof(whenmenu)/sizeof(*whenmenu)); j++) 00818 if (whenmenu[j].argument() == n) {i->value(j); break;} 00819 } else { 00820 int mod = 0; 00821 int m = i->value(); 00822 int n = int(whenmenu[m].argument()); 00823 if (!n) return; // should not happen 00824 if (n == ZERO_ENTRY) n = 0; 00825 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00826 if (o->selected && o->is_widget()) { 00827 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 00828 q->o->when(n|(q->o->when()&FL_WHEN_NOT_CHANGED)); 00829 mod = 1; 00830 } 00831 } 00832 if (mod) set_modflag(1); 00833 } 00834 } 00835 00836 void when_button_cb(Fl_Light_Button* i, void *v) { 00837 if (v == LOAD) { 00838 if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); 00839 i->value(current_widget->o->when()&FL_WHEN_NOT_CHANGED); 00840 } else { 00841 int mod = 0; 00842 int n = i->value() ? FL_WHEN_NOT_CHANGED : 0; 00843 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00844 if (o->selected && o->is_widget()) { 00845 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 00846 q->o->when(n|(q->o->when()&~FL_WHEN_NOT_CHANGED)); 00847 mod = 1; 00848 } 00849 } 00850 if (mod) set_modflag(1); 00851 } 00852 } 00853 00854 uchar Fl_Widget_Type::resizable() const { 00855 if (is_window()) return ((Fl_Window*)o)->resizable() != 0; 00856 Fl_Group* p = (Fl_Group*)o->parent(); 00857 if (p) return p->resizable() == o; 00858 else return 0; 00859 } 00860 00861 void Fl_Widget_Type::resizable(uchar v) { 00862 if (v) { 00863 if (resizable()) return; 00864 if (is_window()) ((Fl_Window*)o)->resizable(o); 00865 else { 00866 Fl_Group* p = (Fl_Group*)o->parent(); 00867 if (p) p->resizable(o); 00868 } 00869 } else { 00870 if (!resizable()) return; 00871 if (is_window()) { 00872 ((Fl_Window*)o)->resizable(0); 00873 } else { 00874 Fl_Group* p = (Fl_Group*)o->parent(); 00875 if (p) p->resizable(0); 00876 } 00877 } 00878 } 00879 00880 void resizable_cb(Fl_Light_Button* i,void* v) { 00881 if (v == LOAD) { 00882 if (current_widget->is_menu_item()) {i->deactivate(); return;} 00883 if (numselected > 1) {i->deactivate(); return;} 00884 i->activate(); 00885 i->value(current_widget->resizable()); 00886 } else { 00887 current_widget->resizable(i->value()); 00888 set_modflag(1); 00889 } 00890 } 00891 00892 void hotspot_cb(Fl_Light_Button* i,void* v) { 00893 if (v == LOAD) { 00894 if (numselected > 1) {i->deactivate(); return;} 00895 if (current_widget->is_menu_item()) i->label("divider"); 00896 else i->label("hotspot"); 00897 i->activate(); 00898 i->value(current_widget->hotspot()); 00899 } else { 00900 current_widget->hotspot(i->value()); 00901 if (current_widget->is_menu_item()) {current_widget->redraw(); return;} 00902 if (i->value()) { 00903 Fl_Type *p = current_widget->parent; 00904 if (!p || !p->is_widget()) return; 00905 while (!p->is_window()) p = p->parent; 00906 for (Fl_Type *o = p->next; o && o->level > p->level; o = o->next) { 00907 if (o->is_widget() && o != current_widget) 00908 ((Fl_Widget_Type*)o)->hotspot(0); 00909 } 00910 } 00911 set_modflag(1); 00912 } 00913 } 00914 00915 void visible_cb(Fl_Light_Button* i, void* v) { 00916 if (v == LOAD) { 00917 i->value(current_widget->o->visible()); 00918 if (current_widget->is_window()) i->deactivate(); 00919 else i->activate(); 00920 } else { 00921 int mod = 0; 00922 int n = i->value(); 00923 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00924 if (o->selected && o->is_widget()) { 00925 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 00926 n ? q->o->show() : q->o->hide(); 00927 q->redraw(); 00928 mod = 1; 00929 if (n && q->parent && q->parent->type_name()) { 00930 if (!strcmp(q->parent->type_name(), "Fl_Tabs")) { 00931 ((Fl_Tabs *)q->o->parent())->value(q->o); 00932 } else if (!strcmp(q->parent->type_name(), "Fl_Wizard")) { 00933 ((Fl_Wizard *)q->o->parent())->value(q->o); 00934 } 00935 } 00936 } 00937 } 00938 if (mod) set_modflag(1); 00939 } 00940 } 00941 00942 void active_cb(Fl_Light_Button* i, void* v) { 00943 if (v == LOAD) { 00944 i->value(current_widget->o->active()); 00945 if (current_widget->is_window()) i->deactivate(); 00946 else i->activate(); 00947 } else { 00948 int mod = 0; 00949 int n = i->value(); 00950 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00951 if (o->selected && o->is_widget()) { 00952 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 00953 n ? q->o->activate() : q->o->deactivate(); 00954 q->redraw(); 00955 mod = 1; 00956 } 00957 } 00958 if (mod) set_modflag(1); 00959 } 00960 } 00961 00963 00964 Fl_Menu_Item fontmenu[] = { 00965 {"Helvetica"}, 00966 {"Helvetica bold"}, 00967 {"Helvetica italic"}, 00968 {"Helvetica bold italic"}, 00969 {"Courier"}, 00970 {"Courier bold"}, 00971 {"Courier italic"}, 00972 {"Courier bold italic"}, 00973 {"Times"}, 00974 {"Times bold"}, 00975 {"Times italic"}, 00976 {"Times bold italic"}, 00977 {"Symbol"}, 00978 {"Terminal"}, 00979 {"Terminal Bold"}, 00980 {"Zapf Dingbats"}, 00981 {0}}; 00982 00983 void labelfont_cb(Fl_Choice* i, void *v) { 00984 if (v == LOAD) { 00985 int n = current_widget->o->labelfont(); 00986 if (n > 15) n = 0; 00987 i->value(n); 00988 } else { 00989 int mod = 0; 00990 int n = i->value(); 00991 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 00992 if (o->selected && o->is_widget()) { 00993 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 00994 q->o->labelfont(n); 00995 q->redraw(); 00996 mod = 1; 00997 } 00998 } 00999 if (mod) set_modflag(1); 01000 } 01001 } 01002 01003 void labelsize_cb(Fl_Value_Input* i, void *v) { 01004 int n; 01005 if (v == LOAD) { 01006 n = current_widget->o->labelsize(); 01007 } else { 01008 int mod = 0; 01009 n = int(i->value()); 01010 if (n <= 0) n = Fl_Widget_Type::default_size; 01011 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01012 if (o->selected && o->is_widget()) { 01013 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01014 q->o->labelsize(n); 01015 q->redraw(); 01016 mod = 1; 01017 } 01018 } 01019 if (mod) set_modflag(1); 01020 } 01021 i->value(n); 01022 } 01023 01024 extern const char *ui_find_image_name; 01025 01026 Fl_Menu_Item labeltypemenu[] = { 01027 {"NORMAL_LABEL",0,0,(void*)0}, 01028 {"SHADOW_LABEL",0,0,(void*)FL_SHADOW_LABEL}, 01029 {"ENGRAVED_LABEL",0,0,(void*)FL_ENGRAVED_LABEL}, 01030 {"EMBOSSED_LABEL",0,0,(void*)FL_EMBOSSED_LABEL}, 01031 {"NO_LABEL",0,0,(void*)(FL_NO_LABEL)}, 01032 {0}}; 01033 01034 void labeltype_cb(Fl_Choice* i, void *v) { 01035 if (v == LOAD) { 01036 int n; 01037 n = current_widget->o->labeltype(); 01038 i->when(FL_WHEN_RELEASE); 01039 for (int j = 0; j < int(sizeof(labeltypemenu)/sizeof(*labeltypemenu)); j++) 01040 if (labeltypemenu[j].argument() == n) {i->value(j); break;} 01041 } else { 01042 int mod = 0; 01043 int m = i->value(); 01044 int n = int(labeltypemenu[m].argument()); 01045 if (n<0) return; // should not happen 01046 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01047 if (o->selected && o->is_widget()) { 01048 Fl_Widget_Type* p = (Fl_Widget_Type*)o; 01049 p->o->labeltype((Fl_Labeltype)n); 01050 p->redraw(); 01051 mod = 1; 01052 } 01053 } 01054 if (mod) set_modflag(1); 01055 } 01056 } 01057 01059 01060 void color_cb(Fl_Button* i, void *v) { 01061 Fl_Color c = current_widget->o->color(); 01062 if (v == LOAD) { 01063 if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); 01064 } else { 01065 int mod = 0; 01066 Fl_Color d = fl_show_colormap(c); 01067 if (d == c) return; 01068 c = d; 01069 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01070 if (o->selected && o->is_widget()) { 01071 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01072 q->o->color(c); q->o->redraw(); 01073 if (q->parent && q->parent->type_name() == tabs_type_name) { 01074 if (q->o->parent()) q->o->parent()->redraw(); 01075 } 01076 mod = 1; 01077 } 01078 } 01079 if (mod) set_modflag(1); 01080 } 01081 i->color(c); i->labelcolor(fl_contrast(FL_BLACK,c)); i->redraw(); 01082 } 01083 01084 void color2_cb(Fl_Button* i, void *v) { 01085 Fl_Color c = current_widget->o->selection_color(); 01086 if (v == LOAD) { 01087 if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); 01088 } else { 01089 int mod = 0; 01090 Fl_Color d = fl_show_colormap(c); 01091 if (d == c) return; 01092 c = d; 01093 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01094 if (o->selected && o->is_widget()) { 01095 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01096 q->o->selection_color(c); q->o->redraw(); 01097 mod = 1; 01098 } 01099 } 01100 if (mod) set_modflag(1); 01101 } 01102 i->color(c); i->labelcolor(fl_contrast(FL_BLACK,c)); i->redraw(); 01103 } 01104 01105 void labelcolor_cb(Fl_Button* i, void *v) { 01106 Fl_Color c = current_widget->o->labelcolor(); 01107 if (v != LOAD) { 01108 int mod = 0; 01109 Fl_Color d = fl_show_colormap(c); 01110 if (d == c) return; 01111 c = d; 01112 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01113 if (o->selected && o->is_widget()) { 01114 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01115 q->o->labelcolor(c); q->redraw(); 01116 mod = 1; 01117 } 01118 } 01119 if (mod) set_modflag(1); 01120 } 01121 i->color(c); i->labelcolor(fl_contrast(FL_BLACK,c)); i->redraw(); 01122 } 01123 01124 static Fl_Button* relative(Fl_Widget* o, int i) { 01125 Fl_Group* g = (Fl_Group*)(o->parent()); 01126 return (Fl_Button*)(g->child(g->find(*o)+i)); 01127 } 01128 01129 static Fl_Menu_Item alignmenu[] = { 01130 {"FL_ALIGN_CENTER",0,0,(void*)(FL_ALIGN_CENTER)}, 01131 {"FL_ALIGN_TOP",0,0,(void*)(FL_ALIGN_TOP)}, 01132 {"FL_ALIGN_BOTTOM",0,0,(void*)(FL_ALIGN_BOTTOM)}, 01133 {"FL_ALIGN_LEFT",0,0,(void*)(FL_ALIGN_LEFT)}, 01134 {"FL_ALIGN_RIGHT",0,0,(void*)(FL_ALIGN_RIGHT)}, 01135 {"FL_ALIGN_INSIDE",0,0,(void*)(FL_ALIGN_INSIDE)}, 01136 {"FL_ALIGN_CLIP",0,0,(void*)(FL_ALIGN_CLIP)}, 01137 {"FL_ALIGN_WRAP",0,0,(void*)(FL_ALIGN_WRAP)}, 01138 {"FL_ALIGN_TEXT_OVER_IMAGE",0,0,(void*)(FL_ALIGN_TEXT_OVER_IMAGE)}, 01139 {"FL_ALIGN_TOP_LEFT",0,0,(void*)(FL_ALIGN_TOP_LEFT)}, 01140 {"FL_ALIGN_TOP_RIGHT",0,0,(void*)(FL_ALIGN_TOP_RIGHT)}, 01141 {"FL_ALIGN_BOTTOM_LEFT",0,0,(void*)(FL_ALIGN_BOTTOM_LEFT)}, 01142 {"FL_ALIGN_BOTTOM_RIGHT",0,0,(void*)(FL_ALIGN_BOTTOM_RIGHT)}, 01143 {"FL_ALIGN_LEFT_TOP",0,0,(void*)(FL_ALIGN_LEFT_TOP)}, 01144 {"FL_ALIGN_RIGHT_TOP",0,0,(void*)(FL_ALIGN_RIGHT_TOP)}, 01145 {"FL_ALIGN_LEFT_BOTTOM",0,0,(void*)(FL_ALIGN_LEFT_BOTTOM)}, 01146 {"FL_ALIGN_RIGHT_BOTTOM",0,0,(void*)(FL_ALIGN_RIGHT_BOTTOM)}, 01147 {0}}; 01148 01149 void align_cb(Fl_Button* i, void *v) { 01150 Fl_Align b = Fl_Align(fl_uintptr_t(i->user_data())); 01151 if (v == LOAD) { 01152 if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); 01153 i->value(current_widget->o->align() & b); 01154 } else { 01155 int mod = 0; 01156 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01157 if (o->selected && o->is_widget()) { 01158 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01159 Fl_Align x = q->o->align(); 01160 Fl_Align y; 01161 if (i->value()) { 01162 y = x | b; 01163 if (b == FL_ALIGN_LEFT || b == FL_ALIGN_TOP) { 01164 Fl_Button *b1 = relative(i,+1); 01165 b1->clear(); 01166 y = y & ~(b1->argument()); 01167 } 01168 if (b == FL_ALIGN_RIGHT || b == FL_ALIGN_BOTTOM) { 01169 Fl_Button *b1 = relative(i,-1); 01170 b1->clear(); 01171 y = y & ~(b1->argument()); 01172 } 01173 } else { 01174 y = x & ~b; 01175 } 01176 if (x != y) { 01177 q->o->align(y); 01178 q->redraw(); 01179 mod = 1; 01180 } 01181 } 01182 } 01183 if (mod) set_modflag(1); 01184 } 01185 } 01186 01187 void align_position_cb(Fl_Choice *i, void *v) { 01188 if (v == LOAD) { 01189 if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); 01190 Fl_Menu_Item *mi = (Fl_Menu_Item*)i->menu(); 01191 Fl_Align b = current_widget->o->align() & FL_ALIGN_POSITION_MASK; 01192 for (;mi->text;mi++) { 01193 if ((Fl_Align)(mi->argument())==b) 01194 i->value(mi); 01195 } 01196 } else { 01197 const Fl_Menu_Item *mi = i->menu() + i->value(); 01198 Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data())); 01199 int mod = 0; 01200 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01201 if (o->selected && o->is_widget()) { 01202 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01203 Fl_Align x = q->o->align(); 01204 Fl_Align y = (x & ~FL_ALIGN_POSITION_MASK) | b; 01205 if (x != y) { 01206 q->o->align(y); 01207 q->redraw(); 01208 mod = 1; 01209 } 01210 } 01211 } 01212 if (mod) set_modflag(1); 01213 } 01214 } 01215 01216 void align_text_image_cb(Fl_Choice *i, void *v) { 01217 if (v == LOAD) { 01218 if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); 01219 Fl_Menu_Item *mi = (Fl_Menu_Item*)i->menu(); 01220 Fl_Align b = current_widget->o->align() & FL_ALIGN_IMAGE_MASK; 01221 for (;mi->text;mi++) { 01222 if ((Fl_Align)(mi->argument())==b) 01223 i->value(mi); 01224 } 01225 } else { 01226 const Fl_Menu_Item *mi = i->menu() + i->value(); 01227 Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data())); 01228 int mod = 0; 01229 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01230 if (o->selected && o->is_widget()) { 01231 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01232 Fl_Align x = q->o->align(); 01233 Fl_Align y = (x & ~FL_ALIGN_IMAGE_MASK) | b; 01234 if (x != y) { 01235 q->o->align(y); 01236 q->redraw(); 01237 mod = 1; 01238 } 01239 } 01240 } 01241 if (mod) set_modflag(1); 01242 } 01243 } 01244 01246 01247 void callback_cb(CodeEditor* i, void *v) { 01248 if (v == LOAD) { 01249 const char *cbtext = current_widget->callback(); 01250 i->buffer()->text( cbtext ? cbtext : "" ); 01251 } else { 01252 int mod = 0; 01253 char *c = i->buffer()->text(); 01254 const char *d = c_check(c); 01255 if (d) { 01256 fl_message("Error in callback: %s",d); 01257 if (i->window()) i->window()->make_current(); 01258 haderror = 1; 01259 } 01260 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01261 if (o->selected) { 01262 o->callback(c); 01263 mod = 1; 01264 } 01265 } 01266 if (mod) set_modflag(1); 01267 free(c); 01268 } 01269 } 01270 01271 void user_data_cb(Fl_Input *i, void *v) { 01272 if (v == LOAD) { 01273 i->static_value(current_widget->user_data()); 01274 } else { 01275 int mod = 0; 01276 const char *c = i->value(); 01277 const char *d = c_check(c); 01278 if (d) {fl_message("Error in user_data: %s",d); haderror = 1; return;} 01279 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01280 if (o->selected) { 01281 o->user_data(c); 01282 mod = 1; 01283 } 01284 } 01285 if (mod) set_modflag(1); 01286 } 01287 } 01288 01289 void user_data_type_cb(Fl_Input *i, void *v) { 01290 static const char *dflt = "void*"; 01291 if (v == LOAD) { 01292 const char *c = current_widget->user_data_type(); 01293 if (!c) c = dflt; 01294 i->static_value(c); 01295 } else { 01296 int mod = 0; 01297 const char *c = i->value(); 01298 const char *d = c_check(c); 01299 if (!*c) i->value(dflt); 01300 else if (!strcmp(c,dflt)) c = 0; 01301 if (!d) { 01302 if (c && *c && c[strlen(c)-1] != '*' && strcmp(c,"long")) 01303 d = "must be pointer or long"; 01304 } 01305 if (d) {fl_message("Error in type: %s",d); haderror = 1; return;} 01306 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01307 if (o->selected) { 01308 o->user_data_type(c); 01309 mod = 1; 01310 } 01311 } 01312 if (mod) set_modflag(1); 01313 } 01314 } 01315 01316 // "v_attributes" let user type in random code for attribute settings: 01317 01318 void v_input_cb(Fl_Input* i, void* v) { 01319 int n = fl_intptr_t(i->user_data()); 01320 if (v == LOAD) { 01321 i->static_value(current_widget->extra_code(n)); 01322 } else { 01323 int mod = 0; 01324 const char *c = i->value(); 01325 const char *d = c_check(c&&c[0]=='#' ? c+1 : c); 01326 if (d) {fl_message("Error in %s: %s",i->label(),d); haderror = 1; return;} 01327 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01328 if (o->selected && o->is_widget()) { 01329 Fl_Widget_Type *t = (Fl_Widget_Type*)o; 01330 t->extra_code(n,c); 01331 mod = 1; 01332 } 01333 } 01334 if (mod) set_modflag(1); 01335 } 01336 } 01337 01338 void subclass_cb(Fl_Input* i, void* v) { 01339 if (v == LOAD) { 01340 if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); 01341 i->static_value(current_widget->subclass()); 01342 } else { 01343 int mod = 0; 01344 const char *c = i->value(); 01345 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01346 if (o->selected && o->is_widget()) { 01347 Fl_Widget_Type *t = (Fl_Widget_Type*)o; 01348 t->subclass(c); 01349 mod = 1; 01350 } 01351 } 01352 if (mod) set_modflag(1); 01353 } 01354 } 01355 01357 01358 // textstuff: set textfont, textsize, textcolor attributes: 01359 01360 // default widget returns 0 to indicate not-implemented: 01361 int Fl_Widget_Type::textstuff(int, Fl_Font&, int&, Fl_Color&) {return 0;} 01362 01363 void textfont_cb(Fl_Choice* i, void* v) { 01364 Fl_Font n; int s; Fl_Color c; 01365 if (v == LOAD) { 01366 if (!current_widget->textstuff(0,n,s,c)) {i->deactivate(); return;} 01367 i->activate(); 01368 if (n > 15) n = FL_HELVETICA; 01369 i->value(n); 01370 } else { 01371 int mod = 0; 01372 n = (Fl_Font)i->value(); 01373 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01374 if (o->selected && o->is_widget()) { 01375 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01376 q->textstuff(1,n,s,c); 01377 q->o->redraw(); 01378 mod = 1; 01379 } 01380 } 01381 if (mod) set_modflag(1); 01382 } 01383 } 01384 01385 void textsize_cb(Fl_Value_Input* i, void* v) { 01386 Fl_Font n; int s; Fl_Color c; 01387 if (v == LOAD) { 01388 if (!current_widget->textstuff(0,n,s,c)) {i->deactivate(); return;} 01389 i->activate(); 01390 } else { 01391 int mod = 0; 01392 s = int(i->value()); 01393 if (s <= 0) s = Fl_Widget_Type::default_size; 01394 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01395 if (o->selected && o->is_widget()) { 01396 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01397 q->textstuff(2,n,s,c); 01398 q->o->redraw(); 01399 mod = 1; 01400 } 01401 } 01402 if (mod) set_modflag(1); 01403 } 01404 i->value(s); 01405 } 01406 01407 void textcolor_cb(Fl_Button* i, void* v) { 01408 Fl_Font n; int s; Fl_Color c; 01409 if (v == LOAD) { 01410 if (!current_widget->textstuff(0,n,s,c)) {i->deactivate(); return;} 01411 i->activate(); 01412 } else { 01413 int mod = 0; 01414 c = i->color(); 01415 Fl_Color d = fl_show_colormap(c); 01416 if (d == c) return; 01417 c = d; 01418 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01419 if (o->selected && o->is_widget()) { 01420 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01421 q->textstuff(3,n,s,c); q->o->redraw(); 01422 mod = 1; 01423 } 01424 } 01425 if (mod) set_modflag(1); 01426 } 01427 i->color(c); i->labelcolor(fl_contrast(FL_BLACK,c)); i->redraw(); 01428 } 01429 01431 // Kludges to the panel for subclasses: 01432 01433 void min_w_cb(Fl_Value_Input* i, void* v) { 01434 if (v == LOAD) { 01435 if (!current_widget->is_window()) {i->parent()->hide(); return;} 01436 i->parent()->show(); 01437 i->value(((Fl_Window_Type*)current_widget)->sr_min_w); 01438 } else { 01439 int mod = 0; 01440 int n = (int)i->value(); 01441 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01442 if (o->selected && o->is_window()) { 01443 ((Fl_Window_Type*)current_widget)->sr_min_w = n; 01444 mod = 1; 01445 } 01446 } 01447 if (mod) set_modflag(1); 01448 } 01449 } 01450 01451 void min_h_cb(Fl_Value_Input* i, void* v) { 01452 if (v == LOAD) { 01453 if (!current_widget->is_window()) return; 01454 i->value(((Fl_Window_Type*)current_widget)->sr_min_h); 01455 } else { 01456 int mod = 0; 01457 int n = (int)i->value(); 01458 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01459 if (o->selected && o->is_window()) { 01460 ((Fl_Window_Type*)current_widget)->sr_min_h = n; 01461 mod = 1; 01462 } 01463 } 01464 if (mod) set_modflag(1); 01465 } 01466 } 01467 01468 void max_w_cb(Fl_Value_Input* i, void* v) { 01469 if (v == LOAD) { 01470 if (!current_widget->is_window()) return; 01471 i->value(((Fl_Window_Type*)current_widget)->sr_max_w); 01472 } else { 01473 int mod = 0; 01474 int n = (int)i->value(); 01475 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01476 if (o->selected && o->is_window()) { 01477 ((Fl_Window_Type*)current_widget)->sr_max_w = n; 01478 mod = 1; 01479 } 01480 } 01481 if (mod) set_modflag(1); 01482 } 01483 } 01484 01485 void max_h_cb(Fl_Value_Input* i, void* v) { 01486 if (v == LOAD) { 01487 if (!current_widget->is_window()) return; 01488 i->value(((Fl_Window_Type*)current_widget)->sr_max_h); 01489 } else { 01490 int mod = 0; 01491 int n = (int)i->value(); 01492 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01493 if (o->selected && o->is_window()) { 01494 ((Fl_Window_Type*)current_widget)->sr_max_h = n; 01495 mod = 1; 01496 } 01497 } 01498 if (mod) set_modflag(1); 01499 } 01500 } 01501 01502 void set_min_size_cb(Fl_Button*, void* v) { 01503 if (v == LOAD) { 01504 } else { 01505 int mod = 0; 01506 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01507 if (o->selected && o->is_window()) { 01508 Fl_Window_Type *win = (Fl_Window_Type*)current_widget; 01509 win->sr_min_w = win->o->w(); 01510 win->sr_min_h = win->o->h(); 01511 mod = 1; 01512 } 01513 } 01514 propagate_load(the_panel, LOAD); 01515 if (mod) set_modflag(1); 01516 } 01517 } 01518 01519 void set_max_size_cb(Fl_Button*, void* v) { 01520 if (v == LOAD) { 01521 } else { 01522 int mod = 0; 01523 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01524 if (o->selected && o->is_window()) { 01525 Fl_Window_Type *win = (Fl_Window_Type*)current_widget; 01526 win->sr_max_w = win->o->w(); 01527 win->sr_max_h = win->o->h(); 01528 mod = 1; 01529 } 01530 } 01531 propagate_load(the_panel, LOAD); 01532 if (mod) set_modflag(1); 01533 } 01534 } 01535 01536 void slider_size_cb(Fl_Value_Input* i, void* v) { 01537 if (v == LOAD) { 01538 if (current_widget->is_window()) 01539 i->parent()->hide(); 01540 else 01541 i->parent()->show(); 01542 if (current_widget->is_valuator()<2) {i->deactivate(); return;} 01543 i->activate(); 01544 i->value(((Fl_Slider*)(current_widget->o))->slider_size()); 01545 } else { 01546 int mod = 0; 01547 double n = i->value(); 01548 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01549 if (o->selected && o->is_widget()) { 01550 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01551 if (q->is_valuator()>=2) { 01552 ((Fl_Slider*)(q->o))->slider_size(n); 01553 q->o->redraw(); 01554 mod = 1; 01555 } 01556 } 01557 } 01558 if (mod) set_modflag(1); 01559 } 01560 } 01561 01562 void min_cb(Fl_Value_Input* i, void* v) { 01563 if (v == LOAD) { 01564 if (current_widget->is_valuator()) { 01565 i->activate(); 01566 i->value(((Fl_Valuator*)(current_widget->o))->minimum()); 01567 } else if (current_widget->is_spinner()) { 01568 i->activate(); 01569 i->value(((Fl_Spinner*)(current_widget->o))->minimum()); 01570 } else { 01571 i->deactivate(); 01572 return; 01573 } 01574 } else { 01575 int mod = 0; 01576 double n = i->value(); 01577 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01578 if (o->selected && o->is_widget()) { 01579 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01580 if (q->is_valuator()) { 01581 ((Fl_Valuator*)(q->o))->minimum(n); 01582 q->o->redraw(); 01583 mod = 1; 01584 } else if (q->is_spinner()) { 01585 ((Fl_Spinner*)(q->o))->minimum(n); 01586 q->o->redraw(); 01587 mod = 1; 01588 } 01589 } 01590 } 01591 if (mod) set_modflag(1); 01592 } 01593 } 01594 01595 void max_cb(Fl_Value_Input* i, void* v) { 01596 if (v == LOAD) { 01597 if (current_widget->is_valuator()) { 01598 i->activate(); 01599 i->value(((Fl_Valuator*)(current_widget->o))->maximum()); 01600 } else if (current_widget->is_spinner()) { 01601 i->activate(); 01602 i->value(((Fl_Spinner*)(current_widget->o))->maximum()); 01603 } else { 01604 i->deactivate(); 01605 return; 01606 } 01607 } else { 01608 int mod = 0; 01609 double n = i->value(); 01610 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01611 if (o->selected && o->is_widget()) { 01612 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01613 if (q->is_valuator()) { 01614 ((Fl_Valuator*)(q->o))->maximum(n); 01615 q->o->redraw(); 01616 mod = 1; 01617 } else if (q->is_spinner()) { 01618 ((Fl_Spinner*)(q->o))->maximum(n); 01619 q->o->redraw(); 01620 mod = 1; 01621 } 01622 } 01623 } 01624 if (mod) set_modflag(1); 01625 } 01626 } 01627 01628 void step_cb(Fl_Value_Input* i, void* v) { 01629 if (v == LOAD) { 01630 if (current_widget->is_valuator()) { 01631 i->activate(); 01632 i->value(((Fl_Valuator*)(current_widget->o))->step()); 01633 } else if (current_widget->is_spinner()) { 01634 i->activate(); 01635 i->value(((Fl_Spinner*)(current_widget->o))->step()); 01636 } else { 01637 i->deactivate(); 01638 return; 01639 } 01640 } else { 01641 int mod = 0; 01642 double n = i->value(); 01643 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01644 if (o->selected && o->is_widget()) { 01645 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01646 if (q->is_valuator()) { 01647 ((Fl_Valuator*)(q->o))->step(n); 01648 q->o->redraw(); 01649 mod = 1; 01650 } else if (q->is_spinner()) { 01651 ((Fl_Spinner*)(q->o))->step(n); 01652 q->o->redraw(); 01653 mod = 1; 01654 } 01655 } 01656 } 01657 if (mod) set_modflag(1); 01658 } 01659 } 01660 01661 void value_cb(Fl_Value_Input* i, void* v) { 01662 if (v == LOAD) { 01663 if (current_widget->is_valuator()) { 01664 i->activate(); 01665 i->value(((Fl_Valuator*)(current_widget->o))->value()); 01666 } else if (current_widget->is_button()) { 01667 i->activate(); 01668 i->value(((Fl_Button*)(current_widget->o))->value()); 01669 } else if (current_widget->is_spinner()) { 01670 i->activate(); 01671 i->value(((Fl_Spinner*)(current_widget->o))->value()); 01672 } else 01673 i->deactivate(); 01674 } else { 01675 int mod = 0; 01676 double n = i->value(); 01677 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01678 if (o->selected && o->is_widget()) { 01679 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01680 if (q->is_valuator()) { 01681 ((Fl_Valuator*)(q->o))->value(n); 01682 mod = 1; 01683 } else if (q->is_button()) { 01684 ((Fl_Button*)(q->o))->value(n != 0); 01685 if (q->is_menu_item()) q->redraw(); 01686 mod = 1; 01687 } else if (q->is_spinner()) { 01688 ((Fl_Spinner*)(q->o))->value(n); 01689 mod = 1; 01690 } 01691 } 01692 } 01693 if (mod) set_modflag(1); 01694 } 01695 } 01696 01698 01699 // subtypes: 01700 01701 Fl_Menu_Item *Fl_Widget_Type::subtypes() {return 0;} 01702 01703 void subtype_cb(Fl_Choice* i, void* v) { 01704 if (v == LOAD) { 01705 Fl_Menu_Item* m = current_widget->subtypes(); 01706 if (!m) {i->deactivate(); return;} 01707 i->menu(m); 01708 int j; 01709 for (j = 0;; j++) { 01710 if (!m[j].text) {j = 0; break;} 01711 if (current_widget->is_spinner()) { 01712 if (m[j].argument() == ((Fl_Spinner*)current_widget->o)->type()) break; 01713 } else { 01714 if (m[j].argument() == current_widget->o->type()) break; 01715 } 01716 } 01717 i->value(j); 01718 i->activate(); 01719 i->redraw(); 01720 } else { 01721 int mod = 0; 01722 int n = int(i->mvalue()->argument()); 01723 Fl_Menu_Item* m = current_widget->subtypes(); 01724 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01725 if (o->selected && o->is_widget()) { 01726 Fl_Widget_Type* q = (Fl_Widget_Type*)o; 01727 if (q->subtypes()==m) { 01728 if (q->is_spinner()) 01729 ((Fl_Spinner*)q->o)->type(n); 01730 else 01731 q->o->type(n); 01732 q->redraw(); 01733 mod = 1; 01734 } 01735 } 01736 } 01737 if (mod) set_modflag(1); 01738 } 01739 } 01740 01742 01743 void propagate_load(Fl_Group* g, void* v) { 01744 if (v == LOAD) { 01745 Fl_Widget*const* a = g->array(); 01746 for (int i=g->children(); i--;) { 01747 Fl_Widget* o = *a++; 01748 o->do_callback(o,LOAD); 01749 } 01750 } 01751 } 01752 01753 void set_cb(Fl_Button*, void*) { 01754 haderror = 0; 01755 Fl_Widget*const* a = the_panel->array(); 01756 for (int i=the_panel->children(); i--;) { 01757 Fl_Widget* o = *a++; 01758 if (o->changed()) { 01759 o->do_callback(); 01760 if (haderror) return; 01761 o->clear_changed(); 01762 } 01763 } 01764 } 01765 01766 void ok_cb(Fl_Return_Button* o, void* v) { 01767 set_cb(o,v); 01768 if (!haderror) the_panel->hide(); 01769 } 01770 01771 void revert_cb(Fl_Button*, void*) { 01772 // We have to revert all dynamically changing fields: 01773 // but for now only the first label works... 01774 if (numselected == 1) current_widget->label(oldlabel); 01775 propagate_load(the_panel, LOAD); 01776 } 01777 01778 void cancel_cb(Fl_Button* o, void* v) { 01779 revert_cb(o,v); 01780 the_panel->hide(); 01781 } 01782 01783 void toggle_overlays(Fl_Widget *,void *); // in Fl_Window_Type.cxx 01784 void overlay_cb(Fl_Button*o,void *v) { 01785 toggle_overlays(o,v); 01786 } 01787 01788 void leave_live_mode_cb(Fl_Widget*, void*); 01789 01790 void live_mode_cb(Fl_Button*o,void *) { 01793 static Fl_Type *live_type = 0L; 01794 static Fl_Widget *live_widget = 0L; 01795 static Fl_Window *live_window = 0L; 01796 // if 'o' is 0, we must quit live mode 01797 if (!o) { 01798 o = wLiveMode; 01799 o->value(0); 01800 } 01801 if (o->value()) { 01802 if (numselected == 1) { 01803 Fl_Group::current(0L); 01804 live_widget = current_widget->enter_live_mode(1); 01805 if (live_widget) { 01806 live_type = current_widget; 01807 Fl_Group::current(0); 01808 int w = live_widget->w(); 01809 int h = live_widget->h(); 01810 live_window = new Fl_Double_Window(w+20, h+55, "Fluid Live Mode Widget"); 01811 live_window->box(FL_FLAT_BOX); 01812 live_window->color(FL_GREEN); 01813 Fl_Group *rsz = new Fl_Group(0, h+20, 130, 35); 01814 rsz->box(FL_NO_BOX); 01815 Fl_Box *rsz_dummy = new Fl_Box(110, h+20, 1, 25); 01816 rsz_dummy->box(FL_NO_BOX); 01817 rsz->resizable(rsz_dummy); 01818 Fl_Button *btn = new Fl_Button(10, h+20, 100, 25, "Exit Live Mode"); 01819 btn->labelsize(12); 01820 btn->callback(leave_live_mode_cb); 01821 rsz->end(); 01822 live_window->add(live_widget); 01823 live_widget->position(10, 10); 01824 live_window->resizable(live_widget); 01825 live_window->set_modal(); // block all other UI 01826 live_window->callback(leave_live_mode_cb); 01827 if (current_widget->is_window()) { 01828 Fl_Window_Type *w = (Fl_Window_Type*)current_widget; 01829 int mw = w->sr_min_w; if (mw>0) mw += 20; 01830 int mh = w->sr_min_h; if (mh>0) mh += 55; 01831 int MW = w->sr_max_w; if (MW>0) MW += 20; 01832 int MH = w->sr_max_h; if (MH>2) MH += 55; 01833 if (mw || mh || MW || MH) 01834 live_window->size_range(mw, mh, MW, MH); 01835 } 01836 live_window->show(); 01837 } else o->value(0); 01838 } else o->value(0); 01839 } else { 01840 if (live_type) 01841 live_type->leave_live_mode(); 01842 if (live_window) { 01843 live_window->hide(); 01844 Fl::delete_widget(live_window); 01845 } 01846 live_type = 0L; 01847 live_widget = 0L; 01848 live_window = 0L; 01849 } 01850 } 01851 01852 // update the panel according to current widget set: 01853 static void load_panel() { 01854 if (!the_panel) return; 01855 01856 // find all the Fl_Widget subclasses currently selected: 01857 numselected = 0; 01858 current_widget = 0; 01859 if (Fl_Type::current) { 01860 if (Fl_Type::current->is_widget()) 01861 current_widget=(Fl_Widget_Type*)Fl_Type::current; 01862 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01863 if (o->is_widget() && o->selected) { 01864 numselected++; 01865 if (!current_widget) current_widget = (Fl_Widget_Type*)o; 01866 } 01867 } 01868 } 01869 if (numselected) 01870 propagate_load(the_panel, LOAD); 01871 else 01872 the_panel->hide(); 01873 } 01874 01875 // This is called when user double-clicks an item, open or update the panel: 01876 void Fl_Widget_Type::open() { 01877 if (!the_panel) the_panel = make_widget_panel(); 01878 load_panel(); 01879 if (numselected) the_panel->show(); 01880 } 01881 01882 Fl_Type *Fl_Type::current; 01883 01884 extern void redraw_overlays(); 01885 extern void check_redraw_corresponding_parent(Fl_Type*); 01886 extern void redraw_browser(); 01887 extern void update_sourceview_position(); 01888 01889 // Called when ui changes what objects are selected: 01890 // p is selected object, null for all deletions (we must throw away 01891 // old panel in that case, as the object may no longer exist) 01892 void selection_changed(Fl_Type *p) { 01893 // store all changes to the current selected objects: 01894 if (p && the_panel && the_panel->visible()) { 01895 set_cb(0,0); 01896 // if there was an error, we try to leave the selected set unchanged: 01897 if (haderror) { 01898 Fl_Type *q = 0; 01899 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01900 o->new_selected = o->selected; 01901 if (!q && o->selected) q = o; 01902 } 01903 if (!p || !p->selected) p = q; 01904 Fl_Type::current = p; 01905 redraw_browser(); 01906 return; 01907 } 01908 } 01909 // update the selected flags to new set: 01910 Fl_Type *q = 0; 01911 for (Fl_Type *o = Fl_Type::first; o; o = o->next) { 01912 o->selected = o->new_selected; 01913 if (!q && o->selected) q = o; 01914 } 01915 if (!p || !p->selected) p = q; 01916 Fl_Type::current = p; 01917 check_redraw_corresponding_parent(p); 01918 redraw_overlays(); 01919 // load the panel with the new settings: 01920 load_panel(); 01921 // update the source viewer to show the code for the selected object 01922 update_sourceview_position(); 01923 } 01924 01926 // Writing the C code: 01927 01928 // test to see if user named a function, or typed in code: 01929 int is_name(const char *c) { 01930 for (; *c; c++) if (ispunct(*c) && *c!='_' && *c!=':') return 0; 01931 return 1; 01932 } 01933 01934 // Test to see if name() is an array entry. If so, and this is the 01935 // highest number, return name[num+1]. Return null if not the highest 01936 // number or a field or function. Return name() if not an array entry. 01937 const char *array_name(Fl_Widget_Type *o) { 01938 const char *c = o->name(); 01939 if (!c) return 0; 01940 const char *d; 01941 for (d = c; *d != '['; d++) { 01942 if (!*d) return c; 01943 if (ispunct(*d) && *d!='_') return 0; 01944 } 01945 int num = atoi(d+1); 01946 int sawthis = 0; 01947 Fl_Type *t = o->prev; 01948 Fl_Type *tp = o; 01949 const char *cn = o->class_name(1); 01950 for (; t && t->class_name(1) == cn; tp = t, t = t->prev); 01951 for (t = tp; t && t->class_name(1) == cn; t = t->next) { 01952 if (t == o) {sawthis=1; continue;} 01953 const char *e = t->name(); 01954 if (!e) continue; 01955 if (strncmp(c,e,d-c)) continue; 01956 int n1 = atoi(e+(d-c)+1); 01957 if (n1 > num || (n1==num && sawthis)) return 0; 01958 } 01959 static char buffer[128]; 01960 // MRS: we want strncpy() here... 01961 strncpy(buffer,c,d-c+1); 01962 snprintf(buffer+(d-c+1),sizeof(buffer) - (d-c+1), "%d]",num+1); 01963 return buffer; 01964 } 01965 01966 // Test to see if extra code is a declaration: 01967 int isdeclare(const char *c) { 01968 while (isspace(*c)) c++; 01969 if (*c == '#') return 1; 01970 if (!strncmp(c,"extern",6)) return 1; 01971 if (!strncmp(c,"typedef",7)) return 1; 01972 if (!strncmp(c,"using",5)) return 1; 01973 return 0; 01974 } 01975 01976 void Fl_Widget_Type::write_static() { 01977 const char* t = subclassname(this); 01978 if (!subclass() || (is_class() && !strncmp(t, "Fl_", 3))) { 01979 write_declare("#include <FL/%s.H>", t); 01980 } 01981 for (int n=0; n < NUM_EXTRA_CODE; n++) { 01982 if (extra_code(n) && isdeclare(extra_code(n))) 01983 write_declare("%s", extra_code(n)); 01984 } 01985 if (callback() && is_name(callback())) { 01986 int write_extern_declaration = 1; 01987 const Fl_Class_Type *cc = is_in_class(); 01988 char buf[1024]; snprintf(buf, 1023, "%s(*)", callback()); 01989 if (cc) { 01990 if (cc->has_function("static void", buf)) 01991 write_extern_declaration = 0; 01992 } else { 01993 if (has_toplevel_function(0L, buf)) 01994 write_extern_declaration = 0; 01995 } 01996 if (write_extern_declaration) 01997 write_declare("extern void %s(%s*, %s);", callback(), t, 01998 user_data_type() ? user_data_type() : "void*"); 01999 } 02000 const char* k = class_name(1); 02001 const char* c = array_name(this); 02002 if (c && !k && !is_class()) { 02003 write_c("\n"); 02004 if (!public_) write_c("static "); 02005 else write_h("extern %s *%s;\n", t, c); 02006 if (strchr(c, '[') == NULL) write_c("%s *%s=(%s *)0;\n", t, c, t); 02007 else write_c("%s *%s={(%s *)0};\n", t, c, t); 02008 } 02009 if (callback() && !is_name(callback())) { 02010 // see if 'o' or 'v' used, to prevent unused argument warnings: 02011 int use_o = 0; 02012 int use_v = 0; 02013 const char *d; 02014 for (d = callback(); *d;) { 02015 if (*d == 'o' && !is_id(d[1])) use_o = 1; 02016 if (*d == 'v' && !is_id(d[1])) use_v = 1; 02017 do d++; while (is_id(*d)); 02018 while (*d && !is_id(*d)) d++; 02019 } 02020 const char* cn = callback_name(); 02021 if (k) { 02022 write_c("\nvoid %s::%s_i(%s*", k, cn, t); 02023 } else { 02024 write_c("\nstatic void %s(%s*", cn, t); 02025 } 02026 if (use_o) write_c(" o"); 02027 const char* ut = user_data_type() ? user_data_type() : "void*"; 02028 write_c(", %s", ut); 02029 if (use_v) write_c(" v"); 02030 write_c(") {\n %s", callback()); 02031 if (*(d-1) != ';') { 02032 const char *p = strrchr(callback(), '\n'); 02033 if (p) p ++; 02034 else p = callback(); 02035 // Only add trailing semicolon if the last line is not a preprocessor 02036 // statement... 02037 if (*p != '#' && *p) write_c(";"); 02038 } 02039 write_c("\n}\n"); 02040 if (k) { 02041 write_c("void %s::%s(%s* o, %s v) {\n", k, cn, t, ut); 02042 write_c(" ((%s*)(o", k); 02043 Fl_Type *q = 0; 02044 for (Fl_Type* p = parent; p && p->is_widget(); q = p, p = p->parent) 02045 write_c("->parent()"); 02046 if (!q || strcmp(q->type_name(), "widget_class")) 02047 write_c("->user_data()"); 02048 write_c("))->%s_i(o,v);\n}\n", cn); 02049 } 02050 } 02051 if (image) { 02052 if (image->written != write_number) { 02053 image->write_static(); 02054 image->written = write_number; 02055 } 02056 } 02057 if (inactive) { 02058 if (inactive->written != write_number) { 02059 inactive->write_static(); 02060 inactive->written = write_number; 02061 } 02062 } 02063 } 02064 02065 const char *Fl_Type::callback_name() { 02066 if (is_name(callback())) return callback(); 02067 return unique_id(this, "cb", name(), label()); 02068 } 02069 02070 extern int varused_test, varused; 02071 02072 void Fl_Widget_Type::write_code1() { 02073 const char* t = subclassname(this); 02074 const char *c = array_name(this); 02075 if (c) { 02076 if (class_name(1)) { 02077 write_public(public_); 02078 write_h(" %s *%s;\n", t, c); 02079 } 02080 } 02081 if (class_name(1) && callback() && !is_name(callback())) { 02082 const char* cn = callback_name(); 02083 const char* ut = user_data_type() ? user_data_type() : "void*"; 02084 write_public(0); 02085 write_h(" void %s_i(%s*, %s);\n", cn, t, ut); 02086 write_h(" static void %s(%s*, %s);\n", cn, t, ut); 02087 } 02088 // figure out if local variable will be used (prevent compiler warnings): 02089 int wused = !name() && is_window(); 02090 const char *ptr; 02091 02092 varused = wused; 02093 02094 if (!name() && !varused) { 02095 varused |= is_parent(); 02096 02097 if (!varused) { 02098 varused_test = 1; 02099 write_widget_code(); 02100 varused_test = 0; 02101 } 02102 } 02103 02104 if (!varused) { 02105 for (int n=0; n < NUM_EXTRA_CODE; n++) 02106 if (extra_code(n) && !isdeclare(extra_code(n))) 02107 { 02108 int instring = 0; 02109 int inname = 0; 02110 for (ptr = extra_code(n); *ptr; ptr ++) { 02111 if (instring) { 02112 if (*ptr == '\\') ptr++; 02113 else if (*ptr == '\"') instring = 0; 02114 } else if (inname && !isalnum(*ptr & 255)) inname = 0; 02115 else if (*ptr == '\"') instring = 1; 02116 else if (isalnum(*ptr & 255) || *ptr == '_') { 02117 size_t len = strspn(ptr, "0123456789_" 02118 "abcdefghijklmnopqrstuvwxyz" 02119 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); 02120 02121 if (!strncmp(ptr, "o", len)) { 02122 varused = 1; 02123 break; 02124 } else ptr += len - 1; 02125 } 02126 } 02127 } 02128 } 02129 02130 write_c("%s{ ", indent()); 02131 if (varused) write_c("%s* o = ", t); 02132 if (name()) write_c("%s = ", name()); 02133 if (is_window()) { 02134 // Handle special case where user is faking a Fl_Group type as a window, 02135 // there is no 2-argument constructor in that case: 02136 if (!strstr(t, "Window")) 02137 write_c("new %s(0, 0, %d, %d", t, o->w(), o->h()); 02138 else 02139 write_c("new %s(%d, %d", t, o->w(), o->h()); 02140 } else { 02141 write_c("new %s(%d, %d, %d, %d", t, o->x(), o->y(), o->w(), o->h()); 02142 } 02143 if (label() && *label()) { 02144 write_c(", "); 02145 switch (i18n_type) { 02146 case 0 : /* None */ 02147 write_cstring(label()); 02148 break; 02149 case 1 : /* GNU gettext */ 02150 write_c("%s(", i18n_function); 02151 write_cstring(label()); 02152 write_c(")"); 02153 break; 02154 case 2 : /* POSIX catgets */ 02155 write_c("catgets(%s,%s,%d,", i18n_file[0] ? i18n_file : "_catalog", 02156 i18n_set, msgnum()); 02157 write_cstring(label()); 02158 write_c(")"); 02159 break; 02160 } 02161 } 02162 write_c(");\n"); 02163 02164 indentation += 2; 02165 02166 if (wused) write_c("%sw = o;\n", indent()); 02167 02168 write_widget_code(); 02169 } 02170 02171 void Fl_Widget_Type::write_color(const char* field, Fl_Color color) { 02172 const char* color_name = 0; 02173 switch (color) { 02174 case FL_FOREGROUND_COLOR: color_name = "FL_FOREGROUND_COLOR"; break; 02175 case FL_BACKGROUND2_COLOR: color_name = "FL_BACKGROUND2_COLOR"; break; 02176 case FL_INACTIVE_COLOR: color_name = "FL_INACTIVE_COLOR"; break; 02177 case FL_SELECTION_COLOR: color_name = "FL_SELECTION_COLOR"; break; 02178 case FL_GRAY0: color_name = "FL_GRAY0"; break; 02179 case FL_DARK3: color_name = "FL_DARK3"; break; 02180 case FL_DARK2: color_name = "FL_DARK2"; break; 02181 case FL_DARK1: color_name = "FL_DARK1"; break; 02182 case FL_BACKGROUND_COLOR: color_name = "FL_BACKGROUND_COLOR"; break; 02183 case FL_LIGHT1: color_name = "FL_LIGHT1"; break; 02184 case FL_LIGHT2: color_name = "FL_LIGHT2"; break; 02185 case FL_LIGHT3: color_name = "FL_LIGHT3"; break; 02186 case FL_BLACK: color_name = "FL_BLACK"; break; 02187 case FL_RED: color_name = "FL_RED"; break; 02188 case FL_GREEN: color_name = "FL_GREEN"; break; 02189 case FL_YELLOW: color_name = "FL_YELLOW"; break; 02190 case FL_BLUE: color_name = "FL_BLUE"; break; 02191 case FL_MAGENTA: color_name = "FL_MAGENTA"; break; 02192 case FL_CYAN: color_name = "FL_CYAN"; break; 02193 case FL_DARK_RED: color_name = "FL_DARK_RED"; break; 02194 case FL_DARK_GREEN: color_name = "FL_DARK_GREEN"; break; 02195 case FL_DARK_YELLOW: color_name = "FL_DARK_YELLOW"; break; 02196 case FL_DARK_BLUE: color_name = "FL_DARK_BLUE"; break; 02197 case FL_DARK_MAGENTA: color_name = "FL_DARK_MAGENTA"; break; 02198 case FL_DARK_CYAN: color_name = "FL_DARK_CYAN"; break; 02199 case FL_WHITE: color_name = "FL_WHITE"; break; 02200 } 02201 const char *var = is_class() ? "this" : name() ? name() : "o"; 02202 if (color_name) { 02203 write_c("%s%s->%s(%s);\n", indent(), var, field, color_name); 02204 } else { 02205 write_c("%s%s->%s((Fl_Color)%d);\n", indent(), var, field, color); 02206 } 02207 } 02208 02209 // this is split from write_code1() for Fl_Window_Type: 02210 void Fl_Widget_Type::write_widget_code() { 02211 Fl_Widget* tplate = ((Fl_Widget_Type*)factory)->o; 02212 const char *var = is_class() ? "this" : name() ? name() : "o"; 02213 02214 if (tooltip() && *tooltip()) { 02215 write_c("%s%s->tooltip(",indent(), var); 02216 switch (i18n_type) { 02217 case 0 : /* None */ 02218 write_cstring(tooltip()); 02219 break; 02220 case 1 : /* GNU gettext */ 02221 write_c("%s(", i18n_function); 02222 write_cstring(tooltip()); 02223 write_c(")"); 02224 break; 02225 case 2 : /* POSIX catgets */ 02226 write_c("catgets(%s,%s,%d,", i18n_file[0] ? i18n_file : "_catalog", 02227 i18n_set, msgnum() + 1); 02228 write_cstring(tooltip()); 02229 write_c(")"); 02230 break; 02231 } 02232 write_c(");\n"); 02233 } 02234 02235 if (is_spinner() && ((Fl_Spinner*)o)->type() != ((Fl_Spinner*)tplate)->type()) 02236 write_c("%s%s->type(%d);\n", indent(), var, ((Fl_Spinner*)o)->type()); 02237 else if (o->type() != tplate->type() && !is_window()) 02238 write_c("%s%s->type(%d);\n", indent(), var, o->type()); 02239 if (o->box() != tplate->box() || subclass()) 02240 write_c("%s%s->box(FL_%s);\n", indent(), var, boxname(o->box())); 02241 02242 // write shortcut command if needed 02243 int shortcut = 0; 02244 if (is_button()) shortcut = ((Fl_Button*)o)->shortcut(); 02245 else if (is_input()) shortcut = ((Fl_Input_*)o)->shortcut(); 02246 else if (is_value_input()) shortcut = ((Fl_Value_Input*)o)->shortcut(); 02247 else if (is_text_display()) shortcut = ((Fl_Text_Display*)o)->shortcut(); 02248 if (shortcut) { 02249 if (use_FL_COMMAND && (shortcut & (FL_CTRL|FL_META))) { 02250 write_c("%s%s->shortcut(FL_COMMAND|0x%x);\n", indent(), var, shortcut & ~(FL_CTRL|FL_META)); 02251 } else { 02252 write_c("%s%s->shortcut(0x%x);\n", indent(), var, shortcut); 02253 } 02254 } 02255 02256 if (is_button()) { 02257 Fl_Button* b = (Fl_Button*)o; 02258 if (b->down_box()) write_c("%s%s->down_box(FL_%s);\n", indent(), var, 02259 boxname(b->down_box())); 02260 if (b->value()) write_c("%s%s->value(1);\n", indent(), var); 02261 } else if (!strcmp(type_name(), "Fl_Input_Choice")) { 02262 Fl_Input_Choice* b = (Fl_Input_Choice*)o; 02263 if (b->down_box()) write_c("%s%s->down_box(FL_%s);\n", indent(), var, 02264 boxname(b->down_box())); 02265 } else if (is_menu_button()) { 02266 Fl_Menu_* b = (Fl_Menu_*)o; 02267 if (b->down_box()) write_c("%s%s->down_box(FL_%s);\n", indent(), var, 02268 boxname(b->down_box())); 02269 } 02270 if (o->color() != tplate->color() || subclass()) 02271 write_color("color", o->color()); 02272 if (o->selection_color() != tplate->selection_color() || subclass()) 02273 write_color("selection_color", o->selection_color()); 02274 if (image) image->write_code(var); 02275 if (inactive) inactive->write_code(var, 1); 02276 if (o->labeltype() != tplate->labeltype() || subclass()) 02277 write_c("%s%s->labeltype(FL_%s);\n", indent(), var, 02278 item_name(labeltypemenu, o->labeltype())); 02279 if (o->labelfont() != tplate->labelfont() || subclass()) 02280 write_c("%s%s->labelfont(%d);\n", indent(), var, o->labelfont()); 02281 if (o->labelsize() != tplate->labelsize() || subclass()) 02282 write_c("%s%s->labelsize(%d);\n", indent(), var, o->labelsize()); 02283 if (o->labelcolor() != tplate->labelcolor() || subclass()) 02284 write_color("labelcolor", o->labelcolor()); 02285 if (is_valuator()) { 02286 Fl_Valuator* v = (Fl_Valuator*)o; 02287 Fl_Valuator* f = (Fl_Valuator*)(tplate); 02288 if (v->minimum()!=f->minimum()) 02289 write_c("%s%s->minimum(%g);\n", indent(), var, v->minimum()); 02290 if (v->maximum()!=f->maximum()) 02291 write_c("%s%s->maximum(%g);\n", indent(), var, v->maximum()); 02292 if (v->step()!=f->step()) 02293 write_c("%s%s->step(%g);\n", indent(), var, v->step()); 02294 if (v->value()) { 02295 if (is_valuator()==3) { // Fl_Scrollbar::value(double) is nott available 02296 write_c("%s%s->Fl_Slider::value(%g);\n", indent(), var, v->value()); 02297 } else { 02298 write_c("%s%s->value(%g);\n", indent(), var, v->value()); 02299 } 02300 } 02301 if (is_valuator()>=2) { 02302 double x = ((Fl_Slider*)v)->slider_size(); 02303 double y = ((Fl_Slider*)f)->slider_size(); 02304 if (x != y) write_c("%s%s->slider_size(%g);\n", indent(), var, x); 02305 } 02306 } 02307 if (is_spinner()) { 02308 Fl_Spinner* v = (Fl_Spinner*)o; 02309 Fl_Spinner* f = (Fl_Spinner*)(tplate); 02310 if (v->minimum()!=f->minimum()) 02311 write_c("%s%s->minimum(%g);\n", indent(), var, v->minimum()); 02312 if (v->maximum()!=f->maximum()) 02313 write_c("%s%s->maximum(%g);\n", indent(), var, v->maximum()); 02314 if (v->step()!=f->step()) 02315 write_c("%s%s->step(%g);\n", indent(), var, v->step()); 02316 if (v->value()!=1.0f) 02317 write_c("%s%s->value(%g);\n", indent(), var, v->value()); 02318 } 02319 02320 {Fl_Font ff; int fs; Fl_Color fc; if (textstuff(4,ff,fs,fc)) { 02321 Fl_Font f; int s; Fl_Color c; textstuff(0,f,s,c); 02322 if (f != ff) write_c("%s%s->textfont(%d);\n", indent(), var, f); 02323 if (s != fs) write_c("%s%s->textsize(%d);\n", indent(), var, s); 02324 if (c != fc) write_color("textcolor", c); 02325 }} 02326 const char* ud = user_data(); 02327 if (class_name(1) && !parent->is_widget()) ud = "this"; 02328 if (callback()) { 02329 write_c("%s%s->callback((Fl_Callback*)%s", indent(), var, callback_name()); 02330 if (ud) 02331 write_c(", (void*)(%s));\n", ud); 02332 else 02333 write_c(");\n"); 02334 } else if (ud) { 02335 write_c("%s%s->user_data((void*)(%s));\n", indent(), var, ud); 02336 } 02337 if (o->align() != tplate->align() || subclass()) { 02338 int i = o->align(); 02339 write_c("%s%s->align(Fl_Align(%s", indent(), var, 02340 item_name(alignmenu, i & ~FL_ALIGN_INSIDE)); 02341 if (i & FL_ALIGN_INSIDE) write_c("|FL_ALIGN_INSIDE"); 02342 write_c("));\n"); 02343 } 02344 // avoid the unsupported combination of flegs when user sets 02345 // "when" to "FL_WHEN_NEVER", but keeps the "no change" set. 02346 // FIXME: This could be reflected in the GUI by graying out the button. 02347 Fl_When ww = o->when(); 02348 if (ww==FL_WHEN_NOT_CHANGED) 02349 ww = FL_WHEN_NEVER; 02350 if (ww != tplate->when() || subclass()) 02351 write_c("%s%s->when(%s);\n", indent(), var, 02352 item_name(whensymbolmenu, ww)); 02353 if (!o->visible() && o->parent()) 02354 write_c("%s%s->hide();\n", indent(), var); 02355 if (!o->active()) 02356 write_c("%s%s->deactivate();\n", indent(), var); 02357 if (!is_group() && resizable()) 02358 write_c("%sFl_Group::current()->resizable(%s);\n", indent(), var); 02359 if (hotspot()) { 02360 if (is_class()) 02361 write_c("%shotspot(%s);\n", indent(), var); 02362 else if (is_window()) 02363 write_c("%s%s->hotspot(%s);\n", indent(), var, var); 02364 else 02365 write_c("%s%s->window()->hotspot(%s);\n", indent(), var, var); 02366 } 02367 } 02368 02369 void Fl_Widget_Type::write_extra_code() { 02370 for (int n=0; n < NUM_EXTRA_CODE; n++) 02371 if (extra_code(n) && !isdeclare(extra_code(n))) 02372 write_c("%s%s\n", indent(), extra_code(n)); 02373 } 02374 02375 void Fl_Widget_Type::write_block_close() { 02376 indentation -= 2; 02377 write_c("%s} // %s* %s\n", indent(), subclassname(this), 02378 name() ? name() : "o"); 02379 } 02380 02381 void Fl_Widget_Type::write_code2() { 02382 write_extra_code(); 02383 write_block_close(); 02384 } 02385 02387 02388 void Fl_Widget_Type::write_properties() { 02389 Fl_Type::write_properties(); 02390 write_indent(level+1); 02391 switch (public_) { 02392 case 0: write_string("private"); break; 02393 case 1: break; 02394 case 2: write_string("protected"); break; 02395 } 02396 if (tooltip() && *tooltip()) { 02397 write_string("tooltip"); 02398 write_word(tooltip()); 02399 } 02400 if (image_name() && *image_name()) { 02401 write_string("image"); 02402 write_word(image_name()); 02403 } 02404 if (inactive_name() && *inactive_name()) { 02405 write_string("deimage"); 02406 write_word(inactive_name()); 02407 } 02408 write_string("xywh {%d %d %d %d}", o->x(), o->y(), o->w(), o->h()); 02409 Fl_Widget* tplate = ((Fl_Widget_Type*)factory)->o; 02410 if (is_spinner() && ((Fl_Spinner*)o)->type() != ((Fl_Spinner*)tplate)->type()) { 02411 write_string("type"); 02412 write_word(item_name(subtypes(), ((Fl_Spinner*)o)->type())); 02413 } else if (o->type() != tplate->type() || is_window()) { 02414 write_string("type"); 02415 write_word(item_name(subtypes(), o->type())); 02416 } 02417 if (o->box() != tplate->box()) { 02418 write_string("box"); write_word(boxname(o->box()));} 02419 if (is_input()) { 02420 Fl_Input_* b = (Fl_Input_*)o; 02421 if (b->shortcut()) write_string("shortcut 0x%x", b->shortcut()); 02422 } 02423 if (is_value_input()) { 02424 Fl_Value_Input* b = (Fl_Value_Input*)o; 02425 if (b->shortcut()) write_string("shortcut 0x%x", b->shortcut()); 02426 } 02427 if (is_text_display()) { 02428 Fl_Text_Display* b = (Fl_Text_Display*)o; 02429 if (b->shortcut()) write_string("shortcut 0x%x", b->shortcut()); 02430 } 02431 if (is_button()) { 02432 Fl_Button* b = (Fl_Button*)o; 02433 if (b->down_box()) { 02434 write_string("down_box"); write_word(boxname(b->down_box()));} 02435 if (b->shortcut()) write_string("shortcut 0x%x", b->shortcut()); 02436 if (b->value()) write_string("value 1"); 02437 } else if (!strcmp(type_name(), "Fl_Input_Choice")) { 02438 Fl_Input_Choice* b = (Fl_Input_Choice*)o; 02439 if (b->down_box()) { 02440 write_string("down_box"); write_word(boxname(b->down_box()));} 02441 } else if (is_menu_button()) { 02442 Fl_Menu_* b = (Fl_Menu_*)o; 02443 if (b->down_box()) { 02444 write_string("down_box"); write_word(boxname(b->down_box()));} 02445 } 02446 if (o->color()!=tplate->color()) 02447 write_string("color %d", o->color()); 02448 if (o->selection_color()!=tplate->selection_color()) 02449 write_string("selection_color %d", o->selection_color()); 02450 if (o->labeltype()!=tplate->labeltype()) { 02451 write_string("labeltype"); 02452 write_word(item_name(labeltypemenu, o->labeltype())); 02453 } 02454 if (o->labelfont()!=tplate->labelfont()) 02455 write_string("labelfont %d", o->labelfont()); 02456 if (o->labelsize()!=tplate->labelsize()) 02457 write_string("labelsize %d", o->labelsize()); 02458 if (o->labelcolor()!=tplate->labelcolor()) 02459 write_string("labelcolor %d", o->labelcolor()); 02460 if (o->align()!=tplate->align()) 02461 write_string("align %d", o->align()); 02462 if (o->when() != tplate->when()) 02463 write_string("when %d", o->when()); 02464 if (is_valuator()) { 02465 Fl_Valuator* v = (Fl_Valuator*)o; 02466 Fl_Valuator* f = (Fl_Valuator*)(tplate); 02467 if (v->minimum()!=f->minimum()) write_string("minimum %g",v->minimum()); 02468 if (v->maximum()!=f->maximum()) write_string("maximum %g",v->maximum()); 02469 if (v->step()!=f->step()) write_string("step %g",v->step()); 02470 if (v->value()!=0.0) write_string("value %g",v->value()); 02471 if (is_valuator()>=2) { 02472 double x = ((Fl_Slider*)v)->slider_size(); 02473 double y = ((Fl_Slider*)f)->slider_size(); 02474 if (x != y) write_string("slider_size %g", x); 02475 } 02476 } 02477 if (is_spinner()) { 02478 Fl_Spinner* v = (Fl_Spinner*)o; 02479 Fl_Spinner* f = (Fl_Spinner*)(tplate); 02480 if (v->minimum()!=f->minimum()) write_string("minimum %g",v->minimum()); 02481 if (v->maximum()!=f->maximum()) write_string("maximum %g",v->maximum()); 02482 if (v->step()!=f->step()) write_string("step %g",v->step()); 02483 if (v->value()!=1.0) write_string("value %g",v->value()); 02484 } 02485 {Fl_Font ff; int fs; Fl_Color fc; if (textstuff(4,ff,fs,fc)) { 02486 Fl_Font f; int s; Fl_Color c; textstuff(0,f,s,c); 02487 if (f != ff) write_string("textfont %d", f); 02488 if (s != fs) write_string("textsize %d", s); 02489 if (c != fc) write_string("textcolor %d", c); 02490 }} 02491 if (!o->visible()) write_string("hide"); 02492 if (!o->active()) write_string("deactivate"); 02493 if (resizable()) write_string("resizable"); 02494 if (hotspot()) write_string(is_menu_item() ? "divider" : "hotspot"); 02495 for (int n=0; n < NUM_EXTRA_CODE; n++) if (extra_code(n)) { 02496 write_indent(level+1); 02497 write_string("code%d",n); 02498 write_word(extra_code(n)); 02499 } 02500 if (subclass()) { 02501 write_indent(level+1); 02502 write_string("class"); 02503 write_word(subclass()); 02504 } 02505 } 02506 02507 int pasteoffset; 02508 extern double read_version; 02509 void Fl_Widget_Type::read_property(const char *c) { 02510 int x,y,w,h; Fl_Font f; int s; Fl_Color cc; 02511 if (!strcmp(c,"private")) { 02512 public_ = 0; 02513 } else if (!strcmp(c,"protected")) { 02514 public_ = 2; 02515 } else if (!strcmp(c,"xywh")) { 02516 if (sscanf(read_word(),"%d %d %d %d",&x,&y,&w,&h) == 4) { 02517 x += pasteoffset; 02518 y += pasteoffset; 02519 // FIXME temporary change! 02520 if (read_version>=2.0 && o->parent() && o->parent()!=o->window()) { 02521 x += o->parent()->x(); 02522 y += o->parent()->y(); 02523 } 02524 o->resize(x,y,w,h); 02525 } 02526 } else if (!strcmp(c,"tooltip")) { 02527 tooltip(read_word()); 02528 } else if (!strcmp(c,"image")) { 02529 image_name(read_word()); 02530 } else if (!strcmp(c,"deimage")) { 02531 inactive_name(read_word()); 02532 } else if (!strcmp(c,"type")) { 02533 if (is_spinner()) 02534 ((Fl_Spinner*)o)->type(item_number(subtypes(), read_word())); 02535 else 02536 o->type(item_number(subtypes(), read_word())); 02537 } else if (!strcmp(c,"box")) { 02538 const char* value = read_word(); 02539 if ((x = boxnumber(value))) { 02540 if (x == ZERO_ENTRY) x = 0; 02541 o->box((Fl_Boxtype)x); 02542 } else if (sscanf(value,"%d",&x) == 1) o->box((Fl_Boxtype)x); 02543 } else if (is_button() && !strcmp(c,"down_box")) { 02544 const char* value = read_word(); 02545 if ((x = boxnumber(value))) { 02546 if (x == ZERO_ENTRY) x = 0; 02547 ((Fl_Button*)o)->down_box((Fl_Boxtype)x); 02548 } 02549 } else if (!strcmp(type_name(), "Fl_Input_Choice") && !strcmp(c,"down_box")) { 02550 const char* value = read_word(); 02551 if ((x = boxnumber(value))) { 02552 if (x == ZERO_ENTRY) x = 0; 02553 ((Fl_Input_Choice*)o)->down_box((Fl_Boxtype)x); 02554 } 02555 } else if (is_menu_button() && !strcmp(c,"down_box")) { 02556 const char* value = read_word(); 02557 if ((x = boxnumber(value))) { 02558 if (x == ZERO_ENTRY) x = 0; 02559 ((Fl_Menu_*)o)->down_box((Fl_Boxtype)x); 02560 } 02561 } else if (is_button() && !strcmp(c,"value")) { 02562 const char* value = read_word(); 02563 ((Fl_Button*)o)->value(atoi(value)); 02564 } else if (!strcmp(c,"color")) { 02565 const char *cw = read_word(); 02566 if (cw[0]=='0' && cw[1]=='x') { 02567 sscanf(cw,"0x%x",&x); 02568 o->color(x); 02569 } else { 02570 int n = sscanf(cw,"%d %d",&x,&y); 02571 if (n == 2) { // back compatibility... 02572 if (x != 47) o->color(x); 02573 o->selection_color(y); 02574 } else { 02575 o->color(x); 02576 } 02577 } 02578 } else if (!strcmp(c,"selection_color")) { 02579 if (sscanf(read_word(),"%d",&x)) o->selection_color(x); 02580 } else if (!strcmp(c,"labeltype")) { 02581 c = read_word(); 02582 if (!strcmp(c,"image")) { 02583 Fluid_Image *i = Fluid_Image::find(label()); 02584 if (!i) read_error("Image file '%s' not found", label()); 02585 else setimage(i); 02586 image_name(label()); 02587 label(""); 02588 } else { 02589 o->labeltype((Fl_Labeltype)item_number(labeltypemenu,c)); 02590 } 02591 } else if (!strcmp(c,"labelfont")) { 02592 if (sscanf(read_word(),"%d",&x) == 1) o->labelfont(x); 02593 } else if (!strcmp(c,"labelsize")) { 02594 if (sscanf(read_word(),"%d",&x) == 1) o->labelsize(x); 02595 } else if (!strcmp(c,"labelcolor")) { 02596 if (sscanf(read_word(),"%d",&x) == 1) o->labelcolor(x); 02597 } else if (!strcmp(c,"align")) { 02598 if (sscanf(read_word(),"%d",&x) == 1) o->align(x); 02599 } else if (!strcmp(c,"when")) { 02600 if (sscanf(read_word(),"%d",&x) == 1) o->when(x); 02601 } else if (!strcmp(c,"minimum")) { 02602 if (is_valuator()) ((Fl_Valuator*)o)->minimum(strtod(read_word(),0)); 02603 if (is_spinner()) ((Fl_Spinner*)o)->minimum(strtod(read_word(),0)); 02604 } else if (!strcmp(c,"maximum")) { 02605 if (is_valuator()) ((Fl_Valuator*)o)->maximum(strtod(read_word(),0)); 02606 if (is_spinner()) ((Fl_Spinner*)o)->maximum(strtod(read_word(),0)); 02607 } else if (!strcmp(c,"step")) { 02608 if (is_valuator()) ((Fl_Valuator*)o)->step(strtod(read_word(),0)); 02609 if (is_spinner()) ((Fl_Spinner*)o)->step(strtod(read_word(),0)); 02610 } else if (!strcmp(c,"value")) { 02611 if (is_valuator()) ((Fl_Valuator*)o)->value(strtod(read_word(),0)); 02612 if (is_spinner()) ((Fl_Spinner*)o)->value(strtod(read_word(),0)); 02613 } else if ((!strcmp(c,"slider_size")||!strcmp(c,"size"))&&is_valuator()==2) { 02614 ((Fl_Slider*)o)->slider_size(strtod(read_word(),0)); 02615 } else if (!strcmp(c,"textfont")) { 02616 if (sscanf(read_word(),"%d",&x) == 1) {f=(Fl_Font)x; textstuff(1,f,s,cc);} 02617 } else if (!strcmp(c,"textsize")) { 02618 if (sscanf(read_word(),"%d",&x) == 1) {s=x; textstuff(2,f,s,cc);} 02619 } else if (!strcmp(c,"textcolor")) { 02620 if (sscanf(read_word(),"%d",&x) == 1) {cc=(Fl_Color)x;textstuff(3,f,s,cc);} 02621 } else if (!strcmp(c,"hide")) { 02622 o->hide(); 02623 } else if (!strcmp(c,"deactivate")) { 02624 o->deactivate(); 02625 } else if (!strcmp(c,"resizable")) { 02626 resizable(1); 02627 } else if (!strcmp(c,"hotspot") || !strcmp(c, "divider")) { 02628 hotspot(1); 02629 } else if (!strcmp(c,"class")) { 02630 subclass(read_word()); 02631 } else if (!strcmp(c,"shortcut")) { 02632 int shortcut = strtol(read_word(),0,0); 02633 if (is_button()) ((Fl_Button*)o)->shortcut(shortcut); 02634 else if (is_input()) ((Fl_Input_*)o)->shortcut(shortcut); 02635 else if (is_value_input()) ((Fl_Value_Input*)o)->shortcut(shortcut); 02636 else if (is_text_display()) ((Fl_Text_Display*)o)->shortcut(shortcut); 02637 } else { 02638 if (!strncmp(c,"code",4)) { 02639 int n = atoi(c+4); 02640 if (n >= 0 && n <= NUM_EXTRA_CODE) { 02641 extra_code(n,read_word()); 02642 return; 02643 } 02644 } else if (!strcmp(c,"extra_code")) { 02645 extra_code(0,read_word()); 02646 return; 02647 } 02648 Fl_Type::read_property(c); 02649 } 02650 } 02651 02652 Fl_Menu_Item boxmenu1[] = { 02653 // these extra ones are for looking up fdesign saved strings: 02654 {"NO_FRAME", 0,0,(void *)FL_NO_BOX}, 02655 {"ROUNDED3D_UPBOX", 0,0,(void *)_FL_ROUND_UP_BOX}, 02656 {"ROUNDED3D_DOWNBOX", 0,0,(void *)_FL_ROUND_DOWN_BOX}, 02657 {"OVAL3D_UPBOX", 0,0,(void *)_FL_ROUND_UP_BOX}, 02658 {"OVAL3D_DOWNBOX", 0,0,(void *)_FL_ROUND_DOWN_BOX}, 02659 {"0", 0,0,(void *)ZERO_ENTRY}, 02660 {"1", 0,0,(void *)FL_UP_BOX}, 02661 {"2", 0,0,(void *)FL_DOWN_BOX}, 02662 {"3", 0,0,(void *)FL_FLAT_BOX}, 02663 {"4", 0,0,(void *)FL_BORDER_BOX}, 02664 {"5", 0,0,(void *)FL_SHADOW_BOX}, 02665 {"6", 0,0,(void *)FL_FRAME_BOX}, 02666 {"7", 0,0,(void *)FL_ROUNDED_BOX}, 02667 {"8", 0,0,(void *)FL_RFLAT_BOX}, 02668 {"9", 0,0,(void *)FL_RSHADOW_BOX}, 02669 {"10", 0,0,(void *)FL_UP_FRAME}, 02670 {"11", 0,0,(void *)FL_DOWN_FRAME}, 02671 {0}}; 02672 02673 extern int fdesign_flip; 02674 int lookup_symbol(const char *, int &, int numberok = 0); 02675 02676 int Fl_Widget_Type::read_fdesign(const char* propname, const char* value) { 02677 int v; 02678 if (!strcmp(propname,"box")) { 02679 float x,y,w,h; 02680 if (sscanf(value,"%f %f %f %f",&x,&y,&w,&h) == 4) { 02681 if (fdesign_flip) { 02682 Fl_Type *p; 02683 for (p = parent; p && !p->is_window(); p = p->parent); 02684 if (p && p->is_widget()) y = ((Fl_Widget_Type*)p)->o->h()-(y+h); 02685 } 02686 x += pasteoffset; 02687 y += pasteoffset; 02688 o->resize(int(x),int(y),int(w),int(h)); 02689 } 02690 } else if (!strcmp(propname,"label")) { 02691 label(value); 02692 } else if (!strcmp(propname,"name")) { 02693 this->name(value); 02694 } else if (!strcmp(propname,"callback")) { 02695 callback(value); user_data_type("long"); 02696 } else if (!strcmp(propname,"argument")) { 02697 user_data(value); 02698 } else if (!strcmp(propname,"shortcut")) { 02699 if (value[0]) { 02700 char buf[128]; sprintf(buf,"o->shortcut(\"%s\");",value); 02701 extra_code(0,buf); 02702 } 02703 } else if (!strcmp(propname,"style")) { 02704 if (!strncmp(value,"FL_NORMAL",9)) return 1; 02705 if (!lookup_symbol(value,v,1)) return 0; 02706 o->labelfont(v); o->labeltype((Fl_Labeltype)(v>>8)); 02707 } else if (!strcmp(propname,"size")) { 02708 if (!lookup_symbol(value,v,1)) return 0; 02709 o->labelsize(v); 02710 } else if (!strcmp(propname,"type")) { 02711 if (!strncmp(value,"NORMAL",6)) return 1; 02712 if (lookup_symbol(value,v,1)) {o->type(v); return 1;} 02713 if (!strcmp(value+strlen(value)-5,"FRAME")) goto TRY_BOXTYPE; 02714 if (!strcmp(value+strlen(value)-3,"BOX")) goto TRY_BOXTYPE; 02715 return 0; 02716 } else if (!strcmp(propname,"lcol")) { 02717 if (!lookup_symbol(value,v,1)) return 0; 02718 o->labelcolor(v); 02719 } else if (!strcmp(propname,"return")) { 02720 if (!lookup_symbol(value,v,0)) return 0; 02721 o->when(v|FL_WHEN_RELEASE); 02722 } else if (!strcmp(propname,"alignment")) { 02723 if (!lookup_symbol(value,v)) { 02724 // convert old numeric values: 02725 int v1 = atoi(value); if (v1 <= 0 && strcmp(value,"0")) return 0; 02726 v = 0; 02727 if (v1 >= 5) {v = FL_ALIGN_INSIDE; v1 -= 5;} 02728 switch (v1) { 02729 case 0: v += FL_ALIGN_TOP; break; 02730 case 1: v += FL_ALIGN_BOTTOM; break; 02731 case 2: v += FL_ALIGN_LEFT; break; 02732 case 3: v += FL_ALIGN_RIGHT; break; 02733 case 4: v += FL_ALIGN_CENTER; break; 02734 default: return 0; 02735 } 02736 } 02737 o->align(v); 02738 } else if (!strcmp(propname,"resizebox")) { 02739 resizable(1); 02740 } else if (!strcmp(propname,"colors")) { 02741 char* p = (char*)value; 02742 while (*p != ' ') {if (!*p) return 0; p++;} 02743 *p = 0; 02744 int v1; 02745 if (!lookup_symbol(value,v,1) || !lookup_symbol(p+1,v1,1)) { 02746 *p=' '; return 0;} 02747 o->color(v,v1); 02748 } else if (!strcmp(propname,"resize")) { 02749 return !strcmp(value,"FL_RESIZE_ALL"); 02750 } else if (!strcmp(propname,"gravity")) { 02751 return !strcmp(value,"FL_NoGravity FL_NoGravity"); 02752 } else if (!strcmp(propname,"boxtype")) { 02753 TRY_BOXTYPE: 02754 int x = boxnumber(value); 02755 if (!x) {x = item_number(boxmenu1, value); if (x < 0) return 0;} 02756 if (x == ZERO_ENTRY) { 02757 x = 0; 02758 if (o->box() != ((Fl_Widget_Type*)factory)->o->box()) return 1; // kludge for frame 02759 } 02760 o->box((Fl_Boxtype)x); 02761 } else { 02762 return 0; 02763 } 02764 return 1; 02765 } 02766 02767 void leave_live_mode_cb(Fl_Widget*, void*) { 02768 live_mode_cb(0, 0); 02769 } 02770 02771 Fl_Widget *Fl_Widget_Type::enter_live_mode(int) { 02772 live_widget = widget(o->x(), o->y(), o->w(), o->h()); 02773 if (live_widget) 02774 copy_properties(); 02775 return live_widget; 02776 } 02777 02778 void Fl_Widget_Type::leave_live_mode() { 02779 } 02780 02784 void Fl_Widget_Type::copy_properties() { 02785 if (!live_widget) 02786 return; 02787 02788 // copy all attributes common to all widget types 02789 Fl_Widget *w = live_widget; 02790 w->label(o->label()); 02791 w->tooltip(tooltip()); 02792 w->type(o->type()); 02793 w->box(o->box()); 02794 w->color(o->color()); 02795 w->selection_color(o->selection_color()); 02796 w->labeltype(o->labeltype()); 02797 w->labelfont(o->labelfont()); 02798 w->labelsize(o->labelsize()); 02799 w->labelcolor(o->labelcolor()); 02800 w->align(o->align()); 02801 02802 // copy all attributes specific to widgets derived from Fl_Button 02803 if (is_button()) { 02804 Fl_Button* d = (Fl_Button*)live_widget, *s = (Fl_Button*)o; 02805 d->down_box(s->down_box()); 02806 d->shortcut(s->shortcut()); 02807 d->value(s->value()); 02808 } 02809 02810 // copy all attributes specific to widgets derived from Fl_Input_ 02811 if (is_input()) { 02812 Fl_Input_* d = (Fl_Input_*)live_widget, *s = (Fl_Input_*)o; 02813 d->shortcut(s->shortcut()); 02814 } 02815 02816 // copy all attributes specific to widgets derived from Fl_Value_Input 02817 if (is_value_input()) { 02818 Fl_Value_Input* d = (Fl_Value_Input*)live_widget, *s = (Fl_Value_Input*)o; 02819 d->shortcut(s->shortcut()); 02820 } 02821 02822 // copy all attributes specific to widgets derived from Fl_Text_Display 02823 if (is_text_display()) { 02824 Fl_Text_Display* d = (Fl_Text_Display*)live_widget, *s = (Fl_Text_Display*)o; 02825 d->shortcut(s->shortcut()); 02826 } 02827 02828 // copy all attributes specific to Fl_Valuator and derived classes 02829 if (is_valuator()) { 02830 Fl_Valuator* d = (Fl_Valuator*)live_widget, *s = (Fl_Valuator*)o; 02831 d->minimum(s->minimum()); 02832 d->maximum(s->maximum()); 02833 d->step(s->step()); 02834 d->value(s->value()); 02835 if (is_valuator()>=2) { 02836 Fl_Slider *d = (Fl_Slider*)live_widget, *s = (Fl_Slider*)o; 02837 d->slider_size(s->slider_size()); 02838 } 02839 } 02840 02841 // copy all attributes specific to Fl_Spinner and derived classes 02842 if (is_spinner()) { 02843 Fl_Spinner* d = (Fl_Spinner*)live_widget, *s = (Fl_Spinner*)o; 02844 d->minimum(s->minimum()); 02845 d->maximum(s->maximum()); 02846 d->step(s->step()); 02847 d->value(s->value()); 02848 } 02849 02850 /* TODO: implement this 02851 {Fl_Font ff; int fs; Fl_Color fc; if (textstuff(4,ff,fs,fc)) { 02852 Fl_Font f; int s; Fl_Color c; textstuff(0,f,s,c); 02853 if (f != ff) write_string("textfont %d", f); 02854 if (s != fs) write_string("textsize %d", s); 02855 if (c != fc) write_string("textcolor %d", c); 02856 }}*/ 02857 02858 if (!o->visible()) 02859 w->hide(); 02860 if (!o->active()) 02861 w->deactivate(); 02862 if (resizable() && w->parent()) 02863 w->parent()->resizable(o); 02864 } 02865 02866 void Fl_Pack_Type::copy_properties() 02867 { 02868 Fl_Group_Type::copy_properties(); 02869 Fl_Pack *d = (Fl_Pack*)live_widget, *s =(Fl_Pack*)o; 02870 d->spacing(s->spacing()); 02871 } 02872 02873 // 02874 // End of "$Id: Fl_Widget_Type.cxx 8172 2011-01-03 08:28:38Z matt $". 02875 //