aswang  1.0
windowclass.h
Go to the documentation of this file.
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 <string>
00023 #include "aswang.h"
00024 #include "Brush.h"
00025 
00026 namespace aswang {
00027         class windowclass {
00028         private:
00029                 WNDCLASS wc;
00030                 bool registered;
00031                 Brush br;
00032         public:
00033                 windowclass() : registered(false),br(RGB(255,255,255)) {
00034                         memset(&wc,0,sizeof(wc));
00035                         wc.hCursor=LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW));
00036                         wc.hbrBackground=br.GetBrush();
00037                 }
00038                 windowclass(AswangStr name) : registered(false),br(RGB(255,255,255)) {
00039                         memset(&wc,0,sizeof(wc));
00040                         wc.hCursor=LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW));
00041                         wc.hbrBackground=br.GetBrush();
00042                         SetName(name);
00043                 }
00044                 ~windowclass() {
00045                         Unregister();
00046                         DestroyIcon(wc.hIcon);
00047                         DestroyCursor(wc.hCursor);
00048                         if(wc.lpszClassName!=NULL) {
00049                                 delete[] wc.lpszClassName;
00050                                 wc.lpszClassName=NULL;
00051                         }
00052                 }
00053 
00054                 void SetName(AswangStr name);
00055                 AswangStr GetName() const {return wc.lpszClassName;}
00056                 void SetStyle(UINT style){wc.style=style;}
00057                 UINT GetStyle() const {return wc.style;}
00058                 void SetHandle(HINSTANCE h){wc.hInstance=h;}
00059                 HINSTANCE GetHandle() const {return wc.hInstance;}
00060                 void SetIcon(HICON h){
00061                         if(wc.hIcon!=NULL)
00062                                 DestroyIcon(wc.hIcon);
00063                         wc.hIcon=h;
00064                 }
00065                 HICON GetIcon() const {return wc.hIcon;}
00066                 void SetCursor(HCURSOR h){
00067                         if(wc.hCursor!=NULL)
00068                                 DestroyCursor(wc.hCursor);
00069                         wc.hCursor=h;
00070                 }
00071                 HCURSOR GetCursor() const {return wc.hCursor;}
00072                 void SetBrush(COLORREF cr) {
00073                         br=cr;
00074                         wc.hbrBackground=br.GetBrush();
00075                 }
00076                 void SetBrush(HBRUSH b) {
00077                         br=b;
00078                         wc.hbrBackground=br.GetBrush();
00079                 }
00080                 const Brush &GetBrush() const {return br;}
00081                 void SetMenu(unsigned long ID){wc.lpszMenuName=MAKEINTRESOURCE(ID);}
00082                 AswangStr GetMenu() const {return wc.lpszMenuName;}
00083                 void SetClassExtra(UINT extra){wc.cbClsExtra=extra;}
00084                 UINT GetClassExtra() const {return wc.cbClsExtra;}
00085                 void SetWindowExra(UINT extra){wc.cbWndExtra=extra;}
00086                 UINT GetWindowExtra() const {return wc.cbWndExtra;}
00087                 void SetProc(WNDPROC newP){wc.lpfnWndProc=newP;}
00088                 WNDPROC GetProc() const {return wc.lpfnWndProc;}
00089                 bool IsRegistered() {
00090                         return registered;
00091                 }
00092 
00093                 void Register();
00094                 void Unregister();
00095         };
00096 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines