예제 #1
0
void graphdefaults()
{
    set_defaults();

   for (int i = 0; i <= MAXCOLORS; i++) { 
   	current_palette.colors[i] = i;
   	BGIpalette[i] = BGIcolor[i];
    }
    SetPaletteEntries(hPalette, BG, MAXCOLORS+1, BGIpalette);
    RealizePalette(hdc[0]);

    SetTextColor(hdc[0], PALETTEINDEX(text_color+BG));
    SetTextColor(hdc[1], PALETTEINDEX(text_color+BG));
    SetBkColor(hdc[0], PALETTEINDEX(BG));
    SetBkColor(hdc[1], PALETTEINDEX(BG));

    SelectClipRgn(hdc[0], NULL);
    SelectClipRgn(hdc[1], NULL);
    SetViewportOrgEx(hdc[0], 0, 0, NULL);
    SetViewportOrgEx(hdc[1], 0, 0, NULL);

    SelectObject(hdc[0], hBrush[fill_settings.pattern]);
    SelectObject(hdc[1], hBrush[fill_settings.pattern]);

    moveto(0,0);
}
예제 #2
0
COLORREF Draw::GetColor(Color c) const {
	COLORREF color = c;
#ifdef PLATFORM_WINCE
	return color;
#else
	if(!palette)
		return color;
	static Index<dword> *SColor;
	ONCELOCK {
		static Index<dword> StaticColor;
		StaticColor << RGB(0x00, 0x00, 0x00) << RGB(0x80, 0x00, 0x00) << RGB(0x00, 0x80, 0x00)
					<< RGB(0x80, 0x80, 0x00) << RGB(0x00, 0x00, 0x80) << RGB(0x80, 0x00, 0x80)
					<< RGB(0x00, 0x80, 0x80) << RGB(0xC0, 0xC0, 0xC0) << RGB(0xC0, 0xDC, 0xC0)
					<< RGB(0xA6, 0xCA, 0xF0) << RGB(0xFF, 0xFB, 0xF0) << RGB(0xA0, 0xA0, 0xA4)
					<< RGB(0x80, 0x80, 0x80) << RGB(0xFF, 0x00, 0x00) << RGB(0x00, 0xFF, 0x00)
					<< RGB(0xFF, 0xFF, 0x00) << RGB(0x00, 0x00, 0xFF) << RGB(0xFF, 0x00, 0xFF)
					<< RGB(0x00, 0xFF, 0xFF) << RGB(0xFF, 0xFF, 0xFF);
		SColor = &StaticColor;
	}
	if(color16 || !AutoPalette())
		return GetNearestColor(handle, color);
	if(SColor->Find(color) >= 0)
		return color;
	if(color == sLightGray)
		return PALETTEINDEX(216 + 17);
	int r = GetRValue(color);
	int g = GetGValue(color);
	int b = GetBValue(color);
	return PALETTEINDEX(r == g && g == b ? (r + 8) / 16 + 216
		                                 : (r + 25) / 51 * 36 +
		                                   (g + 25) / 51 * 6 +
		                                   (b + 25) / 51);
#endif
}
예제 #3
0
void setcolor(int c)
{
    c &= MAXCOLORS;
    color = c;
    SetTextColor(hdc[0], PALETTEINDEX(c+BG));
    SetTextColor(hdc[1], PALETTEINDEX(c+BG));
}
예제 #4
0
static void setgattr (Gwidget_t *widget, Ggattr_t *ap) {
    HBRUSH brush, pbrush;
    HPEN pen, ppen;
    PALETTEENTRY *colorp;
    long color, mode, style, width, flag, pati;
    double intens;

    if (!(ap->flags & G_GATTRCOLOR))
        ap->color = WPU->defgattr.color;
    if (!(ap->flags & G_GATTRWIDTH))
        ap->width = WPU->defgattr.width;
    if (!(ap->flags & G_GATTRMODE))
        ap->mode = WPU->defgattr.mode;
    if (!(ap->flags & G_GATTRFILL))
        ap->fill = WPU->defgattr.fill;
    if (!(ap->flags & G_GATTRSTYLE))
        ap->style = WPU->defgattr.style;
    flag = FALSE;
    mode = ap->mode;
    if (mode != WPU->gattr.mode) {
        WPU->gattr.mode = mode;
        SetROP2 (GC, (int) mode);
    }
    WPU->gattr.fill = ap->fill;
    color = ap->color;
    if (color >= G_MAXCOLORS || !(WPU->colors[color].inuse))
        color = 1;
    if (color != WPU->gattr.color)
        WPU->gattr.color = color, flag = TRUE;
    width = ap->width;
    if (width != WPU->gattr.width)
        WPU->gattr.width = width, flag = TRUE;
    style = ap->style;
    if (style != WPU->gattr.style)
        WPU->gattr.style = style, flag = TRUE;

    if (!flag)
        return;
    WPU->gattr.color = color;
    if (Gdepth == 1) {
        colorp = &WPU->colors[color].color;
        intens = (
            0.3 * colorp->peBlue + 0.59 * colorp->peRed +
            0.11 * colorp->peGreen
        ) / 255.0;
        pati = (intens <= 0.0625) ? 16 : -16.0 * (log (intens) / 2.7725887222);
        brush = WPU->grays[pati];
    } else
        brush = CreateSolidBrush (PALETTEINDEX (WPU->gattr.color));
    pbrush = SelectObject (GC, brush);
    if (Gdepth != 1)
        DeleteObject (pbrush);
    pen = CreatePen (
        (int) gstyles[WPU->gattr.style], WPU->gattr.width,
        PALETTEINDEX (WPU->gattr.color)
    );
    ppen = SelectObject (GC, pen);
    DeleteObject (ppen);
    SetTextColor (GC, PALETTEINDEX (WPU->gattr.color));
}
예제 #5
0
bool createstatusline(void)
{
	BITMAPINFO *bi;
	BITMAPINFOHEADER *bih;
	LOGPALETTE *lp;

	deletestatusline();
	statusline_hdc = CreateCompatibleDC(NULL);
	if (!statusline_hdc)
		return false;
	lp = (LOGPALETTE*)xcalloc(uae_u8, sizeof(LOGPALETTE) + 3 * sizeof(PALETTEENTRY));
	lp->palNumEntries = 4;
	lp->palVersion = 0x300;
	lp->palPalEntry[1].peBlue = lp->palPalEntry[1].peGreen = lp->palPalEntry[0].peRed = 0x10;
	lp->palPalEntry[2].peBlue = lp->palPalEntry[2].peGreen = lp->palPalEntry[2].peRed = 0xff;
	lp->palPalEntry[3].peBlue = lp->palPalEntry[3].peGreen = lp->palPalEntry[3].peRed = 0x7f;
	statusline_palette = CreatePalette(lp);
	SelectPalette(statusline_hdc, statusline_palette, FALSE);
	statusline_width = (WIN32GFX_GetWidth() + 31) & ~31;
	bi = (BITMAPINFO*)xcalloc(uae_u8, sizeof(BITMAPINFOHEADER) + 4 * sizeof(RGBQUAD));
	bih = &bi->bmiHeader;
	bih->biSize = sizeof(BITMAPINFOHEADER);
	bih->biWidth = statusline_width;
	bih->biHeight = -statusline_height;
	bih->biPlanes = 1;
	bih->biBitCount = 8;
	bih->biCompression = BI_RGB;
	bih->biClrUsed = 4;
	bih->biClrImportant = 4;
	bi->bmiColors[1].rgbBlue = bi->bmiColors[1].rgbGreen = bi->bmiColors[1].rgbRed = 0x10;
	bi->bmiColors[2].rgbBlue = bi->bmiColors[2].rgbGreen = bi->bmiColors[2].rgbRed = 0xff;
	bi->bmiColors[3].rgbBlue = bi->bmiColors[3].rgbGreen = bi->bmiColors[3].rgbRed = 0x7f;
	statusline_bitmap = CreateDIBSection(statusline_hdc, bi, DIB_RGB_COLORS, &statusline_bm, NULL, 0);
	xfree(bi);
	if (!statusline_bitmap) {
		deletestatusline();
		return false;
	}
	SelectObject(statusline_hdc, statusline_bitmap);
	RealizePalette(statusline_hdc);

	statusline_font = CreateFont(-10, 0,
		0, 0,
		FW_NORMAL,
		FALSE,
		FALSE,
		FALSE,
		DEFAULT_CHARSET,
		OUT_TT_PRECIS,
		CLIP_DEFAULT_PRECIS,
		PROOF_QUALITY,
		VARIABLE_PITCH | FF_DONTCARE,
		_T("Verdana"));
	SelectObject(statusline_hdc, statusline_font);
	SetTextColor(statusline_hdc, PALETTEINDEX(2));
	SetBkColor(statusline_hdc, PALETTEINDEX(1));
	SetBkMode(statusline_hdc, OPAQUE);
	return true;
}
예제 #6
0
inline void select_fill_color()
{
    if (text_color != fill_settings.color) { 
	text_color = fill_settings.color;
	SetTextColor(hdc[0], PALETTEINDEX(text_color+BG));
	SetTextColor(hdc[1], PALETTEINDEX(text_color+BG));
    }
}
예제 #7
0
    void select(int color) 
    {
	for (l2elem* elem = next; elem != this; elem = elem->next) { 
	    pen_cache_item* ci = (pen_cache_item*)elem;
	    if (ci->color == color &&
		ci->style == line_settings.linestyle &&
		ci->width == line_settings.thickness &&
		(line_settings.linestyle != USERBIT_LINE 
		 || line_settings.upattern == ci->pattern))
	    {
		ci->unlink(); // LRU discipline
		ci->link_after(this); 

		if (hPen != ci->pen) { 
		    hPen = ci->pen;
		    SelectObject(hdc[0], hPen);
		    SelectObject(hdc[1], hPen);
		}
		return;	    
	    }
	}
	hPen = NULL;
	if (line_settings.linestyle == USERBIT_LINE) { 
	    LOGBRUSH lb;
	    lb.lbColor = PALETTEINDEX(color);
	    lb.lbStyle = BS_SOLID;
	    DWORD style[32]; 
	    hPen = ExtCreatePen(PS_GEOMETRIC|PS_USERSTYLE, 
				line_settings.thickness, &lb, 
				convert_userbits(style,line_settings.upattern),
				style);
	} 
	if (hPen == NULL) { 
	    hPen = CreatePen(line_style_cnv[line_settings.linestyle], 
			     line_settings.thickness, 
			     PALETTEINDEX(color));
	}
	SelectObject(hdc[0], hPen);
	SelectObject(hdc[1], hPen);
	
	pen_cache_item* p;
	if (free == NULL) {
	    p = (pen_cache_item*)prev; 
	    p->unlink();
	    DeleteObject(p->pen);	    
	} else { 
	    p = free;
	    free = (pen_cache_item*)p->next;
	}
	p->pen   = hPen;
	p->color = color;
	p->width = line_settings.thickness;
	p->style = line_settings.linestyle;
	p->pattern = line_settings.upattern;
	p->link_after(this);
    }  
