Example #1
0
long
GNEVehicleFrame::VTypeSelector::onCmdSelectVType(FXObject*, FXSelector, void*) {
    // get list of VTypes
    const auto& vTypes = myVehicleFrameParent->getViewNet()->getNet()->getDemandElementByType(SUMO_TAG_VTYPE);
    // Check if value of myTypeMatchBox correspond to a VType
    for (const auto& i : vTypes) {
        if (i.first == myTypeMatchBox->getText().text()) {
            // set color of myTypeMatchBox to black (valid)
            myTypeMatchBox->setTextColor(FXRGB(0, 0, 0));
            // Set new current VType
            myCurrentVehicleType = i.second;
            // show vehicle attributes modul
            myVehicleFrameParent->myVehicleAttributes->showAttributesCreatorModul(myVehicleFrameParent->myItemSelector->getCurrentTagProperties());
            // show help creation
            myVehicleFrameParent->myHelpCreation->showHelpCreation();
            // Write Warning in console if we're in testing mode
            WRITE_DEBUG(("Selected item '" + myTypeMatchBox->getText() + "' in VTypeSelector").text());
            return 1;
        }
    }
    // if VType selecte is invalid, select
    myCurrentVehicleType = nullptr;
    // hide all moduls if selected item isn't valid
    myVehicleFrameParent->myVehicleAttributes->hideAttributesCreatorModul();
    // hide help creation
    myVehicleFrameParent->myHelpCreation->hideHelpCreation();
    // set color of myTypeMatchBox to red (invalid)
    myTypeMatchBox->setTextColor(FXRGB(255, 0, 0));
    // Write Warning in console if we're in testing mode
    WRITE_DEBUG("Selected invalid item in VTypeSelector");
    return 1;
}
Example #2
0
long dlgReglas::onCmdNewRegla(FXObject *sender, FXSelector sel, void *) {
	FXString nombre, patron;
	FXColor fg, bg;

	numReglas++;
	nombre = "<Nuevo>";
	patron = "<Nuevo patron>";
	fg = FXRGB(0, 0, 0);
	bg = FXRGB(255, 255, 255);

	indxRegla = numReglas-1;

	reglas[indxRegla].nombre = nombre;
	reglas[indxRegla].patron = patron;
	reglas[indxRegla].colorFG = fg;
	reglas[indxRegla].colorBG = bg;

	nomActual = reglas[indxRegla].nombre;
	patActual = reglas[indxRegla].patron;
	fgActual = fg;
	bgActual = bg;

	lstReglas->appendItem(nombre);
	lstReglas->selectItem(indxRegla);

	return 1;
	}
Example #3
0
// Read registry
void ShutterBug::readRegistry(){
  filename=getApp()->reg().readStringEntry("SETTINGS","filename","image.gif");
  fileformat=getApp()->reg().readIntEntry("SETTINGS","fileformat",TYPE_GIF);
  setX(getApp()->reg().readIntEntry("SETTINGS","x",50));
  setY(getApp()->reg().readIntEntry("SETTINGS","y",50));
  weight=getApp()->reg().readIntEntry("SETTINGS","weight",3);
  rectangle.x=getApp()->reg().readIntEntry("SETTINGS","snapx",50);
  rectangle.y=getApp()->reg().readIntEntry("SETTINGS","snapy",50);
  rectangle.w=getApp()->reg().readIntEntry("SETTINGS","snapw",50);
  rectangle.h=getApp()->reg().readIntEntry("SETTINGS","snaph",50);
  delay=getApp()->reg().readLongEntry("SETTINGS","snapdelay",2000000000);
  rate=getApp()->reg().readLongEntry("SETTINGS","snaprate",1000000000);
  filecount=getApp()->reg().readIntEntry("SETTINGS","count",1);
  inside=getApp()->reg().readIntEntry("SETTINGS","inside",false);
  color=getApp()->reg().readColorEntry("SETTINGS","color",FXRGB(255,128,128));
  size=getApp()->reg().readIntEntry("SETTINGS","size",0);
  quantize=getApp()->reg().readIntEntry("SETTINGS","quantize",true);
  if(size){
    if(size<0){
      rectangle.x=0;
      rectangle.y=0;
      rectangle.w=getRoot()->getWidth();
      rectangle.h=getRoot()->getHeight();
      }
    else{
      rectangle.w=size;
      rectangle.h=size;
      }
    }
  }
Example #4
0
long AlphaBallControl::onPaint(FXObject*,FXSelector,void* ptr){
  FXEvent *event=(FXEvent*)ptr;
  FXDCWindow dc(this,event);
  FXint d=dial->getWidth();
  dc.setForeground(backColor);
  dc.fillRectangle(0,0,width,height);
 /* dc.fillRectangle(border,border,dialx-border,height-(border<<1));
  dc.fillRectangle(dialx+dial->getWidth(),border,width-border-dialx-dial->getWidth(),height-(border<<1));
  dc.fillRectangle(dialx,border,dial->getWidth(),dialy-border);
  dc.fillRectangle(dialx,dialy+dial->getHeight(),dial->getWidth(),height-border-dialy-dial->getHeight());  
  //dc.drawImage(dial,dialx,dialy);
  dc.setForeground(borderColor);
  dc.drawArc(dialx+1,dialy,d,d,90*64,45*64);
  dc.drawArc(dialx,dialy+1,d,d,135*64,45*64);
  dc.setForeground(baseColor);
  dc.drawArc(dialx-1,dialy,d,d,270*64,45*64);
  dc.drawArc(dialx,dialy-1,d,d,315*64,45*64);
  dc.setForeground(shadowColor);
  dc.drawArc(dialx,dialy,d,d,45*64,180*64);
  dc.setForeground(hiliteColor);
  dc.drawArc(dialx,dialy,d,d,225*64,180*64);
  dc.setForeground(FXRGB(255,255,255));*/
  // pinta el spot  
  dc.setForeground(FXRGB(0,0,0));
  dc.fillArc(dialx+spotx-2,dialy+spoty-2,5,5,0,360*64); 

  int vmax;
  getMaxBound(vmax,spotx,spoty);
  dc.drawArc(dialx+dial->getWidth()*0.5 - vmax,dialy+dial->getHeight()*0.5 - vmax,2*vmax,2*vmax,0,360*64);
  drawFrame(dc,0,0,width,height);
  return 1;
}
// ===========================================================================
// method definitions
// ===========================================================================
GUIParameterTableWindow::GUIParameterTableWindow(GUIMainWindow& app, GUIGlObject& o, int noRows) :
    FXMainWindow(app.getApp(), (o.getFullName() + " Parameter").c_str(), NULL, NULL, DECOR_ALL, 20, 20, 500, (FXint)((noRows + numParams(&o))  * 20 + 60)),
    myObject(&o),
    myApplication(&app),
    myCurrentPos(0) {
    noRows += numParams(&o);
    myTable = new FXTable(this, this, MID_TABLE, TABLE_COL_SIZABLE | TABLE_ROW_SIZABLE | LAYOUT_FILL_X | LAYOUT_FILL_Y);
    myTable->setVisibleRows((FXint)(noRows + 1));
    myTable->setVisibleColumns(3);
    myTable->setTableSize((FXint)(noRows + 1), 3);
    myTable->setBackColor(FXRGB(255, 255, 255));
    myTable->setColumnText(0, "Name");
    myTable->setColumnText(1, "Value");
    myTable->setColumnText(2, "Dynamic");
    myTable->getRowHeader()->setWidth(0);
    FXHeader* header = myTable->getColumnHeader();
    header->setItemJustify(0, JUSTIFY_CENTER_X);
    header->setItemSize(0, 240);
    header->setItemJustify(1, JUSTIFY_CENTER_X);
    header->setItemSize(1, 120);
    header->setItemJustify(2, JUSTIFY_CENTER_X);
    header->setItemSize(2, 60);
    setIcon(GUIIconSubSys::getIcon(ICON_APP_TABLE));
    myLock.lock();
    myObject->addParameterTable(this);
    myLock.unlock();
    AbstractMutex::ScopedLocker locker(myGlobalContainerLock);
    myContainer.push_back(this);
    // Table cannot be editable
    myTable->setEditable(FALSE);
}
Example #6
0
long
fit_window::on_change_spectral_range(FXObject *, FXSelector, void*_txt)
{
  const char * txt = (const char *) _txt;

  if (update_spectral_range (txt))
    {
      m_wl_entry->setTextColor(FXRGB(0,0,0));
      if (m_canvas) m_canvas->update_limits();
    }
  else
    {
      m_wl_entry->setTextColor(FXRGB(180,0,0));
    }

  return 1;
}
Example #7
0
void 
GNEFrame::GenericParametersEditor::refreshGenericParametersEditor() {
    // update text field depending of AC
    if(myAC) {
        myTextFieldGenericParameter->setText(getGenericParametersStr().c_str());
        myTextFieldGenericParameter->setTextColor(FXRGB(0, 0, 0));
    } else if(myACs.size()) {
        // check if generic parameters of all inspected ACs are different
        std::string genericParameter = myACs.front()->getAttribute(GNE_ATTR_GENERIC);

        for (auto i : myACs) {
            if(genericParameter != i->getAttribute(GNE_ATTR_GENERIC)) {
                genericParameter = "different generic attributes";
            }
        }
        myTextFieldGenericParameter->setText(genericParameter.c_str());
        myTextFieldGenericParameter->setTextColor(FXRGB(0, 0, 0));
    }
}
Example #8
0
// Handle repaint
long ShutterBug::onPaint(FXObject*,FXSelector,void* ptr){
  register FXEvent *event=(FXEvent*)ptr;
  FXDCWindow dc(this,event);
  dc.setForeground(backColor);
  dc.fillRectangle(0,0,width,height);
  dc.setForeground(FXRGB(0,0,0));
  dc.drawRectangle(0,0,width-1,height-1);
  dc.drawIcon(bigicon,0,0);
  return 1;
  }
Example #9
0
/*
  Example proportional layout using FXSpring widgets
*/
int main(int argc,char **argv){

  // Create application object
  FXApp application("Ratio","FoxTest");

  // Initialize and open display
  application.init(argc,argv);

  // Create main window
  FXMainWindow *main=new FXMainWindow(&application,"Ratio",NULL,NULL,DECOR_ALL,0,0,400,200,8,8,8,8,6,6);

  // Add quit button and connect it to application
  new FXButton(main,"&Quit",NULL,&application,FXApp::ID_QUIT,FRAME_RAISED|FRAME_THICK|LAYOUT_SIDE_BOTTOM|LAYOUT_CENTER_X,0,0,0,0,20,20,2,2);

  // Label above it
  new FXLabel(main,"FXSpring can be used to keep widgets at fixed size ratios.\n\nResize the window to see how it behaves!",NULL,LAYOUT_SIDE_TOP|LAYOUT_FILL_X);

  // Layout manager to place the springs
  FXHorizontalFrame *horz=new FXHorizontalFrame(main,FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0, 0,0);

  // First spring is set to behave normally in Y direction,
  // but to have a ratio 1 for the X direction
  FXSpring *spring1=new FXSpring(horz,LAYOUT_FILL_X|LAYOUT_FILL_Y,1,0, 0,0,0,0, 0,0,0,0);
  FXLabel *label1=new FXLabel(spring1,"1",NULL,LAYOUT_FILL_X|LAYOUT_FILL_Y);
  label1->setBackColor(FXRGB(255,0,0));

  // Second spring has ratio 2 in the X direction
  FXSpring *spring2=new FXSpring(horz,LAYOUT_FILL_X|LAYOUT_FILL_Y,2,0, 0,0,0,0, 0,0,0,0);
  FXLabel *label2=new FXLabel(spring2,"2",NULL,LAYOUT_FILL_X|LAYOUT_FILL_Y);
  label2->setBackColor(FXRGB(0,255,0));

  // Second spring has ratio 3 in the X direction
  FXSpring *spring3=new FXSpring(horz,LAYOUT_FILL_X|LAYOUT_FILL_Y,3,0, 0,0,0,0, 0,0,0,0);
  FXLabel *label3=new FXLabel(spring3,"3",NULL,LAYOUT_FILL_X|LAYOUT_FILL_Y);
  label3->setBackColor(FXRGB(0,0,255));

  application.create();

  main->show(PLACEMENT_SCREEN);

  return application.run();
  }
