Exemplo n.º 1
0
static void dc_Init_ScreenDC (void)
{
    __mg_screen_dc.DataType = TYPE_HDC;
    __mg_screen_dc.DCType   = TYPE_SCRDC;
    __mg_screen_dc.hwnd = 0;
    __mg_screen_dc.gc = PHYSICALGC;

    __mg_screen_dc.bkcolor = PIXEL_lightwhite;
    __mg_screen_dc.bkmode = 0;

    __mg_screen_dc.brushtype = BT_SOLID;
    __mg_screen_dc.brushcolor = PIXEL_lightwhite;
    __mg_screen_dc.BrushOrig.x = __mg_screen_dc.BrushOrig.y = 0;

    __mg_screen_dc.pentype = PT_SOLID;
    __mg_screen_dc.pencolor = PIXEL_black;
    __mg_screen_dc.CurPenPos.x = __mg_screen_dc.CurPenPos.y = 0;

    __mg_screen_dc.textcolor = PIXEL_black;
    __mg_screen_dc.pLogFont = GetSystemFont (SYSLOGFONT_WCHAR_DEF);
    __mg_screen_dc.tabstop = 8;
    __mg_screen_dc.CurTextPos.x = __mg_screen_dc.CurTextPos.y = 0;
    __mg_screen_dc.cExtra = __mg_screen_dc.alExtra = __mg_screen_dc.blExtra = 0;

    __mg_screen_dc.ViewOrig.x = __mg_screen_dc.ViewOrig.y = 0;
    __mg_screen_dc.ViewExtent.x = __mg_screen_dc.ViewExtent.y = 1;
    __mg_screen_dc.WindowOrig.x = __mg_screen_dc.WindowOrig.y = 0;
    __mg_screen_dc.WindowExtent.x = __mg_screen_dc.WindowExtent.y = 1;

    __mg_screen_dc.bIsClient = FALSE;

    // init local clip region
    InitClipRgn (&__mg_screen_dc.lcrgn, &sg_FreeClipRectList);
    // init effective clip region
    InitClipRgn (&__mg_screen_dc.ecrgn, &sg_FreeClipRectList);

    // init global clip region information
    __mg_screen_dc.pGCRInfo = NULL;
    __mg_screen_dc.oldage = 0;

    __mg_screen_dc.DevRC.left = 0;
    __mg_screen_dc.DevRC.top  = 0;
    __mg_screen_dc.DevRC.right = WIDTHOFPHYGC - 1;
    __mg_screen_dc.DevRC.bottom = HEIGHTOFPHYGC - 1;

    // Set local clip region and effetive clip region to the screen.
    SetClipRgn (&__mg_screen_dc.lcrgn, &__mg_screen_dc.DevRC);
    SetClipRgn (&__mg_screen_dc.ecrgn, &__mg_screen_dc.DevRC);
}
Exemplo n.º 2
0
/*
 * Function: HDC GUIAPI CreateCompatibleDC (HDC hdc)
 *     This function create a memory dc, which is compatible 
 *     with specified hdc.
 * Parameters:
 *     HDC hdc: the specified DC handle.
 * Return:
 *     None.
 */
