| 1 |
/* lwindowclass.cxx |
| 2 |
$Id: lwindowclass.cxx,v 1.2 1997/10/18 04:57:39 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 |
|
| 33 |
#include "standard.h" |
| 34 |
#include "lwindowclass.h" |
| 35 |
|
| 36 |
LHashTable LWindowClass::g_hashClass; // szClass->LWindowClass* |
| 37 |
|
| 38 |
LWindowClass* LWindowClass::find_class (char* szName) |
| 39 |
{ |
| 40 |
HashKey key = LHashTable::make_case_string_key (szName); |
| 41 |
LWindowClass* pClass = NULL; |
| 42 |
g_hashClass.find (key, &pClass); |
| 43 |
return pClass; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
bool LWindowClass::register_class (char* szName, long event_mask, |
| 48 |
EventHandlerMap* pEventHandlerMap) |
| 49 |
{ |
| 50 |
if (!g_hashClass.is_init ()) |
| 51 |
g_hashClass.init (sizeof (LWindowClass*), 101); |
| 52 |
|
| 53 |
HashKey key = LHashTable::make_case_string_key (szName); |
| 54 |
LWindowClass* pClass = NULL; |
| 55 |
g_hashClass.find (key, &pClass); |
| 56 |
|
| 57 |
if (pClass) |
| 58 |
return false; |
| 59 |
|
| 60 |
m_szName = (char*) malloc (strlen (szName) + 1); |
| 61 |
strcpy (m_szName, szName); |
| 62 |
m_pEventHandlerMap = pEventHandlerMap; |
| 63 |
m_attribute.event_mask = event_mask; |
| 64 |
m_attribute_mask |= CWEventMask; |
| 65 |
|
| 66 |
pClass = this; |
| 67 |
g_hashClass.add (key, &pClass); |
| 68 |
|
| 69 |
return true; |
| 70 |
} |