Example #1
0
static PetscErrorCode PetscDrawClear_Win32(PetscDraw draw)
{
  PetscDraw_Win32 *windraw = (PetscDraw_Win32*)draw->data;

  PetscFunctionBegin;
  /* clear primary buffer */
  ExtFloodFill(windraw->node->Buffer,0,0,COLOR_WINDOW,FLOODFILLBORDER);
  /* if exists clear secondary buffer */
  if (windraw->node->DoubleBuffered) ExtFloodFill(windraw->node->DoubleBuffer,0,0,COLOR_WINDOW,FLOODFILLBORDER);

  /* force WM_PAINT message so cleared buffer will show */
  InvalidateRect(windraw->hWnd,NULL,TRUE);
  UpdateWindow(windraw->hWnd);
  PetscFunctionReturn(0);
}
Example #2
0
static PetscErrorCode PetscDrawGetPopup_Win32(PetscDraw draw,PetscDraw *popdraw)
{
  PetscDraw_Win32 *pop;
  HANDLE          hThread = NULL;
  WindowNode      newnode;
  PetscErrorCode ierr;
  
  PetscFunctionBegin;
  ierr = PetscNew(PetscDraw_Win32,&pop);CHKERRQ(ierr);
  (*popdraw)->data = pop;
  
  /* the following is temporary fix for initializing a global datastructure */
  if(!g_hWindowListMutex) {
    g_hWindowListMutex = CreateMutex(NULL,FALSE,NULL);
  }
  ierr = PetscMemcpy((*popdraw)->ops,&DvOps,sizeof(DvOps));CHKERRQ(ierr);
  
  pop->hReadyEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  CreateThread(NULL, 0,(LPTHREAD_START_ROUTINE)PopMessageLoopThread_Win32,*popdraw,0,(unsigned long*)hThread);
  CloseHandle(hThread);
  WaitForSingleObject(pop->hReadyEvent, INFINITE);
  CloseHandle(pop->hReadyEvent);
  WaitForSingleObject(g_hWindowListMutex, INFINITE);
  
  draw->popup             = (*popdraw);
  ierr                    = PetscNew(struct _p_WindowNode,&newnode);CHKERRQ(ierr);
  newnode->MouseListHead  = NULL;
  newnode->MouseListTail  = NULL;
  newnode->wnext          = WindowListHead;
  newnode->wprev          = NULL;
  newnode->hWnd           = pop->hWnd;
  if(WindowListHead != NULL) {
    WindowListHead->wprev = newnode;
  }
  WindowListHead          = newnode;
  pop->hdc                = GetDC(pop->hWnd);
  
  pop->stringheight   = 10; 
  pop->stringwidth    = 6;
  pop->linewidth      = 1;   /* default pixel sizes of graphics until user changes them */
  pop->pointdiameter  = 1;
  pop->node           = newnode;
  
  newnode->bitwidth  = pop->w;
  newnode->bitheight = pop->h;
  
  /* Create and initialize primary graphics buffer */
  newnode->Buffer = CreateCompatibleDC(pop->hdc);
  newnode->BufferBit = CreateCompatibleBitmap(pop->hdc,pop->w,pop->h);
  newnode->store = SelectObject(newnode->Buffer,newnode->BufferBit);
  ExtFloodFill(newnode->Buffer,0,0,COLOR_WINDOW,FLOODFILLBORDER);
  
  
  newnode->event          = CreateEvent(NULL, TRUE, FALSE, NULL);
  newnode->DoubleBuffered = PETSC_FALSE;
  
  ReleaseDC(pop->hWnd,pop->hdc);
  ReleaseMutex(g_hWindowListMutex);
  PetscFunctionReturn(0);
}
Example #3
0
void
Fill(HDC hdc, LONG x, LONG y, COLORREF color)
{
    HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color));
    ExtFloodFill(hdc, x, y, GetPixel(hdc, x, y), FLOODFILLSURFACE);
    DeleteObject(SelectObject(hdc, oldBrush));
}
Example #4
0
EXTERN_C_BEGIN
#undef __FUNCT__
#define __FUNCT__ "PetscDrawCreate_Win32"
PetscErrorCode  PetscDrawCreate_Win32(PetscDraw draw)
{
  PetscDraw_Win32 *windraw;
  HANDLE          hThread = NULL;
  PetscErrorCode  ierr;
  WindowNode      newnode;

  PetscFunctionBegin;
  ierr       = PetscNew(&windraw);CHKERRQ(ierr);
  draw->data = windraw;

  /* the following is temporary fix for initializing a global datastructure */
  if (!g_hWindowListMutex) g_hWindowListMutex = CreateMutex(NULL,FALSE,NULL);
  ierr = PetscMemcpy(draw->ops,&DvOps,sizeof(DvOps));CHKERRQ(ierr);

  windraw->hReadyEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
  /* makes call to MessageLoopThread to creat window and attach a thread */
  CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)MessageLoopThread_Win32,draw,0,(unsigned long*)hThread);
  CloseHandle(hThread);
  WaitForSingleObject(windraw->hReadyEvent,INFINITE);
  CloseHandle(windraw->hReadyEvent);
  WaitForSingleObject(g_hWindowListMutex,INFINITE);

  ierr                   = PetscNew(&newnode);CHKERRQ(ierr);
  newnode->MouseListHead = NULL;
  newnode->MouseListTail = NULL;
  newnode->wnext         = WindowListHead;
  newnode->wprev         = NULL;
  newnode->hWnd          = windraw->hWnd;
  if (WindowListHead != NULL) WindowListHead->wprev = newnode;
  WindowListHead         = newnode;
  windraw->hdc           = GetDC(windraw->hWnd);

  windraw->stringheight  = 10;
  windraw->stringwidth   = 6;
  windraw->linewidth     = 1;    /* default pixel sizes of graphics until user changes them */
  windraw->pointdiameter = 1;
  windraw->node          = newnode;

  windraw->x = draw->x;
  windraw->y = draw->y;
  windraw->w = newnode->bitwidth    = draw->w;
  windraw->h = newnode->bitheight   = draw->h;

  /* Create and initialize primary graphics buffer */
  newnode->Buffer    = CreateCompatibleDC(windraw->hdc);
  newnode->BufferBit = CreateCompatibleBitmap(windraw->hdc,windraw->w,windraw->h);
  newnode->store     = SelectObject(newnode->Buffer,newnode->BufferBit);
  ExtFloodFill(newnode->Buffer,0,0,COLOR_WINDOW,FLOODFILLBORDER);

  newnode->event          = CreateEvent(NULL,TRUE,FALSE,NULL);
  newnode->DoubleBuffered = PETSC_FALSE;

  ReleaseDC(windraw->hWnd,windraw->hdc);
  ReleaseMutex(g_hWindowListMutex);
  PetscFunctionReturn(0);
}
Example #5
0
void ChannelHandler::DrawChannellist()
{
	if(g_pDrawingHandler == 0)
	{
		new DrawingHandler();
	}
	if(g_pDrawingHandler != 0)
	{
		//let's box this shit first
		//a black box with a nice fine white surrounding
		RECT *rect = new RECT;
		rect->left = 0;
		rect->right = this->leftbarsize;
		rect->top = 0;
		rect->bottom = this->height;

		HDC channelListDC = g_pDrawingHandler->getChannelListHDC();
		g_pDrawingHandler->SetChannelListRect(rect);


		BitBlt(channelListDC,rect->left-5,rect->top-5,rect->right - rect->left + 10,rect->bottom - rect->top + 10,NULL,0,0,WHITENESS);
		BitBlt(channelListDC,rect->left,rect->top,rect->right - rect->left,rect->bottom - rect->top,NULL,0,0,BLACKNESS);
		ExtFloodFill(channelListDC,(rect->left+rect->right)/2,(rect->top+rect->bottom)/2,RGB(0,0,0),FLOODFILLSURFACE);

		int TextSize = 18;
		RECT *temprect = new RECT;
		temprect->left = rect->left;
		temprect->right = rect->right;
		temprect->top = rect->top;
		temprect->bottom = rect->top+TextSize;


		char tempChar[200];

		if(this->ChannelList->begin() != this->ChannelList->end())
		{
			for (std::list<MessageBoxCF *>::iterator tempIter = ChannelList->begin(); tempIter != ChannelList->end(); tempIter++)
			{
				strncpy(tempChar,(*tempIter)->GetName().c_str(),200);
				snprintf(tempChar,200,"%s %i",tempChar,(*tempIter)->GetUnread());
			
				// new draw
				DrawText(channelListDC,tempChar,-1,temprect,DT_WORDBREAK + DT_CALCRECT);
				DrawText(channelListDC,tempChar,-1,temprect,DT_WORDBREAK);
				temprect->top = temprect->bottom;
				temprect->right = rect->right;
	/*
				// old draw
				DrawText(g_pBackbufferDC,tempChar,-1,temprect,DT_SINGLELINE + DT_VCENTER + DT_NOCLIP);
				temprect->top += TextSize;
				temprect->bottom += TextSize;
	*/			
			}
		}
		delete(temprect);
		delete(rect);
	}
}
Example #6
0
BOOL AddToolbarBitmap(HWND control, LPCTSTR name)
{
    // Load bitmap

    HBITMAP hbm =
	LoadImage(hInst, name, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);

    // Create DC

    HDC hdc = CreateCompatibleDC(NULL);

    // Select the bitmap

    SelectObject(hdc, hbm);

    // Select a brush

    SelectObject(hdc, GetSysColorBrush(COLOR_BTNFACE));

    // Get the colour of the first pixel

    COLORREF colour = GetPixel(hdc, 0, 0);

    // Flood fill the bitmap

    ExtFloodFill(hdc, 0, 0, colour, FLOODFILLSURFACE);

    // And the centres of the icons

    for (int x = 11; x < 336; x += 24)
	if (GetPixel(hdc, x, 11) == colour)
	    ExtFloodFill(hdc, x, 11, colour, FLOODFILLSURFACE);

    // Delete the DC

    DeleteObject(hdc);

    // Add bitmap

    TBADDBITMAP bitmap =
	{NULL, (UINT_PTR)hbm};

    SendMessage(control, TB_ADDBITMAP, 14, (LPARAM)&bitmap);
}
Example #7
0
/*
*--------------------------------------------------------------------------------
*  函数名:	BeginDraw
*  功能	 :	用当前画刷颜色填充封闭区域
*  参数	 :	CPoint ptPoint	 -   当前的坐标点
*  算法  :	重载函数,调用 API 函数进行填充
*--------------------------------------------------------------------------------
*/
void CPaintTub::BeginDraw(const CPoint& ptPoint)
{
	HDC hDC = m_hDC;

	// 得到当前坐标点的颜色
	COLORREF crCurPos = GetPixel(hDC, ptPoint.x, ptPoint.y);

	HBRUSH hBrush = CreateSolidBrush(m_crPenColor);
	HBRUSH hOldBrush = (HBRUSH) SelectObject(hDC, hBrush);

	// 填充颜色, Windows API
	ExtFloodFill(hDC, ptPoint.x, ptPoint.y, crCurPos, FLOODFILLSURFACE);

	SelectObject(hDC, hOldBrush);
	DeleteObject(hOldBrush);
	DeleteObject(hBrush);
}
Example #8
0
static PetscErrorCode PetscDrawSetDoubleBuffer_Win32(PetscDraw draw)
{
  PetscDraw_Win32 *windraw = (PetscDraw_Win32*)draw->data;
  HDC             hdc      = GetDC(windraw->hWnd);

  PetscFunctionBegin;
  windraw->node->DoubleBuffer    = CreateCompatibleDC(hdc);
  windraw->node->DoubleBufferBit = CreateCompatibleBitmap(hdc,windraw->w,windraw->h);
  windraw->node->dbstore         = SelectObject(windraw->node->DoubleBuffer,windraw->node->DoubleBufferBit);
  /* Fill background of second buffer */
  ExtFloodFill(windraw->node->DoubleBuffer,0,0,COLOR_WINDOW,FLOODFILLBORDER);
  /* Copy current buffer into seconf buffer and set window data as double buffered */
  BitBlt(windraw->node->DoubleBuffer,0,0,windraw->w,windraw->h,
         windraw->node->Buffer,0,0, SRCCOPY);

  windraw->node->DoubleBuffered = PETSC_TRUE;
  ReleaseDC(windraw->hWnd,hdc);
  PetscFunctionReturn(0);
}
Example #9
0
BOOL DrawKnob(HDC hdc, RECT rect, UINT state)
{
    // Calculate dimensions

    int width = rect.right - rect.left;
    int height = rect.bottom - rect.top;

    // Load bitmap

    HBITMAP bitmap =
	LoadImage(hInst, "Knob", IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);

    // Create DC

    HDC hbdc = CreateCompatibleDC(hdc);

    // Select the bitmap

    SelectObject(hbdc, bitmap);

    // Select a brush

    SelectObject(hbdc, GetSysColorBrush(COLOR_BTNFACE));

    // Get the colour of the centre pixel

    COLORREF colour = GetPixel(hbdc, width / 2, height / 2);

    // Flood fill the bitmap

    ExtFloodFill(hbdc, width / 2, height / 2, colour, FLOODFILLSURFACE);

    // Copy the bitmap

    BitBlt(hdc, rect.left, rect.top, width, height,
    	   hbdc, 0, 0, SRCCOPY);

    DeleteObject(bitmap);
    DeleteObject(hbdc);

    return TRUE;
}
Example #10
0
/**********************************************************************
 *          FloodFill   (GDI32.@)
 */