Example #10
0
void AlphaBallControl::updatedial(){
  register FXColor *colors=(FXColor*)dial->getData();
  float vx,vy;
  for(register FXint y=0; y<dial->getHeight(); y++){
    for(register FXint x=0; x<dial->getWidth(); x++){
      if(xytospot(vx,vy,x,y)){        
        colors[y*dial->getWidth()+x]=FXRGB(0.0f,0.0f,255.0f);
      }else{
        colors[y*dial->getWidth()+x]=backColor;
        }
      }
    }
}
Example #11
0
long CALCDigitBox::onPopupMenu(FXObject*,FXSelector sel,void* ptr)
{
#ifdef HAVE_RTTI
  FXString str="";

  //Attemp to get tip text
  switch(FXSELID(sel))
  {
  case FXSpinner::ID_INCREMENT:
  case FXSpinner::ID_DECREMENT:
  case FXSpinner::ID_ENTRY:
  case ID_NUMDIGITS:
    str=DIGITNUMDIGITS_HELP;
    break;
  case ID_DEFAULTDIGITS:
    str=DIGITDEFAULTDIGITS_HELP;
    break;
  }

  if(!str.empty())
  {
    FXEvent* event=(FXEvent*)ptr;
    FXMenuPane pane(this);
    new FXMenuCommand(&pane,"&Huh?",NULL,this,ID_CLARIFY);

    clarify=FALSE;

    pane.create();
    pane.popup(NULL,event->root_x,event->root_y);
    getApp()->runModalWhileShown(&pane);

    if(clarify)
    {
      FXMenuPane clarification(this,FRAME_LINE);

      FXButton* button=new FXButton(&clarification,str,NULL,&clarification,FXWindow::ID_HIDE,JUSTIFY_LEFT);
      button->setFont(getApp()->getNormalFont());
      button->setTextColor(getApp()->getForeColor());
      button->setBackColor(FXRGB(255,255,192));

      clarification.create();
      clarification.popup(NULL,event->root_x,event->root_y);
      getApp()->runModalWhileShown(&clarification);
    }
  }
#endif
  return 1;
}
Example #12
0
void fx_disp_window::setup_name()
{
    regress_pro *app = (regress_pro *) getApp();

    FXHorizontalFrame *modelfm = new FXHorizontalFrame(this, LAYOUT_FILL_X|FRAME_GROOVE, 0,0,0,0, 0,0,0,0, 0,0);
    FXString model_name(disp->dclass->full_name);
    model_name.append(" Model");
    FXLabel *model_label = new FXLabel(modelfm, model_name, NULL, LABEL_NORMAL|LAYOUT_FILL_X, 0, 0, 0, 0, 2*DEFAULT_PAD, 2*DEFAULT_PAD, 3*DEFAULT_PAD, 3*DEFAULT_PAD);
    model_label->setFont(&app->big_web_font);
    model_label->setTextColor(app->blue_web);
    model_label->setBackColor(FXRGB(255, 206, 91));

    FXHorizontalFrame *namehf = new FXHorizontalFrame(this, LAYOUT_FILL_X);
    new FXLabel(namehf, "Name ");
    FXTextField *tf = new FXTextField(namehf, 24, this, ID_NAME, FRAME_SUNKEN);
    tf->setText(CSTR(disp->name));
}
// ===========================================================================
// method definitions
// ===========================================================================
GUIDialog_Breakpoints::GUIDialog_Breakpoints(GUIMainWindow* parent, std::vector<SUMOTime>& breakpoints, MFXMutex& breakpointLock)
    : FXMainWindow(parent->getApp(), "Breakpoints Editor", NULL, NULL, DECOR_ALL, 20, 20, 300, 300),
      myParent(parent), myBreakpoints(&breakpoints), myBreakpointLock(&breakpointLock) {
    FXHorizontalFrame* hbox = new FXHorizontalFrame(this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0);

    // build the table
    myTable = new MFXAddEditTypedTable(hbox, this, MID_TABLE, LAYOUT_FILL_X | LAYOUT_FILL_Y);
    myTable->setVisibleRows(20);
    myTable->setVisibleColumns(1);
    myTable->setTableSize(20, 1);
    myTable->setBackColor(FXRGB(255, 255, 255));
    myTable->setCellType(0, CT_REAL);
    SUMOTime begin = string2time(OptionsCont::getOptions().getString("begin"));
    SUMOTime end = string2time(OptionsCont::getOptions().getString("end"));
    if (end < 0) {
        end = SUMOTime_MAX;
    }
    myTable->setNumberCellParams(0, begin / 1000, end / 1000, 1, 10, 100, "%.2f");
    myTable->getRowHeader()->setWidth(0);
    myBreakpointLock->lock();
    rebuildList();
    myBreakpointLock->unlock();
    // build the layout
    FXVerticalFrame* layout = new FXVerticalFrame(hbox, LAYOUT_TOP, 0, 0, 0, 0, 4, 4, 4, 4);
    // "Load"
    new FXButton(layout, "Load\t\t", 0, this, MID_CHOOSEN_LOAD, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3);
    // "Save"
    new FXButton(layout, "Save\t\t", 0, this, MID_CHOOSEN_SAVE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3);
    new FXHorizontalSeparator(layout, SEPARATOR_GROOVE | LAYOUT_FILL_X);
    // "Clear List"
    new FXButton(layout, "Clear\t\t", 0, this, MID_CHOOSEN_CLEAR, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3);
    new FXHorizontalSeparator(layout, SEPARATOR_GROOVE | LAYOUT_FILL_X);
    // "Close"
    new FXButton(layout, "Close\t\t", 0, this, MID_CANCEL, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3);
    //
    setIcon(GUIIconSubSys::getIcon(ICON_APP_BREAKPOINTS));
    myParent->addChild(this);
}
Example #14
0
dlgReglas::dlgReglas(guiWindow *owner):FXDialogBox(owner,"Reglas",DECOR_TITLE|DECOR_BORDER
	|DECOR_RESIZE)
	{
	FXint i;


	// Interior
	FXVerticalFrame *vert = new FXVerticalFrame(this
		,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);

	FXHorizontalFrame *horiz = new FXHorizontalFrame(vert
		, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);

	// Lista de items creados y botones

	FXGroupBox *gbItems = new FXGroupBox(horiz,"Reglas creadas",FRAME_GROOVE|LAYOUT_LEFT
		|LAYOUT_FILL_Y,0,0,0,0, 4,4,4,4, 4, 4);

	FXHorizontalFrame *frmBotones = new FXHorizontalFrame(gbItems, LAYOUT_BOTTOM|LAYOUT_FILL_X);
	new FXButton(frmBotones, "Nueva", NULL, this, dlgReglas::ID_NEW_REGLA
		, LAYOUT_LEFT|FRAME_RAISED);
	new FXButton(frmBotones, "Eliminar", NULL, this, dlgReglas::ID_DEL_REGLA
		, LAYOUT_LEFT|FRAME_RAISED);

	lstReglas = new FXList(gbItems, this, dlgReglas::ID_INDEX
		,LIST_BROWSESELECT|HSCROLLER_NEVER|LAYOUT_FIX_WIDTH|LAYOUT_TOP|LAYOUT_FILL_Y
		, 0, 0, 150, 400);


	// Datos Regla Actual
	// Conectamos a la copia local del Dialogo
	indxRegla = 0;
	nomActual = reglas[0].nombre;
	patActual = reglas[0].patron;
	fgActual = reglas[0].colorFG;
	bgActual = reglas[0].colorBG;

	tgtNombre.connect(nomActual);
	tgtNombre.setTarget(this);
	tgtNombre.setSelector(ID_CAMBIO_NOM);

	tgtPatron.connect(patActual);
	tgtPatron.setTarget(this);
	tgtPatron.setSelector(ID_CAMBIO_PAT);

	tgtColorFG.connect(fgActual);
	tgtColorFG.setTarget(this);
	tgtColorFG.setSelector(ID_CAMBIO_FG);

	tgtColorBG.connect(bgActual);
	tgtColorBG.setTarget(this);
	tgtColorBG.setSelector(ID_CAMBIO_BG);


	FXVerticalFrame *vertDatos = new FXVerticalFrame(horiz, LAYOUT_LEFT|LAYOUT_FILL_Y);

	new FXLabel(vertDatos, "Nombre");
	tfNombre = new FXTextField(vertDatos, 20, &tgtNombre, FXDataTarget::ID_VALUE);
	tfNombre->setText("<Nuevo>");

	new FXLabel(vertDatos, "Patron");
	tfPatron = new FXTextField(vertDatos, 20, &tgtPatron, FXDataTarget::ID_VALUE);
	tfPatron->setText("<Patron>");

	FXMatrix *matColores = new FXMatrix(vertDatos, 2);

	new FXLabel(matColores, "Color Frente:");
	new FXLabel(matColores, "Color Fondo:");	

	new FXColorWell(matColores,FXRGB(0,0,0), &tgtColorFG, FXDataTarget::ID_VALUE
		,FRAME_SUNKEN|FRAME_THICK
		|LAYOUT_LEFT|LAYOUT_CENTER_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT
		|LAYOUT_FILL_ROW,0,0,40,24);


	new FXColorWell(matColores,FXRGB(255,255,255), &tgtColorBG, FXDataTarget::ID_VALUE
		,FRAME_SUNKEN|FRAME_THICK
		|LAYOUT_LEFT|LAYOUT_CENTER_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT
		|LAYOUT_FILL_ROW,0,0,40,24);
	
	// Parte inferior

	new FXHorizontalSeparator(vert,SEPARATOR_RIDGE|LAYOUT_FILL_X);

	FXHorizontalFrame *closebox = new FXHorizontalFrame(vert
		,LAYOUT_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH);

	new FXButton(closebox,"&Aceptar",NULL, this, FXDialogBox::ID_ACCEPT
		,BUTTON_INITIAL|BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0, 20,20);
	new FXButton(closebox,"&Cancelar",NULL, this, FXDialogBox::ID_CANCEL
		,BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0, 20,20);

	}