예제 #8
0
void floodfill(int x, int y, int border)
{
    select_fill_color();
    if (bgiemu_handle_redraw || visual_page != active_page) { 
	FloodFill(hdc[1], x, y, PALETTEINDEX(border+BG));
    }
    if (visual_page == active_page) { 
	FloodFill(hdc[0], x, y, PALETTEINDEX(border+BG));
    } 
}
예제 #9
0
void putpixel(int x, int y, int c)
{
    c &= MAXCOLORS;
    if (bgiemu_handle_redraw || visual_page != active_page) { 
	SetPixel(hdc[1], x, y, PALETTEINDEX(c+BG));
    }
    if (visual_page == active_page) { 
	SetPixel(hdc[0], x, y, PALETTEINDEX(c+BG));
    }
}
예제 #10
0
파일: ftpal.c 프로젝트: Gaikokujin/WinNT4
VOID vTestPal1(void)
{
    HPALETTE hpal1;
    UINT uiTemp;

    hpal1 = CreatePalette((LPLOGPALETTE) &logpalVGA);

    if (hpal1 == (HPALETTE) 0)
    {
	DbgPrint("vTestPal1 failed to create palette\n");
	return;
    }

    AnimatePalette(hpal1, 0, 100, NULL);
    SetPaletteEntries(hpal1, 0, 100, NULL);

    uiTemp = GetNearestPaletteIndex(hpal1, 0);

    if (uiTemp != 0)
	DbgPrint("GetNearestPaletteIndex failed 0 %lx\n", uiTemp);

    uiTemp = GetNearestPaletteIndex(hpal1, 0x00000080);

    if (uiTemp != 1)
	DbgPrint("GetNearestPaletteIndex failed 1 %lx\n", uiTemp);

    uiTemp = GetNearestPaletteIndex(hpal1, 0x00C0C0C0);

    if (uiTemp != 7)
	DbgPrint("GetNearestPaletteIndex failed 7 %lx\n", uiTemp);

    uiTemp = GetNearestPaletteIndex(hpal1, 0x0000FF00);

    if (uiTemp != 10)
	DbgPrint("GetNearestPaletteIndex failed 10 %lx\n", uiTemp);

    uiTemp = GetNearestPaletteIndex(hpal1, 0x00FFFFFF);

    if (uiTemp != 15)
	DbgPrint("GetNearestPaletteIndex failed 15 %lx\n", uiTemp);

    uiTemp = GetNearestPaletteIndex(hpal1, PALETTEINDEX(5));

    if (uiTemp != 5)
	DbgPrint("GetNearestPaletteIndex failed 15 %lx\n", uiTemp);

    uiTemp = GetNearestPaletteIndex(hpal1, PALETTEINDEX(10));

    if (uiTemp != 10)
	DbgPrint("GetNearestPaletteIndex failed 15 %lx\n", uiTemp);

    if (!DeleteObject(hpal1))
	DbgPrint("vTestPal1 failed to delete palette\n");
}
예제 #11
0
void PaintRoutine (HDC hdc, int cxClient, int cyClient)
{
     HBRUSH hBrush ;
     int    i, x1, x2, y1, y2 ;
     RECT   rect ;

          // Draw window background using palette index 33

     SetRect (&rect, 0, 0, cxClient, cyClient) ;
     hBrush = CreateSolidBrush (PALETTEINDEX (33)) ;
     FillRect (hdc, &rect, hBrush) ;
     DeleteObject (hBrush) ;

          // Draw the 33 balls

     SelectObject (hdc, GetStockObject (NULL_PEN)) ;

     for (i = 0 ; i < 33 ; i++)
     {
          x1 =  i      * cxClient / 33 ;
          x2 = (i + 1) * cxClient / 33 ;

          if (i < 9)
          {
               y1  = i      * cyClient / 9 ;
               y2 = (i + 1) * cyClient / 9 ;
          }
          else if (i < 17)
          {
               y1 = (16 - i) * cyClient / 9 ;
               y2 = (17 - i) * cyClient / 9 ;
          }
          else if (i < 25)
          {
               y1 = (i - 16) * cyClient / 9 ;
               y2 = (i - 15) * cyClient / 9 ;
          }
          else 
          {
               y1 = (32 - i) * cyClient / 9 ;
               y2 = (33 - i) * cyClient / 9 ;
          }

          hBrush = CreateSolidBrush (PALETTEINDEX (i)) ;
          SelectObject (hdc, hBrush) ;
          Ellipse (hdc, x1, y1, x2, y2) ;
          DeleteObject (SelectObject (hdc, GetStockObject (WHITE_BRUSH))) ;
     }
     return ;
}
예제 #12
0
static void text_output(int x, int y, const char* str)
{ 
    select_font();
    if (text_color != color) { 
	text_color = color;
	SetTextColor(hdc[0], PALETTEINDEX(text_color+BG));
	SetTextColor(hdc[1], PALETTEINDEX(text_color+BG));
    }
    if (bgiemu_handle_redraw || visual_page != active_page) { 
        TextOut(hdc[1], x, y, str, strlen(str));
    }
    if (visual_page == active_page) { 
        TextOut(hdc[0], x, y, str, strlen(str));
    } 
}
예제 #13
0
uint QColormap::pixel(const QColor &color) const
{
    const QColor c = color.toRgb();
    COLORREF rgb = RGB(c.red(), c.green(), c.blue());
    if (d->hpal)
        return PALETTEINDEX(GetNearestPaletteIndex(d->hpal, rgb));
    return rgb;
}
예제 #14
0
COLORREF CAppPalette::getColorAt(int index)
{
   ASSERT(index >= 0 && index < NumAppColors);

   COLORREF retval = (m_paletteDevice ? PALETTEINDEX(index) : getRgbAt(index));

   return retval;
}
void CColorPaletteButton::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	
	// Do not call CButton::OnPaint() for painting messages
   COLORREF buttonColor = (m_appPalette.isPaletteDevice() ? 
      PALETTEINDEX(m_appPalette.getEditIndex()) : 
      m_appPalette.getEditColor() );

   TRACE("CColorPaletteButton::OnPaint() - buttonColor = %08x\n",buttonColor);

   CRect rect;
   GetClientRect(&rect);
   CPen penHighlight(PS_SOLID,1,GetSysColor(COLOR_BTNHIGHLIGHT));
   CPen* oldPen = dc.SelectObject(&penHighlight);
   dc.MoveTo(rect.left,rect.bottom);
   dc.LineTo(rect.right,rect.bottom);
   dc.LineTo(rect.right,rect.top - 1);

   CPen penShadow(PS_SOLID,1,GetSysColor(COLOR_BTNSHADOW));
   dc.SelectObject(&penShadow);
   dc.MoveTo(rect.left,rect.bottom - 1);
   dc.LineTo(rect.left,rect.top);
   dc.LineTo(rect.right,rect.top);

   CPen penFace(PS_SOLID,1,GetSysColor(COLOR_BTNFACE));
   dc.SelectObject(&penFace);
   dc.MoveTo(rect.left + 1,rect.bottom - 1);
   dc.LineTo(rect.right - 1,rect.bottom - 1);
   dc.LineTo(rect.right - 1,rect.top);

   CPen penDarkShadow(PS_SOLID,1,GetSysColor(COLOR_3DDKSHADOW));
   dc.SelectObject(&penDarkShadow);
   dc.MoveTo(rect.left + 1,rect.bottom - 2);
   dc.LineTo(rect.left + 1,rect.top + 1);
   dc.LineTo(rect.right - 1,rect.top + 1);

   dc.SelectObject(oldPen);

   m_appPalette.pushPalette(&dc);

   CBrush brush;
   brush.CreateSolidBrush(buttonColor);
   CBrush* oldBrush = dc.SelectObject(&brush);
   rect.top += 2;
   rect.left += 2;
   rect.bottom -= 1;
   rect.right -= 1;
   dc.SelectObject(&brush);
   dc.FillRect(&rect,&brush);

   dc.SelectObject(oldBrush);

   m_appPalette.popPalette(&dc);
}
예제 #16
0
inline void MaptoGray(COLORREF & cr)
{
	if ( (cr & 0xFF000000) != PALETTEINDEX(0) ) // not paletteindex
	{
		BYTE gray = ( GetRValue(cr) * 77 + GetGValue(cr) * 150 + GetBValue(cr) * 29 + 128 ) / 256;
	
		cr = (cr & 0xFF000000) | RGB(gray, gray, gray);
	}
}
예제 #17
0
/**
 * Retrieves system palette entries. Includes a workaround for some
 * video drivers which may not support the GSPE call but may return
 * valid values from this procedure.
 */
