summaryrefslogtreecommitdiff
path: root/iup/src/iup_register.c
blob: 2e9954aa8a08edf3388232c561d7ea7483ac515c (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/** \file
* \brief Register the Internal Controls
*
* See Copyright Notice in "iup.h"
*/

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

#include "iup.h"

#include "iup_object.h"
#include "iup_register.h"
#include "iup_stdcontrols.h"


static Itable *iregister_table = NULL;   /* table indexed by name containing Iclass* address */

void iupRegisterInit(void)
{
  iregister_table = iupTableCreate(IUPTABLE_STRINGINDEXED);
}

void iupRegisterFinish(void)
{
  char* name = iupTableFirst(iregister_table);
  while (name)
  {
    Iclass* ic = (Iclass*)iupTableGetCurr(iregister_table);
    iupClassRelease(ic);
    name = iupTableNext(iregister_table);
  }

  iupTableDestroy(iregister_table);
  iregister_table = NULL;
}

int iupRegisterGetClasses(char *list[], int n)
{
  int i = 0;
  char* name = iupTableFirst(iregister_table);

  if (!list || !n)
    return iupTableCount(iregister_table);

  while (name)
  {
    list[i] = name;
    i++;
    if (i == n)
      break;

    name = iupTableNext(iregister_table);
  }

  return i;
}

Iclass* iupRegisterFindClass(const char* name)
{
  return (Iclass*)iupTableGet(iregister_table, name);
}

void iupRegisterClass(Iclass* ic)
{
  Iclass* old_ic = (Iclass*)iupTableGet(iregister_table, ic->name);
  if (old_ic)
    iupClassRelease(old_ic);

  iupTableSet(iregister_table, ic->name, (void*)ic, IUPTABLE_POINTER);
}


/***************************************************************/

void iupRegisterInternalClasses(void)
{
  iupRegisterClass(iupDialogGetClass());
  iupRegisterClass(iupMessageDlgGetClass());
  iupRegisterClass(iupColorDlgGetClass());
  iupRegisterClass(iupFontDlgGetClass());
  iupRegisterClass(iupFileDlgGetClass());

  iupRegisterClass(iupTimerGetClass());
  iupRegisterClass(iupImageGetClass());
  iupRegisterClass(iupImageRGBGetClass());
  iupRegisterClass(iupImageRGBAGetClass());
  iupRegisterClass(iupUserGetClass());
  iupRegisterClass(iupClipboardGetClass());

  iupRegisterClass(iupRadioGetClass());
  iupRegisterClass(iupFillGetClass());
  iupRegisterClass(iupHboxGetClass());
  iupRegisterClass(iupVboxGetClass());
  iupRegisterClass(iupZboxGetClass());
  iupRegisterClass(iupCboxGetClass());
  iupRegisterClass(iupSboxGetClass());
  iupRegisterClass(iupNormalizerGetClass());
  iupRegisterClass(iupSplitGetClass());

  iupRegisterClass(iupMenuGetClass());
  iupRegisterClass(iupItemGetClass());
  iupRegisterClass(iupSeparatorGetClass());
  iupRegisterClass(iupSubmenuGetClass());

  iupRegisterClass(iupLabelGetClass());
  iupRegisterClass(iupButtonGetClass());
  iupRegisterClass(iupToggleGetClass());
  iupRegisterClass(iupCanvasGetClass());
  iupRegisterClass(iupFrameGetClass());
  iupRegisterClass(iupTextGetClass());
  iupRegisterClass(iupMultilineGetClass());
  iupRegisterClass(iupListGetClass());

  iupRegisterClass(iupProgressBarGetClass());
  iupRegisterClass(iupValGetClass());
  iupRegisterClass(iupTabsGetClass());
  iupRegisterClass(iupSpinGetClass());
  iupRegisterClass(iupSpinboxGetClass());
  iupRegisterClass(iupTreeGetClass());
}