Exemplo n.º 1
0
/***************************************************
* Function 	:    CreatePrimitivesForlistTracesScreen
* Parameters 	:    none
* Return 	:    none
* Description	:    Creates GPL widgets used in screen - listTracesScreen
***************************************************/
void CreatePrimitivesForlistTracesScreen(void)
{
    SetLineType(0);
    SetLineThickness(0);
    SetColor(12678);
    SetFont((void*)&Gentium_Plain_0_0_22);
    while(!OutTextXY(17,54,(XCHAR*)listTracesScreen_OTE_18text));
}
Exemplo n.º 2
0
/***************************************************
* Function 	:    CreatePrimitivesForcurrentlyRecordingScreen
* Parameters 	:    none
* Return 	:    none
* Description	:    Creates GPL widgets used in screen - currentlyRecordingScreen
***************************************************/
void CreatePrimitivesForcurrentlyRecordingScreen(void)
{
    SetLineType(0);
    SetLineThickness(0);
    SetColor(12678);
    SetFont((void*)&Gentium_Plain_0_0_22);
    while(!OutTextXY(57,84,(XCHAR*)currentlyRecordingScreen_OTE_4text));
}
Exemplo n.º 3
0
/***************************************************
* Function 	:    CreatePrimitivesForhomeScreen
* Parameters 	:    none
* Return 	:    none
* Description	:    Creates GPL widgets used in screen - homeScreen
***************************************************/
void CreatePrimitivesForhomeScreen(void)
{
    SetLineType(0);
    SetLineThickness(0);
    SetColor(12678);
    SetFont((void*)&Gentium_Plain_0_0_22);
    while(!OutTextXY(130,127,(XCHAR*)homeScreen_OTE_4text));
}
Exemplo n.º 4
0
void  OGL2DBase::MajorGridDrawSetup()
{
    SetDrawColor(plot2Dbase.defaultPenSet->GetColor(plot2Dbase.plotAnnotation.gridLineDataPen));
    SetLine(plot2Dbase.plotAnnotation.majorGridWidth);
    SetLineType(plot2Dbase.plotAnnotation.majorGridLineType);
    if (plot2Dbase.plotAnnotation.gridOverData)
        SetGridHigh();
}
Exemplo n.º 5
0
void DrawGridVerticals( void )
{
    SHORT   x;

    SetLineType( DOTTED_LINE );
    for (x = GRAPH_GRID_LEFT + GRID_SPACING_HORIZONTAL - graphOffset; x < GRAPH_GRID_RIGHT; x += GRID_SPACING_HORIZONTAL)
    {
        Line( x, GRAPH_GRID_TOP, x, GRAPH_GRID_BOTTOM );
    }
}
Exemplo n.º 6
0
void DrawGridHorizontals( void )
{
    SHORT   y;

    SetLineType( DOTTED_LINE );
    for (y = GRAPH_GRID_TOP + GRID_SPACING_VERTICAL; y < GRAPH_GRID_BOTTOM; y += GRID_SPACING_VERTICAL)
    {
        Line( GRAPH_GRID_LEFT, y, GRAPH_GRID_RIGHT, y );
    }
}
Exemplo n.º 7
0
void IndicateFocus( SHORT lineColor )
{
    EDITBOX *currentEditbox;
    BUTTON  *currentMinus;

    currentEditbox  = (EDITBOX *)GOLFindObject( CURRENT_EDITBOX );
    currentMinus    = (BUTTON *) GOLFindObject( CURRENT_MINUS );

    SetColor( lineColor );
    SetLineType( SOLID_LINE );

    Rectangle(  currentEditbox->hdr.left-1, currentEditbox->hdr.top-1,
                currentMinus->hdr.right+1, currentMinus->hdr.bottom+1 );
}
Exemplo n.º 8
0
static WORD DrawOrHideDecoration(void)
{
	static int drawState;

	OBJ_HEADER *pObj;
	SHORT l, t, r, b;

	if (showDecoration != showDecorationPrev) {
		showDecorationPrev = showDecoration;
		drawState = 0;
	}

	switch (drawState) {
	case 0:
		// prepare style
		SetLineThickness(THICK_LINE);
		SetLineType(DASHED_LINE);

		if (showDecoration)
			SetColor(GFX_SCHEMEDEFAULT.Color1);
		else
			SetColor(GFX_SCHEMEDEFAULT.CommonBkColor);

		drawState++;
		/* fall through */

	case 1:
		// draw/hide decoration
		pObj = GOLFindObject(ID_BUTTON);
		if (pObj == NULL)
			break;

		l = pObj->left - 5;
		t = pObj->top - 5;
		r = pObj->right + 5;
		b = pObj->bottom + 5;

		if (!Rectangle(l, t, r, b))
			return 0;

		drawState++;
		/* fall through */

	default:
		break;
	}

	return 1;
}
Exemplo n.º 9
0
	void CMenuElementUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcsicmp(pstrName, _T("icon")) == 0){
			SetIcon(pstrValue);
		}
		else if( _tcsicmp(pstrName, _T("iconsize")) == 0 ) {
			LPTSTR pstr = NULL;
			LONG cx = 0, cy = 0;
			cx = _tcstol(pstrValue, &pstr, 10);  ASSERT(pstr);    
			cy = _tcstol(pstr + 1, &pstr, 10);    ASSERT(pstr);   
			SetIconSize(cx, cy);
		}
		else if( _tcsicmp(pstrName, _T("checkitem")) == 0 ) {		
			SetCheckItem(_tcsicmp(pstrValue, _T("true")) == 0 ? true : false);		
		}
		else if( _tcsicmp(pstrName, _T("ischeck")) == 0 ) {		
			if (CMenuWnd::GetGlobalContextMenuObserver().GetMenuCheckInfo() != NULL && CMenuWnd::GetGlobalContextMenuObserver().GetMenuCheckInfo()->find(GetName()) == CMenuWnd::GetGlobalContextMenuObserver().GetMenuCheckInfo()->end())
			{
				SetChecked(_tcsicmp(pstrValue, _T("true")) == 0 ? true : false);
			}	
		}	
		else if( _tcsicmp(pstrName, _T("linetype")) == 0){
			if (_tcsicmp(pstrValue, _T("true")) == 0)
				SetLineType();
		}
		else if( _tcsicmp(pstrName, _T("expland")) == 0 ) {
			SetShowExplandIcon(_tcsicmp(pstrValue, _T("true")) == 0 ? true : false);
		}
		else if( _tcsicmp(pstrName, _T("linecolor")) == 0){
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			SetLineColor(_tcstoul(pstrValue, &pstr, 16));
		}
		else if( _tcsicmp(pstrName, _T("linepadding")) == 0 ) {
			RECT rcInset = { 0 };
			LPTSTR pstr = NULL;
			rcInset.left = _tcstol(pstrValue, &pstr, 10);  ASSERT(pstr);    
			rcInset.top = _tcstol(pstr + 1, &pstr, 10);    ASSERT(pstr);    
			rcInset.right = _tcstol(pstr + 1, &pstr, 10);  ASSERT(pstr);    
			rcInset.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);    
			SetLinePadding(rcInset);
		}
		else if	( _tcsicmp(pstrName, _T("height")) == 0){
			SetFixedHeight(_ttoi(pstrValue));
		}
		else
			CListContainerElementUI::SetAttribute(pstrName, pstrValue);
	}