HDC GUIAPI CreateCompatibleDC(HDC hdc)
{
    GAL_GC gc;
    PDC pdc;
    PDC pMemDC = NULL;

    pdc = dc_HDC2PDC(hdc);

    if (!(pMemDC = malloc (sizeof(DC)))) return HDC_INVALID;
    pthread_mutex_lock (&__mg_gdilock);
    if (GAL_AllocateGC (pdc->gc, RECTW (pdc->DevRC), RECTH (pdc->DevRC), 
            GAL_BytesPerPixel (pdc->gc), &gc) != 0) {
        pthread_mutex_unlock (&__mg_gdilock);
        return HDC_INVALID;
    }
    pthread_mutex_unlock (&__mg_gdilock);

    memcpy (pMemDC, pdc, sizeof(DC));

    pMemDC->DataType = TYPE_HDC;
    pMemDC->DCType   = TYPE_MEMDC;
    pMemDC->inuse = TRUE;
    pMemDC->gc = gc;

    // clip region info
    InitClipRgn (&pMemDC->lcrgn, &sg_FreeClipRectList);
    InitClipRgn (&pMemDC->ecrgn, &sg_FreeClipRectList);
    pMemDC->pGCRInfo = NULL;
    pMemDC->oldage = 0;

    pMemDC->DevRC.left = 0;
    pMemDC->DevRC.top  = 0;
    pMemDC->DevRC.right = RECTW(pdc->DevRC);
    pMemDC->DevRC.bottom = RECTH(pdc->DevRC);

    SetClipRgn (&pMemDC->ecrgn, &pMemDC->DevRC);
    
    return (HDC)pMemDC;
}
Exemplo n.º 3
0
static BOOL InitWndManagementInfo (void)
{
    if (!InitMainWinMetrics())
        return FALSE;

    __mg_capture_wnd = 0;
    __mg_active_mainwnd = NULL;

    __mg_ptmi = NULL;

    __mg_ime_wnd = 0;
    sg_hCaretWnd = 0;

    g_rcScr.left = g_rcScr.top = 0;
    g_rcScr.right = GetGDCapability (HDC_SCREEN, GDCAP_MAXX) + 1;
    g_rcScr.bottom = GetGDCapability (HDC_SCREEN, GDCAP_MAXY) + 1;

    InitClipRgn (&sg_ScrGCRInfo.crgn, &sg_FreeClipRectList);
    SetClipRgn (&sg_ScrGCRInfo.crgn, &g_rcScr);
    pthread_mutex_init (&sg_ScrGCRInfo.lock, NULL);
    sg_ScrGCRInfo.age = 0;

    return TRUE;
}
Exemplo n.º 4
0
/************************************************************************
 Function: void AnimateText(BYTE mov)
                                                                       
 Overview: Routine to move or animate the text.
  		                                         
 Input: mov - number of pixels the text will be moved
                                                                       
 Output: none
************************************************************************/
void AnimateText(BYTE mov)
{
    static SHORT    xPos = STXXPOS, yPos = STXYPOS;
    static SHORT    x, y;
    SHORT           width;
    SHORT           height;

    SHORT           newX, newY, oldX, oldY;
    XCHAR           NewChar, *pString;

    // set the clipping region
    SetClip(CLIP_ENABLE);
    SetClipRgn(STXXPOS + 2, STXYPOS + 2, STXXPOS + STXWIDTH - 2, STXYPOS + STXHEIGHT - 2);

    // set the font
    SetFont(pHWData->pHWFont);

    // calculate string width & height	
    width = GetTextWidth((XCHAR *)pHWData->pHWStr, pHWData->pHWFont);
    height = GetTextHeight(pHWData->pHWFont);

    //-----------------------------------------------------------------
    // interlace the erasing and printing of characters
    // check first if we need to move in the positive or negative direction
    if((xPos + width) >= (STXXPOS + STXWIDTH))
        x = -(mov);
    if(xPos <= (STXXPOS))
        x = (mov);

    if((yPos + height) >= (STXYPOS + STXHEIGHT))
        y = -(mov);
    if(yPos <= (STXYPOS))
        y = (mov);

    pString = pHWData->pHWStr;
    oldX = xPos;
    oldY = yPos;
    newX = xPos + x;
    newY = yPos + y;
    while((XCHAR)15 < (XCHAR)(NewChar = *pString++))
    {

        // remove the old position of the character
        SetColor(FontScheme2->CommonBkColor);
        MoveTo(oldX, oldY);
        WAIT_UNTIL_FINISH(OutChar(NewChar));
        oldX = GetX();
        oldY = GetY();

        // display the character in the new position
        SetColor(BRIGHTBLUE);
        MoveTo(newX, newY);
        WAIT_UNTIL_FINISH(OutChar(NewChar));
        newX = GetX();
        newY = GetY();
    }

    xPos += x;
    yPos += y;

    // disable the clipping
    SetClip(CLIP_DISABLE);
}
Exemplo n.º 5
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.º 6
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.º 7
0
int SetNullClipRgn(HDC hdc)
{
	SetClipRgn(hdc, 0, 0, 0, 0);
	hdc->clip->null = 1;
	return 0;
}