| 1 |
/* lwindowclass.h -*- C++ -*- |
| 2 |
$Id: lwindowclass.h,v 1.3 1997/10/18 04:57:40 elf Exp $ |
| 3 |
|
| 4 |
written by Marc Singer |
| 5 |
9 May 1997 |
| 6 |
|
| 7 |
This file is part of the project XO. See the file README for |
| 8 |
more information. |
| 9 |
|
| 10 |
Copyright (C) 1997 Marc Singer |
| 11 |
|
| 12 |
This program is free software; you can redistribute it and/or |
| 13 |
modify it under the terms of the GNU General Public License as |
| 14 |
published by the Free Software Foundation; either version 2 of the |
| 15 |
License, or (at your option) any later version. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but |
| 18 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 |
General Public License for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License |
| 23 |
in a file called COPYING along with this program; if not, write to |
| 24 |
the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA |
| 25 |
02139, USA. |
| 26 |
|
| 27 |
----------- |
| 28 |
DESCRIPTION |
| 29 |
----------- |
| 30 |
*/ |
| 31 |
|
| 32 |
#if !defined (__LWINDOWCLASS_H__) |
| 33 |
# define __LWINDOWCLASS_H__ |
| 34 |
|
| 35 |
/* ----- Includes */ |
| 36 |
|
| 37 |
#include "lhash.h" |
| 38 |
|
| 39 |
/* ----- Classes */ |
| 40 |
|
| 41 |
class LDisplay; |
| 42 |
class LWindow; |
| 43 |
|
| 44 |
typedef void (*PFNEvent) (LWindow* pWindow, XEvent* pEvent); |
| 45 |
typedef struct { |
| 46 |
int event_type; |
| 47 |
PFNEvent pfn; |
| 48 |
} EventHandlerMap; |
| 49 |
|
| 50 |
|
| 51 |
class LWindowClass { |
| 52 |
protected: |
| 53 |
static LHashTable g_hashClass; // szClass->LWindowClass* |
| 54 |
|
| 55 |
char* m_szName; // Class name, case insensitive |
| 56 |
EventHandlerMap* m_pEventHandlerMap; |
| 57 |
|
| 58 |
XSetWindowAttributes m_attribute; |
| 59 |
unsigned long m_attribute_mask; |
| 60 |
|
| 61 |
void* m_pvUser; // Associated instance specific data |
| 62 |
|
| 63 |
public: |
| 64 |
LWindowClass () { |
| 65 |
zero (); } |
| 66 |
~LWindowClass () { |
| 67 |
release_this (); } |
| 68 |
void zero (void) { |
| 69 |
memset (this, 0, sizeof (*this)); } |
| 70 |
bool register_class (char* szName, |
| 71 |
long event_mask, EventHandlerMap* pEventHandlerMap); |
| 72 |
void release_this (void) {} |
| 73 |
|
| 74 |
static LWindowClass* find_class (char* szName); |
| 75 |
|
| 76 |
unsigned long attributes (XSetWindowAttributes* pAttribute) { |
| 77 |
memcpy (pAttribute, &m_attribute, sizeof (m_attribute)); |
| 78 |
return m_attribute_mask; } |
| 79 |
void* data (void) { |
| 80 |
return m_pvUser; } |
| 81 |
|
| 82 |
EventHandlerMap* event_handler_map (void) { |
| 83 |
return m_pEventHandlerMap; } |
| 84 |
|
| 85 |
void set_background_pixel (unsigned long pixel) { |
| 86 |
m_attribute.background_pixel = pixel; |
| 87 |
m_attribute_mask |= CWBackPixel; } |
| 88 |
|
| 89 |
void set_bit_gravity (int gravity) { |
| 90 |
m_attribute.bit_gravity = gravity; |
| 91 |
m_attribute_mask |= CWBitGravity; } |
| 92 |
|
| 93 |
void* set_data (void* pv) { |
| 94 |
void* pvPrev = m_pvUser; m_pvUser = pv; return pvPrev; } |
| 95 |
}; |
| 96 |
|
| 97 |
|
| 98 |
#endif /* __LWINDOWCLASS_H__ */ |