aswang
1.0
|
00001 /* 00002 Copyright 2003 Joseph Alvis 00003 00004 This file is part of Aswang. 00005 00006 Aswang is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU Lesser General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 Aswang is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public License 00017 along with Aswang. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #pragma once 00021 00022 #include <map> 00023 #include <deque> 00024 #include "aswang.h" 00025 00026 namespace aswang { 00028 class DC { 00029 HDC dc; 00030 HWND fromWindow; 00031 typedef std::map<DWORD,std::deque<HGDIOBJ> > object_map_type; 00032 object_map_type object_map; 00033 public: 00034 DC() : dc(NULL),fromWindow(NULL) {} 00036 DC(HWND fw) : dc(NULL),fromWindow(fw) {Get();} 00038 DC(HWND fw,HDC ndc) : dc(ndc),fromWindow(fw) {} 00040 DC(HDC ndc) : dc(ndc),fromWindow(NULL) {} 00042 DC(const DC &ndc) : dc(NULL),fromWindow(NULL) { 00043 dc=ndc.CreateCompatibleHDC(); 00044 } 00045 virtual ~DC() {} 00046 00048 virtual void SetWindow(HWND fw){fromWindow=fw;} 00050 virtual HWND GetWindow() const {return fromWindow;} 00052 virtual bool Get(); 00054 virtual void Free(); 00056 virtual void _Release(); 00058 virtual void _Delete(); 00060 virtual HDC GetHDC() const {return dc;} 00062 virtual void SetHDC(HDC ndc) {dc=ndc;} 00064 virtual void SetPos(int x,int y) const; 00066 virtual POINT GetPos() const; 00068 virtual void DrawLine(int width,int height); 00070 virtual void DrawRect(int x,int y,int width,int height); 00072 virtual void DrawRect(const RECT *r); 00074 virtual HDC CreateCompatibleHDC() const; 00076 virtual void Copy(const DC &dvc); 00078 virtual HBITMAP CreateCompatibleBitmap() const; 00080 virtual void Select(HGDIOBJ obj); 00082 virtual void Unselect(HGDIOBJ obj); 00084 virtual void UnselectAll(); 00086 virtual void SolidFill(HBRUSH brush); 00088 virtual void FillRect(int x,int y,int width,int height,HBRUSH hbr); 00090 virtual void FillRect(const RECT *r,HBRUSH hbr); 00092 virtual void DrawAbsLine(int x,int y); 00094 virtual void Draw(HICON hIcon,int destX=0,int destY=0); 00095 00097 virtual DC &operator = (HWND fw); 00099 virtual DC &operator = (HDC ndc); 00101 virtual DC &operator = (const DC &ndc); 00103 virtual operator HDC () const {return dc;} 00104 }; 00105 }