summaryrefslogtreecommitdiff
path: root/iup/src/iup_classbase.h
blob: 1ced9c69abd33916475852da2780985f002d309d (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/** \file
 * \brief Base Class
 *
 * See Copyright Notice in "iup.h"
 */
 
#ifndef __IUP_CLASSBASE_H 
#define __IUP_CLASSBASE_H

#ifdef __cplusplus
extern "C" {
#endif


/** \defgroup iclassbase Base Class
 * \par
 * See \ref iup_classbase.h
 * \ingroup iclass
 */


/** Register all common base attributes: \n
 * WID                                   \n
 * SIZE, RASTERSIZE, POSITION            \n
 * FONT (and derived)                    \n\n
 * All controls that are positioned inside a dialog must register all common base attributes.
 * \ingroup iclassbase */
void iupBaseRegisterCommonAttrib(Iclass* ic);

/** Register all visual base attributes: \n
 * VISIBLE, ACTIVE                       \n
 * ZORDER, X, Y                          \n
 * TIP (and derived)                     \n\n
 * All controls that are positioned inside a dialog must register all visual base attributes.
 * \ingroup iclassbase */
void iupBaseRegisterVisualAttrib(Iclass* ic);

/** Register all common callbacks: \n
* MAP_CB, UNMAP_CB, GETFOCUS_CB, KILLFOCUS_CB, ENTERWINDOW_CB, LEAVEWINDOW_CB, K_ANY, HELP_CB.
* \ingroup iclassbase */
void iupBaseRegisterCommonCallbacks(Iclass* ic);

/* Register driver dependent common attributes. 
   Used only from iupBaseRegisterCommonAttrib */
void iupdrvBaseRegisterCommonAttrib(Iclass* ic);

/** Updates the expand member of the IUP object from the EXPAND attribute.
 * Should be called in the beginning of the ComputeNaturalSize for a container.
 * \ingroup iclassbase */
void iupBaseContainerUpdateExpand(Ihandle* ih);

/** Initializes the natural size using the user size, then
 * if a container then update the "expand" member from the EXPAND attribute, then
 * call \ref iupClassObjectComputeNaturalSize for containers if they have children or
 * call \ref iupClassObjectComputeNaturalSize for non-containers if user size is not defined.
 * Must be called for each children in the container. \n
 * First call is in iupLayoutCompute.
 * \ingroup iclassbase */
void iupBaseComputeNaturalSize(Ihandle* ih);

/** Update the current size from the available size, the natural size, expand and shrink.
 * Call \ref iupClassObjectSetChildrenCurrentSize for containers if they have children.
 * Must be called for each children in the container. \n
 * First call is in iupLayoutCompute.
 * \ingroup iclassbase */
void iupBaseSetCurrentSize(Ihandle* ih, int w, int h, int shrink);

/** Set the current position and update children position for containers.
 * Call \ref iupClassObjectSetChildrenPosition for containers if they have children.
 * Must be called for each children in the container. \n
 * First call is in iupLayoutCompute.
 * \ingroup iclassbase */
void iupBaseSetPosition(Ihandle* ih, int x, int y);

/* Updates the SIZE attribute if defined. 
   Called only from iupdrvSetStandardFontAttrib. */
void iupBaseUpdateSizeFromFont(Ihandle* ih);


/** \defgroup iclassbasemethod Base Class Methods
 * \par
 * See \ref iup_classbase.h
 * \ingroup iclassbase
 */

/** Driver dependent \ref Iclass::LayoutUpdate method.
 * \ingroup iclassbasemethod */
void iupdrvBaseLayoutUpdateMethod(Ihandle *ih);

/** Driver dependent \ref Iclass::UnMap method.
 * \ingroup iclassbasemethod */
void iupdrvBaseUnMapMethod(Ihandle* ih);

/** Native type void \ref Iclass::Map method.
 * \ingroup iclassbasemethod */
int iupBaseTypeVoidMapMethod(Ihandle* ih);


/** \defgroup iclassbaseattribfunc Base Class Attribute Functions
 * \par
 * Used by the controls for iupClassRegisterAttribute. 
 * \par
 * See \ref iup_classbase.h
 * \ingroup iclassbase
 * @{
 */

/* common */
char* iupBaseGetWidAttrib(Ihandle* ih);
int iupBaseSetNameAttrib(Ihandle* ih, const char* value);
int iupBaseSetRasterSizeAttrib(Ihandle* ih, const char* value);
int iupBaseSetSizeAttrib(Ihandle* ih, const char* value);
char* iupBaseGetSizeAttrib(Ihandle* ih);
char* iupBaseGetRasterSizeAttrib(Ihandle* ih);

/* visual */
char* iupBaseGetVisibleAttrib(Ihandle* ih);
int iupBaseSetVisibleAttrib(Ihandle* ih, const char* value);
char* iupBaseGetActiveAttrib(Ihandle *ih);
int iupBaseSetActiveAttrib(Ihandle* ih, const char* value);
int iupdrvBaseSetZorderAttrib(Ihandle* ih, const char* value);
char *iupdrvBaseGetXAttrib(Ihandle *ih);
char *iupdrvBaseGetYAttrib(Ihandle *ih);
int iupdrvBaseSetTipAttrib(Ihandle* ih, const char* value);
int iupdrvBaseSetTipVisibleAttrib(Ihandle* ih, const char* value);
int iupdrvBaseSetBgColorAttrib(Ihandle* ih, const char* value);
int iupdrvBaseSetFgColorAttrib(Ihandle* ih, const char* value);
char* iupBaseNativeParentGetBgColorAttrib(Ihandle* ih);

/* other */
char* iupBaseContainerGetExpandAttrib(Ihandle* ih);
int iupdrvBaseSetCursorAttrib(Ihandle* ih, const char* value);
char* iupdrvBaseGetClientSizeAttrib(Ihandle* ih);

/* Windows Only */
char* iupdrvBaseGetTitleAttrib(Ihandle* ih);
int iupdrvBaseSetTitleAttrib(Ihandle* ih, const char* value);

/** @} */



/** \defgroup iclassbaseutil Base Class Utilities
 * \par
 * See \ref iup_classbase.h
 * \ingroup iclassbase
 * @{
 */

#define iupMAX(_a,_b) ((_a)>(_b)?(_a):(_b))
#define iupROUND(_x) ((int)((_x)>0? (_x)+0.5: (_x)-0.5))

#define iupCOLOR8TO16(_x) ((unsigned short)(_x*257))  /* 65535/255 = 257 */
#define iupCOLOR16TO8(_x) ((unsigned char)(_x/257))

#define iupBYTECROP(_x)   ((unsigned char)((_x)<0?0:((_x)>255)?255:(_x)))

enum{IUP_ALIGN_ALEFT, IUP_ALIGN_ACENTER, IUP_ALIGN_ARIGHT};
#define IUP_ALIGN_ABOTTOM IUP_ALIGN_ARIGHT
#define IUP_ALIGN_ATOP IUP_ALIGN_ALEFT

enum{IUP_SB_NONE, IUP_SB_HORIZ, IUP_SB_VERT};
int iupBaseGetScrollbar(Ihandle* ih);

char* iupBaseNativeParentGetBgColor(Ihandle* ih);
void iupBaseCallValueChangedCb(Ihandle* ih);

/** @} */


#ifdef __cplusplus
}
#endif

#endif