当前位置: 首页>>代码示例>>C++>>正文


C++ Fl_Input::take_focus方法代码示例

本文整理汇总了C++中Fl_Input::take_focus方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Input::take_focus方法的具体用法?C++ Fl_Input::take_focus怎么用?C++ Fl_Input::take_focus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fl_Input的用法示例。


在下文中一共展示了Fl_Input::take_focus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: numberOrStringOptionChooser

double numberOrStringOptionChooser(const std::string &category, int index,
                                   const std::string &name, bool isNumber,
                                   const std::string &title,
                                   bool isInteractive, double minimum,
                                   double maximum, double step)
{
  double valn = 0.;
  std::string vals = "";
  if(isNumber)
    NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), valn);
  else
    StringOption(GMSH_GET, category.c_str(), index, name.c_str(), vals);

  int nn = (isInteractive ? 2 : 3);
  int width = nn * BB + (nn + 1) * WB, height = 2 * BH + 3 * WB;
  std::string t = title;
  if(t.empty()) t = (isNumber ? "Number Chooser" : "String Chooser");
  Fl_Window *win = new paletteWindow(width, height, false, t.c_str());
  win->set_modal();
  win->hotspot(win);
  inputValueFloat *number = 0;
  Fl_Input *string = 0;
  if(isNumber){
    number = new inputValueFloat(WB, WB, width - 2 * WB, BH);
    number->value(valn);
    if(isInteractive){
      static opt_data d;
      d.category = category;
      d.index = index;
      d.name = name;
      number->minimum(minimum);
      number->maximum(maximum);
      number->step(step, 1);
      number->callback(interactive_cb, (void*)&d);
      number->when(FL_WHEN_RELEASE);
    }
  }
  else{
    string = new Fl_Input(WB, WB, width - 2 * WB, BH);
    string->value(vals.c_str());
  }
  Fl_Button *ok = new Fl_Return_Button
    (width - nn * BB - nn * WB, 2 * WB + BH, BB, BH, "OK");
  Fl_Button *def = new Fl_Button
    (width - (nn - 1) * BB - (nn - 1) * WB, 2 * WB + BH, BB, BH, "Default");
  Fl_Button *cancel = 0;
  if(!isInteractive)
    cancel = new Fl_Button
      (width - BB - WB, 2 * WB + BH, BB, BH, "Cancel");
  win->end();
  win->show();
  if(number) number->take_focus();
  if(string) string->take_focus();
  bool done = false;
  while(win->shown()){
    if(done) break;
    Fl::wait();
    for (;;) {
      Fl_Widget* o = Fl::readqueue();
      if (!o) break;
      if (o == win || o == cancel) {
        done = true;
        break;
      }
      if(o == ok){
        if(isNumber){
          valn = number->value();
          NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index,
                       name.c_str(), valn);
        }
        else{
          vals = string->value();
          StringOption(GMSH_SET|GMSH_GUI, category.c_str(), index,
                       name.c_str(), vals);
        }
        done = true;
        break;
      }
      if(o == def){
        if(isNumber){
          NumberOption(GMSH_GET_DEFAULT, category.c_str(), index,
                       name.c_str(), valn);
          number->value(valn);
          if(isInteractive) number->do_callback();
        }
        else{
          StringOption(GMSH_GET_DEFAULT, category.c_str(), index,
                       name.c_str(), vals);
          string->value(vals.c_str());
        }
        break;
      }
    }
  }
  delete win;

  if(isNumber){
    NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), valn);
    return valn;
  }
//.........这里部分代码省略.........
开发者ID:kevinr2763,项目名称:gmsh,代码行数:101,代码来源:helpWindow.cpp


注:本文中的Fl_Input::take_focus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。