Example #1
0
static int PaletteWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    int x, y;
    static GAL_Color colorPal[256], myPal[256];
    switch (message) {
    case MSG_CREATE:
        GetPalette(HDC_SCREEN, 0, 256, colorPal);
#ifdef _DEBUG
	int i;
        for (i = 0; i < 256; i++) {
            printf ("i = %d\n, red = %d\n, green = %d\n, blue = %d\n\n", 
                    i, colorPal[i].r, colorPal[i].g, colorPal[i].b);
        }
#endif
        break;

    case MSG_PAINT:
        {
            if (g_bShowBall)
                SendMessage (hWnd, MSG_LBUTTONDOWN, 0, 0);
        }
        break;
    case MSG_LBUTTONDOWN:
        g_bShowBall = TRUE;
        hdc = GetClientDC(hWnd);
        InitMyPalette(myPal);
        SetPalette(hdc, 0, 256, myPal);
        SetBrushColor(hdc, COLOR_red);
        FillCircle(hdc, 10, 10, 8);
        for (y = 0; y < 240; y += 20) {
            for (x = 0; x < 320; x += 20) {
              BitBlt(hdc, 0, 0, 20, 20, hdc, x, y, 0);
              SetColorfulPalette(hdc);
            }
        }
        ReleaseDC(hdc);
        break;

    case MSG_RBUTTONDOWN:
        SetColorfulPalette(HDC_SCREEN);
        SetBrushColor(HDC_SCREEN, PIXEL_yellow);
        FillCircle(HDC_SCREEN, 50, 50, 15);
        break;

    case MSG_CLOSE:
        DestroyAllControls (hWnd);
        DestroyMainWindow (hWnd);
        PostQuitMessage (hWnd);
        return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Example #2
0
static int DrawYSpace ( HDC hdc, int x, int y, int w, int h, PSCOLORDIA scld)
{
    int i;
    Uint8 r, g, b;
    HDC mdc;
    
    mdc = CreateCompatibleDCEx (hdc, scld->ysp_w, 256);
    for (i = 0; i < 256; i ++) {
        HSV2RGB (scld->clrh, scld->clrs, i, &r, &g, &b );
        SetPenColor (mdc, RGB2Pixel(mdc, r, g, b));
        MoveTo (mdc, 0, i);
        LineTo (mdc, 20 * scld->SCALE_W, i);
    }
    SetBrushColor (mdc, PIXEL_lightgray);
    FillBox (mdc, 21 * scld->SCALE_W, 0, scld->ysp_w * scld->SCALE_W, 256);
    scld->pz = scld->clrv ;
    SetPenColor (mdc, RGB2Pixel(mdc, 0, 0, 0));
    MoveTo ( mdc, 21 * scld->SCALE_W, scld->pz);
    LineTo ( mdc, 28 * scld->SCALE_W, scld->pz-3);
    MoveTo ( mdc, 21 * scld->SCALE_W, scld->pz);
    LineTo ( mdc, 28 * scld->SCALE_W, scld->pz+3);
    StretchBlt (mdc, 0, 0, scld->ysp_w, 256, hdc, x, y, w, h, 0);
    DeleteMemDC (mdc);
    return 0;
}
Example #3
0
static void setup_anim_mem_dc (HWND hwnd, ANIMATIONINFO* anim_info)
{
    gal_pixel bk_pixel;
    HDC hdc;

    if (!anim_info->anim)
        return;

    if (anim_info->mem_dc)
        DeleteCompatibleDC (anim_info->mem_dc);
    hdc = GetClientDC (hwnd);
#ifdef _USE_NEWGAL
    anim_info->mem_dc = CreateCompatibleDCEx (hdc,
                    anim_info->anim->width, anim_info->anim->height);
#else
    anim_info->mem_dc = CreateCompatibleDC (hdc);
#endif

    if (GetWindowExStyle (hwnd) & WS_EX_TRANSPARENT)
        bk_pixel = GetWindowBkColor (GetParent (hwnd));
    else
        bk_pixel = GetWindowBkColor (hwnd);

    SetBkColor (anim_info->mem_dc, bk_pixel);
    SetBrushColor (anim_info->mem_dc, bk_pixel);
    FillBox (anim_info->mem_dc, 0, 0,
            GetGDCapability (hdc, GDCAP_MAXX)+1,
            GetGDCapability (hdc, GDCAP_MAXY)+1);

    ReleaseDC (hdc);
}
Example #4
0
void UI_Out_800_600_SetMainFromColor ( int nBkColor )
{

	HDC hDC  = GetClientDC ( UI_Out_800_600_Get_From_Handl() ) ;
	SetBrushColor ( hDC , nBkColor ) ;
	FillBox ( hDC , 0 , 0 , 800 , 2 ) ;
	FillBox ( hDC , 0 , 24 , 800 , 1 ) ;
	FillBox ( hDC , 0 , 48+3 , 800 , 3 ) ;
	FillBox ( hDC , 0 , 149+3 , 800 , 3 ) ;
	FillBox ( hDC , 0 , 171+6 , 800 , 9-6 ) ;
	FillBox ( hDC , 0 , 204 , 800 , 4 ) ;
	FillBox ( hDC , 0 , 306 , 360 , 2 ) ;
	FillBox ( hDC , 360 , 482 , 325 , 2 ) ;
	FillBox ( hDC , 360 , 507 , 440 , 2 ) ;
	FillBox ( hDC , 0 , 597 , 800 , 3 ) ;
	FillBox ( hDC , 0 , 0 , 1 , 24 ) ;
	FillBox ( hDC , 799 , 0 , 1 , 24 ) ;
	FillBox ( hDC , 0 , 24 , 4 , 600 - 24 ) ;
	FillBox ( hDC , 796 , 24 , 4 , 600 - 24 ) ;
	FillBox ( hDC , 168 , 24 , 3 , 180 - 24 ) ;
	FillBox ( hDC , 339 , 24 , 3 , 180 - 24 ) ;
	FillBox ( hDC , 460 , 24 , 3 , 180 - 24 ) ;
	FillBox ( hDC , 581 , 24 , 3 , 180 - 24 ) ;
	FillBox ( hDC , 357 , 171+6 , 3 , 600 - 171-6 ) ;
	FillBox ( hDC , 683 , 149+6 , 3 , 509 - 149-6 ) ;
	FillBox ( hDC , 621 , 149+6 , 3 , 180 - 149-6 ) ;
	FillBox ( hDC , 530 , 171+6 , 3 , 208 - 171-6 ) ;
	ReleaseDC ( hDC ) ;

}
Example #5
0
static int DrawIndication (HDC hdc, PSCOLORDIA scld)
{
    scld->px = scld->clrh * scld->sp_w/360;
    scld->py = scld->sp_h - scld->clrs * scld->sp_h/255;
    SetBrushColor (hdc, RGB2Pixel (hdc, 0, 0, 0));
    Circle(hdc, scld->px, scld->py, 5);
    return 0;
}
Example #6
0
static void fill_corner(HDC hdc, int left, int top,
                 int right, int bottom, int corner, gal_pixel fillc)
{
    SetBrushColor(hdc, fillc);
    FillBox(hdc, left, top, corner, corner);
    FillBox(hdc, right-corner, top, corner, corner);
    FillBox(hdc, right-corner, bottom-corner, corner, corner);
    FillBox(hdc, left, bottom-corner, corner, corner);
}
Example #7
0
/**
The default function to drawn the background. It fills the supplied rectangle with the background colour.
*/
EXPORT_C void MTmCustom::DrawBackground(CGraphicsContext& aGc,const TPoint& /*aTextLayoutTopLeft*/,const TRect& aRect,
										const TLogicalRgb& aBackground,TRect& aRectDrawn) const
	{
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	SetBrushColor(aGc,aBackground);
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	aGc.DrawRect(aRect);
	aRectDrawn = aRect;
	}
static void this_paint_desktop(void* context, HDC dc_desktop, const RECT* inv_rc)
{
    PBITMAP bg_bmp = NULL;
	int i = 0;
    DSPITEM* item;

    if(((Context *)context)->bg)
        bg_bmp = ((Context *)context)->bg;

    SelectClipRect (dc_desktop, inv_rc);
    if (bg_bmp) {
        FillBoxWithBitmap (dc_desktop, 0, 0,
                g_rcDesktop.right, g_rcDesktop.bottom, bg_bmp);
    }else {
        SetBrushColor (dc_desktop, PIXEL_blue);
        FillBox(dc_desktop, g_rcDesktop.left, g_rcDesktop.top,
                RECTW(g_rcDesktop), RECTH(g_rcDesktop));
    }
    
    item = icon_info.app_items;
    for(i = 0; i < icon_info.nr_apps; i++, item++)
	{
        if(i == icon_info.focus)
        {
            SetBrushColor (dc_desktop, PIXEL_darkblue);
            FillBox(dc_desktop, item->hot_spot_rc.left, 
                    item->hot_spot_rc.top,
                    RECTW(item->hot_spot_rc), 
                    RECTH(item->hot_spot_rc));
        }
        FillBoxWithBitmap (dc_desktop,
                item->hot_spot_rc.left,
                item->hot_spot_rc.top,
                RECTW(item->hot_spot_rc),
                RECTH(item->hot_spot_rc), 
                &item->bmp);
        SetBkMode(dc_desktop, BM_TRANSPARENT);
        TextOut(dc_desktop, 
                item->text_rc.left, item->text_rc.top, item->name);
	}
}
//-----------------------------------------------------
void CTestRectGc::ConstructL(TPoint aPt, TSize aSize, TRgb aPenColor, TRgb aBrushColor, CGraphicsContext::TBrushStyle aBrushStyle)
    {    
    SetPenColor(aPenColor);
    SetBrushColor(aBrushColor);
    
    SetBrushStyle(aBrushStyle);
    SetDrawType(EDrawRect);
    SetExtent(aPt, aSize);
   
   	iFrameNo = g_FrameStart+=5; //Offset frame start for next control
   	g_FrameStart %= KNumAnimFrames;			
   }
Example #10
0
void WindowClearAll (PCONINFO con, int color)
{
    HDC hdc;
    RECT rcClient;
    
    GetClientRect (con->hWnd, &rcClient);

    hdc = GetPrivateClientDC (con->hWnd);
    SetBrushColor (hdc, SysColorIndex [color_map (color)]);
    FillBox (hdc, rcClient.left, rcClient.top,
                  RECTW (rcClient), RECTH (rcClient));
}
Example #11
0
static void drawButton(HWND hDlg, HDC IDCButton, unsigned int flag)
{
	HWND hWnd;
	RECT rect;
	MBPrivData* privData;
	DWORD old_bkmode;
	gal_pixel old_color;
	HDC hdc;
	char* text;

	privData = (MBPrivData*)GetWindowAdditionalData(hDlg);
	hWnd = GetDlgItem(hDlg, IDCButton);
	GetClientRect(hWnd, &rect);

	hdc = GetDC(hWnd);

	if(flag == BUTTON_SELECTED) {
		old_color = SetBrushColor(hdc, gp_hilite_bgc);
		old_bkmode = SetBkMode(hdc, BM_TRANSPARENT);
		FillBox(hdc, rect.left, rect.top, RECTW(rect), RECTH(rect));
		SetTextColor(hdc, gp_hilite_fgc);
		text = (char*)GetWindowAdditionalData2(hWnd);
		DrawText(hdc, text, -1, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

		SetBrushColor(hdc, old_color);
		SetBkMode(hdc, old_bkmode);
	} else if(flag == BUTTON_UNSELECTED) {
		old_color = SetBrushColor(hdc, gp_normal_bgc);
		old_bkmode = SetBkMode(hdc, BM_TRANSPARENT);
		FillBox(hdc, rect.left, rect.top, RECTW(rect), RECTH(rect));
		SetTextColor (hdc, gp_normal_fgc);
		text = (char*)GetWindowAdditionalData2(hWnd);
		DrawText(hdc, text, -1, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

		SetBrushColor(hdc, old_color);
		SetBkMode(hdc, old_bkmode);
	}

	ReleaseDC(hdc);
}
Example #12
0
/*
 *                       
 *         
 *                                  ¨x¨x¨x¨x¨x¨x¨xtop_line(dark)
 *                                   ---------top_line(light)
 *                                ¨† ¨‡        ¨‡¨†
 *        left_line(dark+light)   ¨† ¨‡        ¨‡¨†right_line(light+dark)
 *                                ¨† ¨‡        ¨‡¨†
 *    base_line_left ¨{¨{¨{¨{¨{¨{¨{                ¨{¨{¨{¨{¨{¨{¨{ base_line_right
 */
static void draw_hilight_box (HWND hWnd, HDC hdc, COOL_INDICATOR_ITEMDATA* item)
{
    int  l,r,t,b; 
    WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd);
    DWORD color;
    DWORD mainc = GetWindowElementAttr (hWnd, WE_FGC_THREED_BODY);	//UI@hilight_box_color
    
	if(item == NULL)
		return;

    l = item->RcTitle.left;
    t = item->RcTitle.top + 2;
    r = item->RcTitle.right + 1;
    b = item->RcTitle.bottom + 1;

    color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_DARKER);
    SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color)));
    MoveTo (hdc, l, t);
    LineTo (hdc, l, b);	//left_line_dark
    MoveTo (hdc, r, t);
    LineTo (hdc, r, b);	//right_line_dark

	MoveTo (hdc, l, t);
	LineTo (hdc, r, t);	//top_line_dark

    color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_LIGHTER);
    SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color)));
    MoveTo (hdc, l + 1, t);
    LineTo (hdc, l + 1, b);	//left_line_light
    MoveTo (hdc, r - 1, t);
    LineTo (hdc, r - 1, b);	//right_line_light

	MoveTo (hdc, l, t+1);
	LineTo (hdc, r, t+1);	//top_line_light

	mainc = GetWindowElementPixelEx(hWnd, hdc, WE_FGC_THREED_BODY);	//to avoid hdc use the color as ARGB
	SetBrushColor(hdc, mainc);	//base line color

	RECT rP;
	GetWindowRect(GetParent(hWnd), &rP);
	int x, y, w, h;
	x = 0;
	y = item->RcTitle.bottom + 2;
	w = item->RcTitle.left + 2;
	h = 4;
	FillBox(hdc, x, y, w, h);	//base_line_left
	x = item->RcTitle.right + 1;
	y = item->RcTitle.bottom + 2;
	w = RECTW(rP) - x;
	h = 4;
	FillBox(hdc, x, y, w, h);	//base_line_right
}
Example #13
0
static int DrawSelSpace (HDC hdc, int x, int y, int w, int h, PSCOLORDIA scld)
{
    Uint8 r, g, b;
    HDC mdc;
    
    mdc = CreateCompatibleDCEx (hdc, w, h);
    HSV2RGB (scld->clrh, scld->clrs, scld->clrv, &r, &g, &b);
    SetBrushColor (mdc, RGB2Pixel(mdc, r, g, b));
    FillBox (mdc, 0, 0, w, h);
    BitBlt (mdc, 0, 0, w, h, hdc, x, y, 0);
    DeleteMemDC (mdc);
    return 0;
}
Example #14
0
static void draw_scroll_button (HWND hWnd, HDC hdc, RECT *title_rc, PPROPSHEETDATA propsheet, DWORD style)
{
    RECT btn_rect = {0, 0, 0, 0};
    int l, r, t, b;

    btn_rect.top = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->top + 1 : title_rc->top;
    btn_rect.right = GetMainWinMetrics (MWM_SB_WIDTH) - 4;
    btn_rect.bottom = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->bottom + 2: title_rc->bottom - 2;
        
    t = btn_rect.top + 5;
    r = btn_rect.right;
    b = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.bottom - 7 : btn_rect.bottom - 4;

    SelectClipRect (hdc, &btn_rect);
    SetBrushColor (hdc, GetWindowBkColor (hWnd));
    FillBox (hdc, btn_rect.left, btn_rect.top, btn_rect.right + 3, btn_rect.bottom); 
    SetPenColor (hdc, GetWindowElementColorEx (hWnd, WEC_3DBOX_DARK));
    for ( ; t <= b; r--, t++, b--) {
        MoveTo (hdc, r, t);
        LineTo (hdc, r, b);
    }
    
    btn_rect.left = propsheet->head_rc.right - GetMainWinMetrics(MWM_SB_WIDTH);
    //btn_rect.top = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.top - 1 : btn_rect.top;
    l = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.left + 5 : btn_rect.left + 4;
    r = btn_rect.right = propsheet->head_rc.right;
    b = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.bottom - 8 : btn_rect.bottom - 5;
    t = btn_rect.top + 6;
    SelectClipRect (hdc, &btn_rect);
    SetBrushColor (hdc, GetWindowBkColor (hWnd));
    FillBox (hdc, btn_rect.left, btn_rect.top, btn_rect.right, btn_rect.bottom);
    SetPenColor (hdc, GetWindowElementColorEx (hWnd, WEC_3DBOX_DARK));
    for ( ; t <= b; l++, t++, b--) {
        MoveTo (hdc, l, t);
        LineTo (hdc, l, b);
    }

}
Example #15
0
void UI_Out_640_480_Show_Info_ByColor(char *pszInfo, unsigned int  bc,unsigned int  tc)
{
	HDC hDC;
	RECT rt;	
	hDC = GetDC(From_Handl); 
	rt.left = rec9.left+16;
	rt.top = rec9.top+16;
	rt.right = rec9.right-16;
	rt.bottom = rec9.bottom-16;
	SetBrushColor(hDC, bc); 
	FillBox(hDC, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top);  
	SetBkMode(hDC, BM_TRANSPARENT); 
	SetTextColor(hDC,  tc); 
	DrawText(hDC , pszInfo, -1, &rt, DT_WORDBREAK | DT_LEFT | DT_VCENTER);  
	ReleaseDC(hDC); 
}
Example #16
0
void GUIAPI Draw3DDownThinFrame (HDC hDC, int l, int t, int r, int b, gal_pixel fillc)
{
    SetPenColor(hDC, GetWindowElementColor (WEC_3DFRAME_LEFT));
    MoveTo(hDC, l, b);
    LineTo(hDC, r, b);
    LineTo(hDC, r, t);
    SetPenColor(hDC, GetWindowElementColor (WEC_3DFRAME_RIGHT));
    MoveTo(hDC, l, b);
    LineTo(hDC, l, t);
    LineTo(hDC, r, t);

    if (fillc != 0) {
         SetBrushColor(hDC, fillc);
         FillBox(hDC, l + 1, t + 1, r - l - 2, b - t - 2);
    }
}
Example #17
0
void UI_Out_640_480_Set_Help_Info(char *pszInfo)
{
	HDC hDC;
	RECT rt;
	hDC = GetDC(From_Handl); 
	rt.left = rec9.left+5;
	rt.top = rec9.bottom-17;
	rt.right = rec9.right-5;
	rt.bottom = rec9.bottom-1;
	SetBrushColor(hDC, TISHI_BACK_COLOR);   
	FillBox(hDC, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top);  
	SetBkMode(hDC, BM_TRANSPARENT); 
	SetTextColor(hDC, RGB(255, 255, 0));    
	DrawText(hDC , pszInfo, -1, &rt, DT_WORDBREAK | DT_LEFT | DT_VCENTER);  
	ReleaseDC(hDC); 
	
}
static void myDrawItem (HWND hWnd, HSVITEM hsvi, HDC hdc, RECT *rcDraw)
{
    const char *name = (const char*)scrollview_get_item_adddata (hsvi);

    SetBkMode (hdc, BM_TRANSPARENT);
    SetTextColor (hdc, PIXEL_black);

    if (scrollview_is_item_hilight(hWnd, hsvi)) {
        SetBrushColor (hdc, PIXEL_blue);
        FillBox (hdc, rcDraw->left+1, rcDraw->top+1, RECTWP(rcDraw)-2, RECTHP(rcDraw)-1);
        SetBkColor (hdc, PIXEL_blue);
        SetTextColor (hdc, PIXEL_lightwhite);
    }

    Rectangle (hdc, rcDraw->left, rcDraw->top, rcDraw->right - 1, rcDraw->bottom);
    TextOut (hdc, rcDraw->left + 3, rcDraw->top + 2, name);
}
static void
draw_ball (HDC hdc, int x, int y)
{
    int bx, by;

    if (field [x][y].color){
        by = STONE_SIZE * (field [x][y].color - 1);
        bx = STONE_SIZE * (field [x][y].frame);
        
        FillBoxWithBitmapPart (hdc, x * STONE_SIZE, y * STONE_SIZE, 
                 STONE_SIZE, STONE_SIZE, 0, 0, &stones,
                 bx, by);
    } else {
        SetBrushColor (hdc, PIXEL_black);
        FillBox (hdc, x * STONE_SIZE, y * STONE_SIZE,
                       STONE_SIZE, STONE_SIZE);
    }
}
Example #20
0
void UI_Out_640_480_Show_Edit(int nEditAt, char *pszInfo)
{

	HDC hDC;
	RECT rt;

	hDC = GetDC(From_Handl); 
	rt.left = rtEdit[nEditAt].left+2;
	rt.top = rtEdit[nEditAt].top+2;
	rt.right = rtEdit[nEditAt].right-2;
	rt.bottom = rtEdit[nEditAt].bottom-2;
	SetBrushColor(hDC, EDIT_BACK_COLOR);    
	FillBox(hDC, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top);  
	SetBkMode(hDC, BM_TRANSPARENT); 
	SetTextColor(hDC, EDIT_FRONT_COLOR);    
	DrawText(hDC , pszInfo, -1, &rt, DT_SINGLELINE | DT_LEFT | DT_VCENTER); 
	ReleaseDC(hDC); 

}
Example #21
0
void UI_Out_640_480_SetMainFromColor(int nBkColor)
{
	HWND hWnd = From_Handl;
	HDC hDC;
	hDC = GetClientDC(hWnd); 
	SetBrushColor(hDC, nBkColor);   
	FillBox(hDC, 2, 23, 636,3); 
	FillBox(hDC, 2, rec3.top-2, 636,2);
	FillBox(hDC, 2, rec5.top-3, 275,3); 
	FillBox(hDC, 2, rec6.top-3, 275,3);
	FillBox(hDC, 2, rec8.top-3, 275,3);
	FillBox(hDC, rec10.left, rec10.bottom+2, rec10.right-rec10.left+2,3);
	FillBox(hDC, 2, rec8.bottom+2, 636,2);
	FillBox(hDC, 2, 23, 2,453);
	FillBox(hDC,rec1.right+2, 23, 2, 453);
	FillBox(hDC,rec2.right+2, 23, 2, 453);
	FillBox(hDC,rec6.right+2, rec6.top-2, 3, rec6.bottom-rec6.top +6);
	ReleaseDC(hDC); 
}
Example #22
0
void UI_Out_640_480_Set_From_Title(HWND hWnd, char* sTitle)
{
	HDC hdc;
	RECT recttitle;
	RECT rectParent; 
	GetClientRect(hWnd, &rectParent);
	hdc = BeginPaint (hWnd); 
	recttitle.left=rectParent.left + 1;
	recttitle.top=rectParent.top + 2;
	recttitle.right=rectParent.right - 3;
	recttitle.bottom=rectParent.top + 21;
	SetBrushColor (hdc, SUBTITLECOLOR); 
	FillBox (hdc, recttitle.left, recttitle.top, recttitle.right-recttitle.left, recttitle.bottom-recttitle.top);   
	SetBkColor(hdc,SUBTITLECOLOR);  
	SetTextColor(hdc,TITLE_TEXT_COLOR); 
	DrawText (hdc, sTitle, -1, &recttitle,
		DT_SINGLELINE | DT_CENTER | DT_VCENTER);   
	SetPenColor (hdc, SEPLINECOLOR2 );	//里层SEPLINECOLOR2
	MoveTo (hdc,rectParent.left + 1, rectParent.top +1);    
	LineTo (hdc, rectParent.right -1,rectParent.top + 1);   
	MoveTo (hdc, rectParent.left +1,rectParent.top +1); 
	LineTo (hdc, rectParent.left +1, rectParent.bottom -1); 
	SetPenColor (hdc, LTFRAMECOLOR );	//外层LTFRAMECOLOR
	MoveTo (hdc, rectParent.left , rectParent.top); 
	LineTo (hdc, rectParent.right, rectParent.top); 
	MoveTo (hdc, rectParent.left , rectParent.top); 
	LineTo (hdc, rectParent.left , rectParent.bottom);  
	//画窗体右下两对边框线
	SetPenColor (hdc, SEPLINECOLOR1 );	//里层SEPLINECOLOR1
	MoveTo (hdc, rectParent.right-2, rectParent.top+1); 
	LineTo (hdc, rectParent.right-2, rectParent.bottom-2);  
	MoveTo (hdc, rectParent.left+1 ,rectParent.bottom -2);  
	LineTo (hdc, rectParent.right-2 , rectParent.bottom -2);    
	SetPenColor (hdc, RBFRAMECOLOR );	//外层RBFRAMECOLOR
	MoveTo (hdc, rectParent.right-1, rectParent.top);   
	LineTo (hdc, rectParent.right-1, rectParent.bottom-1);  
	MoveTo (hdc, rectParent.left, rectParent.bottom-1); 
	LineTo (hdc, rectParent.right-1, rectParent.bottom-1);  
	EndPaint (hWnd, hdc);   
}
Example #23
0
/****************************** Drawing Helpers *******************************/
void GUIAPI Draw3DUpFrame(HDC hDC, int l, int t, int r, int b, gal_pixel fillc)
{
    r--;
    b--;

    SetPenColor(hDC, GetWindowElementColor (WEC_3DFRAME_RIGHT_INNER));
    Rectangle(hDC, l, t, r, b);
    SetPenColor(hDC, GetWindowElementColor (WEC_3DFRAME_LEFT_INNER));
    Rectangle(hDC, l, t, r - 1, b - 1);
    SetPenColor(hDC, GetWindowElementColor (WEC_3DFRAME_LEFT_OUTER));
    MoveTo(hDC, l, b);
    LineTo(hDC, r, b);
    LineTo(hDC, r, t);
    SetPenColor(hDC, GetWindowElementColor (WEC_3DFRAME_RIGHT_OUTER));
    MoveTo(hDC, l + 1, b - 1);
    LineTo(hDC, l + 1, t + 1);
    LineTo(hDC, r - 1, t + 1); 

    if (fillc != 0) {
         SetBrushColor(hDC, fillc);
         FillBox(hDC, l + 2, t + 2, r - l - 3, b - t - 3);
    }
}
Example #24
0
static void anim_treat_frame_disposal (ANIMATIONINFO* anim_info,
                                       ANIMATIONFRAME* frame)
{
    int disposal = -1;

    if (frame)
        disposal = frame->disposal;
    else {
        SetBrushColor (anim_info->mem_dc, GetBkColor(anim_info->mem_dc));
        FillBox (anim_info->mem_dc, anim_info->anim->frames->off_x, anim_info->anim->frames->off_y,
                 anim_info->anim->frames->width, anim_info->anim->frames->height);
    }

    switch (disposal) {
    case 2:
        restore_bk_color (anim_info, frame);
        break;
    case 3:
        restore_prev_frame (anim_info, frame->prev);
        break;
    default:
        break;
    }
}
Example #25
0
void UIShape::SetBrushColor(const QString &Color)
{
    SetBrushColor(UIWidget::GetQColor(Color));
}
Example #26
0
/**
Draw text and its highlit background if any. The text should be drawn with its origin
at aTextOrigin after optionally drawing the background in aRect; and the text should be expanded
in width by aExtraPixels, normally by using letterspacing. The default function
draws the text with no special effects and supports standard and rounded highlighting only.
The font, colour, and text style, which are specified in aFormat, have already been selected into the graphics context.
*/
EXPORT_C void MTmCustomExtension::DrawText(CGraphicsContext& aGc,const TPoint& /*aTextLayoutTopLeft*/,const TRect& aRect,
								  const TTmLineInfo& /*aLineInfo*/,const TTmCharFormat& aFormat,
								  const TDesC& aText,const TInt aStart, const TInt aEnd, const TPoint& aTextOrigin,TInt aExtraPixels) const
	{
	TUint effects = aFormat.iEffects;
	CGraphicsContext::TTextParameters contextParam;
	contextParam.iStart = aStart;
	contextParam.iEnd = aEnd;
	
	// Draw the highlight.
	if (effects)
		{
		if (effects & TTmCharFormat::EBackground)
			{
			// Draw the background.
			if (!(effects & TTmCharFormat::ERounded))
				{
				SetBrushColor(aGc,aFormat.iBackgroundColor);
				aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
				aGc.SetPenStyle(CGraphicsContext::ENullPen);
				aGc.DrawRect(aRect);
				aGc.SetPenStyle(CGraphicsContext::ESolidPen);
				}

			// Draw the background with rounded corners.
			else
				{
				/*
				The pen is made solid, not null, and the pen colour is set, to
				work around some bugs in DrawRoundRect: see ER5U defect EDNGASR-487K64.
				*/
				SetBrushColor(aGc,aFormat.iBackgroundColor);
				aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
				aGc.SetPenStyle(CGraphicsContext::ESolidPen);
				SetPenColor(aGc,aFormat.iBackgroundColor);
				TSize corner(Min(aRect.Height(),aRect.Width()) / 3,aRect.Height() / 3);
				aGc.DrawRoundRect(aRect,corner);
				//+ fill in flat side if needed; draw ordinary rectangle if both sides are flat.
				SetPenColor(aGc,aFormat.iTextColor);
				}
			}

		// Draw the text offset towards the bottom-right in the highlight colour before drawing in the text colour.
		else if (effects & TTmCharFormat::EShadow)
			{
			SetPenColor(aGc,aFormat.iBackgroundColor);
			if (aExtraPixels)
				aGc.SetCharJustification(aExtraPixels,aText.Length());
			TPoint p(aTextOrigin);
			p.iX += 2;
			p.iY += 2;
			if (aStart < 0 || aEnd < 0)
				aGc.DrawText(aText,p);
			else
				aGc.DrawText(aText,&contextParam,p);
			SetPenColor(aGc,aFormat.iTextColor);
			}
		}

	// Draw the text, with letterspacing if needed.
	if (aExtraPixels)
		aGc.SetCharJustification(aExtraPixels,aText.Length());
	if (aStart < 0 || aEnd < 0)
		aGc.DrawText(aText,aTextOrigin);
	else	
		aGc.DrawText(aText,&contextParam,aTextOrigin);
	}
