Пример #1
0
uiBasis:: uiBasis( Fl_Group &tabs, const BasisInfo  &bi ) :
name( bi.name ),
group( new Fl_Group( tabs.x(), tabs.y()+24, tabs.w(), tabs.h()-24, bi.name.c_str() ) ),
input()
{
    //--------------------------------------------------------------------------
    // record the new tab
    //--------------------------------------------------------------------------
    tabs.add(group);
    group->labelfont( FL_COURIER );
    group->labelsize( 14 );
  
    
    
    static const int bh = 23;
    
    //--------------------------------------------------------------------------
    // create the parameters
    //--------------------------------------------------------------------------
    const int    h     = group->h();
    const size_t nb    = bi.param.size();
    const int    hfree = h - nb * bh;
    const int    hskip = hfree/(nb+1);
    
    int       y = group->y();
    const int x = group->x() + 8;

    for( size_t i=1; i <= nb; ++i )
    {
        y += hskip;
        const string &param = bi.param[i];
        Fl_Input *box = new Fl_Input(x,y,100,bh,param.c_str());
        box->input_type(FL_FLOAT_INPUT);
        box->labeltype( FL_NORMAL_LABEL );
        box->align(FL_ALIGN_RIGHT);
        box->labelfont(FL_HELVETICA);
        box->labelsize(12);
        box->textsize(12);
        box->textfont(FL_HELVETICA);
        group->add(box);
        box->value("0.0");
        y += bh;
        input.push_back(box);
        box->callback(ChangeCB);
        box->when(FL_WHEN_RELEASE);
    }
    
    
    
}
int main( int argc, char **argv )
{
  Fl_Double_Window *win = new Fl_Double_Window( 100, 100, 400, 300, "Flu_Chat_Buffer_Try" );
  Flu_Chat_Buffer *b = new Flu_Chat_Buffer( 0, 0, 400, 200 );
  Fl_Input *in = new Fl_Input( 80, 210, 100, 30, "Send:" );
  in->when( FL_WHEN_ENTER_KEY_ALWAYS );
  in->callback( sendMsg, b );
  win->end();
  win->resizable( win );

  b->addSystemMessage( "System message" );
  b->addRemoteMessage( "<Remote User> ", "Remote user's message" );
  b->addLocalMessage( "<Local User> ", "Local user's message" );

  win->show();

  return( Fl::run() );
}
Пример #3
0
//==== Create & Init Text Input  ====//
void GroupLayout::AddInput( StringInput& text_input, const char* label )
{
    assert( m_Group && m_Screen );

    //==== Button ====//
    AddParmButton( label );

    //==== Add Text Input ====//
    int iw = FitWidth( m_ButtonWidth, m_InputWidth );
    Fl_Input* input = new Fl_Input( m_X, m_Y, iw, m_StdHeight );
    input->box( FL_THIN_DOWN_BOX );
    input->textsize( 12 );
    input->when( FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE );
    m_Group->add( input );
    AddX( iw );

    AddY( m_StdHeight );
    NewLineX();

    text_input.Init( m_Screen, input );
}
Пример #4
0
//==== Create & Init Float Input  ====//
void GroupLayout::AddInput( Input& input, const char* label, const char* format )
{
    assert( m_Group && m_Screen );

    //==== Parm Button ====//
    VspButton* button = AddParmButton( label );

    //==== Add Text Input ====//
    int iw = FitWidth( m_ButtonWidth, m_InputWidth );
    Fl_Input* flinput = new Fl_Input( m_X, m_Y, iw, m_StdHeight );
    flinput->type( 1 );
    flinput->box( FL_THIN_DOWN_BOX );
    flinput->textsize( 12 );
    flinput->when( FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE );
    m_Group->add( flinput );
    AddX( iw );

    AddY( m_StdHeight );
    NewLineX();

    input.Init( m_Screen, flinput, format, button );
}
Пример #5
0
// add parameter string to tree
Fl_Widget *onelabGroup::_addParameterWidget(onelab::string &p, int ww, int hh,
                                            Fl_Tree_Item *n, bool highlight, Fl_Color c)
{
  char *path = strdup(getPath(n).c_str());
  _treeStrings.push_back(path);

  // macro button
  if(p.getAttribute("Macro") == "Gmsh"){
    Fl_Button *but = new Fl_Button(1, 1, ww / _widgetLabelRatio, hh);
    but->box(FL_FLAT_BOX);
    but->color(_tree->color());
    but->selection_color(_tree->color());
    but->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
    //TODO but->callback(onelab_string_button_cb, (void*)path);
    if(highlight) but->color(c);
    return but;
  }

  // non-editable value
  if(p.getReadOnly()){
    Fl_Output *but = new Fl_Output(1, 1, ww, hh);
    but->value(p.getValue().c_str());
    but->align(FL_ALIGN_RIGHT);
    if(highlight) but->color(c);
    return but;
  }

  // simple string (no menu)
  if(p.getChoices().empty() && p.getKind() != "file"){
    Fl_Input *but = new Fl_Input(1, 1, ww, hh);
    but->value(p.getValue().c_str());
    //TODO but->callback(onelab_string_input_cb, (void*)path);
    but->when(FL_WHEN_ENTER_KEY);
    but->align(FL_ALIGN_RIGHT);
    if(highlight) but->color(c);
    return but;
  }

  // general string input
  Fl_Input_Choice *but = new Fl_Input_Choice(1, 1, ww, hh);
  std::string multipleSelection = p.getAttribute("MultipleSelection");
  if(multipleSelection.size())
    ;//but->menubutton()->callback(multiple_selection_menu_cb, but);
  std::vector<Fl_Menu_Item> menu;
  for(unsigned int j = 0; j < p.getChoices().size(); j++){
    char *str = strdup(p.getChoices()[j].c_str());
    _treeStrings.push_back(str);
    bool divider = (p.getKind() == "file" &&
                    j == p.getChoices().size() - 1);
    int choice = multipleSelection.size() ? FL_MENU_TOGGLE : 0;
    if(multipleSelection.size() > j && multipleSelection[j] == '1')
      choice |= FL_MENU_VALUE;
    Fl_Menu_Item it = {str, 0, 0, 0, divider ? FL_MENU_DIVIDER : choice};
    menu.push_back(it);
  }
  //if(p.getKind() == "file"){
  //  Fl_Menu_Item it = {"Choose...", 0, onelab_input_choice_file_chooser_cb, (void*)n};
  //  menu.push_back(it);
  //  Fl_Menu_Item it2 = {"Edit...", 0, onelab_input_choice_file_edit_cb, (void*)n};
  //  menu.push_back(it2);
  //  if(GuessFileFormatFromFileName(p.getValue()) >= 0){
  //    Fl_Menu_Item it3 = {"Merge...", 0, onelab_input_choice_file_merge_cb, (void*)n};
  //    menu.push_back(it3);
  //  }
  //}
  Fl_Menu_Item it = {0};
  menu.push_back(it);
  but->menubutton()->copy(&menu[0]);
  but->value(p.getValue().c_str());
  but->callback(onelab_string_input_choice_cb, (void*)path);
  but->input()->when(FL_WHEN_ENTER_KEY);
  but->align(FL_ALIGN_RIGHT);
  if(highlight) but->input()->color(c);
  return but;
}
Пример #6
0
void createSystemArea(int32_t x, int32_t y, int32_t w, int32_t h){

    tsconf::GameConfig *conf = tsconf::GetGameConfig();
    int curH_L = y;

    if((x+(tsconf::smallPadding<<1)+tsconf::largeWidgetWidth)>w){ //Enter no-space mode



    }
    else{ //We got space.

        curH_L+=tsconf::smallPadding;
        Fl_Group *startupGroup = new Fl_Group(x+tsconf::smallPadding, curH_L, w-(tsconf::smallPadding*2), tsconf::largeWidgetHeight, "Startup Directory");
        startupGroup->box(FL_EMBOSSED_BOX);

        startupGroup->begin();
            Fl_Input *startupInput = new Fl_Input(x+tsconf::smallPadding+12, curH_L+12, (w-(tsconf::smallPadding*2))-76, tsconf::smallWidgetHeight);
            startupInput->value(conf->startupdir);
            startupInput->when(FL_WHEN_CHANGED);
            startupInput->callback(startupCallback);

            int newX = static_cast<Fl_Widget *>(startupInput)->x()+static_cast<Fl_Widget *>(startupInput)->w();
            Fl_Button *chooseStartupButton = new Fl_Button(newX+12, curH_L+12, 40, tsconf::smallWidgetHeight, "...");
            chooseStartupButton->callback(DirectoryChooser, startupInput);
        startupGroup->end();

        curH_L+=tsconf::smallPadding+tsconf::largeWidgetHeight;
        Fl_Group *sgmnameGroup = new Fl_Group(x+tsconf::smallPadding, curH_L, w-(tsconf::smallPadding*2), tsconf::largeWidgetHeight, "SGM File Name");
        sgmnameGroup->box(FL_EMBOSSED_BOX);

        sgmnameGroup->begin();
            Fl_Input *sgmnameInput = new Fl_Input(x+tsconf::smallPadding+12, curH_L+12, (w-(tsconf::smallPadding*2))-24, tsconf::smallWidgetHeight);
            sgmnameInput->value(conf->sgmname);
            sgmnameInput->when(FL_WHEN_CHANGED);
            sgmnameInput->callback(sgmnameCallback);

        sgmnameGroup->end();

        curH_L+=tsconf::smallPadding+tsconf::largeWidgetHeight;
        Fl_Group *tsgmnameGroup = new Fl_Group(x+tsconf::smallPadding, curH_L, w-(tsconf::smallPadding*2), tsconf::largeWidgetHeight, "TSGM File Name");
        tsgmnameGroup->box(FL_EMBOSSED_BOX);

        tsgmnameGroup->begin();
            Fl_Input *tsgmnameInput = new Fl_Input(x+tsconf::smallPadding+12, curH_L+12, (w-(tsconf::smallPadding*2))-24, tsconf::smallWidgetHeight);
            tsgmnameInput->value(conf->tsgmname);
            tsgmnameInput->when(FL_WHEN_CHANGED);
            tsgmnameInput->callback(tsgmnameCallback);


        tsgmnameGroup->end();

        curH_L+=tsconf::smallPadding+tsconf::largeWidgetHeight;
        Fl_Group *mainfuncGroup = new Fl_Group(x+tsconf::smallPadding, curH_L, w-(tsconf::smallPadding*2), tsconf::largeWidgetHeight, "Main Function");
        mainfuncGroup->box(FL_EMBOSSED_BOX);

        mainfuncGroup->begin();
            Fl_Input *mainfuncInput = new Fl_Input(x+tsconf::smallPadding+12, curH_L+12, (w-(tsconf::smallPadding*2))-24, tsconf::smallWidgetHeight);
            mainfuncInput->value(conf->gamefunc);
            mainfuncInput->when(FL_WHEN_CHANGED);
            mainfuncInput->callback(mainfuncCallback);


        mainfuncGroup->end();
    }


}