Example #1
0
/**
  Constructor for View

  /usr/lib/Wt/examples/widgetgallery/examples/ComboBoxModel.cpp
  https://www.webtoolkit.eu/widgets/forms/combo-box
  https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WComboBox.html

 */
View::View(const Wt::WEnvironment& env)
    : Wt::WApplication(env)
{
  setTitle("DropDown Demo");


  log("info") << "Test";

  // This is the container for the full screen.
  Wt::WContainerWidget *pScreenContainer = new Wt::WContainerWidget();
  pScreenContainer->resize(Wt::WLength::Auto, Wt::WLength::Auto);
  // Add the primary container to the root widget?
  root()->addWidget(pScreenContainer);

  // Choose the grid layout.
  Wt::WGridLayout *pScreenLayout = new Wt::WGridLayout();
  pScreenContainer->setLayout(pScreenLayout);

  int nRow = 0;
  int nColoumn = 0;

 
  // Create the label
  Wt::WText *lblSeriesChoice = new Wt::WText("Series:");
  // set right align the label
  lblSeriesChoice->setTextAlignment(Wt::AlignRight);
  pScreenLayout->addWidget(lblSeriesChoice, nRow, nColoumn+0);

  // Create the dropdown
  Wt::WComboBox *cbSeries = new Wt::WComboBox();
  cbSeries->addItem("");
  cbSeries->addItem("New");
  cbSeries->addItem("Krakken awoke");
  cbSeries->addItem("Appocalypse survival");
  cbSeries->setCurrentIndex(0); // Empty string
  pScreenLayout->addWidget(cbSeries, nRow, nColoumn+1);


  // Create the connection
  cbSeries->activated().connect(this, &View::DropDownSelectionChangeOtherDropDown);
  cbSeries->activated().connect(this, &View::DropDownSelectionChangeTab);
  /* Signals connect to Slots.
  * You may specify up to 6 arguments which may be of arbitrary types that are Copyable, that may be passed through the signal to connected slots.
  *   https://www.webtoolkit.eu/wt/doc/reference/html/group__signalslot.html
  * I think the 
  *   first parm - is a pointer to the target class.
  *   second parm - is the name of the method?
  * 
  * See: Wt::Signal.
  */


  /*
  * Let row 1 and column 1 take the excess space.?
  */
  pScreenLayout->setRowStretch(0, 0);
  pScreenLayout->setColumnStretch(0, 0);
} // end
      VideoPanel::VideoPanel(std::map<std::string, std::string>& p) : _parameter(p), Wt::Ext::Panel() {
        //        setLayout(new Wt::WFitLayout());
        Wt::WBorderLayout*l = new Wt::WBorderLayout();
        setLayout(l);
        std::set<std::string> avail_codecs;
        if (_parameter.count("available_codecs") > 0) {
          LOGDEBUG("Available codes" << _parameter["available_codecs"]);
          org::esb::util::StringTokenizer st(_parameter["available_codecs"], ",");
          while (st.hasMoreTokens()) {
            std::string codec_id = st.nextToken();
            avail_codecs.insert(codec_id);
            LOGDEBUG("avalable codec list" << codec_id);
          }
        }
        /*
         * Combobox for the Codec Selector
         */
        KeyValueModel * codec_model = new KeyValueModel();
        codec_model->addModelData("novideo", "No Video");
        codec_model->addModelData("copy", "Stream Copy");

        AVCodec *codec = NULL;
        int a = 0;
        while ((codec = av_codec_next(codec))) {
          if (codec->encode && codec->type == AVMEDIA_TYPE_VIDEO) {
            if (avail_codecs.count(codec->name) > 0) {
              codec_model->addModelData(codec->name, codec->long_name);
            } else {
              if (avail_codecs.size() == 0)
                codec_model->addModelData(codec->name, codec->long_name);
            }
          }
        }
        codec_model->sort(1);

        _codec = new ComboBox();

        _codec->setModel(codec_model);
        _codec->setModelColumn(1);
        _codec->setSelectedEntry(_parameter["codec_id"]);
        _codec->setTextSize(50);
        _codec->resize(300, Wt::WLength());


        _codec->activated().connect(SLOT(this, VideoPanel::codecSelected));


        main_panel = new Wt::Ext::Panel();
        Wt::WFitLayout * fit = new Wt::WFitLayout();
        main_panel->setLayout(fit);
        //main_panel->setBorder(false);

        l->addWidget(main_panel, Wt::WBorderLayout::Center);

        Wt::Ext::Panel * top_panel = new Wt::Ext::Panel();
        top_panel->resize(Wt::WLength(), 40);
        top_panel->setLayout(new Wt::WFitLayout());
        top_panel->setBorder(false);
        //        top_panel->layout()->addWidget(_codec);

        Wt::WContainerWidget *top = new Wt::WContainerWidget();
        top_panel->layout()->addWidget(top);
        Wt::WGridLayout * grid = new Wt::WGridLayout();
        top->setLayout(grid);
        top->resize(Wt::WLength(), 40);

        l->addWidget(top_panel, Wt::WBorderLayout::North);
        Wt::WLabel * label = new Wt::WLabel("Codec:");
        label->setBuddy(_codec);

        grid->addWidget(label, 0, 0);
        grid->addWidget(_codec, 0, 1);
        grid->addWidget(new Wt::WText(""), 0, 2);
        grid->setColumnStretch(1, 1);




        setCodecGui(_parameter["codec_id"]);
        //l->addWidget(builder,Wt::WBorderLayout::Center);
        //        return;
      }
