Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
glcompdefs.h
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#pragma once
12
13#include <stdbool.h>
14#include <stdio.h>
15#include <stdint.h>
16#include <stdlib.h>
17#include <string.h>
18#include <stdarg.h>
19#include <math.h>
20#ifdef _WIN32
21#include <windows.h>
22#include <winuser.h>
23#include <tchar.h>
24#endif
25#include <glcomp/opengl.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31
32#define GLCOMPSET_PANEL_COLOR_R 0.16f
33#define GLCOMPSET_PANEL_COLOR_G 0.44f
34#define GLCOMPSET_PANEL_COLOR_B 0.87f
35#define GLCOMPSET_PANEL_COLOR_ALPHA 0.5f
36#define GLCOMPSET_PANEL_SHADOW_COLOR_R 0.0f
37#define GLCOMPSET_PANEL_SHADOW_COLOR_G 0.0f
38#define GLCOMPSET_PANEL_SHADOW_COLOR_B 0.0f
39#define GLCOMPSET_PANEL_SHADOW_COLOR_A 0.3f
40#define GLCOMPSET_PANEL_SHADOW_WIDTH 4.0f
41
42#define GLCOMPSET_BUTTON_COLOR_R 0.0f
43#define GLCOMPSET_BUTTON_COLOR_G 1.0f
44#define GLCOMPSET_BUTTON_COLOR_B 0.3f
45#define GLCOMPSET_BUTTON_COLOR_ALPHA 0.6f
46#define GLCOMPSET_BUTTON_THICKNESS 3.0f
47#define GLCOMPSET_BUTTON_BEVEL_BRIGHTNESS 1.7f
48#define GLCOMPSET_FONT_SIZE 14.0f
49
50#define GLCOMPSET_BUTTON_FONT_COLOR_R 0.0f
51#define GLCOMPSET_BUTTON_FONT_COLOR_G 0.0f
52#define GLCOMPSET_BUTTON_FONT_COLOR_B 0.0f
53#define GLCOMPSET_BUTTON_FONT_COLOR_ALPHA 1.0f
54
55#define GLCOMPSET_FONT_SIZE_FACTOR 0.7f
56
57#define GLCOMPSET_LABEL_COLOR_R 0.0f
58#define GLCOMPSET_LABEL_COLOR_G 0.0f
59#define GLCOMPSET_LABEL_COLOR_B 0.0f
60#define GLCOMPSET_LABEL_COLOR_ALPHA 1.0f
61
62#define GLCOMPSET_FONT_COLOR_R 0.0f
63#define GLCOMPSET_FONT_COLOR_G 0.0f
64#define GLCOMPSET_FONT_COLOR_B 0.0f
65#define GLCOMPSET_FONT_COLOR_ALPHA 1.0f
66#define GLCOMPSET_FONT_DESC "Times Italic"
67#define GL_FONTOPTIMIZE 1
68
69
70#define GL_FONTVJUSTIFY 0
71#define GL_FONTHJUSTIFY 0
72
73#define GLCOMPSET_BORDERWIDTH 2.0f
74#define GLCOMPSET_PANEL_BORDERWIDTH 3.0f
75#define GLCOMPSET_BUTTON_BEVEL 5.0f
76#define GLCOMPSET_BEVEL_DIFF 0.001f
77#define GLCOMP_DEFAULT_WIDTH 10.0f
78#define GLCOMP_DEFAULT_HEIGHT 10.0f
79
82
87
91
95
97 typedef struct _glCompObj glCompObj;
98
99/*call backs for widgets*/
100 typedef void (*glcompdrawfunc_t) (void *obj);
101 typedef void (*glcompclickfunc_t)(glCompObj *obj, float x,
102 float y, glMouseButtonType t);
103 typedef void (*glcompdoubleclickfunc_t) (glCompObj * obj, float x,
104 float y,
106 typedef void (*glcompmouseoverfunc_t) (glCompObj * obj, float x,
107 float y);
108 typedef void (*glcompmouseinfunc_t) (glCompObj * obj, float x,
109 float y);
110 typedef void (*glcompmouseoutfunc_t) (glCompObj * obj, float x,
111 float y);
112 typedef void (*glcompmousedownfunc_t) (glCompObj * obj, float x,
113 float y, glMouseButtonType t);
114 typedef void (*glcompmouseupfunc_t) (glCompObj * obj, float x,
115 float y, glMouseButtonType t);
116 typedef void (*glcompmousedragfunct_t) (glCompObj * obj, float dx,
117 float dy,
119
120 typedef struct {
121 int topAnchor; /*anchor booleans */
125
126 float top; /*anchor values */
127 float left;
128 float right;
129 float bottom;
130
131
132 } glCompAnchor;
133
138
139 typedef struct {
140 float x, y, z;
141 } glCompPoint;
142
143 typedef struct {
144 int cnt;
146 }glCompPoly;
147
148 typedef struct {
149 float R;
150 float G;
151 float B;
152 float A; //Alpha
153 } glCompColor;
154
155 typedef struct {
157 float w;
158 float h;
159 } glCompRect;
160
161 typedef struct {
162 uint32_t id;
163 char *def;
164 char *text;
165 float width;
166 float height;
170 unsigned char *data; /*data */
171 } glCompTex;
172
173
174
175/*opengl font*/
176 typedef struct {
177 char *fontdesc; //font description , only used with pango fonts
179 void *glutfont; /*glut font pointer if used */
181 glCompTex *tex; /* texture, if type is pangotext */
182 int size;
183 int reference; /*if font has references to parent */
185 bool is2D;
187 } glCompFont;
188
201
202
203/*
204 common widget properties
205 also each widget has pointer to its parents common
206*/
207 typedef struct {
209 glCompPoint refPos; /*calculated pos after anchors and aligns */
210 float width, height;
215 void *compset; // compset
216 void *parent; /*parent widget */
217 int data;
218 glCompFont *font; //pointer to font to use
221 int layer; /*keep track of object order, what to draw on top */
225 } glCompCommon;
226
227/*generic image*/
228 typedef struct {
229 glObjType objType; /*always keep this here for each drawable object */
232 float width, height; /* width and height in world coords */
233 /* char *pngFile; */
235 } glCompImage;
236
237/*generic panel*/
238 typedef struct {
239 glObjType objType; /*always keep this here for each drawable object */
243 char *text;
245 } glCompPanel;
246
247/*label*/
248 typedef struct {
249 glObjType objType; /*always keep this here for each drawable object */
251 char *text;
253 } glCompLabel;
254
255/*buttons*/
257 glObjType objType; /*always keep this here for each drawable object */
259 float width, height;
261 bool status;
264 glCompImage *image; /*glyph */
265 int data;
266
267 };
268
269/*texture based image*/
270
271/*object prototype*/
276
277 typedef struct {
279 glCompPoint pos; /*current mouse pos,*/
280 glCompPoint GLpos;/*3d converted opengl position*/
281 glCompPoint GLinitPos;/*mouse button down pos*/
282 glCompPoint GLfinalPos;/*mouse button up pos*/
283
284 float dragX, dragY;/*GLpos - GLinitpos*/
288 int down;
289
290
291 } glCompMouse;
292
293
294
295/*main widget set manager*/
296 typedef struct {
297 glObjType objType; /*always keep this here for each drawable object */
299
301 size_t objcnt;
305 } glCompSet;
306
307#ifdef __cplusplus
308}
309#endif
static float dy
Definition draw.c:38
static float dx
Definition draw.c:37
void(* glcompmouseoutfunc_t)(glCompObj *obj, float x, float y)
Definition glcompdefs.h:110
void(* glcompmousedragfunct_t)(glCompObj *obj, float dx, float dy, glMouseButtonType t)
Definition glcompdefs.h:116
void(* glcompmouseinfunc_t)(glCompObj *obj, float x, float y)
Definition glcompdefs.h:108
glCompTexType
Definition glcompdefs.h:92
@ glTexImage
Definition glcompdefs.h:92
@ glTexLabel
Definition glcompdefs.h:92
glCompVJustify
Definition glcompdefs.h:83
@ glFontVJustifyTop
Definition glcompdefs.h:83
@ glFontVJustifyBottom
Definition glcompdefs.h:84
@ glFontVJustifyCenter
Definition glcompdefs.h:84
@ glFontVJustifyNone
Definition glcompdefs.h:83
glCompHJustify
Definition glcompdefs.h:85
@ glFontHJustifyLeft
Definition glcompdefs.h:85
@ glFontHJustifyRight
Definition glcompdefs.h:86
@ glFontHJustifyCenter
Definition glcompdefs.h:86
@ glFontHJustifyNone
Definition glcompdefs.h:85
void(* glcompmouseoverfunc_t)(glCompObj *obj, float x, float y)
Definition glcompdefs.h:106
void(* glcompmouseupfunc_t)(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompdefs.h:114
void(* glcompmousedownfunc_t)(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompdefs.h:112
void(* glcompdoubleclickfunc_t)(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompdefs.h:103
void(* glcompdrawfunc_t)(void *obj)
Definition glcompdefs.h:100
glObjType
Definition glcompdefs.h:93
@ glPanelObj
Definition glcompdefs.h:93
@ glLabelObj
Definition glcompdefs.h:93
@ glImageObj
Definition glcompdefs.h:94
@ glButtonObj
Definition glcompdefs.h:93
void(* glcompclickfunc_t)(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompdefs.h:101
glCompMouseStatus
Definition glcompdefs.h:88
@ glMouseDown
Definition glcompdefs.h:88
@ glMouseUp
Definition glcompdefs.h:88
glMouseButtonType
Definition glcompdefs.h:89
@ glMouseRightButton
Definition glcompdefs.h:89
@ glMouseMiddleButton
Definition glcompdefs.h:90
@ glMouseLeftButton
Definition glcompdefs.h:89
glCompAlignment
Definition glcompdefs.h:80
@ glAlignTop
Definition glcompdefs.h:80
@ glAlignLeft
Definition glcompdefs.h:80
@ glAlignCenter
Definition glcompdefs.h:81
@ glAlignBottom
Definition glcompdefs.h:80
@ glAlignNone
Definition glcompdefs.h:80
@ glAlignParent
Definition glcompdefs.h:81
@ glAlignRight
Definition glcompdefs.h:81
static int z
glCompCommon common
Definition glcompdefs.h:258
bool status
false not pressed, true pressed
Definition glcompdefs.h:261
glCompLabel * label
Definition glcompdefs.h:260
bool refStatus
false not pressed, true pressed
Definition glcompdefs.h:262
glObjType objType
Definition glcompdefs.h:257
glCompImage * image
Definition glcompdefs.h:264
glCompCommon common
Definition glcompdefs.h:274
glObjType objType
Definition glcompdefs.h:273
glcompdoubleclickfunc_t doubleclick
Definition glcompdefs.h:192
glcompmouseoutfunc_t mouseout
Definition glcompdefs.h:195
glcompmouseupfunc_t mouseup
Definition glcompdefs.h:197
glcompclickfunc_t click
Definition glcompdefs.h:191
glcompmouseinfunc_t mousein
Definition glcompdefs.h:194
glcompmousedownfunc_t mousedown
Definition glcompdefs.h:196
glcompmousedragfunct_t mousedrag
Definition glcompdefs.h:198
glcompdrawfunc_t draw
Definition glcompdefs.h:190
glcompmouseoverfunc_t mouseover
Definition glcompdefs.h:193
glCompColor color
Definition glcompdefs.h:212
glCompCallBacks callbacks
Definition glcompdefs.h:222
glCompCallBacks functions
Definition glcompdefs.h:223
glCompPoint pos
Definition glcompdefs.h:208
glCompFont * font
Definition glcompdefs.h:218
glCompAnchor anchor
Definition glcompdefs.h:220
glCompAlignment align
Definition glcompdefs.h:219
glCompJustify justify
Definition glcompdefs.h:224
void * parent
Definition glcompdefs.h:216
glCompPoint refPos
Definition glcompdefs.h:209
void * compset
Definition glcompdefs.h:215
float borderWidth
Definition glcompdefs.h:211
glCompColor color
Definition glcompdefs.h:178
int transparent
Definition glcompdefs.h:180
void * glutfont
Definition glcompdefs.h:179
glCompTex * tex
Definition glcompdefs.h:181
char * fontdesc
Definition glcompdefs.h:177
glCompJustify justify
Definition glcompdefs.h:184
glObjType objType
Definition glcompdefs.h:229
glCompCommon common
Definition glcompdefs.h:230
glCompTex * texture
Definition glcompdefs.h:231
glCompHJustify HJustify
Definition glcompdefs.h:136
glCompVJustify VJustify
Definition glcompdefs.h:135
char * text
Definition glcompdefs.h:251
glCompCommon common
Definition glcompdefs.h:250
glObjType objType
Definition glcompdefs.h:249
glCompCallBacks callbacks
Definition glcompdefs.h:286
glCompPoint GLfinalPos
Definition glcompdefs.h:282
glCompCallBacks functions
Definition glcompdefs.h:287
glMouseButtonType t
Definition glcompdefs.h:278
glCompPoint GLpos
Definition glcompdefs.h:280
glCompPoint GLinitPos
Definition glcompdefs.h:281
glCompPoint pos
Definition glcompdefs.h:279
glCompObj * clickedObj
Definition glcompdefs.h:285
float shadowwidth
Definition glcompdefs.h:241
glCompCommon common
Definition glcompdefs.h:240
glCompImage * image
Definition glcompdefs.h:244
glCompColor shadowcolor
Definition glcompdefs.h:242
glObjType objType
Definition glcompdefs.h:239
char * text
Definition glcompdefs.h:243
glCompPoint * pts
Definition glcompdefs.h:145
glCompPoint pos
Definition glcompdefs.h:156
glCompCommon common
Definition glcompdefs.h:298
size_t textureCount
Definition glcompdefs.h:302
glCompObj ** obj
Definition glcompdefs.h:300
size_t objcnt
Definition glcompdefs.h:301
glObjType objType
Definition glcompdefs.h:297
glCompTex ** textures
Definition glcompdefs.h:303
glCompMouse mouse
Definition glcompdefs.h:304
char * def
Definition glcompdefs.h:163
uint32_t id
Definition glcompdefs.h:162
unsigned char * data
Definition glcompdefs.h:170
float height
Definition glcompdefs.h:166
int userCount
Definition glcompdefs.h:168
float width
Definition glcompdefs.h:165
glCompTexType type
Definition glcompdefs.h:167
char * text
Definition glcompdefs.h:164