int AwtPalette::FetchPaletteEntries(HDC hDC, PALETTEENTRY* pPalEntries)
{
    LOGPALETTE* pLogPal = 0;
    HPALETTE hPal = 0;
    HPALETTE hPalOld = 0;
    int numEntries;

    numEntries = ::GetSystemPaletteEntries(hDC, 0, 256, pPalEntries);

    if (numEntries > 0) {
        return numEntries;
    }
    // Workaround: some drivers do not support GetSysPalEntries

    pLogPal = (LOGPALETTE*) new char[sizeof(LOGPALETTE)
                                    + 256*sizeof(PALETTEENTRY)];
    if (pLogPal == NULL) {
        return 0;
    }

    pLogPal->palVersion = 0x300;
    pLogPal->palNumEntries = 256;
    int iEntry;
    PALETTEENTRY* pEntry;
    for (iEntry = 0; iEntry < 256; iEntry++) {
        pEntry = pLogPal->palPalEntry + iEntry;
        pEntry->peRed = iEntry;
        pEntry->peGreen = pEntry->peBlue = 0;
        pEntry->peFlags = PC_EXPLICIT;
    }
    hPal = ::CreatePalette(pLogPal);
    delete pLogPal;
    if ( hPal == 0 ) {
        return 0;
    }

    hPalOld = ::SelectPalette(hDC, hPal, 1);
    if (hPalOld == 0) {
        ::DeleteObject(hPal);
        return 0;
    }
    ::RealizePalette(hDC);

    COLORREF rgb;
    for (iEntry = 0; iEntry < 256; iEntry++) {
        rgb = ::GetNearestColor(hDC, PALETTEINDEX(iEntry));
        pPalEntries[iEntry].peRed = GetRValue(rgb);
        pPalEntries[iEntry].peGreen = GetGValue(rgb);
        pPalEntries[iEntry].peBlue = GetBValue(rgb);
    }

    ::SelectPalette(hDC, hPalOld, 0 );
    ::DeleteObject(hPal);
    ::RealizePalette(hDC);

    return 256;
}
예제 #18
0
파일: ftpal.c 프로젝트: Gaikokujin/WinNT4
VOID vTestPal2(HDC hdc)
{
    HPALETTE hpalDefault;
    HBRUSH hbrDefault, hbr;
    DWORD ulIndex, ulPal;
    PALETTEENTRY palentry;

    hpalDefault = GetStockObject(DEFAULT_PALETTE);

    SelectPalette(hdc, hpalDefault, 0);
    SelectPalette(hdc, hpalDefault, 0);
    SelectPalette(hdc, hpalDefault, 0);
    SelectPalette(hdc, hpalDefault, 0);

    for (ulIndex = 0; ulIndex < 20; ulIndex++)
    {
	ulPal = PALETTEINDEX(ulIndex);

	if (!(ulPal & 0x01000000))
	    DbgPrint("PALETTEINDEX failed to do it\n");

	hbr = CreateSolidBrush(PALETTEINDEX(ulIndex));
	hbrDefault = SelectObject(hdc, hbr);
	PatBlt(hdc, ulIndex * 20, 0, 20, 20, PATCOPY);
	SelectObject(hdc, hbrDefault);
	DeleteObject(hbr);

	GetPaletteEntries(hpalDefault, ulIndex, 1, (LPPALETTEENTRY) &ulPal);

	hbr = CreateSolidBrush(ulPal);
	hbrDefault = SelectObject(hdc, hbr);
	PatBlt(hdc, ulIndex * 20, 20, 20, 20, PATCOPY);
	SelectObject(hdc, hbrDefault);
	DeleteObject(hbr);

	GetPaletteEntries(hpalDefault, ulIndex, 1, (LPPALETTEENTRY) &palentry);

	hbr = CreateSolidBrush(PALETTERGB(palentry.peRed, palentry.peGreen, palentry.peBlue));
	hbrDefault = SelectObject(hdc, hbr);
	PatBlt(hdc, ulIndex * 20, 40, 20, 20, PATCOPY);
	SelectObject(hdc, hbrDefault);
	DeleteObject(hbr);
    }
}
예제 #19
0
int GPcanvasclear (Gwidget_t *widget) {
    HBRUSH brush, pbrush;

    /* FIXME: drain repaint messages */
    brush = CreateSolidBrush (PALETTEINDEX (0));
    pbrush = SelectObject (GC, brush);
    Rectangle (GC, 0, 0, (int) WPU->vsize.x, (int) WPU->vsize.y);
    SelectObject (GC, pbrush);
    return 0;
}
예제 #20
0
PaletteWindow::PaletteWindow(
     HINSTANCE      hInst,
     HWND           hWndParent,
     unsigned short usWidth,
     unsigned short usHeight
) : ChildWindow(hInst, PALETTE_CLASS_NAME, GetAppName(), WS_CHILD, CHILD_ID_PALETTE, hWndParent) {
     pClientBitmap = new Bitmap(pF1CarBitmap, usWidth, usHeight);
     ASSERT(pClientBitmap != NULL);

     pCursorPalette  = new Cursor(Instance(), APP_CURSOR_PALETTE);
     ASSERT(pCursorPalette != NULL);

     /*
     ** Build palette image once only in memory.
     */
     PaintWindowUpdate        pwu(Handle());
     PaintCompatibleWindow    pcw(pwu.DC());
     HPALETTE                 hOldPalette;
     unsigned short           i, x, y, w;
     RECT                     rect;

     hOldPalette = SelectPalette(pcw.DC(), hPalette, FALSE);
     (void) RealizePalette(pcw.DC());

     ASSERT(pClientBitmap != NULL);
     pcw.SelectBitmap(pClientBitmap);
     {
          /*
          ** Draw palette in client bitmap.
          */
          w = usWidth / PALETTE_BOX_ITEMS_PER_LINE;
          for (i = 0, x = 0, y = 0; i < NUM_COLOURS_IN_PALETTE; i++, x += w) {
               SolidBrush     brush(PALETTEINDEX(i));

               if (i % PALETTE_BOX_ITEMS_PER_LINE == 0 && i != 0) {
                    x = 0;
                    y += PALETTE_BOX_ITEM_HEIGHT;
               }

               rect.bottom    = y;
               rect.top       = y + PALETTE_BOX_ITEM_HEIGHT;
               rect.left      = x;
               rect.right     = x + w;
               pcw.FillRect(&rect, &brush);
               pcw.MoveTo(rect.left,  rect.bottom);
               pcw.LineTo(rect.left,  rect.top);
               pcw.LineTo(rect.right, rect.top);
               pcw.LineTo(rect.right, rect.bottom);
               pcw.LineTo(rect.left,  rect.bottom);
          }
     }
     pcw.DeselectBitmap();
     (void) SelectPalette(pcw.DC(), hOldPalette, FALSE);
}
예제 #21
0
COLOR	MDIORGB_ConvertColour (OOTint pmClrNum)
{
    COLORREF	myBaseColour, myDesiredColour;
    BYTE	myRed, myGreen, myBlue;
    
    if (!MIO_selectedRunWindowInfo -> xor)
    {
    	return (COLOR) PALETTEINDEX (pmClrNum);
    }
    
    // Gets ugly - Handle XOR
    
    // The main problem is that Windows can draw in XOR mode, but it uses the
    // pixel values.  This means that if we want XOR to work with a particular
    // colour value (i.e. drawing on top of colour x comes out in the original
    // colour, then one a direct colour display we need to XOR the RGB of the 
    // colour we want to draw with the RGB of colour x, and then draw the line
    // in XOR mode in the resulting colour.
    
    // With a CLUT display, it's even more complicated.  We need to find out
    // the index to the actual display CLUT used by colour x. We then XOR it 
    // with the index of the colour we're drawing in. We then get an index 
    // number to the actual display CLUT that we want to use. We then have to 
    // figure out what RGB or palette index will correspond to that index in
    // the display CLUT.
    
    // For direct colour
    myBaseColour = GetNearestColor (
    				MIO_selectedRunWindowInfo -> deviceContext,
    				(COLORREF) PALETTEINDEX (0));
    myDesiredColour = GetNearestColor (
    				MIO_selectedRunWindowInfo -> deviceContext,
    				(COLORREF) PALETTEINDEX (pmClrNum));
    myRed = GetRValue (myBaseColour) ^ GetRValue (myDesiredColour);   				
    myGreen = GetGValue (myBaseColour) ^ GetGValue (myDesiredColour);   				
    myBlue = GetBValue (myBaseColour) ^ GetBValue (myDesiredColour);   				
    
    return (COLOR) RGB (myRed, myGreen, myBlue); 
} // MDIORGB_ConvertColour
예제 #22
0
void PaintRoutine (HDC hdc, int cxClient, int cyClient)
{
     static TCHAR szText [] = TEXT (" Fade In and Out ") ;
     int          x, y ;
     SIZE         sizeText ;

     SetTextColor (hdc, PALETTEINDEX (0)) ;
     GetTextExtentPoint32 (hdc, szText, lstrlen (szText), &sizeText) ;

     for (x = 0 ; x < cxClient ; x += sizeText.cx)
     for (y = 0 ; y < cyClient ; y += sizeText.cy)
     {
          TextOut (hdc, x, y, szText, lstrlen (szText)) ;
     }
     return ;
}
예제 #23
0
bool VDUIListViewW32::Create(IVDUIParameters *pParameters) {
	mbCheckable = pParameters->GetB(nsVDUI::kUIParam_Checkable, false);

	DWORD dwFlags = LVS_REPORT | WS_TABSTOP;

	if (pParameters->GetB(nsVDUI::kUIParam_NoHeader, false))
		dwFlags |= LVS_NOCOLUMNHEADER;

	if (!CreateW32(pParameters, WC_LISTVIEW, dwFlags))
		return false;

	ListView_SetExtendedListViewStyle(mhwnd, LVS_EX_FULLROWSELECT | ListView_GetExtendedListViewStyle(mhwnd));

	if (mbCheckable) {
		const int cx = GetSystemMetrics(SM_CXMENUCHECK);
		const int cy = GetSystemMetrics(SM_CYMENUCHECK);

		if (HBITMAP hbm = CreateBitmap(cx, cy, 1, 1, NULL)) {
			if (HDC hdc = CreateCompatibleDC(NULL)) {
				if (HGDIOBJ hbmOld = SelectObject(hdc, hbm)) {
					bool success = false;

					RECT r = { 0, 0, cx, cy };

					SetBkColor(hdc, PALETTEINDEX(0));
					ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &r, "", 0, NULL);
					DrawFrameControl(hdc, &r, DFC_BUTTON, DFCS_BUTTONCHECK|DFCS_CHECKED);

					SelectObject(hdc, hbmOld);

					if (HIMAGELIST himl = ImageList_Create(cx, cy, ILC_COLOR, 1, 1)) {
						if (ImageList_Add(himl, hbm, NULL) >= 0)
							ListView_SetImageList(mhwnd, himl, LVSIL_STATE);
						else
							ImageList_Destroy(himl);
					}
				}

				DeleteDC(hdc);
			}

			DeleteObject(hbm);
		}
	}

	return true;
}
예제 #24
0
void
ArxDbgUiDlgColor::OnPaint() 
{
    CPaintDC dc(this);                // device context for painting
    setToAcadColorPalette(&dc);       // make colors match AutoCAD's

        // draw all colors but BYLAYER and BYBLOCK
    for (int j=1; j<=255; j++) {
        dc.FillSolidRect(m_colorTiles[j], PALETTEINDEX(j));
        dc.DrawEdge(m_colorTiles[j], EDGE_SUNKEN, BF_RECT);
    }

    drawCurrentColorSwatch(&dc);    // draw the current color at the bottom

    CString str;
    SetDlgItemText(ARXDBG_TXT_COLOR, ArxDbgUtils::colorToStr(m_currentIndex, str));
}
예제 #25
0
파일: ftpal.c 프로젝트: Gaikokujin/WinNT4
VOID vPaintStripes(HDC hdc, RECT *prcl)
{
    LOGPALETTE256 logPal256;
    DWORD ulTemp;
    HBRUSH hBrush, hOldBrush;
    HPALETTE hpalExplicit,hpalTemp;

    logPal256.palVersion    = 0x300;
    logPal256.palNumEntries = 256;

// Set up explicit palette.

    for (ulTemp = 0; ulTemp < 256; ulTemp++)
    {
	logPal256.palPalEntry[ulTemp].peRed	 = ulTemp;
	logPal256.palPalEntry[ulTemp].peGreen	 = 0;
	logPal256.palPalEntry[ulTemp].peBlue	 = 0;
	logPal256.palPalEntry[ulTemp].peFlags	 = PC_EXPLICIT;
    }

    hpalExplicit = CreatePalette((LOGPALETTE *) &logPal256);
    hpalTemp = SelectPalette(hdc,hpalExplicit,0);
    RealizePalette(hdc);

// Paint Surface with all colors.

    for (ulTemp = 0; ulTemp < 256; ulTemp++)
    {
	hBrush = CreateSolidBrush(PALETTEINDEX(ulTemp));
	hOldBrush = SelectObject(hdc,hBrush);

	PatBlt(hdc,
	       (((prcl->right - prcl->left) * ulTemp) / 256),
	       0,
	       (((prcl->right - prcl->left) / 256) + 3) ,
	       (prcl->bottom - prcl->top),
	       PATCOPY);

	SelectObject(hdc, hOldBrush);
	DeleteObject(hBrush);
    }

    SelectPalette(hdc,hpalTemp,0);
    DeleteObject(hpalExplicit);
}
예제 #26
0
static void MoveImage(HWND hWnd) {   

	HDC		hDC;
	HBRUSH	hbrColor, hbrOld;
	gravstruct *gp = &gravs;
	unsigned char	ball;
	
	hDC = GetDC(hWnd);									// get HDC to this window	
		
    SelectPalette(hDC, hPal, 0);
    RealizePalette(hDC);

	hbrOld = (HBRUSH)SelectObject(hDC, (HBRUSH)GetStockObject(BLACK_BRUSH));     // select the black pen			
	// Mask center point
	Ellipse(hDC, REC_CORNERS(gp->width/2, gp->height/2, gp->sr));   	

	// Resize center point
	switch (rand() % 4) {
	case 0:
		if (gp->sr < STARRADIUS)
			gp->sr++;
		break;
	case 1:
		if (gp->sr > 2)
			gp->sr--;
	}
	if (iColorCycle) {
		if (gp->starcolor+=6 > (PALSIZE-21))
			gp->starcolor = 1;
	}

	hbrColor = CreateSolidBrush(PALETTEINDEX(gp->starcolor));
	
	// Draw center point	
	SelectObject(hDC, hbrColor);
	Ellipse(hDC, REC_CORNERS(gp->width/2, gp->height/2, gp->sr));   	

	for (ball = 0; ball <= gp->nplanets; ball++)
		draw_planet(hDC, &gp->planets[ball]);	
	
	SelectObject(hDC, hbrOld);
	DeleteObject(hbrColor);								// delete the pen
	
	ReleaseDC(hWnd, hDC);
}
예제 #27
0
void CDIBPal::Draw(HDC hDC, RECT* pRect, BOOL bBkgnd)
{
    int iColors = GetNumColors();
    HPALETTE hOldPal = ::SelectPalette(hDC, (HPALETTE)m_hObject, bBkgnd);
    ::RealizePalette(hDC);
    int i, j, top, left, bottom, right, w, h;
    w = pRect->right - pRect->left;
    h = pRect->bottom - pRect->top;
    for (j=0, top=pRect->top; j<16 && iColors; j++, top=bottom) {
        bottom = pRect->top + (j+1) * h / 16 + 1;
        for(i=0, left=pRect->left; i<16 && iColors; i++, left=right) {
            right = pRect->left + (i+1) * w / 16 + 1;
            CBrush br (PALETTEINDEX(j * 16 + i));
            HBRUSH brold = (HBRUSH)::SelectObject(hDC, br.m_hObject);
            ::Rectangle(hDC, left-1, top-1, right, bottom);
            ::SelectObject(hDC, brold);
            iColors--;
        }
    }
    ::SelectPalette(hDC, hOldPal, FALSE);
}
예제 #28
0
void CDIBPal::Draw(CDC* pDC, CRect* pRect, BOOL bBkgnd)
{
#if 0
    int iColors = GetNumColors();
    CPalette *pOldPal = pDC->SelectPalette(this, bBkgnd);
    pDC->RealizePalette();
    int i, j, top, left, bottom, right;
    for (j=0, top=0; j<16 && iColors; j++, top=bottom) {
        bottom = (j+1) * pRect->bottom / 16 + 1;
        for(i=0, left=0; i<16 && iColors; i++, left=right) {
            right = (i+1) * pRect->right / 16 + 1;
            CBrush br (PALETTEINDEX(j * 16 + i));
            CBrush *brold = pDC->SelectObject(&br);
            pDC->Rectangle(left-1, top-1, right, bottom);
            pDC->SelectObject(brold);
            iColors--;
        }
    }
    pDC->SelectPalette(pOldPal, FALSE);
#else
    Draw(pDC->GetSafeHdc(), pRect, bBkgnd);
#endif
}
예제 #29
0
void initgraph(int* device, int* mode, char const* /*pathtodriver*/, 
			   int size_width, int size_height)
{
    int index;
    static WNDCLASS wcApp;

    gdi_error_code = grOk;

    if (wcApp.lpszClassName == NULL) { 
	wcApp.lpszClassName = "BGIlibrary";
	wcApp.hInstance = 0;
	wcApp.lpfnWndProc = WndProc;
	wcApp.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcApp.hIcon = 0;
	wcApp.lpszMenuName = 0;
	wcApp.hbrBackground = (HBRUSH__ *) GetStockObject(BLACK_BRUSH);
	wcApp.style = CS_SAVEBITS;
	wcApp.cbClsExtra = 0;
	wcApp.cbWndExtra = 0;
	
	if (!RegisterClass(&wcApp)) { 
	    gdi_error_code = GetLastError();
	    return;
	}
	
	pPalette = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED,
	    sizeof(LOGPALETTE)+sizeof(PALETTEENTRY)*PALETTE_SIZE);
	
	pPalette->palVersion = 0x300;
	pPalette->palNumEntries = PALETTE_SIZE;
	memset(pPalette->palPalEntry, 0, sizeof(PALETTEENTRY)*PALETTE_SIZE); 
	for (index = 0; index < BG; index++) {
	    pPalette->palPalEntry[index].peFlags = PC_EXPLICIT;
	    pPalette->palPalEntry[index].peRed = index;
	    pPalette->palPalEntry[PALETTE_SIZE-BG+index].peFlags = PC_EXPLICIT;
	    pPalette->palPalEntry[PALETTE_SIZE-BG+index].peRed = 
		PALETTE_SIZE-BG+index;
	}		
	hBackgroundBrush = CreateSolidBrush(PALETTEINDEX(BG));
	hBrush[EMPTY_FILL] = (HBRUSH__*) GetStockObject(NULL_BRUSH);
	hBrush[SOLID_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, SolidBrushBitmap));
	hBrush[LINE_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, LineBrushBitmap));
	hBrush[LTSLASH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, LtslashBrushBitmap));
	hBrush[SLASH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, SlashBrushBitmap));
	hBrush[BKSLASH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, BkslashBrushBitmap));
	hBrush[LTBKSLASH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, LtbkslashBrushBitmap));
	hBrush[HATCH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, HatchBrushBitmap));
	hBrush[XHATCH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, XhatchBrushBitmap));
	hBrush[INTERLEAVE_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, InterleaveBrushBitmap));
	hBrush[WIDE_DOT_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, WidedotBrushBitmap));
	hBrush[CLOSE_DOT_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, ClosedotBrushBitmap));
	hBrush[USER_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, SolidBrushBitmap));
    }
    memcpy(BGIpalette, BGIcolor, sizeof BGIpalette);
    current_palette.size = MAXCOLORS+1;
    for (index = 10; index <= MAXCOLORS; index++) {
	pPalette->palPalEntry[index] = BGIcolor[0];
    }
    for (index = 0; index <= MAXCOLORS; index++) {
	current_palette.colors[index] = index;
	pPalette->palPalEntry[index+BG] = BGIcolor[index];
    }
    hPalette = CreatePalette(pPalette);
    detect_mode(device, mode);
    set_defaults();

	if (size_width) window_width=size_width;
	if (size_height) window_height=size_height;

    hWnd = CreateWindow("BGIlibrary", "Windows BGI", 
			WS_OVERLAPPEDWINDOW,
		        0, 0, window_width+BORDER_WIDTH, 
			window_height+BORDER_HEIGHT,
			(HWND)NULL,  (HMENU)NULL,
	    		0, NULL);
    if (hWnd == NULL) { 
	gdi_error_code = GetLastError();
	return;
    }
    ShowWindow(hWnd, *mode == VGAMAX ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL);
    UpdateWindow(hWnd);
}
예제 #30
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT messg, 
			 WPARAM wParam, LPARAM lParam)
{
    int i;
    static bool palette_changed = false;

    switch (messg) { 
      case WM_PAINT: 
	if (hdc[0] == 0) {
	    hdc[0] = BeginPaint(hWnd, &ps);
            SelectPalette(hdc[0], hPalette, FALSE);
	    RealizePalette(hdc[0]);
	    hdc[1] = CreateCompatibleDC(hdc[0]);
            SelectPalette(hdc[1], hPalette, FALSE);
	    hdc[2] = CreateCompatibleDC(hdc[0]);
            SelectPalette(hdc[2], hPalette, FALSE);
	    hdc[3] = CreateCompatibleDC(hdc[0]);
            SelectPalette(hdc[3], hPalette, FALSE);

	    screen_width = GetDeviceCaps(hdc[0], HORZRES);
	    screen_height = GetDeviceCaps(hdc[0], VERTRES);
	    hBitmap[active_page] = 
		CreateCompatibleBitmap(hdc[0], screen_width, screen_height);
	    SelectObject(hdc[1], hBitmap[active_page]);	    

	    SetTextColor(hdc[0], PALETTEINDEX(text_color+BG));
	    SetTextColor(hdc[1], PALETTEINDEX(text_color+BG));
	    SetBkColor(hdc[0], PALETTEINDEX(BG));
	    SetBkColor(hdc[1], PALETTEINDEX(BG));

	    SelectObject(hdc[0], hBrush[fill_settings.pattern]);
	    SelectObject(hdc[1], hBrush[fill_settings.pattern]);

	    RECT scr;
	    scr.left = -view_settings.left;
	    scr.top = -view_settings.top; 
	    scr.right = screen_width-view_settings.left-1;
	    scr.bottom = screen_height-view_settings.top-1;
	    FillRect(hdc[1], &scr, hBackgroundBrush);
	}
	if (hRgn != NULL) { 
	    SelectClipRgn(hdc[0], NULL);
	}
	if (visual_page != active_page) { 
	    SelectObject(hdc[1], hBitmap[visual_page]); 
	} 
        BitBlt(hdc[0], -view_settings.left, 
	       -view_settings.top, window_width, window_height, 
	       hdc[1], -view_settings.left, -view_settings.top, 
	       SRCCOPY);
	if (hRgn != NULL) { 
	    SelectClipRgn(hdc[0], hRgn);
	}
	if (visual_page != active_page) { 
	    SelectObject(hdc[1], hBitmap[active_page]); 
	} 
	ValidateRect(hWnd, NULL);
	break;
      case WM_SETFOCUS:
	if (palette_changed) { 
	    HPALETTE new_palette = CreatePalette(pPalette);
	    SelectPalette(hdc[0], new_palette, FALSE);
	    RealizePalette(hdc[0]);
	    SelectPalette(hdc[1], new_palette, FALSE);
	    SelectPalette(hdc[2], new_palette, FALSE);
	    SelectPalette(hdc[3], new_palette, FALSE);
	    DeleteObject(hPalette);
	    hPalette = new_palette;
	    palette_changed = false;
	}
	break;
      case WM_PALETTECHANGED: 
	RealizePalette(hdc[0]);
	UpdateColors(hdc[0]);
	palette_changed = true;
	break;
      case WM_DESTROY: 
        EndPaint(hWnd, &ps);
	hdc[0] = 0;
	DeleteObject(hdc[1]);
	DeleteObject(hdc[2]);
	DeleteObject(hdc[3]);
	if (hPutimageBitmap) { 
	    DeleteObject(hPutimageBitmap);
	    hPutimageBitmap = NULL;
	}
	for (i = 0; i < MAX_PAGES; i++) { 
	    if (hBitmap[i] != NULL) {
		DeleteObject(hBitmap[i]);
		hBitmap[i] = 0;
	    }
	}
	DeleteObject(hPalette);
	hPalette = 0;
	PostQuitMessage(0);
	break;
      case WM_SIZE: 
	window_width = LOWORD(lParam);
	window_height = HIWORD(lParam);
	break;
      case WM_TIMER:
	KillTimer(hWnd, TIMER_ID);
	timeout_expired = true;
	break;
      case WM_CHAR:
	kbd_queue.put((TCHAR) wParam);
	break;

		// Handle some mouse events, too (1-Oct-2000, Matthew Weathers, Erik Habbestad)
	  case WM_LBUTTONDOWN:
		  iClickedMouseX = LOWORD(lParam);
		  iClickedMouseY = HIWORD(lParam);
		  bMouseDown = true;
		  iWhichMouseButton = LEFT_BUTTON;
		  break;
	  case WM_LBUTTONUP:
		  iClickedMouseX = LOWORD(lParam);
		  iClickedMouseY = HIWORD(lParam);
		  bMouseUp = true;
		  iWhichMouseButton = LEFT_BUTTON;
		  break;
	  case WM_RBUTTONDOWN:
		  iClickedMouseX = LOWORD(lParam);
		  iClickedMouseY = HIWORD(lParam);
		  bMouseDown = true;
		  iWhichMouseButton = RIGHT_BUTTON;
		  break;
	  case WM_RBUTTONUP:
		  iClickedMouseX = LOWORD(lParam);
		  iClickedMouseY = HIWORD(lParam);
		  bMouseUp = true;
		  iWhichMouseButton = RIGHT_BUTTON;
		  break;
	  case WM_MOUSEMOVE:
		  iCurrentMouseX = LOWORD(lParam);
		  iCurrentMouseY = HIWORD(lParam);
		  break;

      default:
	return DefWindowProc(hWnd, messg, wParam, lParam);
    }
    return 0;
}