/* 
 * draw_propsheet:
 *
 * This function draw nonclilent area of propsheet control . 
 *
 * Author: Peng LIU
 * Date: 2007-12-03
 */
static void draw_propsheet (HWND hwnd, HDC hdc, PCONTROL ctrl, 
   PPROPSHEETDATA propsheet, PPROPPAGE page)
{
    RECT title_rc = {0, 0, 1, 0}, rc;
    int flag = 0;
    DWORD main_c, old_brush_c;
    int scrollbtn_left = 0;

    title_rc.bottom = propsheet->head_rc.bottom;
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
        title_rc.top = propsheet->head_rc.top;
    } 
    
    main_c = GetWindowElementAttr (hwnd, WE_MAINC_THREED_BODY);

    /* Draw the content window border*/
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM)  {
        SetRect(&rc, 0, 0, 
                propsheet->head_rc.right, 
                ctrl->bottom - ctrl->top - RECTH(propsheet->head_rc) + 1);
        /*
        rc.left = 0;
        rc.right = propsheet->head_rc.right;
        rc.top = 0;
        rc.bottom = rc.top + ctrl->bottom - ctrl->top - RECTH(propsheet->head_rc) + 1;
        */
    }
    else {
        SetRect(&rc, 0, propsheet->head_rc.bottom - 1, 
                propsheet->head_rc.right,
                propsheet->head_rc.bottom 
                + ctrl->bottom - ctrl->top - RECTH(propsheet->head_rc));
        /*
        rc.left = 0;
        rc.top = propsheet->head_rc.bottom - 1;
        rc.right = propsheet->head_rc.right;
        rc.bottom = rc.top + ctrl->bottom - ctrl->top - RECTH(propsheet->head_rc) + 1;
        */
    }
    ((WINDOWINFO*)GetWindowInfo (hwnd))->we_rdr->draw_3dbox(hdc, 
            &rc, main_c, LFRDR_BTN_STATUS_NORMAL);


    /* Just for PSS_SCROLLABLE style 
       if title is overload (too many titles for the propsheet) 
       we should move-right the leftmot title some pixel 
       and we should draw a small icon (left arrow) for the sheet */
    if ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) {
        title_rc.right = (propsheet->overload == TRUE) ? 
                        title_rc.right + get_metrics (MWM_SB_WIDTH) : title_rc.right;
        if (propsheet->overload == TRUE)
            scrollbtn_left = propsheet->head_rc.right - get_metrics (MWM_SB_WIDTH);
    }

    old_brush_c = SetBrushColor (hdc, DWORD2PIXEL (hdc, main_c));
    while (page) {
        if (((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) && propsheet->overload == TRUE)
            if (((title_rc.right + page->width > scrollbtn_left) || (page->width == 0))
                            && !(propsheet->first_display_page == page))
                break;
        
        if ((ctrl->dwStyle & 0x0fL) == PSS_COMPACTTAB) {
            if (((title_rc.right + page->width > propsheet->head_rc.right) || (page->width == 0))
                            && !(propsheet->first_display_page == page))
                break;
        }

        /* draw some box for title */
        if (title_rc.right == 1)
            title_rc.left = title_rc.right - 1;
        else
            title_rc.left = title_rc.right;

        title_rc.right = title_rc.left + page->width;
        
        flag = 0;
        if (page == propsheet->active)
            flag = flag | LFRDR_TAB_ACTIVE;

        if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) 
            flag = flag | LFRDR_TAB_BOTTOM;

        if (page->icon) {
            flag = flag | LFRDR_TAB_ICON;
             
            ((WINDOWINFO*)GetWindowInfo (hwnd))->we_rdr->draw_tab (hwnd, hdc, 
                    &title_rc, page->title,main_c, flag, page->icon);
        }
        else 
            ((WINDOWINFO*)GetWindowInfo (hwnd))->we_rdr->draw_tab (hwnd, hdc, 
                    &title_rc, page->title, main_c, flag, 0);

        page = page->next;
    }

    /* draw scroll button , just for PSS_SCROLLABLE style */
    if ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE && 
         propsheet->overload == TRUE)  
        draw_scroll_button (hwnd, hdc, &title_rc, propsheet, ctrl->dwStyle);

    SetBrushColor (hdc, DWORD2PIXEL(hdc, old_brush_c));
}
static int ScrollbarProc(HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    /** IDC of SCROLLBAR control */
    static int _my_scroll_idc = 100;

    /** scrollbar handle of main window  */
    static HWND hwnd_sb_main;

    /** scrollbar handle of control */
    HWND hwnd_sb_ctrl;

    switch (message)
    {
        case MSG_CREATE:
            {
                _rect_invalid.left   = SEP;
                _rect_invalid.top    = 0;
                _rect_invalid.right  = g_rcScr.right;
                _rect_invalid.bottom = g_rcScr.bottom;

                SCROLLINFO scinfo = {0};
                scinfo.fMask = SIF_ALL;
                scinfo.nMin = SB_MIN;
                scinfo.nMax = SB_MAX;
                scinfo.nPage = SB_PAGE;
                scinfo.nPos = SB_MIN;

                calc_circle_pos (scinfo.nPos);
                calc_box_pos (scinfo.nPos);

                /** classic VSCROLL with SBS_NOTNOTIFYPARENT */

                hwnd_sb_main = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                        | SBS_NOTNOTIFYPARENT
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 50, 20, 150, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_main, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_main, MSG_SETFOCUS, 0, 0);

                /** flat VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        43, 50, 20, 150, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        66, 50, 20, 150, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        92, 50, 20, 150, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** classic NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        120, 50, 20, 34, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** flat NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        140, 50, 20, 34, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        160, 50, 20, 34, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        184, 50, 20, 34, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** classic NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        210, 50, 20, 150, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** flat NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        232, 50, 20, 150, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        254, 50, 20, 150, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        276, 50, 20, 150, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** classic HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 220, 150, 20, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** flat HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 240, 150, 20, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 260, 150, 20, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 280, 150, 20, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);
            }
            break;

        case MSG_COMMAND:
            {
                int code = HIWORD(wParam);
                HWND scroll = (HWND)lParam;
                int pos = 0;

                switch (code) 
                {
                    case SB_LINELEFT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, --pos, TRUE);
                        }

                        break;

                    case SB_LINERIGHT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGELEFT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGERIGHT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_LINEUP:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, --pos, TRUE);
                        }

                        break;

                    case SB_LINEDOWN:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGEUP:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGEDOWN:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_THUMBPOSITION:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);
                        }
                        break;

                    case SB_THUMBTRACK:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);
                        }
                        break;

                    case SB_TOP:
                        {
                            pos = SB_MIN;
                        }
                        break;

                    case SB_BOTTOM:
                        {
                            pos = SB_MAX;
                        }
                        break;

                    default:
                        break;
                }

                draw_shape (hwnd, pos);
            }
            break;

        case MSG_HSCROLL:
            {
                int pos = 0;
                switch (wParam)
                {
                    case SB_LINELEFT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, --pos, TRUE);
                        }

                        break;

                    case SB_LINERIGHT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGELEFT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGERIGHT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;
                    case SB_THUMBPOSITION:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_THUMBTRACK:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_TOP:
                        {
                            pos = SB_MIN;
                        }
                        break;

                    case SB_BOTTOM:
                        {
                            pos = SB_MAX;
                        }
                        break;

                    default:
                        break;
                }
                draw_shape (hwnd, pos);
            }
            break;

        case MSG_VSCROLL:
            {
                int pos = 0;
                switch (wParam)
                {
                    case SB_LINEUP:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, --pos, TRUE);
                            
                        }

                        break;

                    case SB_LINEDOWN:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGEUP:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGEDOWN:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;
                    case SB_THUMBPOSITION:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_THUMBTRACK:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_TOP:
                        {
                            pos = SB_MIN;
                        }
                        break;

                    case SB_BOTTOM:
                        {
                            pos = SB_MAX;
                        }
                        break;
                    default:
                        break;
                }
                draw_shape (hwnd, pos);
            }
            break;

        case MSG_PAINT:
            {
                HDC hdc = BeginPaint(hwnd); 

                /** separator */
                MoveTo (hdc, SEP, 0);
                LineTo (hdc, SEP, g_rcScr.bottom);

                /** circle */
                Circle (hdc, CC_CENTER_X, CC_CENTER_Y, _radius);

                /** top and bottom line of box */
                MoveTo (hdc, SEP + 20, BOX_Y_MIN);
                LineTo (hdc, SEP + 20 + BOX_WIDTH + 40, BOX_Y_MIN);

                MoveTo (hdc, SEP + 20, BOX_Y_MAX);
                LineTo (hdc, SEP + 20 + BOX_WIDTH + 40, BOX_Y_MAX);

                /** box */
                SetBrushColor (hdc, PIXEL_black);
                FillBox (hdc, SEP + 40, _box_pos_y, BOX_WIDTH, BOX_HEIGHT);

                EndPaint (hwnd, hdc);
            }
            break;

        case MSG_CLOSE:
            {
                DestroyMainWindow (hwnd);
                PostQuitMessage (hwnd);
                return 0;
            }
    }

    return DefaultMainWinProc(hwnd, message, wParam, lParam);
}
static int PaletteWndProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	
	switch ( message ) {
	case MSG_SETCURSOR:
        SetCursorEx(0, FALSE);
        return 0;
 case MSG_CREATE:
        /* fill our palette with a gradually altering sequence of colors */
        for (c=0; c<64; c++) {
            palette[c].r = c*4;
            palette[c].g = 0;
            palette[c].b = 0;
        }
        for (c=64; c<128; c++) {
            palette[c].r = (127-c)*4;
            palette[c].g = (c-64)*4;
            palette[c].b = 0;
        }
        for (c=128; c<192; c++) {
            palette[c].r = 0;
            palette[c].g = (191-c)*4;
            palette[c].b = (c-128)*4;
        }
        for (c=192; c<256; c++) {
            palette[c].r = 0;
            palette[c].g = 0;
            palette[c].b = (255-c)*4;
        }
        SetTimer(hWnd, IDT_PAL, 1); 
        mem_dc = CreateCompatibleDC (hdc);
	break;
	case MSG_TIMER:
		switch(wParam){
            case IDT_PAL:
		temp = palette[255];
		for (c =255; c>0; c--)
		palette[c] = palette [c-1];
		palette[0] = temp;
		SetPalette(mem_dc, 0, 255, palette);

                for (c=255; c>0; c--){
                    pix = RGB2Pixel (mem_dc, palette[c].r, palette[c].g, palette[c].b);
                    SetBrushColor (mem_dc, pix);
                    FillCircle (mem_dc, SCREEN_W/2, SCREEN_H/2, c);
                }
		InvalidateRect (hWnd , NULL , FALSE);
                break;
        }
        break;
	case MSG_PAINT:
		hdc = BeginPaint(hWnd);	
		BitBlt (mem_dc, 0, 0, SCREEN_W, SCREEN_H, hdc, 0, 0, 0);
                
		EndPaint(hWnd, hdc);
	break;
	case MSG_CLOSE:
		KillTimer(hWnd , IDT_PAL);
		DeleteCompatibleDC(mem_dc);
		DestroyMainWindow (hWnd);
		PostQuitMessage (hWnd);
		break;
	}
		

	return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Example #30
