Exemplo n.º 1
0
int main(int argc, char **argv) {
	ThemeLoader::init();
	IconLoader::init();
	win = new EdeWindow(455, 485, "Theme demo");
	win->begin();
	{ Fl_Button* o = new Fl_Button(355, 450, 90, 25, "Load");
	  o->tooltip("Load predefined theme");
	  o->callback(load_theme_cb);
	} // Fl_Button* o
	{ Fl_Menu_Bar* o = new Fl_Menu_Bar(0, 0, 455, 25);
	  o->menu(menu_);
	} // Fl_Menu_Bar* o
	{ Fl_Round_Button* o = new Fl_Round_Button(5, 285, 90, 25, "round");
	  o->down_box(FL_ROUND_DOWN_BOX);
	} // Fl_Round_Button* o
	{ new Fl_Return_Button(5, 195, 90, 25, "button");
	} // Fl_Return_Button* o
	{ new Fl_Input(160, 196, 285, 25, "input:");
	} // Fl_Input* o
	{ Fl_Output* o = new Fl_Output(160, 225, 285, 25, "output:");
	  o->value("Some output value");
	} // Fl_Output* o
	{ Fl_File_Browser* o = new Fl_File_Browser(5, 30, 210, 125);
	  o->load("/");
	} // Fl_File_Browser* o
	{ Fl_Check_Browser* o = new Fl_Check_Browser(220, 30, 225, 125);
	  o->add("foo");
	  o->add("foo");
	  o->add("foo");
	} // Fl_Check_Browser* o
	{ Fl_Progress* o = new Fl_Progress(5, 160, 210, 25, "progress bar");
	  o->value(50);
	} // Fl_Progress* o
	{ Fl_Slider* o = new Fl_Slider(220, 160, 225, 25);
	  o->type(1);
	  o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
	} // Fl_Slider* o
	{ new Fl_Light_Button(5, 225, 90, 25, "button");
	} // Fl_Light_Button* o
	{ Fl_Check_Button* o = new Fl_Check_Button(5, 255, 90, 25, "check");
	  o->down_box(FL_DOWN_BOX);
	} // Fl_Check_Button* o
	{ Fl_File_Input* o = new Fl_File_Input(160, 256, 285, 35, "file:");
	  o->value("/home/foo/baz/taz.txt");
	} // Fl_File_Input* o
	{ Fl_Text_Editor* o = new Fl_Text_Editor(160, 325, 285, 115, "Text editor");
	  o->buffer(new Fl_Text_Buffer());
	} // Fl_Text_Editor* o
	{ Fl_Box* o = new Fl_Box(25, 328, 80, 80, "image");
	  IconLoader::set(o, "utilities-terminal", ICON_SIZE_MEDIUM);
	} // Fl_Box* o
	win->end();
	win->show(argc, argv);

	Fl::run();
	ThemeLoader::shutdown();
	IconLoader::shutdown();
	return 0;
}
Exemplo n.º 2
0
int dialog_checklist(std::string checklist_options, bool return_value, bool check_all, char separator)
{
  Fl_Group         *g, *g_inside, *buttongroup;
  Fl_Box           *dummy1, *dummy2;
  Fl_Return_Button *but_ok;
  Fl_Button        *but_cancel;
  Fl_Check_Browser *browser;

  std::vector<std::string> vec;
  size_t vec_size;
  int range;

  split(checklist_options, separator, vec);
  vec_size = vec.size();

  if (vec_size < 2) {
    title = "error: checklist";
    msg = "Two or more options required!";
    dialog_message(MESSAGE_TYPE_INFO);
    return 1;
  }

  if (!title) {
    title = "Select your option(s)";
  }

  win = new Fl_Double_Window(420, 356, title);
  win->callback(close_cb, 1);
  {
    g = new Fl_Group(0, 0, 420, 310);
    {
      g_inside = new Fl_Group(0, 0, 420, 310);
      {
        browser = new Fl_Check_Browser(10, 10, 400, 299);
        browser->box(FL_THIN_DOWN_BOX);
        browser->color(fl_lighter(fl_lighter(FL_BACKGROUND_COLOR)));
        browser->clear_visible_focus();
        for (auto it = vec.begin(); it != vec.end(); ++it) {
          std::string &s = *it;
          browser->add(s.c_str());
        }
        if (check_all) {
          browser->check_all();
        }
        dummy1 = new Fl_Box(10, 308, 400, 1);
        dummy1->box(FL_NO_BOX);
        vec.clear();
      }
      g_inside->resizable(dummy1);
      g_inside->end();
    }
    g->resizable(g_inside);
    g->end();

    buttongroup = new Fl_Group(0, 310, 420, 42);
    {
      int but_w = measure_button_width(fl_cancel, 20);
      range = but_w + 40;
      but_cancel = new Fl_Button(win->w() - 10 - but_w, 320, but_w, 26, fl_cancel);
      but_cancel->callback(close_cb, 1);
      but_w = measure_button_width(fl_ok, 40);
      but_ok = new Fl_Return_Button(but_cancel->x() - 10 - but_w, 320, but_w, 26, fl_ok);
      but_ok->callback(close_cb, 0);
      dummy2 = new Fl_Box(but_ok->x() - 1, 310, 1, 1);
      dummy2->box(FL_NO_BOX);
    }
    buttongroup->resizable(dummy2);
    buttongroup->end();
  }
  run_window(win, g, range, 100);

  if (ret == 0) {
    std::string list;
    for (size_t i = 1; i <= vec_size; ++i) {
      if (return_value) {
        if (browser->checked(i)) {
          list.append(quote);
          list.append(browser->text(i));
          list.append(quote);
          list.push_back(separator);
        }
      } else {
        list.append(quote);
        list += (browser->checked(i)) ? "TRUE" : "FALSE";
        list.append(quote);
        list.push_back(separator);
      }
    }
    /* strip trailing separator */
    list.pop_back();
    std::cout << list << std::endl;
  }

  return ret;
}