summaryrefslogtreecommitdiff
path: root/iup/src/win/iupwin_handle.c
blob: d5a7f77996bf78b8a6dfc13227c9768e072ebdbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/** \file
 * \brief HWND to ihandle table
 *
 * See Copyright Notice in "iup.h"
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>  

#include "iup.h"

#include "iup_object.h"
#include "iup_table.h" 

#include "iupwin_handle.h"  


static Itable* winhandle_table; /* table indexed by HWND containing Ihandle* address */

Ihandle* iupwinHandleGet(void* handle)
{
  Ihandle* ih;
  if (!handle)
    return NULL;
  ih = (Ihandle*)iupTableGet(winhandle_table, (char*)handle);
  if (ih && !iupObjectCheck(ih))
    return NULL;
  return ih;
}

void iupwinHandleSet(Ihandle *ih)
{
  iupTableSet(winhandle_table, (char*)ih->handle, ih, IUPTABLE_POINTER);
}

void iupwinHandleAdd(Ihandle *ih, InativeHandle* hWnd)
{
  iupTableSet(winhandle_table, (char*)hWnd, ih, IUPTABLE_POINTER);
}

void iupwinHandleRemove(Ihandle *ih)
{
  iupTableRemove(winhandle_table, (char*)ih->handle);
}

void iupwinHandleInit(void)
{
  winhandle_table = iupTableCreate(IUPTABLE_POINTERINDEXED);
}

void iupwinHandleFinish(void)
{
  iupTableDestroy(winhandle_table);
  winhandle_table = NULL;
}