0
static int FaceEnrollWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int ret=0;
	RECT rect={142,221,180,240};

	switch (message) 
	{
		case MSG_CREATE:
			UpdateFaceRegWindow( hWnd, hdc);
			InitShowFaceImage();
			FaceRegState=FACE_REG_PREPARE;

			SetTimer(hWnd, IDC_FACE_TIMER1, IDC_TIMER_NUM);
			break;
		case MSG_ERASEBKGND:
                {
                        HDC hdc = (HDC)wParam;
                        const RECT* clip = (const RECT*)lParam;
                        BOOL fGetDC = FALSE;
                        RECT rcTemp;
                        if(hdc == 0)
                        {
                                hdc = GetClientDC(hWnd);
                                fGetDC = TRUE;
                        }

                        if(clip)
                        {
                                rcTemp = *clip;
                                ScreenToClient(hWnd, &rcTemp.left, &rcTemp.top);
                                ScreenToClient(hWnd,&rcTemp.right, &rcTemp.bottom);
                                IncludeClipRect(hdc, &rcTemp);
                        }
			UpdateFaceRegWindow(hWnd,hdc);

                        if(fGetDC) ReleaseDC (hdc);
                        	return 0;
                }
			return 0;
		
                case MSG_PAINT:
		{
			char buf[20];
                        hdc = BeginPaint(hWnd);
			SelectFont(hdc,gfont);
			SetTextColor(hdc,PIXEL_lightwhite);
       	 		SetBkMode(hdc,BM_TRANSPARENT);
                        SetPenColor(hdc,PIXEL_black);
    			SetBrushColor(hdc,PIXEL_lightgray);
			SetPenWidth(hdc, 2);
			LineEx(hdc,-1,221,322,222);
			FillBox(hdc,-1,223,322,20);
			if(RegBegin == REG_PREPARE)
			{
				sprintf(buf,"0%%");
				TextOut(hdc,145,225,buf);
			}
			else
			{
                        	SetBrushColor (hdc, PIXEL_blue);
                        	if(FaceCount>=FACE_NUM)  // 0,220,320,20
                        	{
                        	        FillBox(hdc,1,223,318,17);
					sprintf(buf,"100%%");
					TextOut(hdc,145,225,buf);
                        	}
                        	else if(FaceCount>0)
                        	{
                        	        FillBox(hdc,1,223,320*FaceCount/FACE_NUM,17);
					sprintf(buf,"%d%%",100*FaceCount/FACE_NUM);
					TextOut(hdc,145,225,buf);
                        	}
				else
				{
					sprintf(buf,"0%%");
					TextOut(hdc,145,225,buf);
				}
			}
                        EndPaint(hWnd,hdc);
		}
		return 0;
		case MSG_KEYDOWN:
			SetMenuTimeOut(time(NULL));
                        if (gOptions.KeyPadBeep)
                                ExKeyBeep();

			if(LOWORD(wParam) == SCANCODE_ESCAPE)
				PostMessage (hWnd, MSG_CLOSE, 0, 0);
			break;

		case MSG_TIMER:
			if (wParam == IDC_FACE_TIMER1)
			{
				KillTimer(hWnd, IDC_FACE_TIMER1);
				if(ismenutimeout)
				{
					PostMessage(hWnd, MSG_CLOSE, 0, 0);
					return 0;
				}
				hdc=GetClientDC(hWnd);
				if(FaceCount==0 && RegCnt==0 && RegBegin<= REG_PREPARE && gOptions.VoiceOn)
				{
					RegCnt=1;
					FaceRegState=FACE_REG_PREPARE;
					ShowFaceHint(hWnd , FACE_REG_PREPARE , hdc, &fvbg,1);
					if(gOptions.VoiceOn)
						ExPlayVoice(VOICE_FACE_START); //start...
					DelayMS(1000);
				}
				if(ShowCaptureFace( hWnd,HDC_SCREEN ,1)) //Extract face template ok
				{

					SetMenuTimeOut(time(NULL));
					ret=RegFaceTmpProc(f_pin);

					if(RET_SUCCESS==ret) //register success
					{
						SendMessage (hWnd, MSG_PAINT, FACE_NUM, 0) ;
						regok=1;
						if(gOptions.VoiceOn)
                                			ExPlayVoice(VOICE_THANK); 
						DelayMS(500);
						PostMessage (hWnd, MSG_CLOSE, 0, 0);
					}
					else if(RET_FAILED==ret) // register failed
					{
						PostMessage (hWnd, MSG_CLOSE, 0, 0);
					}
					else if(RET_SAME==ret && RegBegin != REG_PREPARE) // move face
					{
						ShowFaceHint(hWnd , HINT_FCHG ,hdc, &fvbg,1);
					}
					else if(RET_CONTINUE==ret)
					{
						if(RegBegin != REG_PREPARE)
						{
							SendMessage (hWnd, MSG_PAINT , FaceCount, 0) ;
							if(FaceCount == 0)
							{
								FaceRegState=FACE_REG_FRONT;
								ShowFaceHint(hWnd , FACE_REG_FRONT , hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_FRONT); 
								DelayMS(600);
							}
							else if(FaceCount == 3)
							{
								FaceRegState=FACE_REG_SCREEN;
								ShowFaceHint(hWnd , FACE_REG_SCREEN ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_SCREEN); 
								DelayMS(600);
							}
							else if(FaceCount == 6)
							{
								FaceRegState=FACE_REG_LEFT;
								ShowFaceHint(hWnd , FACE_REG_LEFT ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_LEFT); 
								DelayMS(600);
							}
							else if(FaceCount == 9)
							{
								FaceRegState=FACE_REG_RIGHT;
								ShowFaceHint(hWnd , FACE_REG_RIGHT ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_RIGHT); 
								DelayMS(600);
							}
							else if(FaceCount == 12)
							{
								FaceRegState=FACE_REG_CAMERA;
								ShowFaceHint(hWnd ,FACE_REG_CAMERA ,hdc, &fvbg,1);
								if(gOptions.VoiceOn)
                                					ExPlayVoice(VOICE_FACE_CAMERA); 
								DelayMS(600);
							}
							else
							{
			                        		ExBeep(1);
							}
						}
						else
						{
			                        	ExBeep(1);
						}
					}
				}
				ReleaseDC(hdc);
				SetTimer(hWnd, IDC_FACE_TIMER1,IDC_TIMER_NUM );
			}
			break;

		case MSG_IDLE:
			if(FaceCount==0 && RegCnt==0 && RegBegin<= REG_PREPARE && gOptions.VoiceOn)
 		        {
                        	RegCnt=1;
				FaceRegState=FACE_REG_PREPARE;
				hdc=GetClientDC(hWnd);
				ShowFaceHint(hWnd , FACE_REG_PREPARE ,hdc, &fvbg,1);
				if(gOptions.VoiceOn)
                			ExPlayVoice(VOICE_FACE_START); //start...
				DelayMS(1000);
				ReleaseDC(hdc);
                        }
			break;

		case MSG_CLOSE:
			KillTimer(hWnd, IDC_FACE_TIMER1);


         		// MainWindowCleanup(hWnd);
                        DestroyMainWindow(hWnd);
		        return 0;
        
	}
    
	return DefaultMainWinProc(hWnd, message, wParam, lParam);
}