FXWindow*
MFXAddEditTypedTable::getControlForItem(FXint r, FXint c) {
    register FXTableItem* item = cells[r * ncols + c];
    if (item == NULL) {
        return 0;
//         cells[r * ncols + c] = item = createItem("", NULL, NULL);
//         if (isItemSelected(r, c)) {
//             item->setSelected(FALSE);
//         }
    }
    delete editor;
    editor = NULL;
    switch (getCellType(c)) {
        case CT_UNDEFINED:
        case CT_STRING: {
            register FXTextField* field;
            register FXuint justify = 0;
            field = new FXTextField(this, 1, NULL, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
            // !!! if(state&LEFT) justify|=JUSTIFY_LEFT;
            // !!! if(state&RIGHT) justify|=JUSTIFY_RIGHT;
            // !!! if(state&TOP) justify|=JUSTIFY_TOP;
            // !!! if(state&BOTTOM) justify|=JUSTIFY_BOTTOM;
            field->create();
            field->setJustify(justify);
            field->setFont(getFont());
            field->setBackColor(getBackColor());
            field->setTextColor(getTextColor());
            field->setSelBackColor(getSelBackColor());
            field->setSelTextColor(getSelTextColor());
            field->setText(item->getText());
            field->selectAll();
            return field;
        }
        case CT_REAL:
//        return myNumberEditor;
        case CT_INT: {
            register FXRealSpinDial* field;
            //register FXuint justify=0;
            field = new FXRealSpinDial(this, 1, NULL, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
            // !!! if(state&LEFT) justify|=JUSTIFY_LEFT;
            // !!! if(state&RIGHT) justify|=JUSTIFY_RIGHT;
            // !!! if(state&TOP) justify|=JUSTIFY_TOP;
            // !!! if(state&BOTTOM) justify|=JUSTIFY_BOTTOM;
            field->create();
//            field->setJustify(justify);
            field->setFont(getFont());
            field->setBackColor(getBackColor());
            field->setTextColor(getTextColor());
            field->setSelBackColor(getSelBackColor());
            field->setSelTextColor(getSelTextColor());
            NumberCellParams p = getNumberCellParams(c);
            if (p.format != "undefined") {
                field->setFormatString((char*) p.format.c_str());
                field->setIncrements(p.steps1, p.steps2, p.steps3);
                field->setRange(p.min, p.max);
            }
            try {
                if (getCellType(c) == CT_REAL) {
                    field->setValue(TplConvert::_2SUMOReal(item->getText().text()));
                } else {
                    field->setValue(TplConvert::_2int(item->getText().text()));
                }
            } catch (NumberFormatException&) {
                field->setValue(0);
            }
            field->selectAll();
            return field;
        }
        case CT_BOOL:
//        return myBoolEditor;
        case CT_ENUM:
//        return myEnumEditor;
        default:
            throw 1;
    }
}
Beispiel #2
0
/**
 * Creates a dimensioning line (line with one, two or no arrows and a text).
 *
 * @param forceAutoText Automatically reposition the text label.
 */
void RS_Dimension::updateCreateDimensionLine(const RS_Vector& p1,
        const RS_Vector& p2, bool arrow1, bool arrow2, bool forceAutoText) {

    // general scale (DIMSCALE)
    double dimscale = getGeneralScale();
    // text height (DIMTXT)
    double dimtxt = getTextHeight()*dimscale;
    // text distance to line (DIMGAP)
    double dimgap = getDimensionLineGap()*dimscale;

    // length of dimension line:
    double distance = p1.distanceTo(p2);
    // arrow size:
    double arrowSize = getArrowSize()*dimscale;

    // do we have to put the arrows outside of the line?
    bool outsideArrows = (distance<arrowSize*2.5);

    // arrow angles:
    double arrowAngle1, arrowAngle2;

    RS_Pen pen(getDimensionLineColor(),
           getDimensionLineWidth(),
           RS2::LineByBlock);

    // Create dimension line:
	RS_Line* dimensionLine = new RS_Line{this, p1, p2};
    dimensionLine->setPen(pen);
//    dimensionLine->setPen(RS_Pen(RS2::FlagInvalid));
	dimensionLine->setLayer(nullptr);
    addEntity(dimensionLine);

    if (outsideArrows==false) {
        arrowAngle1 = dimensionLine->getAngle2();
        arrowAngle2 = dimensionLine->getAngle1();
    } else {
        arrowAngle1 = dimensionLine->getAngle1();
        arrowAngle2 = dimensionLine->getAngle2();

        // extend dimension line outside arrows
		RS_Vector dir = RS_Vector::polar(arrowSize*2, arrowAngle2);
        dimensionLine->setStartpoint(p1 + dir);
        dimensionLine->setEndpoint(p2 - dir);
    }
double dimtsz=getTickSize()*dimscale;
if(dimtsz < 0.01) {
    //display arrow
    // Arrows:
    RS_SolidData sd;
    RS_Solid* arrow;

    if (arrow1) {
        // arrow 1
        arrow = new RS_Solid(this, sd);
        arrow->shapeArrow(p1,
                          arrowAngle1,
                          arrowSize);
//        arrow->setPen(RS_Pen(RS2::FlagInvalid));
        arrow->setPen(pen);
		arrow->setLayer(nullptr);
        addEntity(arrow);
    }

    if (arrow2) {
        // arrow 2:
        arrow = new RS_Solid(this, sd);
        arrow->shapeArrow(p2,
                          arrowAngle2,
                          arrowSize);
//        arrow->setPen(RS_Pen(RS2::FlagInvalid));
        arrow->setPen(pen);
		arrow->setLayer(nullptr);
        addEntity(arrow);
    }
}else{
    //display ticks
    // Arrows:

    RS_Line* tick;
	RS_Vector tickVector = RS_Vector::polar(dimtsz,arrowAngle1 + M_PI*0.25); //tick is 45 degree away

    if (arrow1) {
        // tick 1
        tick = new RS_Line(this, p1-tickVector, p1+tickVector);
        tick->setPen(pen);
//        tick->setPen(RS_Pen(RS2::FlagInvalid));
		tick->setLayer(nullptr);
        addEntity(tick);
    }

    if (arrow2) {
        // tick 2:
        tick = new RS_Line(this, p2-tickVector, p2+tickVector);
        tick->setPen(pen);
//        tick->setPen(RS_Pen(RS2::FlagInvalid));
		tick->setLayer(nullptr);
        addEntity(tick);
    }
}
    // Text label:
    RS_MTextData textData;
    RS_Vector textPos;

        double dimAngle1 = dimensionLine->getAngle1();
        double textAngle;
        bool corrected=false;
        if (getAlignText())
            textAngle =0.0;
        else
            textAngle = RS_Math::makeAngleReadable(dimAngle1, true, &corrected);

    if (data.middleOfText.valid && !forceAutoText) {
        textPos = data.middleOfText;
    } else {
        textPos = dimensionLine->getMiddlePoint();

        if (!getAlignText()) {
			// rotate text so it's readable from the bottom or right (ISO)
			// quadrant 1 & 4
			double const a = corrected?-M_PI_2:M_PI_2;
			RS_Vector distV = RS_Vector::polar(dimgap + dimtxt/2.0, dimAngle1+a);

            // move text away from dimension line:
            textPos+=distV;
        }
        //// the next update should still be able to adjust this
        ////   auto text position. leave it invalid
                data.middleOfText = textPos;
    }

    textData = RS_MTextData(textPos,
                           dimtxt, 30.0,
                           RS_MTextData::VAMiddle,
                           RS_MTextData::HACenter,
                           RS_MTextData::LeftToRight,
                           RS_MTextData::Exact,
                           1.0,
                           getLabel(),
                           getTextStyle(),
//                           "standard",
                           textAngle);

    RS_MText* text = new RS_MText(this, textData);

    // move text to the side:
    RS_Vector distH;
    if (text->getUsedTextWidth()>distance) {
        distH.setPolar(text->getUsedTextWidth()/2.0
                       +distance/2.0+dimgap, textAngle);
        text->move(distH);
    }
    text->setPen(RS_Pen(getTextColor(), RS2::WidthByBlock, RS2::SolidLine));
//    text->setPen(RS_Pen(RS2::FlagInvalid));
	text->setLayer(nullptr);
    //horizontal text, split dimensionLine
    if (getAlignText()) {
        double w =text->getUsedTextWidth()/2+dimgap;
        double h = text->getUsedTextHeight()/2+dimgap;
		RS_Vector v1 = textPos - RS_Vector{w, h};
		RS_Vector v2 = textPos + RS_Vector{w, h};
		RS_EntityContainer c;
		c.addRectangle(v1, v2);
		RS_VectorSolutions sol1;
		for(RS_Entity* e: c) {
			sol1.push_back(
						RS_Information::getIntersection(dimensionLine, e, true)
						);
		}

        //are text intersecting dimensionLine?
		if (sol1.size()>1) {
            //yes, split dimension line
			RS_Line* dimensionLine2 =
					static_cast<RS_Line*>(dimensionLine->clone());
            v1 = sol1.get(0);
			v2 = sol1.get(1);
            if (p1.distanceTo(v1) < p1.distanceTo(v2)) {
                dimensionLine->setEndpoint(v1);
                dimensionLine2->setStartpoint(v2);
            } else {
                dimensionLine->setEndpoint(v2);
                dimensionLine2->setStartpoint(v1);
            }
            addEntity(dimensionLine2);
        }
    }

    addEntity(text);
}
Beispiel #3
0
void virKeyboardWin::keyBoardInit()
{
	char* keyb[] ={"`~","1!","2@","3#","4$","5%","6^","7&","8*","9(","0)","-_","=+","delete",
	 "tab" ,"q","w","e","r","t","y","u","i","o","p","[{","]}","\\|",
		"caps lock" ,"a","s","d","f","g","h","j","k","l",";:","'\"", "return" ,
	 "shift" ,"z","x","c","v","b","n","m",",<",".>","/?","shift",
	 "ctrl" , "alt" ,"space", "alt" ,"ctrl" };
	int i,j,temp;
	setRwNum(60);
	comboBoxInit();
	uint16_t w = (getWinWidth()- getWinWidth()/29)/14;
	uint16_t h = getWinHigh()/6;
	uint8_t n ;//中间按键数量
	uint16_t x;//x的位置
	uint16_t wt;
	for(i=0;i<4;i++) //1-3 line
	{
		wt = w ;
		switch(i)
		{
			case 0:{n = 12;temp = 0;}break;
			case 1:{
				wt += w/2;
				n = 12;
			} ;break;
			case 2:{
				wt += w*3/4;
				n = 11;
			}break;
			case 3:{
				wt += w+w/4;
				n = 10;
			}break;
			default:break;
		}	
		getRwList()[temp] = new buttonWin(0,i*h,wt,h,keyb[temp],this,getQueue());
		((controlWin*)getRwList()[temp])->setTextColor(getTextColor());
		((controlWin*)getRwList()[temp])->setBackColor(getBackColor());
		getRwList()[temp]->setWinProc(keyboardProc);
		getRwList()[temp]->registerWin();
		for(j=0;j<n;j++)
		{
			temp ++;
			getRwList()[temp] = new buttonWin(wt,i*h,w,h,keyb[temp],this,getQueue());
			((controlWin*)getRwList()[temp])->setTextColor(getTextColor());
			((controlWin*)getRwList()[temp])->setBackColor(getBackColor());
			getRwList()[temp]->setWinProc(keyboardProc);
			getRwList()[temp]->registerWin();
			wt += w;	
		}
		x = wt;
		temp ++;//每一行最后一个
		wt = w;
		switch(i)
		{
			case 0:{wt += w/2;}break;
			case 1:{wt = w;}break;
			case 2:{wt += w*3/4;}break;
			case 3:{wt += w+w/4;}break;
			default:break;
		}	
		getRwList()[temp] = new buttonWin(x,i*h,wt,h,keyb[temp],this,getQueue());
		((controlWin*)getRwList()[temp])->setTextColor(getTextColor());
		((controlWin*)getRwList()[temp])->setBackColor(getBackColor());
		getRwList()[temp]->setWinProc(keyboardProc);
		getRwList()[temp]->registerWin();
		temp ++;
	}
	//line 4
	x = 2*w;
	for(i=0;i<5;i++)
	{
		if(i==2)
		{
			getRwList()[temp] = new buttonWin(x,4*h,w*5,h,keyb[temp],this,getQueue());
			((controlWin*)getRwList()[temp])->setTextColor(getTextColor());
			((controlWin*)getRwList()[temp]) ->setBackColor(getBackColor());
			getRwList()[temp]->setWinProc(keyboardProc);
			getRwList()[temp]->registerWin();
			x+=w*5;
		}else{
			getRwList()[temp] = new buttonWin(x,4*h,w,h,keyb[temp],this,getQueue());
			((controlWin*)getRwList()[temp])->setTextColor(getTextColor());
			((controlWin*)getRwList()[temp]) ->setBackColor(getBackColor());
			getRwList()[temp]->setWinProc(keyboardProc);
			getRwList()[temp]->registerWin();
			x += w;
		}
		temp++;
	}
	getRwList()[temp] = new buttonWin(0,4*h,2*w,h,"V",this,getQueue());
	((controlWin*)getRwList()[temp])->setTextColor(getTextColor());
	((controlWin*)getRwList()[temp]) ->setBackColor(getBackColor());
	getRwList()[temp]->setWinProc(keyboardProc);
	getRwList()[temp]->registerWin();
	temp++;
	getRwList()[temp] = new buttonWin(x,4*h,3*w+w/2,h,"V",this,getQueue());
	((controlWin*)getRwList()[temp])->setTextColor(getTextColor());
	((controlWin*)getRwList()[temp]) ->setBackColor(getBackColor());
	getRwList()[temp]->setWinProc(keyboardProc);
	getRwList()[temp]->registerWin();
	temp++;
		
}