BOOL WINAPI FloodFill( HDC hdc, INT x, INT y, COLORREF color )
{
    return ExtFloodFill( hdc, x, y, color, FLOODFILLBORDER );
}
Example #11
0
static void TipOfDay_DoPaint(HWND hwnd, HDC hdc, BOOL bUpdateTextOnly)
{
    RECT rcTip, rcSeperator, rcDidYou, rcBulb, rc = s_rcDraw;
    HBRUSH hBrush;
    HWND hwndStatic;
    HFONT hDidYouFont, hTipFont, hOldFont;
    TCHAR szDidYou[32];
    HANDLE hOldHandle;
    COLORREF crOldBackground;

    hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);

    hwndStatic = GetDlgItem(hwnd, IDC_TXT_TIPSTRING);
    GetWindowRect(hwndStatic, &rcTip);
    Window_ScreenToClientRect(hwnd, &rcTip);

    hwndStatic = GetDlgItem(hwnd, IDC_BMP_BULB);
    GetWindowRect(hwndStatic, &rcBulb);

    crOldBackground = SetBkColor(hdc, GetSysColor(COLOR_WINDOW));

    if (!bUpdateTextOnly)
    {
        HBRUSH hBrushShadow = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW));
        HBRUSH hOldBrush;
        HDC hdcMem;
        HBITMAP hOldBitmap;
        BITMAP bm;

        Paint_Draw3DRect(hdc, &rc, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNSHADOW), 1);
        InflateRect(&rc, -1, -1);
        Paint_FillRect(hdc, &rc, GetSysColor(COLOR_WINDOW));
        
        rcSeperator = rc;

        rc.right = rcTip.left - 10;
        Paint_FillRect(hdc, &rc, GetSysColor(COLOR_BTNSHADOW));

        GetObject(s_hBulbBitmap, sizeof(BITMAP), &bm);

        Window_ScreenToClientRect(hwnd, &rcBulb);
        hdcMem = CreateCompatibleDC(hdc);
        hOldBitmap      = SelectObject(hdcMem, s_hBulbBitmap);
        rcBulb.bottom   = rcBulb.top + bm.bmHeight;
        rcBulb.right    = rcBulb.left + bm.bmWidth;
        hOldBrush       = SelectObject(hdcMem, hBrushShadow);
        ExtFloodFill(hdcMem, 0, 0, RGB(255, 255, 255), FLOODFILLSURFACE);
        BitBlt(hdc, rcBulb.left, rcBulb.top, Rect_Width(&rcBulb), Rect_Height(&rcBulb),
                hdcMem, 0, 0, SRCCOPY);

        SelectObject(hdcMem, hOldBitmap);
        DeleteObject(SelectObject(hdcMem, hOldBrush));
        DeleteDC(hdcMem);

        rcSeperator.top     = rcBulb.bottom + 6;
        rcSeperator.bottom  = rcSeperator.top + 1;

        Paint_FillRect(hdc, &rcSeperator, GetSysColor(COLOR_BTNSHADOW));
    }

    hDidYouFont = CreateFont(22, 0, 0, 0, FW_BOLD, 0, 0, 0,
                            DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
                            CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                            DEFAULT_PITCH | FF_SWISS, _T("Times"));

    hTipFont    = CreateFont(16, 0, 0, 0, FW_NORMAL, 0, 0, 0,
                            DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
                            CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                            DEFAULT_PITCH | FF_SWISS, _T("Arial"));

    hOldFont = SelectObject(hdc, hDidYouFont);
    hOldHandle = String_SetResourceHandle(PCPControls_GetHandle());
    _tcsncpy(szDidYou, String_LoadString(IDS_TIP_DIDYOU), sizeof(szDidYou));
    String_SetResourceHandle(hOldHandle);
    rcDidYou        = rcTip;
    rcDidYou.top    = rcBulb.top;
    DrawText(hdc, szDidYou, -1, &rcDidYou, DT_SINGLELINE);

    SelectObject(hdc, hTipFont);
    Paint_FillRect(hdc, &rcTip, GetSysColor(COLOR_WINDOW));
    DrawText(hdc, s_szCurrentTip, -1, &rcTip, DT_WORDBREAK);
    SelectObject(hdc, hOldFont);
    SetBkColor(hdc, crOldBackground);
    DeleteObject(hDidYouFont);
    DeleteObject(hTipFont);
}