?? ghal_windows.cpp
字號:
//
// This file is modify-able for portting NANA GUI to other
// OS platform system.the only thing you need to do is re-program
// the function below.
//
//
//
#include "stdafx.h"
#include "..\nana\GHAL.h"
#include "GHAL_windows.h"
CWnd *g_pwnd;
void window_GHAL_init(CWnd *pwnd)
{
g_pwnd = pwnd;
}
extern "C" void GHAL_put_pixel(int x,int y,COLOR color)
{
CDC *pdc = g_pwnd->GetDC();
COLORREF c = color?RGB(0,0,0):RGB(255,255,255);
pdc->SetPixel(x,y,c);
g_pwnd->ReleaseDC(pdc);
}
extern "C" void GHAL_put_line(int x1,int y1,int x2,int y2,COLOR color)
{
CDC *pdc = g_pwnd->GetDC();
COLORREF c = color?RGB(0,0,0):RGB(255,255,255);
CPen cpen(PS_SOLID,1,c);
CPen *poldpen = pdc->SelectObject(&cpen);
pdc->MoveTo(x1,y1);
pdc->LineTo(x2,y2);
pdc->SelectObject(poldpen);
g_pwnd->ReleaseDC(pdc);
}
extern "C" void GHAL_RefreshAll(void)
{
}
extern "C" void GHAL_put_bmp(int x1,int y1,PNANA_BITMAP pbmp)
{
int x,y;
COLORREF color;
unsigned char *pdata = pbmp->pData;
unsigned char cMask;
unsigned char cValue;
CDC *pdc = g_pwnd->GetDC();
if(pbmp->biBitCount == 1)
{
//單色位圖繪制
for(y=0;y<pbmp->biHeight;y++)
{
cMask = 0x80;
cValue = *pdata ++;
for(x=0;x<pbmp->biWidth;x++)
{
if(cMask==0)
{
cMask = 0x80;
cValue = *pdata ++;
}
if(pbmp->biReverseColor)
{
color = (cValue & cMask)?RGB(255,255,255):RGB(0,0,0);
}else{
color = (cValue & cMask)?RGB(0,0,0):RGB(255,255,255);
}
pdc->SetPixel(x+x1,y+y1,color);
cMask = cMask>>1;
}
}
}
g_pwnd->ReleaseDC(pdc);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -