コード例 #1
0
ファイル: button.c プロジェクト: VVillwin/minigui
static void draw_bitmap_button(PCONTROL pCtrl, HDC hdc, DWORD dwStyle, 
                          RECT *prcText)
{
    if (BUTTON_DATA(pCtrl)) {
        int x = prcText->left;
        int y = prcText->top;
        int w = RECTWP (prcText);
        int h = RECTHP (prcText);
        PBITMAP bmp = (PBITMAP)(BUTTON_DATA(pCtrl));
        RECT prcClient;

        GetClientRect ((HWND)pCtrl, &prcClient);
        if (dwStyle & BS_REALSIZEIMAGE) {
            x += (w - bmp->bmWidth) >> 1;
            y += (h - bmp->bmHeight) >> 1;
            w = h = 0;

            if (bmp->bmWidth > RECTW(prcClient)){
                x = prcClient.top + BTN_WIDTH_BORDER;
                y = prcClient.left + BTN_WIDTH_BORDER;
                w = RECTW(prcClient) - 2*BTN_WIDTH_BORDER-1;
            }

            if (bmp->bmHeight > RECTH(prcClient)){
                x = prcClient.top + BTN_WIDTH_BORDER;
                y = prcClient.left + BTN_WIDTH_BORDER;
                h = RECTH(prcClient) - 2*BTN_WIDTH_BORDER-1;
            }

        }
        else {
コード例 #2
0
ファイル: slider.c プロジェクト: VVillwin/minigui
static void slider_draw_attached (HDC hdc, skin_item_t* item)
{
	int pos_min, pos_max, x, y, w, h;
    si_nrmslider_t* slider = (si_nrmslider_t*) item->type_data;
	double percent;
    
    if ( slider->slider_info.cur_pos < slider->slider_info.min_pos ) 
        slider->slider_info.cur_pos = slider->slider_info.min_pos;
	if ( slider->slider_info.cur_pos > slider->slider_info.max_pos )
        slider->slider_info.cur_pos = slider->slider_info.max_pos;

    percent = (slider->slider_info.cur_pos - slider->slider_info.min_pos) * 1. /
					 (slider->slider_info.max_pos - slider->slider_info.min_pos);
					 
	if (item->style & SI_NRMSLIDER_HORZ) {	/* - */
		pos_min = item->rc_hittest.left;
		pos_max = item->rc_hittest.right - BMP(item, slider->thumb_bmp_index).bmWidth;
		x = pos_min + (pos_max - pos_min) * percent; 
		y = item->rc_hittest.top;
		// pbar
		w = RECTW(item->rc_hittest) * percent;
		h = RECTH(item->rc_hittest);

        h = h < BMP(item, slider->thumb_bmp_index).bmHeight ? 
            h : BMP(item, slider->thumb_bmp_index).bmHeight; 
	}
	else{	/* | */
		pos_min = item->rc_hittest.top;
		pos_max = item->rc_hittest.bottom - BMP(item, slider->thumb_bmp_index).bmHeight;
		y = pos_min + (pos_max - pos_min) * percent;
		x = item->rc_hittest.left;
		// pbar
		h = RECTH(item->rc_hittest) * percent;
		w = RECTW(item->rc_hittest);

        w = w < BMP(item, slider->thumb_bmp_index).bmWidth? 
            w : BMP(item, slider->thumb_bmp_index).bmWidth; 
	}
	if ( item->style & SI_NRMSLIDER_STATIC )
		FillBoxWithBitmap ( hdc, item->rc_hittest.left, item->rc_hittest.top, 
							w, h, &BMP(item, slider->thumb_bmp_index) );
	else
    	FillBoxWithBitmapPart ( hdc, x, y, 
								BMP(item, slider->thumb_bmp_index).bmWidth,
								BMP(item, slider->thumb_bmp_index).bmHeight,
								0, 0, 
								&BMP(item, slider->thumb_bmp_index),
								0, 0);
}
コード例 #3
0
ファイル: slider.c プロジェクト: VVillwin/minigui
static int get_changed_pos (skin_item_t* item, int x, int y)
{
	sie_slider_t sie;
	int cur_pos = 0;
	si_nrmslider_t* nrmslider = (si_nrmslider_t*) item->type_data;
	
	sie.min_pos = 0;

	if (item->style & SI_NRMSLIDER_HORZ) {	/* - */
		sie.max_pos = RECTW (item->rc_hittest)  - BMP(item,nrmslider->thumb_bmp_index).bmWidth;
		sie.cur_pos = x - item->rc_hittest.left - BMP(item,nrmslider->thumb_bmp_index).bmWidth/2;

		ROUND (sie.cur_pos, sie.min_pos, sie.max_pos);

		cur_pos = .5 + nrmslider->slider_info.min_pos + sie.cur_pos *
			(0. + nrmslider->slider_info.max_pos - nrmslider->slider_info.min_pos) / sie.max_pos;
	}
	else {	/* | */
		sie.max_pos = RECTH (item->rc_hittest)  - BMP(item,nrmslider->thumb_bmp_index).bmHeight;
		sie.cur_pos = y - item->rc_hittest.top  - BMP(item,nrmslider->thumb_bmp_index).bmHeight/2;

		ROUND (sie.cur_pos, sie.min_pos, sie.max_pos);

		cur_pos = .5 + nrmslider->slider_info.min_pos + sie.cur_pos *
			(0. + nrmslider->slider_info.max_pos - nrmslider->slider_info.min_pos) / sie.max_pos;
	}
	return cur_pos;
}
コード例 #4
0
ファイル: OptionsAbout.cpp プロジェクト: adamjoniec/theimp
void COptionsAbout::DrawScroller( HDC hdc )
{
	bDrawingScroller = TRUE;

	HDC hDC = hdc; if (!hdc ) hDC = ::GetDC( m_hWnd );

	HDC hdcSrc = CreateCompatibleDC( hDC );
	::SelectObject( hdcSrc, pimgAboutScroller->hBitmap );

	RECT rc; GetWindowRect( &rc );
	int x = (RECTW(rc)-pimgAbout->w)/2 + 40, 
		 y = (RECTH(rc)-pimgAbout->h)/2 + 215,
		 w = 270, h = 23;

	HRGN hrgnClip = CreateRectRgn( x,y, x+w, y+h );
	SelectClipRgn( hDC, hrgnClip ); ::DeleteObject( hrgnClip );
	
	::BitBlt( hDC, x,y, w, h, hdcSrc, frame,0, SRCCOPY );
	if ( frame > pimgAboutScroller->w) frame=-270;

	DeleteDC( hdcSrc );


	if ( !hdc ) ::ReleaseDC( m_hWnd, hDC );

	bDrawingScroller = FALSE;
}
コード例 #5
0
ファイル: PlayBack.cpp プロジェクト: tongjinlv/Linux_Cpp
PlayBack::PlayBack(CdrMain *cdrMain) : 
	mCurrentState(STATE_IDLE), 
	mTargetState(STATE_IDLE), 
	mStopFlag(0), 
	bmpIcon()
{
	RECT rect;
	HWND hMainWnd = cdrMain->getHwnd();
	db_msg("PlayBack:-----------------------\n");
	GetWindowRect(hMainWnd, &rect);

	mHwnd = CreateWindowEx(WINDOW_PLAYBACK, "",
			WS_NONE,
			WS_EX_TRANSPARENT | WS_EX_USEPARENTFONT,
			WINDOWID_PLAYBACK,
			0, 0, RECTW(rect), RECTH(rect),
			hMainWnd, (DWORD)this);
	if(mHwnd == HWND_INVALID) {
		return;
	}
	showWindow(SW_HIDE);

	mCdrMain = cdrMain;
	mIZetaMediaPlayer = new zeta::iZetaMediaPlayer();
	mPlayBackListener = new PlayBackListener(this);
	
	ResourceManager *rm = ResourceManager::getInstance();
	rm->setHwnd(WINDOWID_PLAYBACK, mHwnd);
	mCurId=0;
}
コード例 #6
0
void gdi_dump_cliprgn(cliprgn_t *p_rgn)
{
  u16 i = 0;
  cliprc_t *p_rc;

  GDI_PRINTF("rgn = 0x%.8x\nbound (%3d, %3d, %3d, %3d)\n", 
    p_rgn, p_rgn->bound.left, p_rgn->bound.top, 
    RECTW(p_rgn->bound), RECTH(p_rgn->bound));

  p_rc = p_rgn->p_head;
  while(p_rc != NULL)
  {
    GDI_PRINTF("rc%.2d  (%3d, %3d, %3d, %3d)\n", 
      i + 1, p_rc->rc.left, p_rc->rc.top,
      RECTW(p_rc->rc), RECTH(p_rc->rc));
    p_rc = p_rc->p_next, i++;
  }
}
コード例 #7
0
BOOL GUIAPI SaveMainWindowContent (HWND hWnd, const char* filename)
{
    RECT rcScreen;
    RECT rcWin;
    BITMAP bitmap;
    int save_ret;

    SetRect (&rcScreen, 0, 0, WIDTHOFPHYGC, HEIGHTOFPHYGC);
    if (hWnd) {
        GetWindowRect (hWnd, &rcWin);
        if (!IntersectRect (&rcWin, &rcWin, &rcScreen))
            return FALSE;
    }
    else
        rcWin = rcScreen;

    bitmap.bmType = BMP_TYPE_NORMAL;
    bitmap.bmBitsPerPixel = BITSPERPHYPIXEL;
    bitmap.bmBytesPerPixel = BYTESPERPHYPIXEL;
    bitmap.bmWidth = RECTW (rcWin);
    bitmap.bmHeight = RECTH (rcWin);
    bitmap.bmPitch = bitmap.bmWidth * bitmap.bmBytesPerPixel;

    if (bitmap.bmWidth == 0 || bitmap.bmHeight == 0) {
#ifdef _DEBUG
        fprintf (stderr, "SaveContent: Empty Rect.\n");
#endif
        return FALSE;
    }
    
    bitmap.bmBits = SaveCoveredScreenBox (rcWin.left, rcWin.top, 
                                    RECTW (rcWin), RECTH (rcWin));
    if (!bitmap.bmBits) {
#ifdef _DEBUG
        fprintf (stderr, "SaveContent: SaveBox error.\n");
#endif
        return FALSE;
    }
    
    save_ret = SaveBitmap (HDC_SCREEN, &bitmap, filename);
    free (bitmap.bmBits);
    return (save_ret == 0);
}
コード例 #8
0
void GUIAPI BitBlt(HDC hsdc, int sx, int sy, int sw, int sh,
                   HDC hddc, int dx, int dy, DWORD dwRop)
{
    PCLIPRECT pClipRect;
    PDC psdc, pddc;
    RECT rcOutput;

    psdc = dc_HDC2PDC(hsdc);
    pddc = dc_HDC2PDC(hddc);

    if (dc_IsGeneralHDC(hddc)) {
        if (!dc_GenerateECRgn (pddc, FALSE)) {
            return;
        }
    }

    if (sw <= 0 || sh <= 0) {
        sw = RECTW (psdc->DevRC);
        sh = RECTH (psdc->DevRC);
    }

    // Transfer logical to device to screen here.
    sw += sx; sh += sy;
    coor_LP2SP(psdc, &sx, &sy);
    coor_LP2SP(psdc, &sw, &sh);
    (sw > sx) ? (sw -= sx) : (sw = sx - sw);
    (sh > sy) ? (sh -= sy) : (sh = sy - sh);
    coor_LP2SP(pddc, &dx, &dy);
    rcOutput.left = dx;
    rcOutput.top  = dy;
    rcOutput.right = dx + sw;
    rcOutput.bottom = dy + sh;
    NormalizeRect(&rcOutput);
    
    ShowCursorForGDI(FALSE, &g_rcScr);

    // set graphics context.
    GAL_SetGC (pddc->gc);

    pClipRect = pddc->ecrgn.head;

    while(pClipRect)
    {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping(pddc->gc, pClipRect->rc.left, pClipRect->rc.top,
                    pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);

            GAL_CrossBlit (psdc->gc, sx, sy, sw, sh, pddc->gc, dx, dy);
        }

        pClipRect = pClipRect->next;
    }

    ShowCursorForGDI(TRUE, &g_rcScr);
}
コード例 #9
0
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);
	}
}
コード例 #10
0
ファイル: paint.c プロジェクト: channinglan/MINIGUI_1.3.3
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));
}
コード例 #11
0
ファイル: showMessageBox.cpp プロジェクト: thatking/camdroid
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);
}
コード例 #12
0
ファイル: coolIndicator.cpp プロジェクト: thatking/camdroid
/*
 *                       
 *         
 *                                  ¨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
}
コード例 #13
0
ファイル: licensePlateWM.cpp プロジェクト: thatking/camdroid
static void draw_hilighted_item(HWND hDlg, HDC hdc)
{
	LicensePlate_CtrlInfo_t* ctrlInfo;
	HWND hwndWidget;
	int prevSel;
	RECT rect;
	int x, y, w, h;
	gal_pixel hilightColor, normalColor;

	hilightColor = RGBA2Pixel(HDC_SCREEN, 0xDC, 0xDC, 0xDC, 0xFF);

//	hilightColor = RGBA2Pixel(HDC_SCREEN, 0x00, 0xFF, 0x99, 0xFF);
	normalColor = RGBA2Pixel(HDC_SCREEN, 0x99, 0x99, 0x99, 0xFF);
	ctrlInfo = (LicensePlate_CtrlInfo_t*)GetWindowAdditionalData(hDlg);

	if(ctrlInfo != NULL) {
		if(ctrlInfo->curSel >= 0) {
			hwndWidget = GetDlgItem(hDlg, ID_NUMBER_START + ctrlInfo->curSel);
			GetWindowRect(hwndWidget, &rect);
			w = ctrlInfo->pBmpArrow->bmWidth;
			h = ctrlInfo->pBmpArrow->bmHeight;
			x = rect.left;
			y = rect.top - h - 4;
			if(w < RECTW(rect)) {
				x = rect.left + ( (RECTW(rect) - w) >> 1 );
			}
			FillBoxWithBitmap(hdc, x, y, w, h, ctrlInfo->pBmpArrow);
			if(hwndWidget && hwndWidget != HWND_INVALID) {
				SetWindowBkColor(hwndWidget, hilightColor );
			}

			prevSel = ctrlInfo->curSel - 1;
			if(prevSel >= 0) {
				hwndWidget = GetDlgItem(hDlg, ID_NUMBER_START + prevSel );
				if(hwndWidget && hwndWidget != HWND_INVALID) {
					SetWindowBkColor(hwndWidget, normalColor );
				}
			}
		} else {
コード例 #14
0
ファイル: gdi.c プロジェクト: channinglan/MINIGUI_1.3.3
/*
 * 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;
}
コード例 #15
0
ファイル: ctrl_setbox.c プロジェクト: github188/1521
static RET_CODE on_sbox_created(control_t *p_ctrl,
                                u16 msg,
                                u32 para1,
                                u32 para2)
{
  rect_t frame = {0};
  MT_ASSERT(p_ctrl != NULL);

  ctrl_get_frame(p_ctrl, &frame);
  
  sbox_set_mid_rect(p_ctrl, 0, 0, RECTW(frame), RECTH(frame));

  return ERR_NOFEATURE;
}
コード例 #16
0
ファイル: ctrl_textfield.c プロジェクト: github188/1521
static void _text_get_draw_rect(control_t *p_ctrl, rect_t *p_rc)
{
  ctrl_text_data_t *p_data = NULL;
  rect_t client_rect = {0};
  
  MT_ASSERT(p_ctrl != NULL);

  ctrl_get_client_rect(p_ctrl, &client_rect);
  p_data = (ctrl_text_data_t *)p_ctrl->priv_data;
  
  p_rc->left = client_rect.left + p_data->mid_rect.left;
  p_rc->top = client_rect.top + p_data->mid_rect.top;
  p_rc->right = p_rc->left + RECTW(p_data->mid_rect);
  p_rc->bottom = p_rc->top + RECTH(p_data->mid_rect);
}
コード例 #17
0
/****************************** Bitmap Support *******************************/
void GUIAPI FillBox (HDC hdc, int x, int y, int w, int h)
{
    PCLIPRECT pClipRect;
    PDC pdc;
    RECT rcOutput;

    pdc = dc_HDC2PDC(hdc);

    if (dc_IsGeneralHDC(hdc)) {
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            return;
        }
    }

    // Transfer logical to device to screen here.
    w += x; h += y;
    coor_LP2SP(pdc, &x, &y);
    coor_LP2SP(pdc, &w, &h);
    rcOutput.left = x;
    rcOutput.top  = y;
    rcOutput.right = w;
    rcOutput.bottom = h;
    NormalizeRect (&rcOutput);
    w = RECTW (rcOutput); h = RECTH (rcOutput);

    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);
    
    // set graphics context.
    GAL_SetGC (pdc->gc);
    GAL_SetFgColor (pdc->gc, pdc->brushcolor);

    pClipRect = pdc->ecrgn.head;
    while(pClipRect)
    {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
                    pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);
        
            GAL_FillBox (pdc->gc, x, y, w, h, pdc->brushcolor);
        }

        pClipRect = pClipRect->next;
    }

    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput);
}
コード例 #18
0
ファイル: ctrl_textfield.c プロジェクト: github188/1521
void text_set_mid_rect(control_t *p_ctrl,
  s16 left, s16 top, u16 width, u16 height)
{
  ctrl_text_data_t *p_data = NULL;
  rect_t frame;

  MT_ASSERT(p_ctrl != NULL);

  ctrl_get_frame(p_ctrl, &frame);

  MT_ASSERT((left + width) <= RECTW(frame));
  MT_ASSERT((top + height) <= RECTH(frame));

  p_data = (ctrl_text_data_t *)p_ctrl->priv_data;
  set_rect(&p_data->mid_rect, left, top, (s16)(left + width),
           (s16)(top + height));
}
コード例 #19
0
ファイル: licensePlateWM.cpp プロジェクト: thatking/camdroid
static void draw_frame_lines(HWND hDlg, HDC hdc)
{
	RECT rect_parent, rect_plate_num;
	gal_pixel lineColor;
	GetClientRect(hDlg, &rect_parent);
	int line_w = RECTW(rect_parent);
//three lines
	lineColor = RGBA2Pixel(hdc, 0X42, 0xCE, 0xFF, 0xFF);
	SetPenColor(hdc, lineColor);
	MoveTo(hdc, 0, ctrlData[IDX_SWITCH_ICON].y-1);
	LineTo(hdc, line_w, ctrlData[IDX_SWITCH_ICON].y-1);

	MoveTo(hdc, 0, ctrlData[IDX_SWITCH_ICON].y+ctrlData[IDX_SWITCH_ICON].h+1);
	LineTo(hdc, line_w, ctrlData[IDX_SWITCH_ICON].y+ctrlData[IDX_SWITCH_ICON].h+1);

	GetWindowRect(GetDlgItem(hDlg, ID_NUMBER_START), &rect_plate_num);
	MoveTo(hdc, 0, rect_plate_num.bottom + 24);
	LineTo(hdc, line_w, rect_plate_num.bottom + 24);
}
コード例 #20
0
ファイル: OptionsAbout.cpp プロジェクト: adamjoniec/theimp
void COptionsAbout::DrawAbout( HDC hdc )
{
	HDC hDC = hdc; if (!hdc ) hDC = ::GetDC( m_hWnd );

	HDC hdcSrc = CreateCompatibleDC( hDC );
	::SelectObject( hdcSrc, pimgAbout->hBitmap );

	RECT rc; GetWindowRect( &rc );
	int x = (RECTW(rc)-pimgAbout->w)/2, 
		 y = (RECTH(rc)-pimgAbout->h)/2;
	TransparentBlt( hDC, x,y, pimgAbout->w, pimgAbout->h, 
		hdcSrc, 0,0,pimgAbout->w, pimgAbout->h, RGB(255,255,255) );

	DeleteDC( hdcSrc );

	DrawScroller( hDC );

	if ( !hdc ) ::ReleaseDC( m_hWnd, hDC );

}
コード例 #21
0
ファイル: progressbar.c プロジェクト: VVillwin/minigui
static void pbarOnNewPos (const CONTROL* pCtrl, PROGRESSDATA* pData, unsigned int new_pos)
{
    double d;
    unsigned int old_pos;
    int range = pData->nMax - pData->nMin;
    int old_prog, new_prog, width;
    RECT rc_client;

    if (range == 0 || new_pos == pData->nPos)
        return;

    old_pos = pData->nPos;
    pData->nPos = new_pos;
    pbarNormalizeParams (pCtrl, pData, pCtrl->dwStyle & PBS_NOTIFY);
    if (old_pos == pData->nPos)
        return;

    GetClientRect ((HWND)pCtrl, &rc_client);

    if (pCtrl->dwStyle & PBS_VERTICAL)
        width = RECTH (rc_client) - (WIDTH_PBAR_BORDER << 1);
    else
        width = RECTW (rc_client) - (WIDTH_PBAR_BORDER << 1);

    old_prog = old_pos - pData->nMin;
    d = (old_prog*1.0)/range;
    old_prog = (int) (d * width);

    new_prog = pData->nPos - pData->nMin;
    d = (new_prog*1.0)/range;
    new_prog = (int) (d * width);

    if (pCtrl->dwStyle & PBS_VERTICAL) {
#if 0
        old_prog = rc_client.bottom - WIDTH_PBAR_BORDER - old_prog;
        new_prog = rc_client.bottom - WIDTH_PBAR_BORDER - new_prog;
        rc_client.top = MIN (old_prog, new_prog) - 4;
        rc_client.bottom = MAX (old_prog, new_prog) + 4;
#endif
    }
    else {
        HDC hdc;
        char text [10];
        RECT rc_text;
        SIZE text_ext;

        sprintf (text, "%.0f%%", (d*100));

        hdc = GetClientDC ((HWND)pCtrl);
        GetTextExtent (hdc, text, -1, &text_ext);
        ReleaseDC (hdc);

        rc_text.left = rc_client.left + ((RECTW(rc_client) - text_ext.cx) >> 1);
        rc_text.top = rc_client.top + ((RECTH(rc_client) - text_ext.cy) >> 1);
        rc_text.right = rc_text.left + text_ext.cx;
        rc_text.bottom = rc_text.top + text_ext.cy;
        InvalidateRect ((HWND)pCtrl, &rc_client, TRUE);

        rc_client.left = MIN (old_prog, new_prog);
        rc_client.right = MAX (old_prog, new_prog);
    }

    InvalidateRect ((HWND)pCtrl, &rc_client, TRUE);

}
コード例 #22
0
ファイル: progressbar.c プロジェクト: VVillwin/minigui
static void pbarOnDraw (HWND hwnd, HDC hdc, PROGRESSDATA* pData, BOOL fVertical)
{
    RECT    rcClient;
    int     x, y, w, h;
    ldiv_t   ndiv_progress;
    unsigned int     nAllPart;
    unsigned int     nNowPart;
    int     whOne, nRem;
    int     ix, iy;
    int     i;
    int     step;
    
    if (pData->nMax == pData->nMin)
        return;
    
    if ((pData->nMax - pData->nMin) > 5)
        step = 5;
    else
        step = 1;

    GetClientRect (hwnd, &rcClient);

    x = rcClient.left + WIDTH_PBAR_BORDER;
    y = rcClient.top + WIDTH_PBAR_BORDER;
    w = RECTW (rcClient) - (WIDTH_PBAR_BORDER << 1);
    h = RECTH (rcClient) - (WIDTH_PBAR_BORDER << 1);

    ndiv_progress = ldiv (pData->nMax - pData->nMin, step);
    nAllPart = ndiv_progress.quot;
    
    ndiv_progress = ldiv (pData->nPos - pData->nMin, step);
    nNowPart = ndiv_progress.quot;
    if (fVertical)
        ndiv_progress = ldiv (h, nAllPart);
    else
        ndiv_progress = ldiv (w, nAllPart);
        
    whOne = ndiv_progress.quot;
    nRem = ndiv_progress.rem;

    SetBrushColor (hdc, GetWindowElementColorEx (hwnd, BKC_HILIGHT_NORMAL));
 
    if (whOne >= 4) {
        if (fVertical) {
            for (i = 0, iy = y + h - 1; i < nNowPart; ++i) {
                if ((iy - whOne) < y) 
                    whOne = iy - y;

                FillBox (hdc, x + 1, iy - whOne, w - 2, whOne - 1);
                iy -= whOne;
                if(nRem > 0) {
                    iy --;
                    nRem --;
                }
            }
        }
        else {
            for (i = 0, ix = x + 1; i < nNowPart; ++i) {
                if ((ix + whOne) > (x + w)) 
                    whOne = x + w - ix;

                FillBox (hdc, ix, y + 1, whOne - 1, h - 2);
                ix += whOne;
                if(nRem > 0) {
                    ix ++;
                    nRem --;
                }
            }
        }
    }
    else {
        // no vertical support
        double d = (nNowPart*1.0)/nAllPart;

        if (fVertical) {
            int prog = (int)(h*d);

            FillBox (hdc, x + 1, rcClient.bottom - WIDTH_PBAR_BORDER - prog, 
                    w - 2, prog);
        }
        else {
            char szText[8];
            SIZE text_ext;
            RECT rc_clip = rcClient;
            int prog = (int)(w*d);

            FillBox (hdc, x, y + 1, (int)(w*d), h - 2);

            SetBkMode (hdc, BM_TRANSPARENT);
            sprintf (szText, "%.0f%%", (d*100));
            GetTextExtent (hdc, szText, -1, &text_ext);
            x += ((w - text_ext.cx) >> 1);
            y += ((h - text_ext.cy) >> 1);

            rc_clip.right = prog;
            SelectClipRect (hdc, &rc_clip);
            SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_HILIGHT_NORMAL));
            SetBkColor (hdc, GetWindowElementColorEx (hwnd, BKC_HILIGHT_NORMAL));
            TextOut (hdc, x, y, szText);

            rc_clip.right = rcClient.right;
            rc_clip.left = prog;
            SelectClipRect (hdc, &rc_clip);
            SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_NORMAL));
            SetBkColor (hdc, GetWindowBkColor (hwnd));
            TextOut (hdc, x, y, szText);
        }
    }
}
コード例 #23
0
ファイル: propsheet.c プロジェクト: VVillwin/minigui
/* re-draw */
static void draw_propsheet (HWND hwnd, HDC hdc, PCONTROL ctrl, PPROPSHEETDATA propsheet, PPROPPAGE page)
{
    int x, ty, by, text_extent;
    RECT title_rc = {0, 0, 1, 0};
    
    title_rc.bottom = propsheet->head_rc.bottom;
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
        title_rc.top = propsheet->head_rc.top;
    } 
    
/* Draw the content window */
#ifdef _FLAT_WINDOW_STYLE
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
        DrawFlatControlFrameEx (hdc, hwnd, 0, 0, propsheet->head_rc.right, 
                                ctrl->bottom - ctrl->top - (propsheet->head_rc.bottom - propsheet->head_rc.top) + 1 ,
                                1, DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0);
    } else {
        DrawFlatControlFrameEx (hdc, hwnd, 0, propsheet->head_rc.bottom - 2,
                            propsheet->head_rc.right, ctrl->bottom - ctrl->top, 1, 
                            DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0);
    }
#else
    
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
        Draw3DThickFrameEx (hdc, hwnd, 0, 0, propsheet->head_rc.right, 
                            ctrl->bottom - ctrl->top - (propsheet->head_rc.bottom - propsheet->head_rc.top) + 2 ,
                            DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0);
    } else {
        Draw3DThickFrameEx (hdc, hwnd, 0, propsheet->head_rc.bottom - 2, 
                            propsheet->head_rc.right, ctrl->bottom - ctrl->top,
                            DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0);
    }
#endif
    
    SetBrushColor (hdc, GetWindowElementColorEx (hwnd, BKC_CONTROL_DEF));
    
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
        FillBox (hdc, 0, propsheet->head_rc.top + 1, propsheet->head_rc.right, propsheet->head_rc.bottom );
    }else {
        FillBox (hdc, 0, 0, propsheet->head_rc.right, propsheet->head_rc.bottom - 2);
    }
    /* 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 + GetMainWinMetrics (MWM_SB_WIDTH) : title_rc.right;
    }
    
    while (page) {
        SIZE size;
        int eff_chars, eff_len;

        /* 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;
        SelectClipRect (hdc, &title_rc);
        x = title_rc.left + _ICON_OFFSET;
        ty = title_rc.top;
        
        if (page != propsheet->active) {
            /* bottom tab or top tab */
            if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
                ty -= 2;
                by = title_rc.bottom - 2;
            } else {
                ty += 2;
                by = title_rc.bottom;
            }

        } else {
            by = title_rc.bottom ;
            FillBox (hdc, title_rc.left+1, ty, title_rc.right - title_rc.left, by);
        }

        /* draw the title's edge */
        /* pc3d style & flat & grap */
        SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_LEFT_INNER));
        if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
            MoveTo (hdc, title_rc.left, ty);
            LineTo (hdc, title_rc.left, by - 1);
            LineTo (hdc, title_rc.right, by - 1);
        } else {
            MoveTo (hdc, title_rc.left, by - 1);
            LineTo (hdc, title_rc.left, ty);
            LineTo (hdc, title_rc.right, ty);
        }

        SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_RIGHT_OUTER));
        if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
            if (page != propsheet->active) {
                MoveTo (hdc, title_rc.left + 1, ty + 3);
            } else {
                MoveTo (hdc, title_rc.left + 1, ty - 2);
            }
            LineTo (hdc, title_rc.left + 1, by - 2);
            LineTo (hdc, title_rc.right - 1, by - 2);
        } else {
            if (page != propsheet->active) {
                MoveTo (hdc, title_rc.left + 1, by - 2);
            } else {
                MoveTo (hdc, title_rc.left + 1, by);
            }
            LineTo (hdc, title_rc.left + 1, ty + 1);
            LineTo (hdc, title_rc.right - 1, ty + 1);
        }
        SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_LEFT_INNER));
        if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
            MoveTo (hdc, title_rc.right - 1, by -1);
            LineTo (hdc, title_rc.right - 1, ty);
        }else {
            if (!page->next && (title_rc.right == propsheet->head_rc.right)) {
                MoveTo (hdc, title_rc.right - 2, ty );
                LineTo (hdc, title_rc.right - 2, by - 1);
                SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_LEFT_OUTER));
                MoveTo (hdc, title_rc.right -1, ty );
                LineTo (hdc, title_rc.right -1, by - 1);
            }
            else {
                MoveTo (hdc, title_rc.right - 1, ty );
                LineTo (hdc, title_rc.right - 1, by - 1);
            }
        }
        
        /* draw the ICON */
        ty += _ICON_OFFSET + 2;
        text_extent = RECTW (title_rc) - _ICON_OFFSET * 2;
        if (page->icon) {
            DrawIcon (hdc, x, ty, GetMainWinMetrics (MWM_ICONX),
                      GetMainWinMetrics (MWM_ICONY), page->icon);
            x += GetMainWinMetrics (MWM_ICONX);
            x += _GAP_ICON_TEXT;
            text_extent -= GetMainWinMetrics (MWM_ICONX) + _GAP_ICON_TEXT;
        }
        
        /* draw the TEXT */
