⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fl_widget_type.cxx

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CXX
📖 第 1 页 / 共 4 页
字号:
  {"FL_WHEN_ENTER_KEY_ALWAYS",0,0,(void*)(FL_WHEN_ENTER_KEY_ALWAYS)},  {0}};void when_cb(Fl_Choice* i, void *v) {  if (v == LOAD) {    if (current_widget->is_menu_item()) {i->hide(); return;} else i->show();    int n = current_widget->o->when() & (~FL_WHEN_NOT_CHANGED);    if (!n) n = ZERO_ENTRY;    for (int j = 0; j < int(sizeof(whenmenu)/sizeof(*whenmenu)); j++)      if (whenmenu[j].argument() == n) {i->value(j); break;}  } else {    int m = i->value();    int n = int(whenmenu[m].argument());    if (!n) return; // should not happen    if (n == ZERO_ENTRY) n = 0;    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;	q->o->when(n|(q->o->when()&FL_WHEN_NOT_CHANGED));      }  }}void when_button_cb(Fl_Light_Button* i, void *v) {  if (v == LOAD) {    if (current_widget->is_menu_item()) {i->hide(); return;} else i->show();    i->value(current_widget->o->when()&FL_WHEN_NOT_CHANGED);  } else {    int n = i->value() ? FL_WHEN_NOT_CHANGED : 0;    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;	q->o->when(n|(q->o->when()&~FL_WHEN_NOT_CHANGED));      }  }}uchar Fl_Widget_Type::resizable() const {  if (is_window()) return ((Fl_Window*)o)->resizable() != 0;  Fl_Group* p = (Fl_Group*)o->parent();  if (p) return p->resizable() == o;  else return 0;}void Fl_Widget_Type::resizable(uchar v) {  if (v) {    if (resizable()) return;    if (is_window()) ((Fl_Window*)o)->resizable(o);    else {      Fl_Group* p = (Fl_Group*)o->parent();      if (p) p->resizable(o);    }  } else {    if (!resizable()) return;    if (is_window()) {      ((Fl_Window*)o)->resizable(0);    } else {      Fl_Group* p = (Fl_Group*)o->parent();      if (p) p->resizable(0);    }  }}void resizable_cb(Fl_Light_Button* i,void* v) {  if (v == LOAD) {    if (current_widget->is_menu_item()) {i->hide(); return;}    if (numselected > 1) {i->hide(); return;}    i->show();    i->value(current_widget->resizable());  } else {    current_widget->resizable(i->value());  }}void hotspot_cb(Fl_Light_Button* i,void* v) {  if (v == LOAD) {    if (numselected > 1) {i->hide(); return;}    if (current_widget->is_menu_item()) i->label("divider");    else i->label("hotspot");    i->show();    i->value(current_widget->hotspot());  } else {    current_widget->hotspot(i->value());    if (current_widget->is_menu_item()) {current_widget->redraw(); return;}    if (i->value()) {      Fl_Type *p = current_widget->parent;      if (!p || !p->is_widget()) return;      while (!p->is_window()) p = p->parent;      for (Fl_Type *o = p->next; o && o->level > p->level; o = o->next) {	if (o->is_widget() && o != current_widget)	  ((Fl_Widget_Type*)o)->hotspot(0);      }    }  }}void visible_cb(Fl_Light_Button* i, void* v) {  if (v == LOAD) {    i->value(current_widget->o->visible());  } else {    int n = i->value();    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;	n ? q->o->show() : q->o->hide();	q->redraw();      }  }}void active_cb(Fl_Light_Button* i, void* v) {  if (v == LOAD) {    i->value(current_widget->o->active());  } else {    int n = i->value();    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;	n ? q->o->activate() : q->o->deactivate();	q->redraw();      }  }}////////////////////////////////////////////////////////////////Fl_Menu_Item fontmenu[] = {{"Helvetica"},{"Helvetica bold"},{"Helvetica italic"},{"Helvetica bold italic"},{"Courier"},{"Courier bold"},{"Courier italic"},{"Courier bold italic"},{"Times"},{"Times bold"},{"Times italic"},{"Times bold italic"},{"Symbol"},{"Terminal"},{"Terminal Bold"},{"Zapf Dingbats"},{0}};void labelfont_cb(Fl_Choice* i, void *v) {  if (v == LOAD) {    int n = current_widget->o->labelfont();    if (n > 15) n = 0;    i->value(n);  } else {    int n = i->value();    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;	q->o->labelfont(n);	q->redraw();      }  }}void labelsize_cb(Fl_Value_Input* i, void *v) {  int n;  if (v == LOAD) {    n = current_widget->o->labelsize();  } else {    n = int(i->value());    if (n <= 0) n = FL_NORMAL_SIZE;    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;	q->o->labelsize(n);	q->redraw();      }  }  i->value(n);}extern const char *ui_find_image_name;void image_cb(Fl_Widget *a, void *) {  Fluid_Image *i = ui_find_image(current_widget->label());  if (!ui_find_image_name) return; // user hit "Cancel"  // if i is zero then user picked a non-existent file.  So that the  // directory they chose is preserved, we change to a normal text label.  for (Fl_Type *o = Fl_Type::first; o; o = o->next)    if (o->selected && o->is_widget()) {    Fl_Widget_Type* p = (Fl_Widget_Type*)o;    dont_touch_image = 1;    p->setimage(i);    p->label(ui_find_image_name);    dont_touch_image = 0;  }  label_cb(label_input,LOAD);  a->when(FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);}Fl_Menu_Item labeltypemenu[] = {  {"Image...",0,image_cb,(void*)(-1)},  {"NORMAL_LABEL",0,0,(void*)0},  {"SYMBOL_LABEL",0,0,(void*)FL_SYMBOL_LABEL},  {"SHADOW_LABEL",0,0,(void*)FL_SHADOW_LABEL},  {"ENGRAVED_LABEL",0,0,(void*)FL_ENGRAVED_LABEL},  {"EMBOSSED_LABEL",0,0,(void*)FL_EMBOSSED_LABEL},  {"NO_LABEL",0,0,(void*)(FL_NO_LABEL)},{0}};void labeltype_cb(Fl_Choice* i, void *v) {  if (v == LOAD) {    int n;    if (current_widget->image) {      n = -1;      i->when(FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);    } else {      n = current_widget->o->labeltype();      i->when(FL_WHEN_RELEASE);    }    for (int j = 0; j < int(sizeof(labeltypemenu)/sizeof(*labeltypemenu)); j++)      if (labeltypemenu[j].argument() == n) {i->value(j); break;}  } else {    int m = i->value();    int n = int(labeltypemenu[m].argument());    if (n<0) return; // should not happen    if (current_widget->image) label_input->activate();    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {      Fl_Widget_Type* p = (Fl_Widget_Type*)o;      if (p->image) {	p->setimage(0);	p->o->label(p->label());      }      p->o->labeltype((Fl_Labeltype)n);      p->redraw();    }  }}////////////////////////////////////////////////////////////////void color_cb(Fl_Button* i, void *v) {  Fl_Color c = current_widget->o->color();  if (v == LOAD) {    if (current_widget->is_menu_item()) {i->hide(); return;} else i->show();  } else {    Fl_Color d = fl_show_colormap(c);    if (d == c) return;    c = d;    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;	q->o->color(c); q->o->redraw();    }  }  i->color(c); i->labelcolor(contrast(FL_BLACK,c)); i->redraw();}void color2_cb(Fl_Button* i, void *v) {  Fl_Color c = current_widget->o->selection_color();  if (v == LOAD) {    if (current_widget->is_menu_item()) {i->hide(); return;} else i->show();  } else {    Fl_Color d = fl_show_colormap(c);    if (d == c) return;    c = d;    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;	q->o->selection_color(c); q->o->redraw();    }  }  i->color(c); i->labelcolor(contrast(FL_BLACK,c)); i->redraw();}void labelcolor_cb(Fl_Button* i, void *v) {  Fl_Color c = current_widget->o->labelcolor();  if (v != LOAD) {    Fl_Color d = fl_show_colormap(c);    if (d == c) return;    c = d;    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;	q->o->labelcolor(c); q->redraw();    }  }  i->color(c); i->labelcolor(contrast(FL_BLACK,c)); i->redraw();}static Fl_Button* relative(Fl_Widget* o, int i) {  Fl_Group* g = (Fl_Group*)(o->parent());  return (Fl_Button*)(g->child(g->find(*o)+i));}static Fl_Menu_Item alignmenu[] = {  {"FL_ALIGN_CENTER",0,0,(void*)(FL_ALIGN_CENTER)},  {"FL_ALIGN_TOP",0,0,(void*)(FL_ALIGN_TOP)},  {"FL_ALIGN_BOTTOM",0,0,(void*)(FL_ALIGN_BOTTOM)},  {"FL_ALIGN_LEFT",0,0,(void*)(FL_ALIGN_LEFT)},  {"FL_ALIGN_RIGHT",0,0,(void*)(FL_ALIGN_RIGHT)},  {"FL_ALIGN_INSIDE",0,0,(void*)(FL_ALIGN_INSIDE)},  {"FL_ALIGN_CLIP",0,0,(void*)(FL_ALIGN_CLIP)},  {"FL_ALIGN_WRAP",0,0,(void*)(FL_ALIGN_WRAP)},  {"FL_ALIGN_TOP_LEFT",0,0,(void*)(FL_ALIGN_TOP_LEFT)},  {"FL_ALIGN_TOP_RIGHT",0,0,(void*)(FL_ALIGN_TOP_RIGHT)},  {"FL_ALIGN_BOTTOM_LEFT",0,0,(void*)(FL_ALIGN_BOTTOM_LEFT)},  {"FL_ALIGN_BOTTOM_RIGHT",0,0,(void*)(FL_ALIGN_BOTTOM_RIGHT)},  {"FL_ALIGN_LEFT_TOP",0,0,(void*)(FL_ALIGN_LEFT_TOP)},  {"FL_ALIGN_RIGHT_TOP",0,0,(void*)(FL_ALIGN_RIGHT_TOP)},  {"FL_ALIGN_LEFT_BOTTOM",0,0,(void*)(FL_ALIGN_LEFT_BOTTOM)},  {"FL_ALIGN_RIGHT_BOTTOM",0,0,(void*)(FL_ALIGN_RIGHT_BOTTOM)},{0}};void align_cb(Fl_Button* i, void *v) {  int b = int(long(i->user_data()));  if (v == LOAD) {    if (current_widget->is_menu_item()) {i->hide(); return;} else i->show();    i->value(current_widget->o->align() & b);  } else {    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type* q = (Fl_Widget_Type*)o;      int x = q->o->align();      int y;      if (i->value()) {	y = x | b;	if (b == FL_ALIGN_LEFT || b == FL_ALIGN_TOP) {	  Fl_Button *b1 = relative(i,+1);	  b1->clear();	  y = y & ~(b1->argument());	}	if (b == FL_ALIGN_RIGHT || b == FL_ALIGN_BOTTOM) {	  Fl_Button *b1 = relative(i,-1);	  b1->clear();	  y = y & ~(b1->argument());	}      } else {	y = x & ~b;      }      if (x != y) {q->o->align(y); q->redraw();}    }  }}////////////////////////////////////////////////////////////////void callback_cb(Fl_Input* i, void *v) {  if (v == LOAD) {    i->static_value(current_widget->callback());  } else {    const char *c = i->value();    const char *d = c_check(c);    if (d) {fl_message("Error in callback: %s",d); haderror = 1; return;}    for (Fl_Type *o = Fl_Type::first; o; o = o->next) if (o->selected) {      o->callback(c);    }  }}void user_data_cb(Fl_Input *i, void *v) {  if (v == LOAD) {    i->static_value(current_widget->user_data());  } else {    const char *c = i->value();    const char *d = c_check(c);    if (d) {fl_message("Error in user_data: %s",d); haderror = 1; return;}    for (Fl_Type *o = Fl_Type::first; o; o = o->next) if (o->selected) {      o->user_data(c);    }  }}void user_data_type_cb(Fl_Input *i, void *v) {  static const char *dflt = "void*";  if (v == LOAD) {    const char *c = current_widget->user_data_type();    if (!c) c = dflt;    i->static_value(c);  } else {    const char *c = i->value();    const char *d = c_check(c);    if (!*c) i->value(dflt);    else if (!strcmp(c,dflt)) c = 0;    if (!d) {      if (c && *c && c[strlen(c)-1] != '*' && strcmp(c,"long"))	d = "must be pointer or long";    }    if (d) {fl_message("Error in type: %s",d); haderror = 1; return;}    for (Fl_Type *o = Fl_Type::first; o; o = o->next) if (o->selected) {      o->user_data_type(c);    }  }}// "v_attributes" let user type in random code for attribute settings:void v_input_cb(Fl_Input* i, void* v) {  int n = int(long(i->user_data()));  if (v == LOAD) {    i->static_value(current_widget->extra_code(n));  } else {    const char *c = i->value();    const char *d = c_check(c&&c[0]=='#' ? c+1 : c);    if (d) {fl_message("Error in %s: %s",i->label(),d); haderror = 1; return;}    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type *t = (Fl_Widget_Type*)o;	t->extra_code(n,c);      }  }}void subclass_cb(Fl_Input* i, void* v) {  if (v == LOAD) {    if (current_widget->is_menu_item()) {i->hide(); return;} else i->show();    i->static_value(current_widget->subclass());  } else {    const char *c = i->value();    for (Fl_Type *o = Fl_Type::first; o; o = o->next)      if (o->selected && o->is_widget()) {	Fl_Widget_Type *t = (Fl_Widget_Type*)o;	t->subclass(c);      }  }}////////////////////////////////////////////////////////////////// textstuff: set textfont, textsize, textcolor attributes:// default widget returns 0 to indicate not-implemented:int Fl_Widget_Type::textstuff(int, Fl_Font&, int&, Fl_Color&) {return 0;}void textfont_cb(Fl_Choice* i, void* v) {  Fl_Font n; int s; Fl_Color c;  if (v == LOAD) {    if (!current_widget->textstuff(0,n,s,c)) {i->hide(); return;}    i->show();    if (n > 15) n = FL_HELVETICA;    i->value(n);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -