📄 hdc.c
字号:
/* Copyright (C) 2004-2005 Li Yudong*//*** This program is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License as published by** the Free Software Foundation; either version 2 of the License, or** (at your option) any later version.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the** GNU General Public License for more details.**** You should have received a copy of the GNU General Public License** along with this program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#include "../include/common.h"#include "../include/semaphore.h"#include "../include/shmem.h"#include "../include/socketio.h"#include "../include/blockheap.h"#include "../include/rect.h"#include "../include/invalidregion.h"#include "../include/clipregion.h"#include "../include/message.h"#include "../include/hdc.h"#include "../include/caret.h"#include "../include/winnc.h"#include "../include/winbase.h"#include "../include/window.h"#include "../include/bmp.h"#include "../include/gdi.h"#include "../include/framebuffer.h"#include "../include/mouse.h"extern PWindowsTree _lGUI_pWindowsTree;extern int _lGUI_iBytesDataType;BOOL GUIAPI CreateStockObject(){ FILE* fp; char* pointer; char* pShmAddr; int* pIdxAddr; int iObjOffset; PEN pen; BRUSH brush; FONT font; pShmAddr=GetShmAddr(); if(!pShmAddr) return false; pIdxAddr=(int*)(pShmAddr+SHMEM_GDI_INDEX_OFFSET); iObjOffset=SHMEM_GDI_OFFSET; //#define WHITE_PEN 0x00000000 pen.iGdiType =GDI_PEN; pen.iPenStyle =PS_SOLID; pen.iPenWidth =1; pen.crPenColor =RGB(0xff,0xff,0xff); memcpy((void*)(pShmAddr+iObjOffset),&pen,sizeof(PEN)); *(pIdxAddr+WHITE_PEN)=iObjOffset; iObjOffset+=sizeof(PEN); //#define LTGRAY_PEN 0x00000001 pen.iGdiType =GDI_PEN; pen.iPenStyle =PS_SOLID; pen.iPenWidth =1; pen.crPenColor =RGB(0xd4,0xd0,0xc8); memcpy((void*)(pShmAddr+iObjOffset),&pen,sizeof(PEN)); *(pIdxAddr+LTGRAY_PEN)=iObjOffset; iObjOffset+=sizeof(PEN); //#define GRAY_PEN 0x00000002 pen.iGdiType =GDI_PEN; pen.iPenStyle =PS_SOLID; pen.iPenWidth =1; pen.crPenColor =RGB(0xc0,0xc0,0xc0); memcpy((void*)(pShmAddr+iObjOffset),&pen,sizeof(PEN)); *(pIdxAddr+GRAY_PEN)=iObjOffset; iObjOffset+=sizeof(PEN); //#define DKGRAY_PEN 0x00000003 pen.iGdiType =GDI_PEN; pen.iPenStyle =PS_SOLID; pen.iPenWidth =1; pen.crPenColor =RGB(0x80,0x80,0x80); memcpy((void*)(pShmAddr+iObjOffset),&pen,sizeof(PEN)); *(pIdxAddr+DKGRAY_PEN)=iObjOffset; iObjOffset+=sizeof(PEN); //#define BLACK_PEN 0x00000004 pen.iGdiType =GDI_PEN; pen.iPenStyle =PS_SOLID; pen.iPenWidth =1; pen.crPenColor =RGB(0x00,0x00,0x00); memcpy((void*)(pShmAddr+iObjOffset),&pen,sizeof(PEN)); *(pIdxAddr+BLACK_PEN)=iObjOffset; iObjOffset+=sizeof(PEN); //#define NULL_PEN 0x00000005 pen.iGdiType =GDI_PEN; pen.iPenStyle =PS_NULL; pen.iPenWidth =1; pen.crPenColor =RGB(0x00,0x00,0x00); memcpy((void*)(pShmAddr+iObjOffset),&pen,sizeof(PEN)); *(pIdxAddr+NULL_PEN)=iObjOffset; iObjOffset+=sizeof(PEN); //#define WHITE_BRUSH 0x00000006 brush.iGdiType =GDI_BRUSH; brush.iBrushStyle =BS_SOLID; // brush style brush.crBrushColor =RGB(0xFF,0xFF,0xFF); memcpy((void*)(pShmAddr+iObjOffset),&brush,sizeof(BRUSH)); *(pIdxAddr+WHITE_BRUSH)=iObjOffset; iObjOffset+=sizeof(BRUSH); //#define LTGRAY_BRUSH 0x00000007 brush.iGdiType =GDI_BRUSH; brush.iBrushStyle =BS_SOLID; // brush style brush.crBrushColor =RGB(0xd4,0xd0,0xc8); memcpy((void*)(pShmAddr+iObjOffset),&brush,sizeof(BRUSH)); *(pIdxAddr+LTGRAY_BRUSH)=iObjOffset; iObjOffset+=sizeof(BRUSH); //#define GRAY_BRUSH 0x00000008 brush.iGdiType =GDI_BRUSH; brush.iBrushStyle =BS_SOLID; // brush style brush.crBrushColor =RGB(0xc0,0xc0,0xc0); memcpy((void*)(pShmAddr+iObjOffset),&brush,sizeof(BRUSH)); *(pIdxAddr+GRAY_BRUSH)=iObjOffset; iObjOffset+=sizeof(BRUSH); //#define DKGRAY_BRUSH 0x00000009 brush.iGdiType =GDI_BRUSH; brush.iBrushStyle =BS_SOLID; // brush style brush.crBrushColor =RGB(0x80,0x80,0x80); memcpy((void*)(pShmAddr+iObjOffset),&brush,sizeof(BRUSH)); *(pIdxAddr+DKGRAY_BRUSH)=iObjOffset; iObjOffset+=sizeof(BRUSH); //#define BLACK_BRUSH 0x0000000A brush.iGdiType =GDI_BRUSH; brush.iBrushStyle =BS_SOLID; // brush style brush.crBrushColor =RGB(0x00,0x00,0x00); memcpy((void*)(pShmAddr+iObjOffset),&brush,sizeof(BRUSH)); *(pIdxAddr+BLACK_BRUSH)=iObjOffset; iObjOffset+=sizeof(BRUSH); //#define NULL_BRUSH 0x0000000B brush.iGdiType =GDI_BRUSH; brush.iBrushStyle =BS_NULL; // brush style brush.crBrushColor =RGB(0x00,0x00,0x00); memcpy((void*)(pShmAddr+iObjOffset),&brush,sizeof(BRUSH)); *(pIdxAddr+NULL_BRUSH)=iObjOffset; iObjOffset+=sizeof(BRUSH); //#define FONT_16_16 0x0000000C fp=fopen(FONT_16_16_SPEC,"rb"); if(!fp) return false; pointer=pShmAddr+SHMEM_FONT_16_16_OFFSET; while(!feof(fp)){ fread(pointer,1,1,fp); pointer++; } fclose(fp); font.iGdiType =GDI_FONT; font.iFontStyle =FONT_16_16; // font style font.iOffset =SHMEM_FONT_16_16_OFFSET; memcpy(&(font.FontLibHeader), (void*)(pShmAddr+SHMEM_FONT_16_16_OFFSET), sizeof(FONTLIBHEADER)); memcpy((void*)(pShmAddr+iObjOffset),&font,sizeof(FONT)); *(pIdxAddr+FONT_16_16)=iObjOffset; iObjOffset+=sizeof(FONT); //#define FONT_14_14 0x0000000D fp=fopen(FONT_14_14_SPEC,"rb"); if(!fp) return false; pointer=pShmAddr+SHMEM_FONT_14_14_OFFSET; while(!feof(fp)){ fread(pointer,1,1,fp); pointer++; } fclose(fp); font.iGdiType =GDI_FONT; font.iFontStyle =FONT_14_14; // font style font.iOffset =SHMEM_FONT_14_14_OFFSET; memcpy(&(font.FontLibHeader), (void*)(pShmAddr+SHMEM_FONT_14_14_OFFSET), sizeof(FONTLIBHEADER)); memcpy((void*)(pShmAddr+iObjOffset),&font,sizeof(FONT)); *(pIdxAddr+FONT_14_14)=iObjOffset; iObjOffset+=sizeof(FONT); //#define FONT_12_12 0x0000000E fp=fopen(FONT_12_12_SPEC,"rb"); if(!fp) return false; pointer=pShmAddr+SHMEM_FONT_12_12_OFFSET; while(!feof(fp)){ fread(pointer,1,1,fp); pointer++; } fclose(fp); font.iGdiType =GDI_FONT; font.iFontStyle =FONT_12_12; // font style font.iOffset =SHMEM_FONT_12_12_OFFSET; memcpy(&(font.FontLibHeader), (void*)(pShmAddr+SHMEM_FONT_12_12_OFFSET), sizeof(FONTLIBHEADER)); memcpy((void*)(pShmAddr+iObjOffset),&font,sizeof(FONT)); *(pIdxAddr+FONT_12_12)=iObjOffset; iObjOffset+=sizeof(FONT); return true; }HGDIOBJ GUIAPI GetStockObject( int iStyle){ char* pShmAddr; int iObjOffset; int iType; PEN* pPen; BRUSH* pBrush; FONT* pFont; pShmAddr=GetShmAddr(); if(!pShmAddr) return false; iObjOffset=*(((int*)(pShmAddr+SHMEM_GDI_INDEX_OFFSET))+iStyle); //get gdi type shm_read((char*)(&iType),iObjOffset,sizeof(int)); switch(iType){ case GDI_PEN: pPen=(PEN*)malloc(sizeof(PEN)); if(!pPen) return NULL; shm_read((char*)pPen,iObjOffset,sizeof(PEN)); return (HGDIOBJ)pPen; case GDI_BRUSH: pBrush=(BRUSH*)malloc(sizeof(BRUSH)); if(!pBrush) return NULL; shm_read((char*)pBrush,iObjOffset,sizeof(BRUSH)); return (HGDIOBJ)pBrush; case GDI_FONT: pFont=(FONT*)malloc(sizeof(FONT)); if(!pFont) return NULL; shm_read((char*)pFont,iObjOffset,sizeof(FONT)); return (HGDIOBJ)pFont; } return NULL;}HDC GUIAPI GetDC( HWND hWnd){ HDC hDC; BITMAP *pBitmap; hDC=malloc(sizeof(DC)); if(!hDC) return NULL; memset(hDC,0,sizeof(DC)); pBitmap=malloc(sizeof(BITMAP)); if(!pBitmap) return NULL; memset(pBitmap,0,sizeof(BITMAP)); hDC->iType=DC_TYPE_WIN; hDC->iCoordType = DC_COORDTYPE_CLIENT; hDC->hWnd=hWnd; hDC->isTextBkTrans =true; hDC->crTextBkColor =RGB(0xff, 0xff, 0xff); hDC->crTextColor =RGB(0x00, 0x00, 0x00); hDC->hPen =(HPEN)(GetStockObject(BLACK_PEN)); hDC->hBrush =(HBRUSH)(GetStockObject(NULL_BRUSH)); hDC->hFont =(HFONT)(GetStockObject(SYS_DEFAULT_FONT)); hDC->hBitmap=(HBITMAP)pBitmap; hDC->pData =NULL; return hDC;}HDC GUIAPI GetWindowDC( HWND hWnd){ HDC hDC; BITMAP *pBitmap; hDC=malloc(sizeof(DC)); if(!hDC) return NULL; memset(hDC,0,sizeof(DC)); pBitmap=malloc(sizeof(BITMAP)); if(!pBitmap) return NULL; memset(pBitmap,0,sizeof(BITMAP)); hDC->iType=DC_TYPE_WIN; hDC->iCoordType = DC_COORDTYPE_WINDOW; hDC->hWnd=hWnd; hDC->isTextBkTrans =true; hDC->crTextBkColor =RGB(0xff, 0xff, 0xff); hDC->crTextColor =RGB(0x00, 0x00, 0x00); hDC->hPen =(HPEN)(GetStockObject(BLACK_PEN)); hDC->hBrush =(HBRUSH)(GetStockObject(NULL_BRUSH)); hDC->hFont =(HFONT)(GetStockObject(SYS_DEFAULT_FONT)); hDC->hBitmap=(HBITMAP)pBitmap; hDC->pData =NULL; return hDC;}HPEN GUIAPI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -