Пример #1
0
long
fit_window::on_cmd_param_change(FXObject *_txt, FXSelector, void*)
{
  FXTextField *txt = (FXTextField *) _txt;
  param_info* p = (param_info*) txt->getUserData();
  FXString vstr = txt->getText();
  double new_val = strtod (vstr.text(), NULL);
  unsigned k = this->get_parameter_index(p);
  m_fit->set_parameter_value(k, new_val);
  if (m_canvas) m_canvas->set_dirty(true);
  return 1;
}
Пример #2
0
long AliasDialog::onModify(FXObject*, FXSelector, void*)
{
    FXint row = m_table->getCurrentItem();
    FXString oldkey = m_table->getItemText(row).before('\t');
    FXDialogBox aliasEdit(this, _("Alias edit"), DECOR_TITLE|DECOR_BORDER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    FXVerticalFrame *contents = new FXVerticalFrame(&aliasEdit, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0);
    FXMatrix *matrix = new FXMatrix(contents, 2, MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
    new FXLabel(matrix, _("Alias:"), NULL, JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
    FXTextField *alias = new FXTextField(matrix, 25, NULL, 0, FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
    alias->setText(oldkey);
    new FXLabel(matrix, _("Command:"), NULL, JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
    FXTextField *command = new FXTextField(matrix, 25, NULL, 0, FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
    command->setText(m_table->getItemText(row).after('\t'));

    FXHorizontalFrame *buttonframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH);
    new dxEXButton(buttonframe, _("&Cancel"), NULL, &aliasEdit, FXDialogBox::ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2);
    new dxEXButton(buttonframe, _("&OK"), NULL, &aliasEdit, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2);

    if(aliasEdit.execute(PLACEMENT_OWNER))
        {
        if(alias->getText().empty() || command->getText().empty())
            return 1;
        if(alias->getText()[0] != '/')
        {
            dxEXMessageBox::information(this, MBOX_OK, _("Information"), _("Alias command has to start with '/'"));
            return 1;
        }
        if(alias->getText().contains(' '))
        {
            dxEXMessageBox::information(this, MBOX_OK, _("Information"), _("Alias command cann't contain space"));
            return 1;
        }
        if(commandExist(alias->getText()) && comparecase(alias->getText(), oldkey))
        {
            dxEXMessageBox::information(this, MBOX_OK, _("Information"), _("Command '%s' already exist"), alias->getText().text());
            return 1;
        }
        m_aliases.erase(oldkey);
        m_aliases.insert(StringPair(alias->getText(), command->getText()));
        updateTable();
    }
    return 1;
}