Exemplo n.º 10
0
/****************************************************************************
  Function:
    void ShowScreenGraph( void )

  Description:
    This function erases the currently displayed screen and replaces it with
    the graphing demonstration.  It draws the initial grid, and initializes
    the variables needed for the demo.

  Precondition:
    None

  Parameters:
    None

  Returns:
    None

  Remarks:
    The global list of graphics objects is destroyed and replaced. Therefore,
    this function cannot be called during the message processing of
    GOLMsgCallback().  It must be called during GOLDrawCallback() processing.
  ***************************************************************************/
void ShowScreenGraph( void )
{
//    strcpy( pageInformation.title, "Potentiometer Graph" );
//    InitializeScreen();
//
//    // Create the hidden controls to receive touchpad messages.
//
//    BtnCreate(          ID_GRAPH_FASTER,
//                        GetMaxX()-8, 0, GetMaxX()-6, 2, 3,
//                        BTN_HIDE,
//                        NULL,
//                        NULL,
//                        NULL );
//
//    BtnCreate(          ID_GRAPH_SLOWER,
//                        GetMaxX()-6, 0, GetMaxX()-4, 2, 3,
//                        BTN_HIDE,
//                        NULL,
//                        NULL,
//                        NULL );
//
//    BtnCreate(          ID_GRAPH_HOME,
//                        GetMaxX()-4, 0, GetMaxX()-2, 2, 3,
//                        BTN_HIDE,
//                        NULL,
//                        NULL,
//                        NULL );

    GOLPanelDraw( GRAPH_PANEL_LEFT, GRAPH_PANEL_TOP, GRAPH_PANEL_RIGHT, GRAPH_PANEL_BOTTOM, 0,
        BLACK, NULL, NULL, NULL, GOL_EMBOSS_SIZE);

    GOLPanelDrawTsk();          // draw panel for graph

    // Draw the initial grid.

    SetColor( WHITE );
    SetLineType( DOTTED_LINE );

    previousTick    = tick;
    graphOffset     = 0;
    graphDataHead   = 0;
    graphDataTail   = 0;
    graphUpdateRate = GRAPH_UPDATE_INTERVAL_INIT;

//    DrawGridVerticals();
//    DrawGridHorizontals();
}
Exemplo n.º 11
0
void  OGL3DBase::DrawOneAxes( const double&         axMin,
                              const double&         axMax,
                              const SC_DoubleArray& majorIncs,
                              const SC_DoubleArray& minorIncs,
                              const PC_AxesFormat&  format,
                                    Point2D&        stPoint,
                                    Point2D&        majTicEndPoint,
                                    Point2D&        minTicEndPoint,
                                    Point2D&        gridEndPoint,
                                    Point2D&        offsetEndPoint,
                                    double&         stComponent,
                                    double&         majTicComponent,
                                    double&         minTicComponent,
                                    double&         gridComponent,
                                    double&         offsetComponent,
                              const double&         zValue,
                                    Plane3D         axPlane,
                                    bool            axisIsLog)
{

    Point2D* endPoint;
    double*  endComponent;

    PC_3DAxesFormat&  axesFormat = plot3Dbase.axesFormat;
    DC_PenSet&        penSet   = *plot3Dbase.defaultPenSet;          //  default PenSet used for plot

    if (format.axesLinePos == PC_AxesFormat::alpBoth)
    {
        SetDrawColor(penSet.GetColor(axesFormat.axesLinePen));
        SetLine(axesFormat.axesLineWidth);
        SetLineSolid();

        HardCopyBlockStart(6);

        stComponent = axMin;
        Point2D axSt = stPoint;
        stComponent = axMax;
        Point2D axEnd = stPoint;
        DrawLine(axSt, axEnd, zValue, axPlane);

        //  needed at axes end to make offsets look clean
        endPoint = &offsetEndPoint;
        endComponent = &offsetComponent;

        stComponent = axMin;
        *endComponent = stComponent;
        DrawLine(stPoint, *endPoint, zValue, axPlane);

        stComponent = axMax;
        *endComponent = stComponent;
        DrawLine(stPoint, *endPoint, zValue, axPlane);

        HardCopyBlockEnd();
    }


    if ((format.axesMajorInc == PC_Axes::aitGrid) ||
        ((format.axesMajorInc == PC_Axes::aitTic) && (format.axesTicPos == PC_AxesFormat::atpBoth)))
    {
        SetDrawColor(penSet.GetColor(axesFormat.majorPen));
        if (format.axesMajorInc == PC_Axes::aitTic)
        {
            SetLine(axesFormat.majorTicWidth);
            endPoint = &majTicEndPoint;
            endComponent = &majTicComponent;
        }
        else
        {
            SetLine(axesFormat.majorGridWidth);
            SetLineType(axesFormat.majorGridLineType);
            endPoint = &gridEndPoint;
            endComponent = &gridComponent;
        }
        HardCopyBlockStart(majorIncs.Size() * 2);
        for (int i = 0; i < majorIncs.Size(); i++)
        {
            stComponent = majorIncs[i];
            if (Limit::WithinOneLimit(axMin, axMax, stComponent))
            {
                *endComponent = stComponent;
                DrawLine(stPoint, *endPoint, zValue, axPlane);
            }
        }
        HardCopyBlockEnd();
    }



    if ((format.axesMinorInc == PC_Axes::aitGrid) ||
        ((format.axesMinorInc == PC_Axes::aitTic) && (format.axesTicPos == PC_AxesFormat::atpBoth)))
    {
        SetDrawColor(penSet.GetColor(axesFormat.minorPen));
        if (format.axesMinorInc == PC_Axes::aitTic)
        {
            SetLine(axesFormat.minorTicWidth);
            endPoint = &minTicEndPoint;
            endComponent = &minTicComponent;
        }
        else
        {
            SetLine(axesFormat.minorGridWidth);
            SetLineType(axesFormat.minorGridLineType);

            endPoint = &gridEndPoint;
            endComponent = &gridComponent;
        }


        HardCopyBlockStart((majorIncs.Size() + 1) * minorIncs.Size()  * 2);

        if (!axisIsLog)
        {
            double multVal = 1.0;
            if (axMin > axMax )
                multVal = -1.0;

            for (int i = -1; i < majorIncs.Size(); i++)
                for (int j = 0; j < minorIncs.Size(); j++)
                {
                    if (i < 0)
                        stComponent = majorIncs[0] - (minorIncs[j] * multVal);
                    else
                        stComponent = majorIncs[i] + (minorIncs[j] * multVal);

                    if (Limit::WithinOneLimit(axMin, axMax, stComponent))
                    {
                        *endComponent = stComponent;
                        DrawLine(stPoint, *endPoint, zValue, axPlane);
                    }
                }
        }
        else
        {
            //
            static const double logIncVals[] = {0.30103, 0.47712, 0.60206, 0.69897,
                                                0.77815, 0.84510, 0.90309, 0.95424};
            if (axMin < axMax)
            {
                for (int i = -1; i < majorIncs.Size(); i++)
                    for (int j = 0; j < 8; j++)
                    {
                        if (i < 0)
                            stComponent = majorIncs[0] - 1.0 + logIncVals[j];
                        else
                            stComponent = majorIncs[i] + logIncVals[j];

                        if (Limit::WithinOneLimit(axMin, axMax, stComponent))
                        {
                            *endComponent = stComponent;
                            DrawLine(stPoint, *endPoint, zValue, axPlane);
                        }
                    }
            }
            else
            {
                for (int i = -1; i < majorIncs.Size(); i++)
                    for (int j = 0; j < 8; j++)
                    {
                        if (i < 0)
                            stComponent = majorIncs[0] + logIncVals[j];
                        else
                            stComponent = majorIncs[i] - 1.0 + logIncVals[j];

                        if (Limit::WithinOneLimit(axMin, axMax, stComponent))
                        {
                            *endComponent = stComponent;
                            DrawLine(stPoint, *endPoint, zValue, axPlane);
                        }
                    }
            }

        }
        HardCopyBlockEnd();

    }
}
Exemplo n.º 12
0
/*********************************************************************
* Function: WORD DmDraw(void *pObj)
*
* Notes: This is the state machine to display the changing numbers.
*
**********************************************************************/
WORD DmDraw(void *pObj)
{
    typedef enum
    {
        DM_STATE_IDLE,
        DM_STATE_FRAME,
        DM_STATE_DRAW_FRAME,
        DM_STATE_INIT,
        DM_STATE_SETALIGN,
        DM_STATE_SETTEXT,
        DM_STATE_ERASETEXT,
        DM_STATE_DRAWTEXT,
        DM_STATE_WRAPUP
    } DM_DRAW_STATES;

    DIGITALMETER *pDm = NULL;
    static DM_DRAW_STATES state = DM_STATE_IDLE;
    static SHORT charCtr = 0, lineCtr = 0;
    static XCHAR CurValue[DM_WIDTH], PreValue[DM_WIDTH];
    static SHORT textWidth = 0;
    static XCHAR ch = 0, pch = 0;

    pDm = (DIGITALMETER *)pObj;

    while(1)
    {

    if(IsDeviceBusy())
        return (0);
    
        switch(state)
        {
            case DM_STATE_DRAW_FRAME:
                if(Rectangle(pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom) == 0)
                    return (0);
                state = DM_STATE_INIT;
                break;

            case DM_STATE_IDLE:
                SetClip(CLIP_DISABLE);
    
#ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                GFX_DRIVER_SetupDrawUpdate( pDm->hdr.left,
                                            pDm->hdr.top,
                                            pDm->hdr.right,
                                            pDm->hdr.bottom);
#endif
                if(GetState(pDm, DM_HIDE) || GetState(pDm, DM_DRAW))
                {
    	            SetColor(pDm->hdr.pGolScheme->CommonBkColor);
    	            if(Bar(pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom) == 0)
    	            	return (0);
    			}
                // if the draw state was to hide then state is still IDLE STATE so no need to change state
                if (GetState(pDm, DM_HIDE))
                {
#ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                    GFX_DRIVER_CompleteDrawUpdate(   pDm->hdr.left,
                                                    pDm->hdr.top,
                                                    pDm->hdr.right,
                                                    pDm->hdr.bottom);
#endif
                	return (1);
                }
                state = DM_STATE_FRAME;	
    
            case DM_STATE_FRAME:
    
    			if(GetState(pDm, DM_DRAW | DM_FRAME) == (DM_DRAW | DM_FRAME))
                {
                    // show frame if specified to be shown
                    SetLineType(SOLID_LINE);
                    SetLineThickness(NORMAL_LINE);
                    if(!GetState(pDm, DM_DISABLED))
                    {
    
                        // show enabled color
                        SetColor(pDm->hdr.pGolScheme->Color1);
                    }
                    else
                    {
    
                        // show disabled color
                        SetColor(pDm->hdr.pGolScheme->ColorDisabled);
                    }
                    state = DM_STATE_DRAW_FRAME;
                    break;
                }
                else 
                {
                    state = DM_STATE_INIT;
                }
    
            case DM_STATE_INIT:
                if(IsDeviceBusy())
                    return (0);
    
                // set clipping area, text will only appear inside the static text area.
                SetClip(CLIP_ENABLE);
                SetClipRgn(pDm->hdr.left + DM_INDENT, pDm->hdr.top, pDm->hdr.right - DM_INDENT, pDm->hdr.bottom);
    
                // set the text color
                if(!GetState(pDm, DM_DISABLED))
                {
                    SetColor(pDm->hdr.pGolScheme->TextColor0);
                }
                else
                {
                    SetColor(pDm->hdr.pGolScheme->TextColorDisabled);
                }
    
                // convert the values to be displayed in string format
                NumberToString(pDm->Pvalue, PreValue, pDm->NoOfDigits, pDm->DotPos);
                NumberToString(pDm->Cvalue, CurValue, pDm->NoOfDigits, pDm->DotPos);
    
                // use the font specified in the object
                SetFont(pDm->hdr.pGolScheme->pFont);
    
                state = DM_STATE_SETALIGN;  // go to drawing of text
    
            case DM_STATE_SETALIGN:
                if(!charCtr)
                {
    
                    // set position of the next character (based on alignment and next character)
                    textWidth = GetTextWidth(CurValue, pDm->hdr.pGolScheme->pFont);
    
                    // Display text with center alignment
                    if(GetState(pDm, (DM_CENTER_ALIGN)))
                    {
                        MoveTo((pDm->hdr.left + pDm->hdr.right - textWidth) >> 1, pDm->hdr.top + (lineCtr * pDm->textHeight));
                    }
    
                    // Display text with right alignment
                    else if(GetState(pDm, (DM_RIGHT_ALIGN)))
                    {
                        MoveTo((pDm->hdr.right - textWidth - DM_INDENT), pDm->hdr.top + (lineCtr * pDm->textHeight));
                    }
    
                    // Display text with left alignment
                    else
                    {
                        MoveTo(pDm->hdr.left + DM_INDENT, pDm->hdr.top + (lineCtr * pDm->textHeight));
                    }
                }
Exemplo n.º 13
0
/*********************************************************************
* Function: WORD BtnDraw(BUTTON *pB)
*
*
* Notes: This is the state machine to draw the button.
*
********************************************************************/
WORD BtnDraw(BUTTON *pB)
{
typedef enum {
	REMOVE,
	BEVEL_DRAW,
    RNDBUTTON_DRAW,
	TEXT_DRAW,
    TEXT_DRAW_RUN,
	FOCUS_DRAW,
} BTN_DRAW_STATES;

static BTN_DRAW_STATES state = REMOVE;
static SHORT width, height, radius;

WORD faceClr, embossLtClr, embossDkClr, xText, yText;

    if(IsDeviceBusy())
        return 0;

    switch(state){

        case REMOVE:

            if(IsDeviceBusy())
                return 0;  

	        if (GetState(pB,BTN_HIDE)) {  				      // Hide the button (remove from screen)
       	        SetColor(pB->hdr.pGolScheme->CommonBkColor);
       	        Bar(pB->hdr.left, pB->hdr.top, pB->hdr.right, pB->hdr.bottom);
		        return 1;
		    }
			/* Note: that width and height adjustment considers the following assumptions:
					1. if circular width = height = radius*2
					2. if vertical capsule width = radius*2
					3. if horizontal capsule height = radius*2
					4. radius must be less than or equal to width if height is greater than width
					5. radius must be less than or equal to height if width is greater than height
					6. if button is cornered, radius must be zero
			*/				
   			radius = pB->radius;								// get radius
	    	width  = (pB->hdr.right - pB->hdr.left) - (radius*2);		// get width
	    	height = (pB->hdr.bottom - pB->hdr.top) - (radius*2);		// get height
            state = BEVEL_DRAW;

        case BEVEL_DRAW:
			if(!GetState(pB,BTN_DISABLED)){
			    if(GetState(pB,BTN_PRESSED)){
			        embossDkClr = pB->hdr.pGolScheme->EmbossLtColor;
			      	embossLtClr = pB->hdr.pGolScheme->EmbossDkColor;
			      	faceClr 	= pB->hdr.pGolScheme->Color1;
			    } else {
			        embossLtClr = pB->hdr.pGolScheme->EmbossLtColor;
			      	embossDkClr = pB->hdr.pGolScheme->EmbossDkColor;
			      	faceClr		= pB->hdr.pGolScheme->Color0;
			    }  
		    }else{    
		        embossLtClr = pB->hdr.pGolScheme->EmbossLtColor;
		      	embossDkClr = pB->hdr.pGolScheme->EmbossDkColor;
		      	faceClr		= pB->hdr.pGolScheme->ColorDisabled;
            } 
   			SetLineThickness(NORMAL_LINE);
			SetLineType(SOLID_LINE);			
            GOLPanelDraw(pB->hdr.left+radius, pB->hdr.top+radius, pB->hdr.right-radius,  	
			   			 pB->hdr.bottom-radius, radius, faceClr, embossLtClr, embossDkClr,  
				  		 pB->pBitmap, GOL_EMBOSS_SIZE);
   			state = RNDBUTTON_DRAW;

        case RNDBUTTON_DRAW:

            if(!GOLPanelDrawTsk()){
                return 0;
            }
   			state = TEXT_DRAW;

        case TEXT_DRAW:
        	if (pB->pText != NULL){
                if (!GetState(pB,BTN_DISABLED)){
        	        if (GetState(pB,BTN_PRESSED)){
	        	        SetColor(pB->hdr.pGolScheme->TextColor1);
	                }else{
		                SetColor(pB->hdr.pGolScheme->TextColor0);
                    }
                }
	            else{
		            SetColor(pB->hdr.pGolScheme->TextColorDisabled);
                }
                SetFont(pB->hdr.pGolScheme->pFont);
                // check text alignment
                if (GetState(pB, BTN_TEXTRIGHT)) 
	                xText = pB->hdr.right-(pB->textWidth+GOL_EMBOSS_SIZE+2);
	            else if (GetState(pB, BTN_TEXTLEFT))    
	                xText = pB->hdr.left+GOL_EMBOSS_SIZE+2;
	            else    
	                xText = (pB->hdr.left+pB->hdr.right-pB->textWidth)>>1;
								
                if (GetState(pB, BTN_TEXTTOP)) 
	                yText = pB->hdr.top+GOL_EMBOSS_SIZE+2;
	            else if (GetState(pB, BTN_TEXTBOTTOM))    
	                yText = pB->hdr.bottom-(pB->textHeight+GOL_EMBOSS_SIZE);
	            else    
	                yText = (pB->hdr.bottom+pB->hdr.top-pB->textHeight)>>1;

           		MoveTo(xText, yText);
           		state = TEXT_DRAW_RUN;
	        }else {
           		state = FOCUS_DRAW;
           		goto rnd_button_draw_focus;
           	}	

        case TEXT_DRAW_RUN:
			if(!OutText(pB->pText))
            	return 0;	
            state = FOCUS_DRAW;
 
        case FOCUS_DRAW:
rnd_button_draw_focus:
            if(IsDeviceBusy())
                return 0;
    
	        if(GetState(pB,BTN_FOCUSED)){
		        SetLineType(FOCUS_LINE);
			    if(GetState(pB,BTN_PRESSED)) {
			        SetColor(pB->hdr.pGolScheme->TextColor1);
			    } else {     
			        SetColor(pB->hdr.pGolScheme->TextColor0);
			    }
			    // check if the object has rounded corners or not    
		        if (!pB->radius) {
					Rectangle(	pB->hdr.left+GOL_EMBOSS_SIZE+2 , pB->hdr.top+GOL_EMBOSS_SIZE+2,
                          		pB->hdr.right-GOL_EMBOSS_SIZE-2, pB->hdr.bottom-GOL_EMBOSS_SIZE-2);
                }    	      
		        else  {
				    // original center is still the same, but radius is reduced
		        	Bevel( pB->hdr.left+radius, pB->hdr.top+radius, 					\
				           pB->hdr.right-radius, pB->hdr.bottom-radius,				\
				           radius - 2 - GOL_EMBOSS_SIZE);
			    }
		        SetLineType(SOLID_LINE);
	        }
	        
            state = REMOVE;
            return 1;
    }
/*********************************************************************
* Function: WORD AcDraw(ANALOGCLOCK *pAc)
*
*
* Notes: This is the state machine to draw the clock.
*
********************************************************************/
WORD AcDraw(void *pObj)
{
    typedef enum
    {
        REMOVE,
        BEVEL_DRAW,
        TICK
    } AC_DRAW_STATES;

    static AC_DRAW_STATES state = REMOVE;
    static SHORT width, height, radius;

    static GFX_COLOR faceClr, handClr;
  
    ANALOGCLOCK *pAc;
    
    pAc = (ANALOGCLOCK *)pObj;
 

   if(IsDeviceBusy())
        return (0);
	
    switch(state)
    {
        case REMOVE:
            if(IsDeviceBusy())
                return (0);

            if(GetState(pAc, AC_HIDE))     // Hide the button (remove from screen)
            {                      
                SetColor(pAc->hdr.pGolScheme->CommonBkColor);
                if(!Bar(pAc->hdr.left, pAc->hdr.top, pAc->hdr.right, pAc->hdr.bottom))
                {
                    return (0);
                }
            }
                      
            if(GetState(pAc, AC_TICK))
            {
                   state = TICK;
                   return(1); //buthave to do goto erase
                //goto erase_current_pos;
            }

            if(GetState(pAc, UPDATE_HOUR))
            {
                   AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap);
                   state = TICK;
                   return(1); //buthave to do goto erase
                //goto erase_current_pos;
            }

            if(GetState(pAc, UPDATE_MINUTE))
            {
                   AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap);
                   state = TICK;
                   return(1); //buthave to do goto erase
                //goto erase_current_pos;
            }

            if(GetState(pAc, UPDATE_SECOND))
            {
                   AcHandsDraw(pAc, SECOND, THICKNESS_SECOND+4, handClr, pAc->pBitmap);
                   state = TICK;
                   return(1); //buthave to do goto erase
                //goto erase_current_pos;
            }



            radius = pAc->radius;    // get radius
            width = (pAc->hdr.right - pAc->hdr.left) - (radius * 2);  // get width
            height = (pAc->hdr.bottom - pAc->hdr.top) - (radius * 2); // get height
            state = BEVEL_DRAW;

        case BEVEL_DRAW:

            faceClr = pAc->hdr.pGolScheme->Color0;
            handClr = pAc->hdr.pGolScheme->Color1;

            SetLineThickness(NORMAL_LINE);
            SetLineType(SOLID_LINE);

            SetColor(faceClr);

            FillCircle(pAc->centerx,pAc->centery, radius);  //Draw Face of Analog Clock
           
            SetColor(handClr);
            FillCircle(pAc->centerx,pAc->centery, 8);  //Draw Middle of Analog Clock

			AcHandsDraw(pAc, SECOND, THICKNESS_SECOND, handClr, pAc->pBitmap);
			AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap);
			AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap);

            state = REMOVE;
            break;

		case TICK:
			
			AcHandsDraw(pAc, SECOND, THICKNESS_SECOND, handClr, pAc->pBitmap);				
								
			if(pAc->valueS++ == 60) 
			{
				pAc->valueS = 1;
				if(pAc->valueM++ == 60)
				{
					pAc->valueM = 1;			
				}
				if(pAc->valueM%12 == 0)
				{
					pAc->valueH++;
					if(pAc->valueH == 60)
						pAc->valueH = 0;
					AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap);	
				}			
				AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap);		
			}
			

			if( ((pAc->valueS - pAc->valueM)<4 && (pAc->valueS - pAc->valueM)>=0) || ((pAc->valueS - pAc->valueM)<-56 && (pAc->valueS - pAc->valueM)>-59) )
				AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap);
				
			if( ((pAc->valueS - pAc->valueH)<4  && (pAc->valueS - pAc->valueH)>=0) || ((pAc->valueS - pAc->valueH)<-56 && (pAc->valueS - pAc->valueH)>-59) )
				AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap);
				
				
			if(pAc->valueS-1 == pAc->valueM)
				AcHandsDraw(pAc, MINUTE, THICKNESS_SECOND+4, handClr, pAc->pBitmap);
			if(pAc->valueS-1 == pAc->valueH)
				AcHandsDraw(pAc, HOUR, THICKNESS_SECOND+4, handClr, pAc->pBitmap);				
	
            state = REMOVE;
            return (1);
    }

    return (1);
}
Exemplo n.º 15
0
/*********************************************************************
* Function: WORD PictDraw(PICTURE *pPict)
*
* Output: returns the status of the drawing
*		  0 - not completed
*         1 - done
*
* Overview: draws picture
*
********************************************************************/
WORD PictDraw(PICTURE *pPict)
{
    typedef enum
    {
        REMOVE,
        DRAW_IMAGE,
        DRAW_BACKGROUND1,
        DRAW_BACKGROUND2,
        DRAW_BACKGROUND3,
        DRAW_BACKGROUND4,
        DRAW_FRAME
    } PICT_DRAW_STATES;

    static PICT_DRAW_STATES state = REMOVE;
    static SHORT posleft;
    static SHORT postop;
    static SHORT posright;
    static SHORT posbottom;

    if(IsDeviceBusy())
        return (0);

    switch(state)
    {
        case REMOVE:
            if(GetState(pPict, PICT_HIDE))
            {
                SetColor(pPict->hdr.pGolScheme->CommonBkColor);
                if(!Bar(pPict->hdr.left, pPict->hdr.top, pPict->hdr.right, pPict->hdr.bottom))
                    return (0);
                return (1);
            }

            posleft = (pPict->hdr.left + pPict->hdr.right - pPict->scale * GetImageWidth(pPict->pBitmap)) >> 1;
            postop = (pPict->hdr.top + pPict->hdr.bottom - pPict->scale * GetImageHeight(pPict->pBitmap)) >> 1;
            posright = (pPict->hdr.right + pPict->hdr.left + pPict->scale * GetImageWidth(pPict->pBitmap)) >> 1;
            posbottom = (pPict->hdr.bottom + pPict->hdr.top + pPict->scale * GetImageHeight(pPict->pBitmap)) >> 1;
            state = DRAW_IMAGE;

        case DRAW_IMAGE:
            if(pPict->pBitmap != NULL)
            {
                if(IsDeviceBusy())
                    return (0);
                if(!PutImage(posleft, postop, pPict->pBitmap, pPict->scale))
                    return (0);
            }

            SetColor(pPict->hdr.pGolScheme->CommonBkColor);
            state = DRAW_BACKGROUND1;

        case DRAW_BACKGROUND1:
            if(!Bar(pPict->hdr.left + 1, pPict->hdr.top + 1, pPict->hdr.right - 1, postop - 1))
                return (0);
            state = DRAW_BACKGROUND2;

        case DRAW_BACKGROUND2:
            if(!Bar(pPict->hdr.left + 1, posbottom, pPict->hdr.right - 1, pPict->hdr.bottom - 1))
                return (0);
            state = DRAW_BACKGROUND3;

        case DRAW_BACKGROUND3:
            if(!Bar(pPict->hdr.left + 1, postop, posleft - 1, posbottom))
                return (0);
            state = DRAW_BACKGROUND4;

        case DRAW_BACKGROUND4:
            if(!Bar(posright, postop, pPict->hdr.right - 1, posbottom))
                return (0);
            state = DRAW_FRAME;

        case DRAW_FRAME:
            if(GetState(pPict, PICT_FRAME))
            {
                SetLineType(SOLID_LINE);
                SetColor(pPict->hdr.pGolScheme->TextColor0);
                if(!Rectangle(pPict->hdr.left, pPict->hdr.top, pPict->hdr.right, pPict->hdr.bottom))
                    return (0);
            }

            state = REMOVE;
            return (1);
    }

    return (1);
}
Exemplo n.º 16
0
/*********************************************************************
* Function: WORD StDraw(STATICTEXT *pSt)
*
* Notes: This is the state machine to draw the static text.
*
********************************************************************/
WORD StDraw(STATICTEXT *pSt)
{
typedef enum {
	ST_STATE_IDLE,
	ST_STATE_CLEANAREA,
	ST_STATE_INIT,
	ST_STATE_SETALIGN,
	ST_STATE_DRAWTEXT
} ST_DRAW_STATES;

static ST_DRAW_STATES state = ST_STATE_IDLE;
static SHORT charCtr = 0, lineCtr = 0;
static XCHAR *pCurLine = NULL;
SHORT textWidth;
XCHAR   ch = 0;


    if(IsDeviceBusy())
        return 0;
        
    switch(state){

        case ST_STATE_IDLE:
        
            SetClip(CLIP_DISABLE);

           	if (GetState(pSt, ST_HIDE)) {
   	   	        SetColor(pSt->hdr.pGolScheme->CommonBkColor);
    	        if(!Bar(pSt->hdr.left,pSt->hdr.top,pSt->hdr.right,pSt->hdr.bottom))
    	            return 0;
    	        // State is still IDLE STATE so no need to set
    	        return 1;
    	    }    
	        
	        if (GetState(pSt, ST_DRAW)) {   	
		       	if (GetState(pSt, ST_FRAME)) {
			       	// show frame if specified to be shown
	   	   	        SetLineType(SOLID_LINE);
	   	   	        SetLineThickness(NORMAL_LINE);
		            if(!GetState(pSt,ST_DISABLED)){
			            // show enabled color
	    	   	        SetColor(pSt->hdr.pGolScheme->Color1);
		    	        if(!Rectangle(pSt->hdr.left,pSt->hdr.top,pSt->hdr.right,pSt->hdr.bottom))
		    	            return 0;
	
	            	}
		            else {
	       	        	// show disabled color
	    	   	        SetColor(pSt->hdr.pGolScheme->ColorDisabled);
			            if(!Rectangle(pSt->hdr.left,pSt->hdr.top,pSt->hdr.right,pSt->hdr.bottom))
			                return 0;
	    	        }
	    	    }    
    	    }
    	    // set clipping area, text will only appear inside the static text area.    
            SetClip(CLIP_ENABLE);
            SetClipRgn(pSt->hdr.left+ST_INDENT, pSt->hdr.top,   		\
                       pSt->hdr.right-ST_INDENT, pSt->hdr.bottom);    
            state = ST_STATE_CLEANAREA;

        case ST_STATE_CLEANAREA:
        
			// clean area where text will be placed.
			SetColor(pSt->hdr.pGolScheme->CommonBkColor);
    	    if(!Bar(pSt->hdr.left+1,pSt->hdr.top + 1,pSt->hdr.right-1,pSt->hdr.bottom-1))
    	        return 0;
            state = ST_STATE_INIT;
    	    
        case ST_STATE_INIT:
        
            if(IsDeviceBusy())
                return 0;

			// set the text color
	        if(!GetState(pSt,ST_DISABLED)){
	   	        SetColor(pSt->hdr.pGolScheme->TextColor0);
	        }    
	        else {
	   	        SetColor(pSt->hdr.pGolScheme->TextColorDisabled);
	        }    
	        // use the font specified in the object
	        SetFont(pSt->hdr.pGolScheme->pFont);
			pCurLine = pSt->pText;						// get first line of text
			state = ST_STATE_SETALIGN;					// go to drawing of text

        case ST_STATE_SETALIGN:
          
st_state_alignment:

			if (!charCtr) {
				// set position of the next character (based on alignment and next character)
			    textWidth = GetTextWidth(pCurLine, pSt->hdr.pGolScheme->pFont);  
			
				// Display text with center alignment
				if (GetState(pSt, (ST_CENTER_ALIGN))) { 			
					MoveTo((pSt->hdr.left+pSt->hdr.right-textWidth) >> 1,	\
					       pSt->hdr.top+(lineCtr * pSt->textHeight));
				}	
				// Display text with right alignment
Exemplo n.º 17
0
/*********************************************************************
* Function: WORD CbDraw(CHECKBOX *pCb)
*
* Output: returns the status of the drawing
*		  0 - not complete
*         1 - done
*
* Overview: Draws check box.
*
********************************************************************/
WORD CbDraw(CHECKBOX *pCb)
{
    typedef enum {
        REMOVE,
        BOX_DRAW,
        RUN_DRAW,
        TEXT_DRAW,
        TEXT_DRAW_RUN,
        CHECK_DRAW,
        FOCUS_DRAW
    } CB_DRAW_STATES;

    static CB_DRAW_STATES state = REMOVE;

    SHORT checkIndent;

    if(IsDeviceBusy())
        return 0;

    switch(state) {

    case REMOVE:
        if(GetState(pCb,CB_HIDE|CB_DRAW)) {

            if(IsDeviceBusy())
                return 0;
            SetColor(pCb->hdr.pGolScheme->CommonBkColor);
            Bar(pCb->hdr.left,pCb->hdr.top,pCb->hdr.right,pCb->hdr.bottom);
            if(GetState(pCb,CB_HIDE))
                return 1;
        }
        state = BOX_DRAW;

    case BOX_DRAW:

        if(GetState(pCb,CB_DRAW)) {

            if(!GetState(pCb,CB_DISABLED)) {

                GOLPanelDraw(pCb->hdr.left+CB_INDENT,pCb->hdr.top+CB_INDENT,
                             pCb->hdr.left+(pCb->hdr.bottom-pCb->hdr.top)-CB_INDENT,
                             pCb->hdr.bottom-CB_INDENT, 0,
                             pCb->hdr.pGolScheme->Color0,
                             pCb->hdr.pGolScheme->EmbossDkColor,
                             pCb->hdr.pGolScheme->EmbossLtColor,
                             NULL, GOL_EMBOSS_SIZE);


            } else {

                GOLPanelDraw(pCb->hdr.left+CB_INDENT,pCb->hdr.top+CB_INDENT,
                             pCb->hdr.left+(pCb->hdr.bottom-pCb->hdr.top)-CB_INDENT,
                             pCb->hdr.bottom-CB_INDENT, 0,
                             pCb->hdr.pGolScheme->ColorDisabled,
                             pCb->hdr.pGolScheme->EmbossDkColor,
                             pCb->hdr.pGolScheme->EmbossLtColor,
                             NULL, GOL_EMBOSS_SIZE);

            }

            state = RUN_DRAW;

        case RUN_DRAW:
            if(!GOLPanelDrawTsk())
                return 0;
            state = TEXT_DRAW;


        case TEXT_DRAW:
            if(pCb->pText != NULL) {

                SetFont(pCb->hdr.pGolScheme->pFont);

                if (!GetState(pCb,CB_DISABLED)) {
                    SetColor(pCb->hdr.pGolScheme->TextColor0);
                } else {
                    SetColor(pCb->hdr.pGolScheme->TextColorDisabled);
                }

                MoveTo(pCb->hdr.left+pCb->hdr.bottom-pCb->hdr.top+CB_INDENT,
                       (pCb->hdr.bottom+pCb->hdr.top-pCb->textHeight)>>1);

                state = TEXT_DRAW_RUN;

            case TEXT_DRAW_RUN:
                if(!OutText(pCb->pText))
                    return 0;
            }

        }
        state = CHECK_DRAW;

    case CHECK_DRAW:

        if(GetState(pCb,CB_DRAW|CB_DRAW_CHECK)) {
            if(IsDeviceBusy())
                return 0;

            if(!GetState(pCb,CB_DISABLED)) {
                if(GetState(pCb,CB_CHECKED)) {
                    SetColor(pCb->hdr.pGolScheme->TextColor0);
                } else {
                    SetColor(pCb->hdr.pGolScheme->Color0);
                }
            } else {
                if(GetState(pCb,CB_CHECKED)) {
                    SetColor(pCb->hdr.pGolScheme->TextColorDisabled);
                } else {
                    SetColor(pCb->hdr.pGolScheme->ColorDisabled);
                }
            }

            checkIndent = (pCb->hdr.bottom-pCb->hdr.top)>>2;

            Bar(pCb->hdr.left+checkIndent+GOL_EMBOSS_SIZE,
                pCb->hdr.top+checkIndent+GOL_EMBOSS_SIZE,
                pCb->hdr.left+(pCb->hdr.bottom-pCb->hdr.top)-checkIndent-GOL_EMBOSS_SIZE,
                pCb->hdr.bottom-checkIndent-GOL_EMBOSS_SIZE);
        }
        state = FOCUS_DRAW;

    case FOCUS_DRAW:
        if(GetState(pCb,CB_DRAW|CB_DRAW_FOCUS)) {
            if(IsDeviceBusy())
                return 0;
            if(GetState(pCb,CB_FOCUSED)) {
                SetColor(pCb->hdr.pGolScheme->TextColor0);
            } else {
                SetColor(pCb->hdr.pGolScheme->CommonBkColor);
            }
            SetLineType(FOCUS_LINE);
            Rectangle(pCb->hdr.left, pCb->hdr.top,
                      pCb->hdr.right, pCb->hdr.bottom);
            SetLineType(SOLID_LINE);
        }
        state = REMOVE;
        return 1;
    }
Exemplo n.º 18
0
WORD GridDraw( GRID *pGrid )
{
    SHORT   i;
    SHORT   j;

    if ((pGrid->hdr.state & GRID_DRAW_ITEMS) || (pGrid->hdr.state & GRID_DRAW_ALL) || (pGrid->hdr.state & GRID_SHOW_FOCUS))
    {
        if (pGrid->hdr.state & GRID_DRAW_ALL)
        {
            // Clear the entire region.
            SetColor( pGrid->hdr.pGolScheme->CommonBkColor );
            Bar( pGrid->hdr.left, pGrid->hdr.top, pGrid->hdr.right, pGrid->hdr.bottom );

            // Draw the grid lines
            if (pGrid->hdr.state & (GRID_SHOW_LINES | GRID_SHOW_BORDER_ONLY | GRID_SHOW_SEPARATORS_ONLY))
            {
                SetLineType( SOLID_LINE );
                SetColor( pGrid->hdr.pGolScheme->EmbossLtColor  );

                // Draw the outside of the box
                // TODO This should have some 3D effects added with GOL_EMBOSS_SIZE
                if (pGrid->hdr.state & (GRID_SHOW_LINES | GRID_SHOW_BORDER_ONLY))
                {
                    Line( pGrid->hdr.left, pGrid->hdr.top,  pGrid->hdr.right, pGrid->hdr.top );
                    LineTo( _cursorX, pGrid->hdr.bottom );
                    LineTo( pGrid->hdr.left, _cursorY );
                    LineTo( pGrid->hdr.left, pGrid->hdr.top );
                }    

                // Draw the lines between each cell
                if (pGrid->hdr.state & (GRID_SHOW_LINES | GRID_SHOW_SEPARATORS_ONLY))
                {
                    for (i=1; i< pGrid->numColumns; i++)
                    {
                        Line( pGrid->hdr.left + i * (pGrid->cellWidth+1), pGrid->hdr.top, 
                              pGrid->hdr.left + i * (pGrid->cellWidth+1), pGrid->hdr.top + pGrid->numRows * (pGrid->cellHeight+1) );
                    }
                    for (i=1; i<pGrid->numRows; i++)
                    {
                        Line( pGrid->hdr.left,  pGrid->hdr.top + i * (pGrid->cellHeight+1),  
                              pGrid->hdr.right, pGrid->hdr.top + i * (pGrid->cellHeight+1) );
                    }
                }    
            }
        }

        for (i = 0; i < pGrid->numColumns; i++)
        {
            for (j = 0; j < pGrid->numRows; j++)
            {
                if ((pGrid->hdr.state & GRID_DRAW_ALL) ||
                    ((pGrid->hdr.state & GRID_DRAW_ITEMS) && (pGrid->gridObjects[CELL_AT(i,j)].status & GRIDITEM_DRAW)) || 
                    ((pGrid->hdr.state & GRID_SHOW_FOCUS) && (i == pGrid->focusX) && (j == pGrid->focusY)))
                {
                    // Clear the cell
                    SetColor( pGrid->hdr.pGolScheme->CommonBkColor );
                    Bar( CELL_LEFT, CELL_TOP, CELL_RIGHT, CELL_BOTTOM );

                    // Draw the cell
                    if ((pGrid->gridObjects[CELL_AT(i,j)].status & GRID_TYPE_MASK) == GRIDITEM_IS_BITMAP)
                    {
                        // Draw the bitmap
                        if (pGrid->gridObjects[CELL_AT(i,j)].data)
                        {
                            PutImage( CELL_LEFT, CELL_TOP, pGrid->gridObjects[CELL_AT(i,j)].data, BITMAP_SCALE );
                        }
                    }
                    else
                    { 
                        // Draw the text
                    }
    
        	        // Draw the focus if applicable.
        	        if ((pGrid->hdr.state & GRID_SHOW_FOCUS) && (i == pGrid->focusX) && (j == pGrid->focusY))
        	        {
                        SetColor( pGrid->hdr.pGolScheme->EmbossLtColor );
                        SetLineType( DOTTED_LINE );
                        SetLineThickness( NORMAL_LINE );   	        
                        Rectangle( CELL_LEFT, CELL_TOP, CELL_RIGHT, CELL_BOTTOM );
                    }  
                    
                    // If the cell is selected, indicate it.
                    if (pGrid->gridObjects[CELL_AT(pGrid->focusX,pGrid->focusY)].status & GRIDITEM_SELECTED)
                    {
                        SetColor( pGrid->hdr.pGolScheme->EmbossLtColor );
                        SetLineType( SOLID_LINE ); 
                        if (pGrid->hdr.state & GRID_SHOW_LINES)
                        {
                            SetLineThickness( THICK_LINE );   	        
                        }
                        else
                        {
                            SetLineThickness( NORMAL_LINE );   	        
                        }    
                        Rectangle( CELL_LEFT-1, CELL_TOP-1, CELL_RIGHT+1, CELL_BOTTOM+1 );
                    }
                    
                    GridClearCellState( pGrid, i, j, GRIDITEM_DRAW );  
                }
            }
        }
        
        //pGrid->state &= ~(GRID_DRAW_ITEMS || GRID_DRAW_ALL || GRID_SHOW_FOCUS); 
        pGrid->hdr.state &= ~(GRID_DRAW_ITEMS || GRID_DRAW_ALL ); 
        
        // Set line state
        SetLineType( SOLID_LINE );
    }

    return 1;
}
Exemplo n.º 19
0
//---------------------------------------------------------------------------
void __fastcall TCross::UpdateAngle(void) {
	int i, j, k, m = -1;
    double a = 90;
    int SwitchType = 0;
    CrossAngleList AngleList;     //转辙角列表
    TSwitchList SwitchList;
    TCrossLine CL;
    int BranchLineNumber = -1;
    MainLineNumber = -1;
    eBranchSide BranchSide;
    for (i = 0; i < Lines.size(); i++) {          // 拆分lpMIDDLE的线段
        if (Lines[i].Pos == lpMIDDLE) {
        	CL = Lines[i];
            Lines[i].EndX = X;
            Lines[i].EndY = Y;
            Lines[i].Pos = lpEND;
            Lines[i].EndSign = true;
            CL.StartX = X;
            CL.StartY = Y;
            CL.Pos = lpSTART;
            CL.StartSign = true;
            Lines.push_back(CL); //拆分后的线段没有lpMIDDLE的,因而不必再检查。
        }
    }
	for (i = 0; i < Lines.size(); i++) {           // 设置各线段的角度。
		if (InRange(X, Y, Lines[i].EndX, Lines[i].EndY, 1)) {
        	Lines[i].Angle = OppositeAngle(Lines[i].StartAngle);
        } else {
			Lines[i].Angle = Lines[i].StartAngle;
        }
    }
    sort(Lines.begin(), Lines.end());                                     // 删除重复线段。
    Lines.erase(unique(Lines.begin(), Lines.end()), Lines.end());
    MaxAngle = MinAngle = GetAngle(Lines[0].Angle, Lines[1].Angle);       //查找最大、最小角度,同时查找与其他线段夹角大于90°的线段,并设置为ltMAIN
    MaxAngleA = MaxAngleB = MinAngleA = MinAngleB = -1;
    for (i = 0; i < Lines.size(); i++) {
	    k = 0;
        for (j = 0; j < Lines.size(); j++) {
            if (i == j)
                continue;
            a = GetAngle(Lines[i].Angle, Lines[j].Angle);
            if (a > 90) {
                k++;
            }
            if (a > MaxAngle) {
                MaxAngle = a;
                MaxAngleA = i;
                MaxAngleB = j;
            }
            if (a < MinAngle) {
            	MinAngle = a;
                MinAngleA = i;
                MinAngleB = j;
            }
        }
        if (k > 1) {
            MainLineNumber = i;
        }
    }
    for (i = 0; i < Lines.size(); i++) {
        Lines[i].Type = GetBranchSide(Lines[MainLineNumber].Angle, Lines[i].Angle);
		SwitchType += Lines[i].Type;
		SetLineType(Lines[i].Type, i);
	}
    FrogNumber = -1;                                  //根据最小角查找对应的辙岔号。
    for (i = 0; i < AngleList.size(); i++) {
        if (EqualAngle(MinAngle, AngleList[i].Angle)) {
        	FrogNumber = AngleList[i].FrogNumber;
            break;
        }
    }
    if (FrogNumber == -1) {
        Type = sNone;
        return;
    }
    switch (SwitchType) {                         // 确定道岔型号
        case 7:		// 左单开
        	switch (FrogNumber) {
                case 6:
                	Type = sSimpleLeft6;
                    break;
                case 9:
                	Type = sSimpleLeft9;
                    break;
                case 7:
                	Type = sSimpleLeft7;
                    break;
	            default:
                	Type = sNone;
            }
        	break;
        case 11:	// 对称
        	switch (FrogNumber) {
                case 6:
                	Type = sSymmetry6;
                    break;
                case 65:
                	Type = sSymmetry65;
                    break;
                case 9:
                	Type = sSymmetry9;
                    break;
            	default:
                	Type = sNone;
            }
            break;
        case 13:	//右单开
        	switch (FrogNumber) {
                case 6:
                	Type = sSimpleRight6;
                    break;
                case 9:
                	Type = sSimpleRight9;
                    break;
                case 7:
                	Type = sSimpleRight7;
                    break;
	            default:
                	Type = sNone;
            }
            break;
        case 15:	//三开对称
        	if (FrogNumber == 7)
                Type = sTreble7;
            else
            	Type = sNone;
            break;
	    default:
        	Type = sNone;
    }
    return;
}