Example #3
0
ComputerView::ComputerView(Wt::WApplication *app, const Wt::WString &computerName,
bool writeAccess, Wt::WContainerWidget *parent) :
	Wt::WContainerWidget(parent),
	app(app), _computerName(computerName), _img_led(NULL)
{
	Wt::WBoxLayout *layout = new Wt::WBoxLayout(Wt::WBoxLayout::TopToBottom, this);

	Wt::WText *_title = new Wt::WText(computerName);
	_title->setStyleClass("ComputerName");
	app->styleSheet().addRule(".ComputerName", "font-size: 36px; text-transform: capitalize;");
	layout->addWidget(_title, 0, Wt::AlignCenter);

	/* create the buttons and connect them to their slots */
	_btn_atx_force_off = new Wt::WPushButton("Force off");
	_btn_atx_force_on = new Wt::WPushButton("Force on");
	_btn_atx_reset = new Wt::WPushButton("Reset");
	_btn_pw_switch_press = new Wt::WPushButton("Press");
	_btn_pw_switch_force_off = new Wt::WPushButton("Force off");

	_btn_atx_force_off->setEnabled(writeAccess);
	_btn_atx_force_on->setEnabled(writeAccess);
	_btn_atx_reset->setEnabled(writeAccess);
	_btn_pw_switch_press->setEnabled(writeAccess);
	_btn_pw_switch_force_off->setEnabled(writeAccess);

	_btn_atx_force_off->clicked().connect(this, &ComputerView::btn_atx_force_off_clicked);
	_btn_atx_force_on->clicked().connect(this, &ComputerView::btn_atx_force_on_clicked);
	_btn_atx_reset->clicked().connect(this, &ComputerView::btn_atx_reset_clicked);
	_btn_pw_switch_press->clicked().connect(this, &ComputerView::btn_pw_switch_press_clicked);
	_btn_pw_switch_force_off->clicked().connect(this, &ComputerView::btn_pw_switch_force_off_clicked);

	/* preload all the images */
	_ico_led_on_file.reset(getImg("green_light.png"));
	_ico_led_off_file.reset(getImg("off_light.png"));
	_ico_ping_file.reset(getImg("ping.png"));
	_ico_atx_pwr_file.reset(getImg("atx_power.png"));
	_ico_pwr_switch_file.reset(getImg("power-button.png"));

	/* create the LED */
	_img_led = new Wt::WImage();
	_img_led->setHeight(Wt::WLength(16));
	setPowerLedStatus(false);

	Wt::WGridLayout *grid = new Wt::WGridLayout();
	grid->addWidget(_img_led, 0, 0, Wt::AlignCenter);
	grid->addWidget(new Wt::WText("Power Led state"), 0, 1);
	grid->addWidget(new Wt::WLabel(""), 0, 5);

	grid->addWidget(new Wt::WImage(_ico_ping_file.get()), 1, 0, Wt::AlignCenter);
	grid->addWidget(new Wt::WText("Ping"), 1, 1);
	_ping_txt = new Wt::WText("N/A");
	grid->addWidget(_ping_txt, 1, 2, 0, 0, Wt::AlignCenter);

	grid->addWidget(new Wt::WImage(_ico_atx_pwr_file.get()), 2, 0, Wt::AlignCenter);
	grid->addWidget(new Wt::WText("ATX power"), 2, 1);
	grid->addWidget(_btn_atx_force_off, 2, 2);
	grid->addWidget(_btn_atx_force_on, 2, 3);
	grid->addWidget(_btn_atx_reset, 2, 4);

	grid->addWidget(new Wt::WImage(_ico_pwr_switch_file.get()), 3, 0, Wt::AlignCenter);
	grid->addWidget(new Wt::WText("Power switch"), 3, 1);
	grid->addWidget(_btn_pw_switch_press, 3, 2);
	grid->addWidget(_btn_pw_switch_force_off, 3, 3);

	grid->setColumnStretch(5, 1);

	layout->addLayout(grid);

	layout->addSpacing(10);

	Wt::WLabel *label = new Wt::WLabel("Logs:");
	layout->addWidget(label);

	_logs_edit = new Wt::WTextArea("");
	_logs_edit->setHeight(150);
	_logs_edit->setMaximumSize(Wt::WLength::Auto, 150);
	label->setBuddy(_logs_edit);
	layout->addWidget(_logs_edit);

	layout->addSpacing(10);
}