Example #15
0
long 
GNEFrame::GenericParametersEditor::onCmdSetGenericParameter(FXObject*, FXSelector, void*) {
    // separate value in a vector of string using | as separator
    std::vector<std::string> parsedValues;
    StringTokenizer st(myTextFieldGenericParameter->getText().text(), "|", true);
    while (st.hasNext()) {
        parsedValues.push_back(st.next());
    }
    // first check if parsed generic parameters are valid
    for(auto i : parsedValues) {
        if(!GNEAttributeCarrier::isGenericParametersValid(i)) {
            WRITE_WARNING("Invalid format of Generic Parameter (" + i + ")");
            myTextFieldGenericParameter->setTextColor(FXRGB(255, 0, 0));
            return 1;
        }
    }
    // now check if there is duplicated parameters
    std::sort(parsedValues.begin(), parsedValues.end());
    for (auto i = parsedValues.begin(); i != parsedValues.end(); i++) {
        if(((i+1) != parsedValues.end())) {
            std::vector<std::string> firstKey, secondKey;
            StringTokenizer stKey1(*i, "=", true);
            StringTokenizer stKey2(*(i+1), "=", true);
            //parse both keys
            while (stKey1.hasNext()) {
                firstKey.push_back(stKey1.next());
            }
            while (stKey2.hasNext()) {
                secondKey.push_back(stKey2.next());
            }
            // compare both keys and stop if are equal
            if((firstKey.size() != 2) || (secondKey.size() != 2) || (firstKey.front() == secondKey.front())) {
                WRITE_WARNING("Generic Parameters wit the same key aren't allowed (" + (*i) + "," + *(i+1) + ")");
                myTextFieldGenericParameter->setTextColor(FXRGB(255, 0, 0));
                return 1;
            }
        }
    }
    // parsed generic parameters ok, then set text field black and continue
    myTextFieldGenericParameter->setTextColor(FXRGB(0, 0, 0));
    myTextFieldGenericParameter->killFocus();
    // clear current existent generic parameters and set parsed generic parameters
    myGenericParameters->clear();
    for(auto i : parsedValues) {
        std::vector<std::string> parsedParameters;
        StringTokenizer stParam(i, "=", true);
        while (stParam.hasNext()) {
            parsedParameters.push_back(stParam.next());
        }
        // Check that parsed parameters are exactly two and contains valid chracters
        if(parsedParameters.size() == 2 && SUMOXMLDefinitions::isValidNetID(parsedParameters.front()) && SUMOXMLDefinitions::isValidAttribute(parsedParameters.back())) {
            myGenericParameters->push_back(std::make_pair(parsedParameters.front(), parsedParameters.back()));
        }
    }
    // if we're editing generic attributes of an AttributeCarrier, set it
    if(myAC) {
        myAC->setAttribute(GNE_ATTR_GENERIC, getGenericParametersStr(), myFrameParent->getViewNet()->getUndoList());
    } else if (myACs.size() > 0) {
        myFrameParent->getViewNet()->getUndoList()->p_begin("Change multiple generic attributes");
        for (auto i : myACs) {
            i->setAttribute(GNE_ATTR_GENERIC, getGenericParametersStr(), myFrameParent->getViewNet()->getUndoList());
        }
        myFrameParent->getViewNet()->getUndoList()->p_end();
    }
    return 1;
}
Example #16
0
void
GNEFrame::openHelpAttributesDialog(SumoXMLTag elementTag) const {
    FXDialogBox *attributesHelpDialog = new FXDialogBox(myScrollWindowsContents, ("Parameters of " + toString(elementTag)).c_str(), GUIDesignDialogBoxResizable, 0, 0, 0, 0, 10, 10, 10, 38, 4, 4);
    // Create FXTable
    FXTable* myTable = new FXTable(attributesHelpDialog, attributesHelpDialog, MID_TABLE, GUIDesignTableNotEditable);
    attributesHelpDialog->setIcon(GUIIconSubSys::getIcon(ICON_MODEINSPECT));
    const auto &attrs = GNEAttributeCarrier::getTagProperties(elementTag);
    int sizeColumnDescription = 0;
    int sizeColumnDefinitions = 0;
    myTable->setVisibleRows((FXint)(attrs.getNumberOfAttributes()));
    myTable->setVisibleColumns(3);
    myTable->setTableSize((FXint)(attrs.getNumberOfAttributes()), 3);
    myTable->setBackColor(FXRGB(255, 255, 255));
    myTable->setColumnText(0, "Attribute");
    myTable->setColumnText(1, "Description");
    myTable->setColumnText(2, "Definition");
    myTable->getRowHeader()->setWidth(0);
    // Iterate over vector of additional parameters
    int itemIndex = 0;
    for (auto i : attrs) {
        // Set attribute 
        FXTableItem* attribute = new FXTableItem(toString(i.first).c_str());
        attribute->setJustify(FXTableItem::CENTER_X);
        myTable->setItem(itemIndex, 0, attribute);
        // Set description of element
        FXTableItem* type = new FXTableItem("");
        type->setText(i.second.getDescription().c_str());
        sizeColumnDescription = MAX2(sizeColumnDescription, (int)i.second.getDescription().size());
        type->setJustify(FXTableItem::CENTER_X);
        myTable->setItem(itemIndex, 1, type);
        // Set definition
        FXTableItem* definition = new FXTableItem(i.second.getDefinition().c_str());
        definition->setJustify(FXTableItem::LEFT);
        myTable->setItem(itemIndex, 2, definition);
        sizeColumnDefinitions = MAX2(sizeColumnDefinitions, (int)i.second.getDefinition().size());
        itemIndex++;
    }
    // set header
    FXHeader* header = myTable->getColumnHeader();
    header->setItemJustify(0, JUSTIFY_CENTER_X);
    header->setItemSize(0, 120);
    header->setItemJustify(1, JUSTIFY_CENTER_X);
    header->setItemSize(1, sizeColumnDescription * 7);
    header->setItemJustify(2, JUSTIFY_CENTER_X);
    header->setItemSize(2, sizeColumnDefinitions * 6);
    // Create horizontal separator
    new FXHorizontalSeparator(attributesHelpDialog, GUIDesignHorizontalSeparator);
    // Create frame for OK Button
    FXHorizontalFrame* myHorizontalFrameOKButton = new FXHorizontalFrame(attributesHelpDialog, GUIDesignAuxiliarHorizontalFrame);
    // Create Button Close (And two more horizontal frames to center it)
    new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
    new FXButton(myHorizontalFrameOKButton, "OK\t\tclose", GUIIconSubSys::getIcon(ICON_ACCEPT), attributesHelpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
    new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
    // Write Warning in console if we're in testing mode
    if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
        WRITE_WARNING("Opening HelpAttributes dialog for tag '" + toString(elementTag) + "' showing " + toString(attrs.getNumberOfAttributes()) + " attributes");
    }
    // create Dialog
    attributesHelpDialog->create();
    // show in the given position
    attributesHelpDialog->show(PLACEMENT_CURSOR);
    // refresh APP
    getApp()->refresh();
    // open as modal dialog (will block all windows until stop() or stopModal() is called)
    getApp()->runModalFor(attributesHelpDialog);
    // Write Warning in console if we're in testing mode
    if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
        WRITE_WARNING("Closing HelpAttributes dialog for tag '" + toString(elementTag) + "'");
    }
}
Example #17
0
void
GNEInspectorFrame::AttrInput::showAttribute(SumoXMLTag tag, SumoXMLAttr attr, const std::string& value) {
    // Set actual Tag and attribute
    myTag = tag;
    myAttr = attr;
    // ShowLabel
    myLabel->setText(toString(myAttr).c_str());
    myLabel->show();
    // Set field depending of the type of value
    if (GNEAttributeCarrier::isBool(myTag, myAttr)) {
        // set value of checkbox
        myCheckBox->setCheck(GNEAttributeCarrier::parse<bool>(value));
        myCheckBox->show();
    } else if (GNEAttributeCarrier::isDiscrete(myTag, myAttr)) {
        // Obtain choices
        const std::vector<std::string>& choices = GNEAttributeCarrier::discreteChoices(myTag, myAttr);
        // Check if are combinable coices
        if (choices.size() > 0 && GNEAttributeCarrier::discreteCombinableChoices(myTag, myAttr)) {
            // hide label
            myLabel->hide();
            // Show button combinable choices
            myButtonCombinableChoices->setText(toString(myAttr).c_str());
            myButtonCombinableChoices->show();
            // Show string with the values
            myTextFieldStrings->setText(value.c_str());
            myTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
            myTextFieldStrings->show();
        } else {
            // fill comboBox
            myChoicesCombo->clearItems();
            for (std::vector<std::string>::const_iterator it = choices.begin(); it != choices.end(); ++it) {
                myChoicesCombo->appendItem(it->c_str());
            }
            myChoicesCombo->setNumVisible((int)choices.size());
            myChoicesCombo->setCurrentItem(myChoicesCombo->findItem(value.c_str()));
            myChoicesCombo->show();
        }
    } else if (GNEAttributeCarrier::isFloat(myTag, myAttr)) {
        // show TextField for real values
        myTextFieldReal->setText(value.c_str());
        myTextFieldReal->setTextColor(FXRGB(0, 0, 0));
        myTextFieldReal->show();
    } else if (GNEAttributeCarrier::isInt(myTag, myAttr)) {
        // Show textField for int attributes
        myTextFieldInt->setText(value.c_str());
        myTextFieldInt->setTextColor(FXRGB(0, 0, 0));
        myTextFieldInt->show();
    } else if (GNEAttributeCarrier::isTime(myTag, myAttr)) {
        // Show myTimeSpinDial for Time attributes
        myTimeSpinDial->setValue((int)GNEAttributeCarrier::parse<SUMOReal>(value));
        myTimeSpinDial->setTextColor(FXRGB(0, 0, 0));
        myTimeSpinDial->show();
    } else {
        // In any other case (String, list, etc.), show value as String
        myTextFieldStrings->setText(value.c_str());
        myTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
        myTextFieldStrings->show();
    }
    // Show AttrInput
    show();
}
MrsvrPlotCanvas::MrsvrPlotCanvas(FXComposite* p, FXuint opts, FXint x,
                                 FXint y,FXint w,FXint h) 
  :FXCanvas(p, this, MrsvrPlotCanvas::ID_PLOT, opts, x, y, w, h)
{


#ifdef DEBUG_MRSVR_PLOT_CANVAS
  printf("MrsvrPlotCanvas::MrsvrPlotCanvas()\n");
#endif //DEBUG_MRSVR_PLOT_CANVAS

  // initilaize control parameter
  //gain = 100;
  //yOffset = 0;
  // set colors
  colorBg   = FXRGB(0,0,0);
  colorAxis = FXRGB(180,180,180);

  windowSizeX = 0;
  windowSizeY = 0;
  
  xAxisWidth = 1;
  yAxisWidth = 1;

  pZeroX      = 0.0;
  //pZeroY      = 0.9;
  pZeroY      = 0.5;

  pXAxisMin   = 0.0;
  pXAxisMax   = 1.0;
  pYAxisMin   = 1.0;
  pYAxisMax   = 0.0;
  pXAxisIntv  = 0.0;
  pYAxisIntv  = 0.0;

  pXLabelX    = pXAxisMax;
  pXLabelY    = pZeroY;
  pYLabelX    = pZeroX;
  pYLabelY    = pYAxisMax;

  windowMargTop = 25;
  windowMargBot = 25;
  windowMargLt  = 30;
  windowMargRt  = 25;

  windowSizeX = 0;
  windowSizeY = 0;
  
  maxPoints    = 0;
  pointsBuffer = NULL;

  numGradX     = 0;
  numGradY     = 0;
  
  // initialize line parameters
  nLines = 0;
  lineDrawFunction = (FXFunction)BLT_SRC;
  lineCapStyle     = (FXCapStyle)CAP_BUTT;
  lineJoinStyle    = (FXJoinStyle)JOIN_ROUND;

  xLabel           = new FXString("x");
  yLabel           = new FXString("y");

  gradSpaceX       = 10;
  gradSpaceY       = 10;

  pUnitX            = (pXAxisMax-pXAxisMin) / 100.0;
  pUnitY            = (pYAxisMax-pYAxisMin) / 100.0;

  calcAxisParam();

  for (int i = 0; i < PLOT_NUM_DATA; i ++) {
    plotPoints[i] = 0;
    plotCursor[i] = 0;

    lineColor[i]  = FXRGB(255,255,255);
    lineStyle[i]  = (FXLineStyle)LINE_SOLID;
    lineWidth[i]  = 1;
    lineStepX[i]  = 0.1;
    offsetY[i]    = 0.0;
    scaleY[i]     = 1.0;
  }

  offsetYAll = 0.0;
  scaleYAll  = 1.0;

  triggerFd = -1;
  plotMode  = MODE_REFRESH_ALL;

  // GUI component
  parentComp = p;
  labelFont  = new FXFont(parentComp->getApp(), "helvetica", 9);
  
  w = ((w == 0)? 1000 : w);
  h = ((h == 0)? 1000 : w);
  offscreen  = new FXImage(parentComp->getApp(), NULL, 
                           IMAGE_SHMI|IMAGE_SHMP|IMAGE_KEEP, w, h);

}
Example #19
0
void FOX16_HtmlCtx::_paintAt(FXDC *dc, HTML_OBJECT *o,
                             int xOffset, int yOffset,
                             int xText, int yText,
                             int w, int h) {
  HTML_OBJECT *c;
  int x;
  int y;
  int printX;
  int printY;
  int objectW;
  int objectH;

  x=xText+HtmlObject_GetX(o);
  y=yText+HtmlObject_GetY(o);
  objectW=HtmlObject_GetWidth(o);
  objectH=HtmlObject_GetHeight(o);

  printX=x-xOffset;
  printY=y-yOffset;

  if (printX<w && printX+objectW>=0 &&
      printY<h && printY+objectH>=0) {
    switch(HtmlObject_GetObjectType(o)) {
#if 0
    case HtmlObjectType_Grid:
      dc->setForeground(FXRGB(255,0,0));
      dc->fillRectangle(printX, printY,
                        HtmlObject_GetWidth(o),
                        HtmlObject_GetHeight(o));
#endif
    case HtmlObjectType_Word: {
      HTML_PROPS *pr;
      HTML_FONT *fnt;
      FXFont *xfnt;
      int ascent=0;
      uint32_t col;

      pr=HtmlObject_GetProperties(o);

      /* select font */
      fnt=HtmlProps_GetFont(pr);
      xfnt=_getFoxFont(fnt);
      if (xfnt) {
        dc->setFont(xfnt);
        ascent=xfnt->getFontAscent();
      }

      /* select foreground color */
      col=HtmlProps_GetForegroundColor(pr);
      if (col==HTML_PROPS_NOCOLOR)
        dc->setForeground(_fgColor);
      else
        dc->setForeground(col);

      /* select background color */
      col=HtmlProps_GetBackgroundColor(pr);
      if (col==HTML_PROPS_NOCOLOR)
        dc->setBackground(_bgColor);
      else
        dc->setBackground(col);

      dc->drawText(printX, printY+ascent, HtmlObject_GetText(o));
      break;
    }

    case HtmlObjectType_Image: {
      HTML_IMAGE *img;

      img=HtmlObject_Image_GetImage(o);
      if (img) {
        FXImage *ximg;

        ximg=GWEN_INHERIT_GETDATA(HTML_IMAGE, FXImage, img);
        if (ximg) {
          HTML_PROPS *pr;
          uint32_t col;

          pr=HtmlObject_GetProperties(o);

          /* select background color */
          col=HtmlProps_GetBackgroundColor(pr);
          if (col==HTML_PROPS_NOCOLOR) {
            dc->setBackground(_bgColor);
            dc->setForeground(_bgColor);
          }
          else {
            dc->setBackground(col);
            dc->setForeground(col);
          }
          dc->fillRectangle(printX, printY, ximg->getWidth(), ximg->getHeight());

          dc->drawImage(ximg, printX, printY);
        }
      }
      break;
    }
    default:
      break;
    }


    c=HtmlObject_Tree_GetFirstChild(o);
    while(c) {
      _paintAt(dc, c, xOffset, yOffset, x, y, w, h);
      c=HtmlObject_Tree_GetNext(c);
    }
  }
}
Example #20
0
// File selector object
FileSelector::FileSelector(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):
        FXPacker(p,opts,x,y,w,h,0,0,0,0,0,0)
{
	FXAccelTable *table=getShell()->getAccelTable();
    target=tgt;
    message=sel;
    
    // Global container
    FXVerticalFrame* cont=new FXVerticalFrame(this,LAYOUT_FILL_Y|LAYOUT_FILL_X|FRAME_NONE,0,0,0,0, 0,0,0,0, 0,0);

    // Container for the action buttons
    FXHorizontalFrame* buttons=new FXHorizontalFrame(cont,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED,0,0,0,0, 5,5,5,5, 0,0);
    
    // Container for the path linker
    FXHorizontalFrame* pathframe=new FXHorizontalFrame(cont,LAYOUT_FILL_X|FRAME_RAISED,0,0,0,0, 0,0,0,0, 0,0);

	// File list
	FXuint options = _ICONLIST_BROWSESELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y;

	FXbool thumbnails=getApp()->reg().readUnsignedEntry("FILEDIALOG","thumbnails",FALSE);
    list=new FileList(this,cont,this,ID_FILELIST,thumbnails,options);
    
	// Set list colors and columns size for detailed mode
	list->setTextColor(getApp()->reg().readColorEntry("SETTINGS","listforecolor",FXRGB(0,0,0)));
	list->setBackColor(getApp()->reg().readColorEntry("SETTINGS","listbackcolor",FXRGB(255,255,255)));
	list->setHeaderSize(0,getApp()->reg().readUnsignedEntry("FILEDIALOG","name_size",200));
    list->setHeaderSize(1,getApp()->reg().readUnsignedEntry("FILEDIALOG","size_size",60));
    list->setHeaderSize(2,getApp()->reg().readUnsignedEntry("FILEDIALOG","type_size",100));
    list->setHeaderSize(3,getApp()->reg().readUnsignedEntry("FILEDIALOG","ext_size",100));
    list->setHeaderSize(4,getApp()->reg().readUnsignedEntry("FILEDIALOG","modd_size",150));
    list->setHeaderSize(5,getApp()->reg().readUnsignedEntry("FILEDIALOG","user_size",50));
    list->setHeaderSize(6,getApp()->reg().readUnsignedEntry("FILEDIALOG","grou_size",50));
    list->setHeaderSize(7,getApp()->reg().readUnsignedEntry("FILEDIALOG","attr_size",100));  	
	
	// Set file selector options
	FXbool hiddenfiles=getApp()->reg().readUnsignedEntry("FILEDIALOG","hiddenfiles",FALSE);
	showHiddenFiles(hiddenfiles);

	FXuint listmode=getApp()->reg().readUnsignedEntry("FILEDIALOG","listmode",0);
	setFileBoxStyle(listmode);

    // Entry buttons
    FXMatrix* fields=new FXMatrix(cont,3,MATRIX_BY_COLUMNS|LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X);
    new FXLabel(fields,_("&File Name:"),NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y);
    filename=new FXTextField(fields,25,this,ID_ACCEPT,TEXTFIELD_ENTER_ONLY|LAYOUT_FILL_COLUMN|LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK);
    new FXButton(fields,_("&OK"),NULL,this,ID_ACCEPT,BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X,0,0,0,0,20,20);
    accept=new FXButton(buttons,FXString::null,NULL,NULL,0,LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,0,0,0,0, 0,0,0,0);
    new FXLabel(fields,_("File F&ilter:"),NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y);
    FXHorizontalFrame* filterframe=new FXHorizontalFrame(fields,LAYOUT_FILL_COLUMN|LAYOUT_FILL_X|LAYOUT_FILL_Y);
  	filefilter=new FXComboBox(filterframe,10,this,ID_FILEFILTER,COMBOBOX_STATIC|FRAME_SUNKEN|LAYOUT_FILL_X);
  	filefilter->setNumVisible(4);

    readonly=new FXCheckButton(filterframe,_("Read Only"),NULL,0,ICON_BEFORE_TEXT|JUSTIFY_LEFT|LAYOUT_CENTER_Y);
    cancel=new FXButton(fields,_("&Cancel"),NULL,NULL,0,BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X,0,0,0,0,20,20);

    // Action buttons
    FXString key;
	FXHotKey hotkey;
	FXButton *btn;
	FXToggleButton *tglbtn;
	
	new FXFrame(buttons,LAYOUT_FIX_WIDTH,0,0,4,1);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_back","Ctrl-Backspace");
    btn=new FXButton(buttons,TAB+_("Go to previous directory")+PARS(key),dirbackicon,this,ID_DIR_BACK,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	btnbackhist=new FXArrowButton(buttons,this,ID_DIR_BACK_HIST,LAYOUT_FILL_Y|FRAME_RAISED|FRAME_THICK|ARROW_DOWN|ARROW_TOOLBAR);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_forward","Shift-Backspace");
    btn=new FXButton(buttons,TAB+_("Go to next directory")+PARS(key),dirforwardicon,this,ID_DIR_FORWARD,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	btnforwardhist=new FXArrowButton(buttons,this,ID_DIR_FORWARD_HIST,LAYOUT_FILL_Y|FRAME_RAISED|FRAME_THICK|ARROW_DOWN|ARROW_TOOLBAR);
	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_up","Backspace");
    btn=new FXButton(buttons,TAB+_("Go to parent directory")+PARS(key),dirupicon,this,ID_DIR_UP,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

 	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_home","Ctrl-H");
    btn=new FXButton(buttons,TAB+_("Go to home directory")+PARS(key),homeicon,this,ID_HOME,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

 	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_work","Shift-F2");
    btn=new FXButton(buttons,TAB+_("Go to working directory")+PARS(key),workicon,this,ID_WORK,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","new_folder","F7");
    btn=new FXButton(buttons,TAB+_("New folder")+PARS(key),newfoldericon,this,ID_NEWDIR,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","big_icons","F10");
    btn=new FXButton(buttons,TAB+_("Big icon list")+PARS(key),bigiconsicon,list,FileList::ID_SHOW_BIG_ICONS,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","small_icons","F11");
    btn=new FXButton(buttons,TAB+_("Small icon list")+PARS(key),smalliconsicon,list,FileList::ID_SHOW_MINI_ICONS,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","detailed_file_list","F12");
    btn=new FXButton(buttons,TAB+_("Detailed file list")+PARS(key),detailsicon,list,FileList::ID_SHOW_DETAILS,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","hidden_files","Ctrl-F6");
    tglbtn=new FXToggleButton(buttons,TAB+_("Show hidden files")+PARS(key),TAB+_("Hide hidden files")+PARS(key),showhiddenicon,hidehiddenicon,list,FileList::ID_TOGGLE_HIDDEN,TOGGLEBUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	tglbtn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","thumbnails","Ctrl-F7");
    tglbtn=new FXToggleButton(buttons,TAB+_("Show thumbnails")+PARS(key),TAB+_("Hide thumbnails")+PARS(key),showthumbicon,hidethumbicon,list,FileList::ID_TOGGLE_THUMBNAILS,TOGGLEBUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	tglbtn->addHotKey(hotkey);

	// Path text
	pathtext=new TextLabel(pathframe,0,this,0,LAYOUT_FILL_X|LAYOUT_FILL_Y);
	pathtext->setBackColor(getApp()->getBaseColor());

    // Path linker
    pathlink = new PathLinker(pathframe,list,NULL,LAYOUT_FILL_X);

    readonly->hide();
  	if(table)
	{
 		FXString key;
		FXHotKey hotkey;
		
  		key=getApp()->reg().readStringEntry("KEYBINDINGS","select_all","Ctrl-A");
		hotkey=_parseAccel(key);	
		table->addAccel(hotkey,list,FXSEL(SEL_COMMAND,FileList::ID_SELECT_ALL));
  	
		key=getApp()->reg().readStringEntry("KEYBINDINGS","deselect_all","Ctrl-Z");
		hotkey=_parseAccel(key);	
		table->addAccel(hotkey,list,FXSEL(SEL_COMMAND,FileList::ID_DESELECT_ALL));
	
  		key=getApp()->reg().readStringEntry("KEYBINDINGS","invert_selection","Ctrl-I");
		hotkey=_parseAccel(key);	
		table->addAccel(hotkey,list,FXSEL(SEL_COMMAND,FileList::ID_SELECT_INVERSE));
	
		key=getApp()->reg().readStringEntry("KEYBINDINGS","new_file","F2");
		hotkey=_parseAccel(key);	
		table->addAccel(hotkey,this,FXSEL(SEL_COMMAND,ID_NEWFILE));
    }

    setSelectMode(SELECT_FILE_ANY);                          // For backward compatibility, this HAS to be the default!
    setPatternList(allfiles);
    setDirectory(FXSystem::getCurrentDirectory());           // Update file list
   	pathlink->setPath(FXSystem::getCurrentDirectory());      // Update path linker
   	pathtext->setText(FXSystem::getCurrentDirectory());      // Update path text

    list->setFocus();
    accept->hide();

	// Change default cursor if single click navigation
	if (single_click==SINGLE_CLICK_DIR_FILE)
		list->setDefaultCursor(getApp()->getDefaultCursor(DEF_HAND_CURSOR));
}
Example #21
0
CDPreferences::CDPreferences(CDWindow* owner)
    : FXDialogBox(owner,"CD Player Preferences",DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE,0,0,400,0, 0,0,0,0),
      showmenubar(owner->menubar->shown()),
      showstatusbar(owner->statusbar->shown()),
      showtooltips(owner->tooltip!=NULL),
      lcdforeclr(owner->lcdforeclr),
      lcdbackclr(owner->lcdbackclr),
      iconclr(owner->iconclr),
      startmode(owner->startmode),
      stoponexit(owner->stoponexit),
      intro(owner->cdplayer.getIntro()),
      introtime(owner->cdplayer.getIntroLength()),
      random(owner->cdplayer.getRandom()),
      repeatmode(owner->cdplayer.getRepeatMode()),
      timemode(owner->canvas->getTimeMode()),
      initseekrate(owner->initseekrate),
      fastseekrate(owner->fastseekrate),
      fastseekstart(owner->fastseekstart),
      usecddb(owner->usecddb),
      cddbsettings(owner->cddbsettings),
      cdwindow(owner)
{
    showmenubartgt.connect(showmenubar);
    showstatusbartgt.connect(showstatusbar);
    showtooltipstgt.connect(showtooltips);
    lcdforeclrtgt.connect(lcdforeclr);
    lcdbackclrtgt.connect(lcdbackclr);
    iconclrtgt.connect(iconclr);
    startmodetgt.connect(startmode);
    stoponexittgt.connect(stoponexit);
    introtgt.connect(intro);
    introtimetgt.connect(introtime);
    randomtgt.connect(random);
    repeatmodetgt.connect(repeatmode);
    timemodetgt.connect(timemode);
    initseekratetgt.connect(initseekrate),
                            fastseekratetgt.connect(fastseekrate),
                            fastseekstarttgt.connect(fastseekstart),
                            usecddbtgt.connect(usecddb);
    proxytgt.connect(cddbsettings.proxy);
    proxyporttgt.connect(cddbsettings.proxyport);
    proxyaddrtgt.connect(cddbsettings.proxyaddr);
    cddbprototgt.connect(cddbsettings.cddbproto,this,ID_CDDBPROTOCHANGED);
    cddbcurrentporttgt.connect((cddbsettings.cddbproto==CDDB_PROTOCOL_HTTP)?cddbsettings.cddbport:cddbsettings.cddbpport);
    cddbaddrtgt.connect(cddbsettings.cddbaddr);
    cbbdpromptmultipletgt.connect(cddbsettings.promptmultiple);
    cbbdlocalcopytgt.connect(cddbsettings.localcopy);

    FXVerticalFrame* contents=new FXVerticalFrame(this,LAYOUT_FILL_X|LAYOUT_FILL_Y);
    FXHorizontalFrame* buttons=new FXHorizontalFrame(contents,PACK_UNIFORM_WIDTH|LAYOUT_BOTTOM|LAYOUT_FILL_X);
    new FXButton(buttons,"&Accept",NULL,this,CDPreferences::ID_ACCEPT,BUTTON_INITIAL|BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0, 20,20);
    new FXButton(buttons,"A&pply",NULL,this,CDPreferences::ID_APPLY,LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0, 20,20);
    new FXButton(buttons,"&Cancel",NULL,this,FXDialogBox::ID_CANCEL,LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0, 20,20);
    new FXHorizontalSeparator(contents,SEPARATOR_RIDGE|LAYOUT_BOTTOM|LAYOUT_FILL_X);

    FXHorizontalFrame* primary=new FXHorizontalFrame(contents,LAYOUT_FILL_X|LAYOUT_FILL_Y);
    FXVerticalFrame* listframe=new FXVerticalFrame(primary,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FIX_WIDTH|LAYOUT_FILL_Y,0,0,120,0, 0,0,0,0, 0,0);
    new FXLabel(listframe,"Category",NULL,JUSTIFY_LEFT|FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X);

    tree=new FXTreeList(listframe,this,ID_LIST,TREELIST_BROWSESELECT|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|LAYOUT_FILL_X|LAYOUT_FILL_Y);

    treeitem.push_back(tree->appendItem(0,"Appearance",NULL,NULL));
    treeitem.push_back(tree->appendItem(treeitem[CDPREFS_APPEARANCE],"Colors",NULL,NULL));
    treeitem.push_back(tree->appendItem(0,"Options",NULL,NULL));
    treeitem.push_back(tree->appendItem(treeitem[CDPREFS_OPTIONS],"Display",NULL,NULL));
    treeitem.push_back(tree->appendItem(treeitem[CDPREFS_OPTIONS],"Player",NULL,NULL));
    treeitem.push_back(tree->appendItem(treeitem[CDPREFS_OPTIONS],"Seek",NULL,NULL));
    treeitem.push_back(tree->appendItem(0,"Hardware",NULL,NULL));
    treeitem.push_back(tree->appendItem(0,"Internet",NULL, NULL));

    tree->expandTree(treeitem[CDPREFS_APPEARANCE]);
    tree->expandTree(treeitem[CDPREFS_OPTIONS]);

    switcher=new FXSwitcher(primary,LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);

    // Appearance panel
    FXVerticalFrame* settingsframe=new FXVerticalFrame(switcher,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(settingsframe,"Appearance");
    new FXHorizontalSeparator(settingsframe,SEPARATOR_LINE|LAYOUT_FILL_X);

    FXGroupBox* settingsbox=new FXGroupBox(settingsframe,"Player Appearance",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXVerticalFrame* appbtnsframe=new FXVerticalFrame(settingsbox,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXCheckButton(appbtnsframe,"Show Menu Bar",&showmenubartgt,FXDataTarget::ID_VALUE,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    new FXCheckButton(appbtnsframe,"Show Status Bar",&showstatusbartgt,FXDataTarget::ID_VALUE,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    new FXCheckButton(appbtnsframe,"Show Tool Tips",&showtooltipstgt,FXDataTarget::ID_VALUE,ICON_BEFORE_TEXT|JUSTIFY_LEFT);

    // Colors panel
    FXVerticalFrame* colorsframe=new FXVerticalFrame(switcher,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(colorsframe,"Colors");
    new FXHorizontalSeparator(colorsframe,SEPARATOR_LINE|LAYOUT_FILL_X);

    FXGroupBox* colorsbox=new FXGroupBox(colorsframe,"Display Colors",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXMatrix *colorsmatrix=new FXMatrix(colorsbox,3,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(colorsmatrix,"Display Foreground Color:",NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FILL_ROW);
    new FXLabel(colorsmatrix,"Display Background Color:",NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FILL_ROW);
    new FXLabel(colorsmatrix,"Button Icon Color:",NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FILL_ROW);
    new FXColorWell(colorsmatrix,FXRGB(0,0,0),&lcdforeclrtgt,FXDataTarget::ID_VALUE,COLORWELL_OPAQUEONLY|FRAME_SUNKEN|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW,0,0,40,24);
    new FXColorWell(colorsmatrix,FXRGB(0,0,0),&lcdbackclrtgt,FXDataTarget::ID_VALUE,COLORWELL_OPAQUEONLY|FRAME_SUNKEN|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW,0,0,40,24);
    new FXColorWell(colorsmatrix,FXRGB(0,0,0),&iconclrtgt,FXDataTarget::ID_VALUE,COLORWELL_OPAQUEONLY|FRAME_SUNKEN|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW,0,0,40,24);

    // Options panel
    FXVerticalFrame* optionsframe=new FXVerticalFrame(switcher,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(optionsframe,"Options");
    new FXHorizontalSeparator(optionsframe,SEPARATOR_LINE|LAYOUT_FILL_X);

    FXGroupBox* startbox=new FXGroupBox(optionsframe,"Startup Action",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXVerticalFrame* startframe=new FXVerticalFrame(startbox,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXRadioButton(startframe,"No Action",&startmodetgt,FXDataTarget::ID_OPTION+CDSTART_NONE,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    new FXRadioButton(startframe,"Start Play on Startup",&startmodetgt,FXDataTarget::ID_OPTION+CDSTART_START,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
#ifndef WIN32
    // Disable UI components for operations not supported on Windows
    new FXRadioButton(startframe,"Stop Play on Startup",&startmodetgt,FXDataTarget::ID_OPTION+CDSTART_STOP,ICON_BEFORE_TEXT|JUSTIFY_LEFT);

    FXGroupBox* stopbox=new FXGroupBox(optionsframe,"Exit Action",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXVerticalFrame* stopframe=new FXVerticalFrame(stopbox,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXCheckButton(stopframe,"Stop Play on Exit",&stoponexittgt,FXDataTarget::ID_VALUE,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
#endif

    // Display panel
    FXVerticalFrame* displayframe=new FXVerticalFrame(switcher,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(displayframe,"Display");
    new FXHorizontalSeparator(displayframe,SEPARATOR_LINE|LAYOUT_FILL_X);

    FXGroupBox* timemodebox=new FXGroupBox(displayframe,"Display Time Modes",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXVerticalFrame* timemodeframe=new FXVerticalFrame(timemodebox,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXRadioButton(timemodeframe,"Album",&timemodetgt,FXDataTarget::ID_OPTION+CDTIME_DISC,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    new FXRadioButton(timemodeframe,"Track",&timemodetgt,FXDataTarget::ID_OPTION+CDTIME_TRACK,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    new FXRadioButton(timemodeframe,"Album Remaining",&timemodetgt,FXDataTarget::ID_OPTION+CDTIME_DISCREM,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    new FXRadioButton(timemodeframe,"Track Remaining",&timemodetgt,FXDataTarget::ID_OPTION+CDTIME_TRACKREM,ICON_BEFORE_TEXT|JUSTIFY_LEFT);

    // Player panel
    FXVerticalFrame* playerframe=new FXVerticalFrame(switcher,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(playerframe,"Player");
    new FXHorizontalSeparator(playerframe,SEPARATOR_LINE|LAYOUT_FILL_X);

    FXGroupBox* playmodebox=new FXGroupBox(playerframe,"Play Modes",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXVerticalFrame* playmodeframe=new FXVerticalFrame(playmodebox,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXCheckButton(playmodeframe,"Shuffle Play",&randomtgt,FXDataTarget::ID_VALUE,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    new FXCheckButton(playmodeframe,"Intro Play",&introtgt,FXDataTarget::ID_VALUE,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    FXHorizontalFrame* introtimeframe=new FXHorizontalFrame(playmodeframe,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(introtimeframe,"Intro Length (seconds):",NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y|LAYOUT_FILL_X);
    new FXSpinner(introtimeframe,4,&introtimetgt,FXDataTarget::ID_VALUE,FRAME_THICK|FRAME_SUNKEN|LAYOUT_CENTER_Y|LAYOUT_RIGHT);

    FXGroupBox* repeatbox=new FXGroupBox(playerframe,"Repeat Mode",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXVerticalFrame* repeatframe=new FXVerticalFrame(repeatbox,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXRadioButton(repeatframe,"None",&repeatmodetgt,FXDataTarget::ID_OPTION+CDREPEAT_NONE,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    new FXRadioButton(repeatframe,"Track",&repeatmodetgt,FXDataTarget::ID_OPTION+CDREPEAT_TRACK,ICON_BEFORE_TEXT|JUSTIFY_LEFT);
    new FXRadioButton(repeatframe,"Album",&repeatmodetgt,FXDataTarget::ID_OPTION+CDREPEAT_DISC,ICON_BEFORE_TEXT|JUSTIFY_LEFT);

    // Seek panel
    FXVerticalFrame* seekframe=new FXVerticalFrame(switcher,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(seekframe,"Seek");
    new FXHorizontalSeparator(seekframe,SEPARATOR_LINE|LAYOUT_FILL_X);

    FXGroupBox* seekratebox=new FXGroupBox(seekframe,"Seek Rate",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXMatrix* seekratematrix=new FXMatrix(seekratebox,2,MATRIX_BY_COLUMNS|LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(seekratematrix,"Initial Seek Rate (seconds):",NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FILL_ROW);
    new FXSpinner(seekratematrix,4,&initseekratetgt,FXDataTarget::ID_VALUE,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_RIGHT);
    new FXLabel(seekratematrix,"Increase Seek Rate After (seconds):",NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FILL_ROW);
    new FXSpinner(seekratematrix,4,&fastseekstarttgt,FXDataTarget::ID_VALUE,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_RIGHT);
    new FXLabel(seekratematrix,"Increased Seek Rate (seconds):",NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FILL_ROW);
    new FXSpinner(seekratematrix,4,&fastseekratetgt,FXDataTarget::ID_VALUE,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_RIGHT);

    // Hardware panel
    FXVerticalFrame* hardframe=new FXVerticalFrame(switcher,LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);
    new FXLabel(hardframe,"Hardware");
    new FXHorizontalSeparator(hardframe,SEPARATOR_LINE|LAYOUT_FILL_X);

    FXGroupBox* hardbox=new FXGroupBox(hardframe,"CD Audio Device",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
    FXHorizontalFrame* devframe=new FXHorizontalFrame(hardbox,LAYOUT_FILL_X|LAYOUT_FILL_Y);
    FXVerticalFrame* devlistframe=new FXVerticalFrame(devframe,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0, 0,0);
    devlist=new FXList(devlistframe,NULL,0,LIST_BROWSESELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y);
    FXVerticalFrame* devbuttons=new FXVerticalFrame(devframe,PACK_UNIFORM_WIDTH,0,0,0,0, 0,0,0,0);
    FXVerticalFrame* devaddframe=new FXVerticalFrame(devbuttons,FRAME_SUNKEN|LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXButton(devaddframe,"Add",NULL,this,ID_DEVICEADD,FRAME_RAISED|LAYOUT_FILL_X,0,0,0,0, 20,20);
    FXVerticalFrame* devremframe=new FXVerticalFrame(devbuttons,FRAME_SUNKEN|LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXButton(devremframe,"Remove",NULL,this,ID_DEVICEREM,FRAME_RAISED|LAYOUT_FILL_X,0,0,0,0, 20,20);
    FXVerticalFrame* devscanframe=new FXVerticalFrame(devbuttons,FRAME_SUNKEN|LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXButton(devscanframe,"Scan",NULL,this,ID_DEVICESCAN,FRAME_RAISED|LAYOUT_FILL_X,0,0,0,0, 20,20);

    // Add devices to list
    FXint i,n=owner->bandtitle->getNumItems();
    FXString *data;

    // Look for device
    for(i=0; i<n; i++)
    {
        data=(FXString*)owner->bandtitle->getItemData(i);
        devlist->appendItem(*data);
    }

    // Internet panel
    FXVerticalFrame* internetframe=new FXVerticalFrame(switcher,LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
    new FXLabel(internetframe,"Internet");
    new FXHorizontalSeparator(internetframe,SEPARATOR_LINE|LAYOUT_FILL_X);

    FXGroupBox* infobox=new FXGroupBox(internetframe,"CD Info",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXVerticalFrame* infoframe=new FXVerticalFrame(infobox,LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);
    FXHorizontalFrame* cddbbuttons=new FXHorizontalFrame(infoframe,LAYOUT_FILL_X|LAYOUT_CENTER_Y,0,0,0,0, 0,0,0,0);
    new FXCheckButton(cddbbuttons,"Obtain info from CDDB",&usecddbtgt,FXDataTarget::ID_VALUE,CHECKBUTTON_NORMAL|LAYOUT_CENTER_Y);
    new FXButton(cddbbuttons,"Advanced...",NULL,this,ID_ADVANCEDCDDB,FRAME_THICK|FRAME_RAISED|LAYOUT_CENTER_Y|LAYOUT_RIGHT);
    new FXCheckButton(infoframe,"Prompt when multiple matches exist",&cbbdpromptmultipletgt,FXDataTarget::ID_VALUE,CHECKBUTTON_NORMAL|LAYOUT_CENTER_Y);
    new FXCheckButton(infoframe,"Keep local copy",&cbbdlocalcopytgt,FXDataTarget::ID_VALUE,CHECKBUTTON_NORMAL|LAYOUT_CENTER_Y);


    FXHorizontalFrame* cddbproto=new FXHorizontalFrame(infoframe,LAYOUT_FILL_X|LAYOUT_CENTER_Y,0,0,0,0, 0,0,0,0);
    new FXLabel(cddbproto,"Method:",NULL,LAYOUT_CENTER_Y);
    new FXRadioButton(cddbproto,"HTTP",&cddbprototgt,FXDataTarget::ID_OPTION+CDDB_PROTOCOL_HTTP,RADIOBUTTON_NORMAL|LAYOUT_CENTER_Y|LAYOUT_RIGHT);
    new FXRadioButton(cddbproto,"CDDBP",&cddbprototgt,FXDataTarget::ID_OPTION+CDDB_PROTOCOL_CDDBP,RADIOBUTTON_NORMAL|LAYOUT_CENTER_Y|LAYOUT_RIGHT);

    FXHorizontalFrame* cddbserv=new FXHorizontalFrame(infoframe,LAYOUT_FILL_X|LAYOUT_CENTER_Y,0,0,0,0, 0,0,0,0);
    new FXLabel(cddbserv,"Server:",NULL,LAYOUT_CENTER_Y);
    new FXTextField(cddbserv,0,&cddbaddrtgt,FXDataTarget::ID_VALUE,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_X);
    FXSpinner* cddbspinner=new FXSpinner(cddbserv,4,&cddbcurrentporttgt,FXDataTarget::ID_VALUE,FRAME_THICK|FRAME_SUNKEN|LAYOUT_RIGHT);
    cddbspinner->setRange(0,65535);

    new FXButton(infoframe,"Get Server List",NULL,this,ID_CDDBSERVERLIST,FRAME_THICK|FRAME_RAISED|LAYOUT_CENTER_Y|LAYOUT_RIGHT);


    FXGroupBox* proxybox=new FXGroupBox(internetframe,"Proxy Settings",GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
    FXVerticalFrame* proxyframe=new FXVerticalFrame(proxybox,LAYOUT_FILL_X|LAYOUT_CENTER_Y,0,0,0,0, 0,0,0,0);
    new FXCheckButton(proxyframe,"Use Proxy Server",&proxytgt,FXDataTarget::ID_VALUE,CHECKBUTTON_NORMAL|LAYOUT_CENTER_Y);
    FXHorizontalFrame* infoproxy=new FXHorizontalFrame(proxyframe,LAYOUT_FILL_X|LAYOUT_CENTER_Y,0,0,0,0, 0,0,0,0);
    new FXLabel(infoproxy,"Proxy:",NULL,LAYOUT_CENTER_Y);
    new FXTextField(infoproxy,0,&proxyaddrtgt,FXDataTarget::ID_VALUE,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_X);
    FXSpinner* proxyspinner=new FXSpinner(infoproxy,4,&proxyporttgt,FXDataTarget::ID_VALUE,FRAME_THICK|FRAME_SUNKEN|LAYOUT_RIGHT);
    proxyspinner->setRange(0,65535);

    new FXButton(internetframe,"Defaults",NULL,this,ID_DEFAULTINTERNET,FRAME_THICK|FRAME_RAISED|LAYOUT_RIGHT,0,0,0,0, 20,20);
}
Example #22
0
FXLinkLabel::FXLinkLabel(FXComposite* p,const FXString& text,FXIcon* ic,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb) :FXLabel(p,text,ic,opts,x,y,w,h,pl,pr,pt,pb) {
    setDefaultCursor(getApp()->getDefaultCursor(DEF_HAND_CURSOR));
    setTextColor(FXRGB(0,0,255));
}
FXTransferManager::FXTransferManager(FXWindow* owner,FXStringList & files,const FXString & destination,FXuint operation) :
    FXMainWindow(owner->getApp(),"Copying File(s)...",NULL,NULL,DECOR_TITLE|DECOR_BORDER,0,0,0,0,0,0,0,0), progress_bar(NULL) {

    FXFontDesc 				fontdescription;
    FXLabel  				* label=NULL;
    FXMatrix 				* matrix=NULL;
    FXVerticalFrame * main=NULL;
    FXint 						spacing=15;

//  if (icon)
//  	spacing=5;

    if (operation==OP_COPY) {
        setTitle("Copying File(s)...");
        transfer = new FXCopyFiles(this,FXTransferManager::ID_THREAD,files,destination);
    }
    else if (operation==OP_MOVE) {
        setTitle("Moving File(s)...");
        transfer = new FXMoveFiles(this,FXTransferManager::ID_THREAD,files,destination);
    }
    else if (operation==OP_DELETE) {
        setTitle("Deleting File(s)...");
        transfer = new FXRemoveFiles(this,FXTransferManager::ID_THREAD,files);
    }


    /// Create Title Font
    getApp()->getNormalFont()->getFontDesc(fontdescription);
    fontdescription.weight = FXFont::Bold;
    titlefont = new FXFont(getApp(),fontdescription);
    titlefont->create();

    main = new FXVerticalFrame(this,LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0,0,0,0,0,0,0);

    if (operation==OP_COPY)
        label = new FXLabel(main,"Copying File(s)...",NULL,LAYOUT_FILL_X|JUSTIFY_LEFT|TEXT_AFTER_ICON,0,0,0,0,spacing,spacing,spacing,0);
    else if (operation==OP_MOVE)
        label = new FXLabel(main,"Moving File(s)...",NULL,LAYOUT_FILL_X|JUSTIFY_LEFT|TEXT_AFTER_ICON,0,0,0,0,spacing,spacing,spacing,0);
    else if (operation==OP_DELETE)
        label = new FXLabel(main,"Deleting File(s)...",NULL,LAYOUT_FILL_X|JUSTIFY_LEFT|TEXT_AFTER_ICON,0,0,0,0,spacing,spacing,spacing,0);

    label->setBackColor(FXRGB(255,255,255));
    label->setFont(titlefont);

    label = new FXLabel(main,"Please wait. This may take a while.",NULL,LAYOUT_FILL_X|JUSTIFY_LEFT|TEXT_AFTER_ICON,0,0,0,0,spacing+30,spacing,0,spacing);
    label->setBackColor(FXRGB(255,255,255));

    new FXSeparator(main,SEPARATOR_GROOVE|LAYOUT_FILL_X);

    matrix = new FXMatrix(main,2,MATRIX_BY_COLUMNS|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0,15,15,15,15);

    if (operation==OP_COPY)
        new FXLabel(matrix,"Copied:",NULL,LABEL_NORMAL|LAYOUT_FILL_X|JUSTIFY_RIGHT|LAYOUT_CENTER_Y);
    else if (operation==OP_MOVE)
        new FXLabel(matrix,"Moved:",NULL,LABEL_NORMAL|LAYOUT_FILL_X|JUSTIFY_RIGHT|LAYOUT_CENTER_Y);
    else if (operation==OP_DELETE)
        new FXLabel(matrix,"Deleted:",NULL,LABEL_NORMAL|LAYOUT_FILL_X|JUSTIFY_RIGHT|LAYOUT_CENTER_Y);

    text_count = new FXTextField(matrix,10,NULL,0,TEXTFIELD_READONLY|TEXTFIELD_INTEGER|LAYOUT_FILL_X|JUSTIFY_LEFT);
    text_count->disable();
    text_count->setTextColor(FXRGB(0,0,255));
    text_count->setText("0");

    new FXLabel(matrix,"File:",NULL,LABEL_NORMAL|LAYOUT_FILL_X|JUSTIFY_RIGHT|LAYOUT_CENTER_Y);
    text_file = new FXTextField(matrix,40,NULL,0,TEXTFIELD_READONLY|LAYOUT_FILL_X);
    text_file->disable();


    if (operation!=OP_DELETE) {
        new FXLabel(matrix,"File Progress:",NULL,LABEL_NORMAL|LAYOUT_FILL_X|JUSTIFY_RIGHT|LAYOUT_CENTER_Y);
        progress_bar = new FXProgressBar(matrix,NULL,0,FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|PROGRESSBAR_PERCENTAGE);
    }



    new FXSeparator(main,SEPARATOR_GROOVE|LAYOUT_FILL_X);
    FXHorizontalFrame *closebox=new FXHorizontalFrame(main,LAYOUT_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,0,0,0,0);
    new FXButton(closebox,tr(" &Cancel "),NULL,this,FXDialogBox::ID_CANCEL,BUTTON_INITIAL|BUTTON_DEFAULT|LAYOUT_CENTER_X|FRAME_RAISED|FRAME_THICK,0,0,0,0, 20,20);
}
Example #24
0
// ===========================================================================
// method definitions
// ===========================================================================
GUIMessageWindow::GUIMessageWindow(FXComposite* parent) :
    FXText(parent, 0, 0, 0, 0, 0, 0, 50),
    myStyles(0),
    myErrorRetriever(0),
    myMessageRetriever(0),
    myWarningRetriever(0) {
    setStyled(true);
    setEditable(false);
    myStyles = new FXHiliteStyle[4];
    // set separator style
    myStyles[0].normalForeColor = FXRGB(0x00, 0x00, 0x88);
    myStyles[0].normalBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[0].selectForeColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[0].selectBackColor = FXRGB(0x00, 0x00, 0x88);
    myStyles[0].hiliteForeColor = FXRGB(0x00, 0x00, 0x88);
    myStyles[0].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[0].activeBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[0].style = 0;
    // set message text style
    myStyles[1].normalForeColor = FXRGB(0x00, 0x88, 0x00);
    myStyles[1].normalBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[1].selectForeColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[1].selectBackColor = FXRGB(0x00, 0x88, 0x00);
    myStyles[1].hiliteForeColor = FXRGB(0x00, 0x88, 0x00);
    myStyles[1].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[1].activeBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[1].style = 0;
    // set error text style
    myStyles[2].normalForeColor = FXRGB(0x88, 0x00, 0x00);
    myStyles[2].normalBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[2].selectForeColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[2].selectBackColor = FXRGB(0x88, 0x00, 0x00);
    myStyles[2].hiliteForeColor = FXRGB(0x88, 0x00, 0x00);
    myStyles[2].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[2].activeBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[2].style = 0;
    // set warning text style
    myStyles[3].normalForeColor = FXRGB(0xe6, 0x98, 0x00);
    myStyles[3].normalBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[3].selectForeColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[3].selectBackColor = FXRGB(0xe6, 0x98, 0x00);
    myStyles[3].hiliteForeColor = FXRGB(0xe6, 0x98, 0x00);
    myStyles[3].hiliteBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[3].activeBackColor = FXRGB(0xff, 0xff, 0xff);
    myStyles[3].style = 0;
    //
    setHiliteStyles(myStyles);
}
Example #25
0
int windowed_worker(int argc, char *argv[], fwin_entrypoint *fwin_main)
{
    fwin_main1 = fwin_main;
#ifdef WIN32
// The following is somewhat unsatisfactory so I will explain my options and
// what is happening.
// On Unix/Linux/Darwin etc I have here a single executable that, depending
// on a command-line flag, runs either as a windowed or a command-line
// program. All is pretty neat and convenient for me!  However...
//
// On Windows when I link code I can link it either as subsystem:windows or
// as subsystem:console. If I use the windows case then it detaches from
// its console when started. The effect I have is that when launched from
// a Windows command prompt asking to be run in console mode it can not
// access the console. Windows XP provides an AttachConsole API that might
// let me re-attach to the console but (a) that is not available with
// earlier versions of Windows and (b) my experimenst with it have not been
// great successes and others report delicacies! However note that even if
// the code is linked as a windows binary it can be launched from the cygwin
// shell and inherits standard input and output very happily! But from a
// regular Windows command shell it does not.
// If, on the other hand I link my code as a console application then when
// launched from a command prompt or a script things work as I might like
// and expect. When launched by double-clicking on an icon, Windows says to
// itself "aha - a console application" and rapidly creates a console for it.
//  This pops up on your screen. But here (in the case I wanted a Windowed
// interface) I just free that console, which then has no other users and
// which therefore gets destroyed. So there is a visual glitch of an unwanted
// console window popping up and instantly vanishing.
//
// The best solution that appears to be open to me under Windows is to
// have two executable versions for each application. They would only need
// to differ in the way they were linked (and hence, possibly, by one bit in
// a header record in them!). One for console and one for windowed use.
// That feels clumsy too.
//
// Web searches show that others have found the same sort of pain when they
// have wanted to create applications that are both console and window
// mode. Ah well. One final suggestion for the two-executable scheme is
// to creats two executables, say cslw.exe and cslc.exe where cslw.exe is
// linked in windows mode and cslc.exe in console mode. cslc.exe just
// creates a process to run cslw.exe. When you do this the handles on
// standard input and output can be inherited by the child process, which
// can therefore read and write characters. However because it still does not
// really have a CONSOLE it can not do the res of what one might like by way
// of supporting curses-like screen updates. A final trick on this is to
// rename those two programs as csl.exe (windowed) and csl.com (console).
// The Windows command processor will use the ".com" extension before the
// ".exe" one, but of course the executable is really in ".exe" format...
// this trick maybe reduces the confusion over file-names! Or maybe it
// makes it worse.

#ifdef KEEP_CONSOLE_OPEN
// I sometimes find a console REALLY useful for debugging.... but when you
// launch by double-clicking on an icon it is truly ugly to have one around.
// So I will allow myself to leave an "#ifdef" here in case that helps me make
// a trick version for debugging...
    FreeConsole();
#endif

#endif

#define COMPANY_NAME  "Codemist-Ltd"
#define PRODUCT_NAME  programName

#define WINDOW_NAME   programName

// registry entries will be filed under Codemist-Ltd/<something>.
    application_object = new FXApp(PRODUCT_NAME,
                                   COMPANY_NAME);
// args can be sent in via command-line args, if that is any help.
// Just at present I do not fully understand what FOX does with these
// arguments but it MAY be that it expects to allow "-geometry" or "-fn"
// etc arguments as per standard for X11 applications.
    application_object->init(argc, argv, TRUE);
#ifndef WIN32
    debug_option = 0;
    for (int i=1; i<argc; i++)
    {   if (strcmp(argv[i], "-g") == 0 ||
                 strcmp(argv[i], "-G") == 0) debug_option = 1;
    }
/*
 * By default if there are any X protocol error (eg relating to missing
 * fonts) X send a message to stdout reporting. Unless I am in debug mode
 * there can be an unwanted distraction so I will hide them. If however
 * I am in debug mode I will set the X protocol to run in synchronous
 * mode, which will slow it down but make debugging easier. I believe I have
 * to set these options after X has been initialised and I want to do it as
 * soon as possible after that, hence this bit of decoding of command-line
 * options is separated from the main chunk.
 */
    if (debug_option) _Xdebug = 1;
    else XSetErrorHandler(IgnoreXError);
#endif

    FXRootWindow *r = application_object->getRootWindow();
    rootWidth = r->getDefaultWidth(),
    rootHeight = r->getDefaultHeight();

// Now I will decide how big the main window should be. If I have information
// in the registry left over from my last run I will use that.
    FXRegistry *reg = &application_object->reg();
    int screenx = reg->readIntEntry("screen", "screenx", -1);
    int screeny = reg->readIntEntry("screen", "screeny", -1);
    int screenw = reg->readIntEntry("screen", "screenw", -1);
    int screenh = reg->readIntEntry("screen", "screenh", -1);

    if (screenx < 0 || screeny < 0 || screenw <= 100 || screenh < 20)
    {   screenx = screeny = 50; // When I had 0 here that was off the screen!
        screenw = 0;
        screenh = (2*rootHeight)/3;
    }
    int fontsize =
        reg->readIntEntry("screen", "fontsize", -1);
#if (FOX_MINOR<=4)
    int fontweight =
        reg->readIntEntry("screen", "fontweight", FONTWEIGHT_BOLD);
    int fontslant =
        reg->readIntEntry("screen", "fontslant", FONTSLANT_REGULAR);
    int fontencoding =
        reg->readIntEntry("screen", "fontencoding", FONTENCODING_DEFAULT);
    int fontsetwidth =
        reg->readIntEntry("screen", "fontsetwidth", FONTSETWIDTH_DONTCARE);
    int fonthints =
        reg->readIntEntry("screen", "fonthints",
                          FONTPITCH_FIXED|FONTHINT_MODERN);
#else
    int fontweight =
        reg->readIntEntry("screen", "fontweight", FXFont::Bold);
    int fontslant =
        reg->readIntEntry("screen", "fontslant", FXFont::Straight);
    int fontencoding =
        reg->readIntEntry("screen", "fontencoding", FONTENCODING_DEFAULT);
    int fontsetwidth =
        reg->readIntEntry("screen", "fontsetwidth", FXFont::NonExpanded);
    int fonthints =
        reg->readIntEntry("screen", "fonthints",
                          FXFont::Fixed|FXFont::Modern);
#endif
    const char *fontname =
        reg->readStringEntry("screen", "fontname",  DEFAULT_FONT_NAME);
// I have a concern here about how long the string that is returned will
// remain valid. As a matter of caution I will not read other string values
// from the registry until I have used or copied this.

// The icon that I use here depends on the name that this program is
// launched with. This situation in perhaps not perfect but it seems the
// easiest route just for now.
    const unsigned char *icondata = fwin;

// This sets alternative custom icons based on the name of the executable
// and it clearly NOT portable... however I find it helpful, and it should
// not impact anybody who wants to make independent use of this library.
    if (strcmp(programName, "csl") == 0) icondata = csl;
    else if (strcmp(programName, "bootstrapreduce") == 0) icondata = csl;
    else if (strcmp(programName, "reduce") == 0) icondata = reduce;
    main_window = new FXMainWindow1(
        application_object,
        WINDOW_NAME,
        new FXICOIcon(application_object, icondata,
                      FXRGB(255,255,255), IMAGE_ALPHAGUESS),
        NULL,    // mini-icon
        DECOR_ALL,
        screenx, screeny,
        screenw, screenh);
    main_menu_bar = new FXMenuBar(main_window,
                                  LAYOUT_SIDE_TOP | LAYOUT_FILL_X);
// NB. NB. NB.
// *NB*  the TEXT_COLUMNWRAP flag is my own PATCH to FOX, and when I build
// FOX I change the files FXText.h and FXText.cpp to implement it. It
// lets me wrap lines at exactly 80 columns, regardless of how whitespace
// happens to lie.
    text = new FXTerminal(main_window, NULL, 0,
        HSCROLLER_NEVER | TEXT_FIXEDWRAP | TEXT_WORDWRAP | TEXT_COLUMNWRAP |
        TEXT_SHOWACTIVE | LAYOUT_FILL_X | LAYOUT_FILL_Y);

// I am really supposed to destroy menus as I exit. So somewhere I need to
// arrange that - or maybe I can hope that my application only closes its
// window when finally terminating, and somebody will tidy up at a system
// level for me.
    fileMenu = new FXMenuPane(main_window);
    new FXMenuCommand(fileMenu, "&Read...", NULL,
                                (FXObject *)text, FXTerminal::ID_READ);
    new FXMenuCommand(fileMenu, "&Save...", NULL,
                                (FXObject *)text, FXTerminal::ID_SAVE);
    new FXMenuCommand(fileMenu, "Save Se&lection...", NULL,
                                (FXObject *)text, FXTerminal::ID_SAVE_SELECTION);
    new FXMenuCommand(fileMenu, "&Print...", NULL,
                                (FXObject *)text, FXTerminal::ID_PRINT);
    new FXMenuCommand(fileMenu, "Pri&nt Selection...", NULL,
                                (FXObject *)text, FXTerminal::ID_PRINT_SELECTION);
    new FXMenuCommand(fileMenu, "&Break\tCtl-C\tInterrupt", NULL,
                                (FXObject *)text, FXTerminal::ID_BREAK);
    new FXMenuCommand(fileMenu, "Bac&ktrace\tCtl-G\tInterrupt/backtrace", NULL,
                                (FXObject *)text, FXTerminal::ID_BACKTRACE);
    new FXMenuCommand(fileMenu, "&Pause\tCtl-S", NULL,
                                (FXObject *)text, FXTerminal::ID_PAUSE);
    new FXMenuCommand(fileMenu, "&Resume\tCtl-Q", NULL,
                                (FXObject *)text, FXTerminal::ID_RESUME);
    new FXMenuCommand(fileMenu, "&Stop/Go\tCtl-Z", NULL,
                                (FXObject *)text, FXTerminal::ID_STOP);
    new FXMenuCommand(fileMenu, "&Discard Output\tCtl-O", NULL,
                                (FXObject *)text, FXTerminal::ID_DISCARD);
    new FXMenuCommand(fileMenu, "&Quit\tCtl-\\\tQuit the application.", NULL,
                                application_object, FXApp::ID_QUIT);

// I make this F&ile not &File since alt-F will be for "move forward one
// word" using emacs-like key bindings.
    new FXMenuTitle(main_menu_bar, "F&ile", NULL, fileMenu);

    editMenu = new FXMenuPane(main_window);
    new FXMenuCommand(editMenu, "&Cut", NULL,
                                (FXObject *)text, FXTerminal::ID_CUT_SEL_X);
    new FXMenuCommand(editMenu, "C&opy", NULL,
                                (FXObject *)text, FXTerminal::ID_COPY_SEL_X);
    new FXMenuCommand(editMenu, "Copy &Text", NULL,
                                (FXObject *)text, FXTerminal::ID_COPY_SEL_TEXT_X);
    new FXMenuCommand(editMenu, "&Paste\tCtl-V", NULL,
                                (FXObject *)text, FXTerminal::ID_PASTE_SEL_X);
    new FXMenuCommand(editMenu, "&Reinput\tCtl-^\tReinput", NULL,
                                (FXObject *)text, FXTerminal::ID_REINPUT);
    new FXMenuCommand(editMenu, "Select &All", NULL,
                                (FXObject *)text, FXText::ID_SELECT_ALL);
    new FXMenuCommand(editMenu, "C&lear\tCtl-L", NULL,
                                (FXObject *)text, FXTerminal::ID_CLEAR);
    new FXMenuCommand(editMenu, "Re&draw\tCtl-R", NULL,
                                (FXObject *)text, FXTerminal::ID_REDRAW);
    new FXMenuCommand(editMenu, "&Home", NULL,
                                (FXObject *)text, FXTerminal::ID_HOME);
    new FXMenuCommand(editMenu, "&End", NULL,
                                (FXObject *)text, FXTerminal::ID_END);
    new FXMenuCommand(editMenu, "&Font...", NULL,
                                (FXObject *)text, FXTerminal::ID_FONT);
    new FXMenuCommand(editMenu, "&Reset Font", NULL,
                                (FXObject *)text, FXTerminal::ID_RESET_FONT);
    new FXMenuCommand(editMenu, "Reset &Window", NULL,
                                (FXObject *)text, FXTerminal::ID_RESET_WINDOW);

    new FXMenuTitle(main_menu_bar, "&Edit", NULL, editMenu);

// Add the special Reduce menus...
    {   const char **red = reduceMenus, *p;
        char curTop[32], topName[32], subName[64], *q;
        curTop[0] = 0;
        reduceMenu = NULL;
        while (*red != NULL)
        {   p = *red++;
//@@ printf("p=%s\n", p);
            q = topName;
            while (*p != '@') *q++ = *p++;
            *q = 0;
            p++;
            q = subName;
            while (*p != '@') *q++ = *p++;
            *q = 0;
//@@ printf("%s : %s\n", topName, subName);
// Do I now have a new top-level menu name?
            if (strcmp(topName, curTop) != 0)
            {   if (reduceMenu != NULL)
                {   new FXMenuTitle(main_menu_bar, curTop, NULL, reduceMenu);
//@@ printf("put %s at top\n", curTop);
                }
                reduceMenu = new FXMenuPane(main_window);
                strcpy(curTop, topName);
//@@ printf("create new sub-menu for %s\n", curTop);
            }
// Add a sub-menu item
//@@ printf("Add in %s\n", subName);
            new FXMenuCommand(reduceMenu, subName, NULL,
                                (FXObject *)text, FXTerminal::ID_REDUCE);
        }
// The final top-level menu now needs setting up.
//@@ printf("final top level item is %s\n", curTop);
        new FXMenuTitle(main_menu_bar, curTop, NULL, reduceMenu);
    }
//@@ printf("Menus should be OK now\n");
    helpMenu = new FXMenuPane(main_window);
    new FXMenuCommand(helpMenu, "&Help\tF1\tHelp", NULL,
                                (FXObject *)text, FXTerminal::ID_HELP);
#ifndef WIN32
#if !defined MACINTOSH || !defined MAC_FRAMEWORK
    new FXMenuCommand(helpMenu, "&Select Browser\t\tSelect Browser", NULL,
                                (FXObject *)text, FXTerminal::ID_BROWSER);
#endif
#endif
    new FXMenuCommand(helpMenu, "&About\t\tAbout", NULL,
                                (FXObject *)text, FXTerminal::ID_ABOUT);

    new FXMenuTitle(main_menu_bar, "Help", NULL, helpMenu, LAYOUT_RIGHT);

    text->setEditable(FALSE);
    text->setStyled(TRUE);

    text->argc = argc;
    text->argv = argv;

    strcpy(mid_stuff, programName);
    main_window->setTitle(programName);

    application_object->create();

// Selecting the font may involve measuring font sizes etc which may
// need the font creating...

    FXFont *font1 = selectFont(fontname, fontsize,
        fontweight, fontslant, fontencoding, fontsetwidth, fonthints);
    font1->create();
    text->setFont(font1);

    if (screenw == 0) text->onCmdResetWindow(NULL, 0, NULL);

//
// I will iconify the window AFTER I have adjusted its size since I do not
// want to end up with a size that is silly and based on just an icon!
// Also somewhere (and I now do not remember where) I picked up the idea
// that minimizing twice over was a good idea...
//
    if (windowed < 0)
    {   main_window->minimize();
        main_window->minimize();
    }

    text->setupShowMath();

    main_window->show();
    text->onCmdHome(NULL, 0, NULL); // actually just to grab the focus!
#ifdef WIN32
    DWORD threadId;
    thread1 = CreateThread(NULL,  // security attributes
                           0,     // stack size
                           worker_thread,
                           (void *)text,
                           0,     // flags
                           &threadId); // Essential for Me/98/95
    if (thread1 == NULL)
    {   fprintf(stderr, "Fatal error attempting to create a thread\n");
        application_object->exit(1);
        exit(1);
    }
#else
    if (pthread_create(&thread1, NULL, worker_thread, (void *)text))
    {   fprintf(stderr, "Fatal error attempting to create a thread\n");
        application_object->exit(1);
        exit(1);
    }
#endif

// Once a second I will try to flush any output buffers. But do not start
// that until everything else is more or less going!
    application_object->addTimeout((FXObject *)text,
                FXTerminal::ID_TIMEOUT, 1000, NULL);

    if (windowed >= 0) main_window->raise(); // Bring to top.

    return application_object->run();
}
FXImage*
GUISUMOAbstractView::checkGDALImage(Decal& d) {
#ifdef HAVE_GDAL
    GDALAllRegister();
    GDALDataset* poDataset = (GDALDataset*)GDALOpen(d.filename.c_str(), GA_ReadOnly);
    if (poDataset == 0) {
        return 0;
    }
    const int xSize = poDataset->GetRasterXSize();
    const int ySize = poDataset->GetRasterYSize();
    // checking for geodata in the picture and try to adapt position and scale
    if (d.width <= 0.) {
        double adfGeoTransform[6];
        if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None) {
            Position topLeft(adfGeoTransform[0], adfGeoTransform[3]);
            const double horizontalSize = xSize * adfGeoTransform[1];
            const double verticalSize = ySize * adfGeoTransform[5];
            Position bottomRight(topLeft.x() + horizontalSize, topLeft.y() + verticalSize);
            if (GeoConvHelper::getProcessing().x2cartesian(topLeft) && GeoConvHelper::getProcessing().x2cartesian(bottomRight)) {
                d.width = bottomRight.x() - topLeft.x();
                d.height = topLeft.y() - bottomRight.y();
                d.centerX = (topLeft.x() + bottomRight.x()) / 2;
                d.centerY = (topLeft.y() + bottomRight.y()) / 2;
                //WRITE_MESSAGE("proj: " + toString(poDataset->GetProjectionRef()) + " dim: " + toString(d.width) + "," + toString(d.height) + " center: " + toString(d.centerX) + "," + toString(d.centerY));
            } else {
                WRITE_WARNING("Could not convert coordinates in " + d.filename + ".");
            }
        }
    }
#endif
    if (d.width <= 0.) {
        d.width = getGridWidth();
        d.height = getGridHeight();
    }

    // trying to read the picture
#ifdef HAVE_GDAL
    const int picSize = xSize * ySize;
    FXColor* result;
    if (!FXMALLOC(&result, FXColor, picSize)) {
        WRITE_WARNING("Could not allocate memory for " + d.filename + ".");
        return 0;
    }
    for (int j = 0; j < picSize; j++) {
        result[j] = FXRGB(0, 0, 0);
    }
    bool valid = true;
    for (int i = 1; i <= poDataset->GetRasterCount(); i++) {
        GDALRasterBand* poBand = poDataset->GetRasterBand(i);
        int shift = -1;
        if (poBand->GetColorInterpretation() == GCI_RedBand) {
            shift = 0;
        } else if (poBand->GetColorInterpretation() == GCI_GreenBand) {
            shift = 1;
        } else if (poBand->GetColorInterpretation() == GCI_BlueBand) {
            shift = 2;
        } else if (poBand->GetColorInterpretation() == GCI_AlphaBand) {
            shift = 3;
        } else {
            WRITE_MESSAGE("Unknown color band in " + d.filename + ", maybe fox can parse it.");
            valid = false;
            break;
        }
        assert(xSize == poBand->GetXSize() && ySize == poBand->GetYSize());
        if (poBand->RasterIO(GF_Read, 0, 0, xSize, ySize, ((unsigned char*)result) + shift, xSize, ySize, GDT_Byte, 4, 4 * xSize) == CE_Failure) {
            valid = false;
            break;
        }
    }
    GDALClose(poDataset);
    if (valid) {
        return new FXImage(getApp(), result, IMAGE_OWNED | IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP, xSize, ySize);
    }
    FXFREE(&result);
#endif
    return 0;
}
Example #27
0
long
GNEInspectorFrame::AttrInput::onCmdSetAttribute(FXObject*, FXSelector, void*) {
    // Declare changed value
    std::string newVal;
    // First, obtain the string value of the new attribute depending of their type
    if (GNEAttributeCarrier::isBool(myTag, myAttr)) {
        // Set true o false depending of the checBox
        if (myCheckBox->getCheck()) {
            newVal = "true";
        } else {
            newVal = "false";
        }
    } else if (GNEAttributeCarrier::isDiscrete(myTag, myAttr)) {
        // Obtain choices
        const std::vector<std::string>& choices = GNEAttributeCarrier::discreteChoices(myTag, myAttr);
        // Check if are combinable coices
        if (choices.size() > 0 && GNEAttributeCarrier::discreteCombinableChoices(myTag, myAttr)) {
            // Get value obtained using AttrEditor
            newVal = myTextFieldStrings->getText().text();
        } else {
            // Get value of ComboBox
            newVal = myChoicesCombo->getText().text();
        }
    } else if (GNEAttributeCarrier::isFloat(myTag, myAttr)) {
        // Check if default value of attribute must be set
        if(myTextFieldReal->getText().empty() && GNEAttributeCarrier::hasDefaultValue(myTag, myAttr)) {
            newVal = GNEAttributeCarrier::getDefaultValue<std::string>(myTag, myAttr);
            myTextFieldReal->setText(newVal.c_str());
        } else {
            // obtain value of myTextFieldReal
            newVal = myTextFieldReal->getText().text();
        }
    } else if (GNEAttributeCarrier::isInt(myTag, myAttr)) {
        // Check if default value of attribute must be set
        if(myTextFieldInt->getText().empty() && GNEAttributeCarrier::hasDefaultValue(myTag, myAttr)) {
            newVal = GNEAttributeCarrier::getDefaultValue<std::string>(myTag, myAttr);
            myTextFieldInt->setText(newVal.c_str());
        } else {
            // obtain value of myTextFieldInt
            newVal = myTextFieldInt->getText().text();
        }
    } else if (GNEAttributeCarrier::isTime(myTag, myAttr)) {
        // obtain value of myTimeSpinDial
        newVal = toString(myTimeSpinDial->getValue());
    } else if (GNEAttributeCarrier::isString(myTag, myAttr)) {
        // Check if default value of attribute must be set
        if(myTextFieldStrings->getText().empty() && GNEAttributeCarrier::hasDefaultValue(myTag, myAttr)) {
            newVal = GNEAttributeCarrier::getDefaultValue<std::string>(myTag, myAttr);
            myTextFieldStrings->setText(newVal.c_str());
        } else {
            // obtain value of myTextFieldStrings
            newVal = myTextFieldStrings->getText().text();
        }
    }

    // Check if attribute must be changed
    if(myInspectorFrameParent->getACs().front()->isValid(myAttr, newVal)) {
        // if its valid for the first AC than its valid for all (of the same type)
        if (myInspectorFrameParent->getACs().size() > 1) {
            myInspectorFrameParent->getViewNet()->getUndoList()->p_begin("Change multiple attributes");
        }
        // Set new value of attribute in all selected ACs
        for (std::vector<GNEAttributeCarrier*>::const_iterator it_ac = myInspectorFrameParent->getACs().begin(); it_ac != myInspectorFrameParent->getACs().end(); it_ac++) {
            (*it_ac)->setAttribute(myAttr, newVal, myInspectorFrameParent->getViewNet()->getUndoList());
        }
        // finish change multiple attributes
        if (myInspectorFrameParent->getACs().size() > 1) {
            myInspectorFrameParent->getViewNet()->getUndoList()->p_end();
        }
        // If previously value of TextField was red, change color to black
        if (GNEAttributeCarrier::isFloat(myTag, myAttr) && myTextFieldStrings != 0) {
            myTextFieldReal->setTextColor(FXRGB(0, 0, 0));
            myTextFieldReal->killFocus();
        } else if (GNEAttributeCarrier::isInt(myTag, myAttr) && myTextFieldStrings != 0) {
            myTextFieldInt->setTextColor(FXRGB(0, 0, 0));
            myTextFieldInt->killFocus();
        } else if (GNEAttributeCarrier::isTime(myTag, myAttr) && myTextFieldStrings != 0) {
            myTimeSpinDial->setTextColor(FXRGB(0, 0, 0));
            myTimeSpinDial->killFocus();
        } else if (GNEAttributeCarrier::isString(myTag, myAttr) && myTextFieldStrings != 0) {
            myTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
            myTextFieldStrings->killFocus();
        }
    } else {
        // IF value of TextField isn't valid, change color to Red depending of type
        if (GNEAttributeCarrier::isFloat(myTag, myAttr) && myTextFieldStrings != 0) {
            myTextFieldReal->setTextColor(FXRGB(255, 0, 0));
        } else if (GNEAttributeCarrier::isInt(myTag, myAttr) && myTextFieldStrings != 0) {
            myTextFieldInt->setTextColor(FXRGB(255, 0, 0));
        } else if (GNEAttributeCarrier::isTime(myTag, myAttr) && myTextFieldStrings != 0) {
            myTimeSpinDial->setTextColor(FXRGB(255, 0, 0));
        } else if (GNEAttributeCarrier::isString(myTag, myAttr) && myTextFieldStrings != 0) {
            myTextFieldStrings->setTextColor(FXRGB(255, 0, 0));
        }
    }
    // Update view net
    myInspectorFrameParent->getViewNet()->update();
    return 1;
}