/* #if defined(_FLAT_WINDOW_STYLE) && !defined(_GRAY_SCREEN) */
#ifdef _FLAT_WINDOW_STYLE                    
        if (page != propsheet->active) {
            SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_DISABLED));
        } else {
            SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_NORMAL));
        }
#else
        SetBkColor (hdc, GetWindowElementColorEx (hwnd, BKC_CONTROL_DEF));
#endif
        text_extent -= 4;
        eff_len = GetTextExtentPoint (hdc, page->title, strlen(page->title), 
                      text_extent, &eff_chars, NULL, NULL, &size);
        TextOutLen (hdc, x + 2, ty, page->title, eff_len);
        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);
    }
}
コード例 #24
0
ファイル: Vcdplyer.cpp プロジェクト: adamjoniec/theimp
/******************************Public*Routine******************************\
* RepaintVideo
*
\**************************************************************************/
BOOL
CMpegMovie::RepaintVideo(
    HWND hwnd,
    HDC hdc
    )
{

	BOOL bRet = FALSE;
	
	long lnativeWidth=0, lnativeHeight=0;
	GetNativeMovieSize( &lnativeWidth, &lnativeHeight );
	if ( !lnativeWidth || !lnativeHeight )
	{
		// No picture, sound only.
		HDC hDC = GetDC( hwnd );

		RECT *prc = &m_rcMovieWindow;
		BitBlt( hDC,  prc->left, prc->top, RECTW((*prc)), RECTH((*prc)),
			NULL, 0, 0, BLACKNESS );

		ReleaseDC( hwnd, hDC );

		return TRUE;
	}

	if ( m_Vw ) {

		// Windowed movie playback don't need repaint.

		return TRUE;

	}	else if( m_Wc ) {


		bRet = (m_Wc->RepaintVideo(hwnd, hdc) == S_OK);

		HDC hDC = GetDC( hwnd );
		int mx = m_rcMovieWindow.left, my = m_rcMovieWindow.top,
			 mw = m_rcMovieWindow.right - mx, mh = m_rcMovieWindow.bottom - my,
			 dx = m_rcMovieDest.left, dy = m_rcMovieDest.top,
			 dw = m_rcMovieDest.right - dx, dh = m_rcMovieDest.bottom - dy;

		int x=0,y=0,w=0,h=0;

		x = mx; y= my; w = mw; h = dy-my;
		BitBlt(hDC, x,y,w,h, NULL, 0,0, BLACKNESS);

		x = mx; y= dy+dh; w = mw; h = my+mh-y;
		BitBlt(hDC, x,y,w,h, NULL, 0,0, BLACKNESS);


		x=mx; y=my; w=dx-mx; h = mh;
		BitBlt(hDC, x,y,w,h, NULL, 0,0, BLACKNESS);

		x=dx+dw; y=my; w=mx+mw-x; h = mh;
		BitBlt(hDC, x,y,w,h, NULL, 0,0, BLACKNESS);

		ReleaseDC( hwnd, hDC );

	}

	return bRet;
		
}
コード例 #25
0
ファイル: mdolphin_proxy.cpp プロジェクト: bytewang/vitas
static int ProxyBoxProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
    RECT rc;
    PROXY_INFO proxys;
    
    switch (message) {
        case MSG_INITDIALOG:
        {
            for (int i=PROXY_HTTP; i<PROXY_MAX; i++) {
                PROXY_ITEM proxy;
                int idc = 0;
                memset(&proxy, 0x0, sizeof(proxy));
                mdolphin_get_proxy((PROXY_TYPE)i, &proxy);
                switch (i) {
                    case PROXY_HTTP:
                        idc = IDC_HTTP_PROXY_HOST;
                        break;
                    case PROXY_SOCKS4:
                    case PROXY_SOCKS5:
                        idc = IDC_SOCKS_PROXY_HOST; 
                        break;
                }
                setProxyItem(hDlg, idc, proxy.host);
                setProxyItem(hDlg, idc+1, proxy.port);
                setProxyItem(hDlg, idc+2, proxy.name);
                setProxyItem(hDlg, idc+3, proxy.pwd);
            }

            GetWindowRect((HWND)(lParam), &rc);
            MoveWindow(hDlg, RECTW(rc)/2-160, RECTH(rc)/2-120, WIN_WIDTH, WIN_HEIGHT, TRUE);
            return 1;
        }
        case MSG_COMMAND:
            switch (wParam) {
                case IDC_PROXY_MANUAL:
                    setProxyCtrlsEnable(hDlg, TRUE);
                    break;
                case IDC_PROXY_AUTO:
                    setProxyCtrlsEnable(hDlg, FALSE);
                    break;
                case IDOK: 
                {
                    BOOL enable = FALSE;
                    proxys.num = 2;
                    proxys.items = (PROXY_ITEM*)malloc(sizeof(PROXY_ITEM) * proxys.num);
                    memset(proxys.items, 0x0, sizeof(PROXY_ITEM) * proxys.num);
                    for (int i=0; i<proxys.num; i++) {
                        int idc = (i<<2) + IDC_HTTP_PROXY_HOST;
                        if (! getProxyItem(hDlg, idc, &proxys.items[i].host))
                            goto err;
                        if (! getProxyItem(hDlg, idc+1, &proxys.items[i].port))
                            goto err;
                        if (! getProxyItem(hDlg, idc+2, &proxys.items[i].name))
                            goto err;
                        if (! getProxyItem(hDlg, idc+3, &proxys.items[i].pwd))
                            goto err;

                        switch (idc) {
                        case IDC_HTTP_PROXY_HOST:
                            proxys.items[i].type = PROXY_HTTP;
                            break;
                        case IDC_SOCKS_PROXY_HOST:
                            proxys.items[i].type = PROXY_SOCKS5;
                            break;
                        default:
                            proxys.items[i].type = PROXY_MAX;
                            break;
                        }
                    }
                    
                    enable = (GetWindowStyle(GetDlgItem(hDlg, IDC_PROXY_AUTO)) & BS_CHECKED)?FALSE:TRUE;
                    mdolphin_set_proxy(&proxys, enable);
err:
                    for (int i=0; i<proxys.num; i++) {
                        if (proxys.items[i].host)
                            free(proxys.items[i].host);
                        if (proxys.items[i].port)
                            free(proxys.items[i].port);
                        if (proxys.items[i].name)
                            free(proxys.items[i].name);
                        if (proxys.items[i].pwd)
                            free(proxys.items[i].pwd);
                    }
                }
                case IDCANCEL:
                    EndDialog (hDlg, wParam);
                    break;
            }
            break;

        case MSG_CLOSE:
            EndDialog (hDlg, IDCANCEL);
            break;
    }

    return DefaultDialogProc (hDlg, message, wParam, lParam);
}
コード例 #26
0
ファイル: text.c プロジェクト: channinglan/MINIGUI_1.3.3
int DrawTextEx (HDC hdc, const char* pText, int nCount, 
                RECT* pRect, int indent, UINT nFormat)
{
    PDC pdc;
    int n, nLines = 0, width = 0;
    BOOL bOutput = TRUE;
    int x, y;
    RECT rcDraw, rcOutput;
    int nTabWidth, tabs; 
    SIZE size;
    int line_height;

    pdc = dc_HDC2PDC(hdc);

    if (nCount == -1)
        nCount = strlen (pText);

    line_height = pdc->pLogFont->size + pdc->alExtra + pdc->blExtra;

    if (nFormat & DT_TABSTOP)
        nTabWidth = HIWORD (nFormat) * 
                    (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width)
                    (pdc->pLogFont, pdc->pLogFont->sbc_devfont);

    else
        nTabWidth = pdc->tabstop * 
                    (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width)
                    (pdc->pLogFont, pdc->pLogFont->sbc_devfont);

    // Transfer logical to device to screen here.
    rcDraw = *pRect;
    coor_LP2SP(pdc, &rcDraw.left, &rcDraw.top);
    coor_LP2SP(pdc, &rcDraw.right, &rcDraw.bottom);
    NormalizeRect (&rcDraw);

    if (dc_IsGeneralHDC(hdc)) {
        pthread_mutex_lock (&pdc->pGCRInfo->lock);
        if (!dc_GenerateECRgn (pdc, FALSE))
            bOutput = FALSE;
    }

    pthread_mutex_lock (&__mg_gdilock);

    // set graphics context.
    GAL_SetGC (pdc->gc);

    // Draw text here.
    if (nFormat & DT_CALCRECT)
        bOutput = FALSE;

    y = rcDraw.top;
    if (nFormat & DT_SINGLELINE) {
        if (nFormat & DT_BOTTOM)
            y = rcDraw.bottom - pdc->pLogFont->size;
        else if (nFormat & DT_VCENTER)
            y = rcDraw.top + ((RECTH (rcDraw) - pdc->pLogFont->size) >> 1);
    }

    while (nCount != 0) {
        int nOutput;
        int maxwidth;

        if (nLines == 0) {
            maxwidth = rcDraw.right - rcDraw.left - indent;
            if (maxwidth <= 0) {
                // new line
                y += pdc->pLogFont->size;
                nLines ++;
                continue;
            }
        }
        else
            maxwidth = rcDraw.right - rcDraw.left;
        
        gdi_start_new_line (pdc->pLogFont);
        tabs = txtGetOneLine (pdc, pText, nCount, nTabWidth, maxwidth, nFormat, &n);

        gdi_get_TextOut_extent (pdc, pdc->pLogFont, pText, n, &size);
        width = size.cx + tabs * nTabWidth;
        n += tabs;

        if ( (pText[n-1] == '\n' || pText[n-1] == '\r') 
             && !(nFormat & DT_SINGLELINE) ) {
            int tmpx = 0, tmpy = 0;

            nOutput = n - 1;
            width -= gdi_width_one_char (pdc->pLogFont, pdc->pLogFont->sbc_devfont, 
                            pText + n - 1, 1, &tmpx, &tmpy);
        }
        else
            nOutput = n;
            
        if (nFormat & DT_RIGHT)
            x = rcDraw.right - width;
        else if (nFormat & DT_CENTER)
            x = rcDraw.left + ((RECTW (rcDraw) - width) >> 1);
        else
            x = rcDraw.left;
        x += (nLines ? 0 : indent);

        rcOutput.left   = x;
        rcOutput.top    = y;
        rcOutput.right  = rcOutput.left + width;
        rcOutput.bottom = rcOutput.top + line_height;
        NormalizeRect(&rcOutput);

        if (nFormat & DT_CALCRECT) {
            if (nLines == 0)
                *pRect = rcOutput;
            else
                GetBoundRect (pRect, pRect, &rcOutput);
        }

        // draw one line
        if (bOutput && width > 0) {
            if (!dc_IsMemHDC(hdc)) ShowCursorForGDI(FALSE, &rcOutput);

            if (nFormat & DT_NOCLIP)
                txtDrawOneLine (pdc, pText, nOutput, x, y, 
                        &rcOutput, nFormat, nTabWidth);
            else {
                RECT rcClip;
                IntersectRect (&rcClip, &rcOutput, &rcDraw);
                txtDrawOneLine (pdc, pText, nOutput, x, y, 
                        &rcClip, nFormat, nTabWidth);
            }
        
            if (!dc_IsMemHDC(hdc)) ShowCursorForGDI (TRUE, &rcOutput);
        }

        pText += n;

        // new line
        y += line_height;
        nLines ++;

        // left characters
        nCount = nCount - n;
    }
コード例 #27
0
ファイル: colordlg.c プロジェクト: VVillwin/minigui
static int ColorDlgProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
    PSCOLORDIA scld;

    switch (message) {
    case MSG_INITDIALOG:
        {
            int i, j;
            Uint8 r, g, b;
            HDC hdc, mdc;
            
            scld = (PSCOLORDIA)lParam;
            SetWindowAdditionalData (hDlg, (LPARAM)scld);

            hdc = GetClientDC (hDlg);
            scld->SpaceDC = CreateCompatibleDCEx(hdc, scld->sp_w, scld->sp_h);
            mdc = CreateCompatibleDCEx (hdc, 360, 256);
            for (i =  0; i < 360; i ++) {
                for (j = 0; j < 256; j ++) {
                    HSV2RGB (i, j, 200, &r, &g, &b);
                    SetPixelRGB(mdc, i, 256-j, r, g, b);
                }
            }
            
            StretchBlt(mdc, 0, 0, 360, 256, scld->SpaceDC, 0, 0, scld->sp_w, scld->sp_h, 0);
            DeleteMemDC(mdc);
            ReleaseDC(hdc);
        }        
        break;

    case MSG_CLOSE:
        EndDialog (hDlg, SELCOLOR_CANCEL);
        break;

    case MSG_DESTROY:
        scld = (PSCOLORDIA)GetWindowAdditionalData (hDlg);
        DeleteMemDC (scld->SpaceDC);
        break;

    case MSG_PAINT:
    {
        HDC hdc;

        scld = (PSCOLORDIA)GetWindowAdditionalData (hDlg);
        hdc = BeginPaint (hDlg);
        DrawAllSpace (hdc, scld);
        EndPaint (hDlg, hdc);
        return 0;
    }

    case MSG_COMMAND:
    {
        int msg = HIWORD(wParam);
        int id = LOWORD(wParam);

        scld = (PSCOLORDIA)GetWindowAdditionalData (hDlg);

        if (msg == EN_CONTCHANGED) {
            UpdateValue (hDlg, id, scld);
        }

        switch(id) {
        case IDC_CANCEL:
            EndDialog (hDlg, SELCOLOR_CANCEL);
            break;
        case IDC_OK:
            scld->H = scld->clrh;
            scld->S = scld->clrs;
            scld->V = scld->clrv;
            HSV2RGB (scld->clrh, scld->clrs, scld->clrv, &scld->R, &scld->G, &scld->B);
            scld->PIXEL = RGB2Pixel (HDC_SCREEN, scld->R, scld->G, scld->B);
            EndDialog (hDlg, SELCOLOR_OK);
            break;
        }
        break;
    }

    case MSG_LBUTTONDOWN:
    {
        int x = LOSWORD (lParam);
        int y = HISWORD (lParam);

        scld = (PSCOLORDIA)GetWindowAdditionalData (hDlg);

        if (PtInRect (&scld->rcSpace, x, y)) {
            HDC dc = GetClientDC (hDlg);
            scld->clrh = (x-scld->rcSpace.left)*360/RECTW(scld->rcSpace);
            scld->clrs = 256-(y-scld->rcSpace.top)*256/RECTH(scld->rcSpace);
            DrawAllSpace (dc, scld);
            SetValue (hDlg, scld);
            ReleaseDC (dc);
        }

        if (PtInRect(&scld->rcYSpace, x,y)) {
            HDC dc = GetClientDC (hDlg);
            scld->clrv = (y-scld->rcYSpace.top)*256 / RECTH(scld->rcYSpace);
            DrawAllSpace (dc, scld);
            SetValue (hDlg, scld);
            ReleaseDC (dc);
        }
    }
    }
    return DefaultDialogProc (hDlg, message, wParam, lParam);
}
コード例 #28
0
ファイル: ctrl_combobox.c プロジェクト: github188/1521
control_t *cbox_create_droplist(control_t *p_ctrl,
                                u16 page,
                                u16 sbar_width,
                                u16 sbar_gap)
{
  ctrl_cbox_data_t *p_data = NULL;
  control_t *p_sbar = NULL;
  control_t *p_root = NULL;
  rect_t rc_cbox, rc_root;
  u16 list_width = 0, list_height = 0;
  u16 sbar_left = 0, sbar_top = 0;

  MT_ASSERT(p_ctrl != NULL);
  p_data = (ctrl_cbox_data_t *)p_ctrl->priv_data;

  ctrl_get_frame(p_ctrl, &rc_cbox);
  // check coordinate
  MT_ASSERT((RECTW(rc_cbox) > sbar_gap + sbar_width)
           && (RECTH(rc_cbox) * page > 2 * sbar_gap));

  list_width = RECTW(rc_cbox);
  list_height = RECTH(rc_cbox) * page;

  p_root = ctrl_get_root(p_ctrl);
  ctrl_get_frame(p_root, &rc_root);
  ctrl_client2screen(p_root, &rc_root);
  ctrl_client2screen(p_ctrl, &rc_cbox);
  
  p_data->p_droplist = ctrl_create_ctrl((u8 *)CTRL_LIST, IDC_CBOX_DROPLIST,
    rc_cbox.left - rc_root.left, rc_cbox.top - rc_root.top,
    list_width, list_height, p_root, 0);
  MT_ASSERT(p_data->p_droplist != NULL);

  if(p_data->p_droplist != NULL)
  {
    // set attr
    list_set_count(p_data->p_droplist, _cbox_calc_droplist_count(p_ctrl), page);
    list_set_field_count(p_data->p_droplist, 1, page);
    list_set_update(p_data->p_droplist, _cbox_droplist_update, (u32)p_ctrl);

    ctrl_set_attr(p_data->p_droplist, OBJ_ATTR_HIDDEN);

    // add scrollbar
    if(sbar_width > 0)
    {
      sbar_left = list_width - 2 * sbar_gap
        - sbar_width + rc_cbox.left - rc_root.left;
      sbar_top = sbar_gap + rc_cbox.top - rc_root.top;
      p_sbar = ctrl_create_ctrl((u8 *)CTRL_SBAR, IDC_CBOX_DROPLIST_SBAR,
                                sbar_left, sbar_top,
                                sbar_width, list_height - 2 * sbar_gap,
                                p_root, 0);
      MT_ASSERT(p_sbar != NULL);

      sbar_set_autosize_mode(p_sbar, TRUE);
      sbar_set_direction(p_sbar, FALSE);
      ctrl_set_attr(p_sbar, OBJ_ATTR_HIDDEN);

      list_set_scrollbar(p_data->p_droplist, p_sbar);
    }
  }

  return p_data->p_droplist;
}
コード例 #29
0
/* create a new page */
static BOOL 
create_page (HWND hwnd, DWORD style, PPROPSHEETDATA propsheet, PROPPAGE *page, 
        PDLGTEMPLATE dlgtpl, WNDPROC proc)
{
    int i, len, w, h;
    PCTRLDATA ctrl;
    HWND hCtrl;
    RECT rcPage;
    DWORD ex_style;

    if ((dlgtpl->controlnr > 0) && !dlgtpl->controls)
        return FALSE;
 
    if (GetWindowExStyle (hwnd) & WS_EX_TRANSPARENT)
        ex_style = WS_EX_TRANSPARENT | WS_EX_USEPARENTRDR;
    else
        ex_style =  WS_EX_USEPARENTRDR;
    
    GetClientRect (hwnd, &rcPage);
    
    w = RECTW(rcPage) - OFFSET_VALUE*2; 
    h = RECTH(rcPage) -RECTH(propsheet->head_rc) - OFFSET_VALUE*2;
    /* create content page */ 
    if ((style & 0xf0L) == PSS_BOTTOM) {
        page->hwnd = CreateWindowEx (CTRL_STATIC, "", SS_LEFT, ex_style, 
                        IDC_STATIC, 
                        OFFSET_VALUE, OFFSET_VALUE, 
                        w, h,
                        hwnd, dlgtpl->dwAddData);
    } else {
        page->hwnd = CreateWindowEx (CTRL_STATIC, "", SS_LEFT, ex_style, 
                        IDC_STATIC, 
                        OFFSET_VALUE, OFFSET_VALUE + propsheet->head_rc.bottom, 
                        w, h,
                        hwnd, dlgtpl->dwAddData);
    }
    if (page->hwnd == HWND_INVALID)
        return FALSE;

    len = strlen (dlgtpl->caption);
    page->title = FixStrAlloc (len);
    if (page->title)
        strcpy (page->title, dlgtpl->caption);

    page->proc = proc;
    page->icon = dlgtpl->hIcon;

    for (i = 0; i < dlgtpl->controlnr; i++) {
        ctrl = dlgtpl->controls + i;
        hCtrl = CreateWindowEx (ctrl->class_name, ctrl->caption,
                    ctrl->dwStyle | WS_CHILD, ctrl->dwExStyle,
                    ctrl->id, ctrl->x, ctrl->y, ctrl->w, ctrl->h,
                    page->hwnd, ctrl->dwAddData);
        
        if (hCtrl == HWND_INVALID) {
            DestroyWindow (page->hwnd);
            if (page->title) {
                FreeFixStr (page->title);
            }
            return FALSE;
        }
    }

    SetWindowCallbackProc (page->hwnd, page->proc);
    SendMessage (page->hwnd, MSG_INITPAGE, 0, dlgtpl->dwAddData);
    return TRUE;
}
コード例 #30
0
ファイル: ImeWnd.cpp プロジェクト: byteman/ctx2000
int CIMEWnd::MsgProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;

    switch (message) {
        case MSG_PAINT:
            hdc = BeginPaint (hwnd);
            draw_border (hwnd, hdc);
            logo.Show(hdc, IMELOGO_LEFT,IMELOGO_TOP,1);
            icon.Show (hdc,imeRect.left,   imeRect.top,   imemgr.cur_ime_bmp_idx);
            icon.Show (hdc,subimeRect.left,subimeRect.top,imemgr.cur_subime_bmp_idx);
            EndPaint (hwnd, hdc);
            break;
        case MSG_LBUTTONDOWN:
        {
               old_x = LOWORD(lParam);
               old_y = HIWORD(lParam);
               int ret = Key_Check(old_x,old_y);

               if(ret == 1)
               {
                    changeInputMothed(hwnd);
               }else if(ret == 2)
               {
                  if(imemgr.cur_ime_type == IME_QUANPIN)
                  {
                      SendMessage(HWND_DESKTOP,MSG_KEYDOWN,SCANCODE_LEFTCONTROL,0);
                      SendMessage(HWND_DESKTOP,MSG_KEYUP,SCANCODE_LEFTCONTROL,0);
                  }else if(imemgr.cur_ime_type == IME_T9){
                      SendMessage(HWND_DESKTOP,MSG_KEYDOWN,SCANCODE_LEFTCONTROL,0);
                      SendMessage(HWND_DESKTOP,MSG_KEYUP,SCANCODE_LEFTCONTROL,0);
                  }else{
                     //关闭状态不用发消息
                  }
              }else{
                SetCapture (hwnd);
                ClientToScreen (hwnd,&old_x,&old_y);
                fCaptured=true;
              }
               break;
           }
        case MSG_LBUTTONUP:
        {
                if(fCaptured){
                    ReleaseCapture ();
                    fCaptured=false;
                }
        }
        break;

    case MSG_MOUSEMOVE:
    {
        if (fCaptured)
        {
            RECT rcWindow;
            GetWindowRect(hwnd, &rcWindow);
            int x = LOSWORD(lParam);
            int y = HISWORD(lParam);
/*
            if( rcWindow.left < 0)
                rcWindow.left = 0;
            if(rcWindow.right > 800)
                rcWindow.right = 800;
            if( rcWindow.top < 0)
                rcWindow.top = 0;
            if(rcWindow.bottom > 480)
                rcWindow.bottom = 480;
                */
            OffsetRect(&rcWindow, x - old_x, y - old_y);
            //if( (rcWindow.left > 0) && (rcWindow.right < 800) &&  (rcWindow.top > 0) && (rcWindow.bottom < 480))
            {
                MoveWindow(hwnd, rcWindow.left, rcWindow.top, RECTW(rcWindow),
                           RECTH(rcWindow), TRUE);
                //RECT rc;
                //GetWindowRect(hWnd, &rc);
                //DPRINTF(JINFO, "rc %d %d\n",rc.left,rc.top);
                //g_SKB->move(rc.left, rc.top - 50);
                old_x = x;
                old_y = y;
            }

        }
        break;
    }
        case MSG_USER_IME_STATUS:
            {
                int type = imemgr.changeIme ();
                //fprintf(stderr,"get type %d \n",type);
                if(type == IME_CLOSE){
                    //std::cerr << "ime close\n";
                    mgiSetActiveIMEWindow(imecon_handle,"");
                }else if(type == IME_QUANPIN){
                    mgiSetActiveIMEWindow(imecon_handle,"quanpin");
                }else if(type == IME_T9){
                    //fprintf(stderr,"change to mgphone\n");
                    if(!mgiSetActiveIMEWindow(imecon_handle,"mgphone"))
                    {
                        fprintf(stderr,"change ime to mgphone faild\n");
                    }else
                    {
                        SendNotifyMessage (t9_ime_hwnd, MSG_IME_OPEN, 0, 0);
                        ShowWindow (t9_ime_hwnd,SW_SHOW);
                    }

                }
                InvalidateRect (hwnd,&refRect,TRUE);
            }
            break;
    };
    return DefaultMainWinProc (hwnd, message, wParam, lParam);
}