Graphviz 13.0.0~dev.20241220.2304
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 <cgraph/list.h>
14#include <stdbool.h>
15#include <stdio.h>
16#include <stdint.h>
17#include <stdlib.h>
18#include <string.h>
19#include <stdarg.h>
20#include <math.h>
21#ifdef _WIN32
22#include <windows.h>
23#include <winuser.h>
24#include <tchar.h>
25#endif
26#include <glcomp/opengl.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32
33#define GLCOMPSET_PANEL_COLOR_R 0.16f
34#define GLCOMPSET_PANEL_COLOR_G 0.44f
35#define GLCOMPSET_PANEL_COLOR_B 0.87f
36#define GLCOMPSET_PANEL_COLOR_ALPHA 0.5f
37#define GLCOMPSET_PANEL_SHADOW_WIDTH 4.0f
38
39#define GLCOMPSET_BUTTON_COLOR_R 0.0f
40#define GLCOMPSET_BUTTON_COLOR_G 1.0f
41#define GLCOMPSET_BUTTON_COLOR_B 0.3f
42#define GLCOMPSET_BUTTON_COLOR_ALPHA 0.6f
43#define GLCOMPSET_BUTTON_THICKNESS 3.0f
44#define GLCOMPSET_BUTTON_BEVEL_BRIGHTNESS 1.7f
45#define GLCOMPSET_FONT_SIZE 14.0f
46
47#define GLCOMPSET_FONT_COLOR_R 0.0f
48#define GLCOMPSET_FONT_COLOR_G 0.0f
49#define GLCOMPSET_FONT_COLOR_B 0.0f
50#define GLCOMPSET_FONT_COLOR_ALPHA 1.0f
51#define GLCOMPSET_FONT_DESC "Times Italic"
52
53#define GLCOMPSET_BORDERWIDTH 2.0f
54#define GLCOMPSET_PANEL_BORDERWIDTH 3.0f
55#define GLCOMPSET_BUTTON_BEVEL 5.0f
56#define GLCOMPSET_BEVEL_DIFF 0.001f
57#define GLCOMP_DEFAULT_WIDTH 10.0f
58#define GLCOMP_DEFAULT_HEIGHT 10.0f
59
62
65
69
71
72 typedef struct glCompObj_ glCompObj;
73
74/*call backs for widgets*/
75 typedef void (*glcompdrawfunc_t) (void *obj);
76 typedef void (*glcompclickfunc_t)(glCompObj *obj, float x,
77 float y, glMouseButtonType t);
78 typedef void (*glcompdoubleclickfunc_t) (glCompObj * obj, float x,
79 float y,
81 typedef void (*glcompmouseoverfunc_t) (glCompObj * obj, float x,
82 float y);
83 typedef void (*glcompmouseinfunc_t) (glCompObj * obj, float x,
84 float y);
85 typedef void (*glcompmouseoutfunc_t) (glCompObj * obj, float x,
86 float y);
87 typedef void (*glcompmousedownfunc_t) (glCompObj * obj, float x,
88 float y, glMouseButtonType t);
89 typedef void (*glcompmouseupfunc_t) (glCompObj * obj, float x,
90 float y, glMouseButtonType t);
91 typedef void (*glcompmousedragfunct_t) (glCompObj * obj, float dx,
92 float dy,
94
95 typedef struct {
96 int topAnchor; /*anchor booleans */
100
101 float top; /*anchor values */
102 float left;
103 float right;
104 float bottom;
105
106
107 } glCompAnchor;
108
113
114 typedef struct {
115 float x, y, z;
116 } glCompPoint;
117
118DEFINE_LIST(glCompPoly, glCompPoint)
119
120 typedef struct {
121 float R;
122 float G;
123 float B;
124 float A; //Alpha
125 } glCompColor;
126
127 typedef struct {
129 float w;
130 float h;
131 } glCompRect;
132
133 typedef struct {
134 uint32_t id;
135 char *def;
136 char *text;
137 int width;
142 unsigned char *data; /*data */
143 } glCompTex;
144
145
146
147/*opengl font*/
148 typedef struct {
149 char *fontdesc; //font description , only used with pango fonts
151 void *glutfont; /*glut font pointer if used */
153 glCompTex *tex; /* texture, if type is pangotext */
154 int size;
156 bool is2D;
157 } glCompFont;
158
171
172typedef struct glCompSet_ glCompSet;
173
174/*
175 common widget properties
176 also each widget has pointer to its parents common
177*/
178 typedef struct {
180 glCompPoint refPos; /*calculated pos after anchors and aligns */
181 float width, height;
187 void *parent; /*parent widget */
188 int data;
192 int layer; /*keep track of object order, what to draw on top */
196 } glCompCommon;
197
202
203/*generic image*/
204 typedef struct {
207 float width, height; /* width and height in world coords */
208 } glCompImage;
209
210/*generic panel*/
217
218/*label*/
219 typedef struct {
221 char *text;
222 } glCompLabel;
223
224/*buttons*/
225 typedef struct {
227 float width, height;
229 bool status;
232 glCompImage *image; /*glyph */
233 int data;
234 } glCompButton;
235
236/*texture based image*/
237
238 typedef struct {
240 float x, y;
241 glCompPoint GLpos;/*3d converted opengl position*/
242 glCompPoint GLinitPos;/*mouse button down pos*/
243 glCompPoint GLfinalPos;/*mouse button up pos*/
244
245 float dragX, dragY;/*GLpos - GLinitpos*/
249 int down;
250
251
252 } glCompMouse;
253
254
255
256/*main widget set manager*/
265
266#ifdef __cplusplus
267}
268#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:85
void(* glcompmousedragfunct_t)(glCompObj *obj, float dx, float dy, glMouseButtonType t)
Definition glcompdefs.h:91
void(* glcompmouseinfunc_t)(glCompObj *obj, float x, float y)
Definition glcompdefs.h:83
glCompTexType
Definition glcompdefs.h:70
@ glTexImage
Definition glcompdefs.h:70
@ glTexLabel
Definition glcompdefs.h:70
glCompVJustify
Definition glcompdefs.h:63
@ glFontVJustifyCenter
Definition glcompdefs.h:63
@ glFontVJustifyNone
Definition glcompdefs.h:63
glCompHJustify
Definition glcompdefs.h:64
@ glFontHJustifyCenter
Definition glcompdefs.h:64
@ glFontHJustifyNone
Definition glcompdefs.h:64
void(* glcompmouseoverfunc_t)(glCompObj *obj, float x, float y)
Definition glcompdefs.h:81
void(* glcompmouseupfunc_t)(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompdefs.h:89
void(* glcompmousedownfunc_t)(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompdefs.h:87
void(* glcompdoubleclickfunc_t)(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompdefs.h:78
void(* glcompdrawfunc_t)(void *obj)
Definition glcompdefs.h:75
void(* glcompclickfunc_t)(glCompObj *obj, float x, float y, glMouseButtonType t)
Definition glcompdefs.h:76
glCompMouseStatus
Definition glcompdefs.h:66
@ glMouseDown
Definition glcompdefs.h:66
@ glMouseUp
Definition glcompdefs.h:66
glMouseButtonType
Definition glcompdefs.h:67
@ glMouseRightButton
Definition glcompdefs.h:67
@ glMouseMiddleButton
Definition glcompdefs.h:68
@ glMouseLeftButton
Definition glcompdefs.h:67
glCompAlignment
Definition glcompdefs.h:60
@ glAlignTop
Definition glcompdefs.h:60
@ glAlignLeft
Definition glcompdefs.h:60
@ glAlignCenter
Definition glcompdefs.h:61
@ glAlignBottom
Definition glcompdefs.h:60
@ glAlignNone
Definition glcompdefs.h:60
@ glAlignParent
Definition glcompdefs.h:61
@ glAlignRight
Definition glcompdefs.h:61
static int z
#define DEFINE_LIST(name, type)
Definition list.h:26
glCompLabel * label
Definition glcompdefs.h:228
glCompImage * image
Definition glcompdefs.h:232
glCompObj base
Definition glcompdefs.h:226
bool status
false not pressed, true pressed
Definition glcompdefs.h:229
bool refStatus
false not pressed, true pressed
Definition glcompdefs.h:230
glcompdoubleclickfunc_t doubleclick
Definition glcompdefs.h:162
glcompmouseoutfunc_t mouseout
Definition glcompdefs.h:165
glcompmouseupfunc_t mouseup
Definition glcompdefs.h:167
glcompclickfunc_t click
Definition glcompdefs.h:161
glcompmouseinfunc_t mousein
Definition glcompdefs.h:164
glcompmousedownfunc_t mousedown
Definition glcompdefs.h:166
glcompmousedragfunct_t mousedrag
Definition glcompdefs.h:168
glcompdrawfunc_t draw
Definition glcompdefs.h:160
glcompmouseoverfunc_t mouseover
Definition glcompdefs.h:163
glCompColor color
Definition glcompdefs.h:183
glCompCallBacks callbacks
Definition glcompdefs.h:193
glCompCallBacks functions
Definition glcompdefs.h:194
glCompPoint pos
Definition glcompdefs.h:179
glCompAnchor anchor
Definition glcompdefs.h:191
glCompAlignment align
Definition glcompdefs.h:190
glCompJustify justify
Definition glcompdefs.h:195
void * parent
Definition glcompdefs.h:187
glCompFont font
font to use
Definition glcompdefs.h:189
glCompPoint refPos
Definition glcompdefs.h:180
glCompSet * compset
compset
Definition glcompdefs.h:186
float borderWidth
Definition glcompdefs.h:182
glCompColor color
Definition glcompdefs.h:150
int transparent
Definition glcompdefs.h:152
void * glutfont
Definition glcompdefs.h:151
glCompTex * tex
Definition glcompdefs.h:153
char * fontdesc
Definition glcompdefs.h:149
glCompJustify justify
Definition glcompdefs.h:155
glCompObj base
Definition glcompdefs.h:205
glCompTex * texture
Definition glcompdefs.h:206
glCompHJustify HJustify
Definition glcompdefs.h:111
glCompVJustify VJustify
Definition glcompdefs.h:110
char * text
Definition glcompdefs.h:221
glCompObj base
Definition glcompdefs.h:220
glCompCallBacks callbacks
Definition glcompdefs.h:247
glCompPoint GLfinalPos
Definition glcompdefs.h:243
glCompCallBacks functions
Definition glcompdefs.h:248
glMouseButtonType t
Definition glcompdefs.h:239
glCompPoint GLpos
Definition glcompdefs.h:241
glCompPoint GLinitPos
Definition glcompdefs.h:242
glCompObj * clickedObj
Definition glcompdefs.h:246
object prototype
Definition glcompdefs.h:199
glCompCommon common
Definition glcompdefs.h:200
float shadowwidth
Definition glcompdefs.h:213
glCompObj base
Definition glcompdefs.h:212
glCompImage * image
Definition glcompdefs.h:215
char * text
Definition glcompdefs.h:214
glCompPoint pos
Definition glcompdefs.h:128
glCompObj ** obj
Definition glcompdefs.h:259
size_t objcnt
Definition glcompdefs.h:260
glCompObj base
Definition glcompdefs.h:258
glCompMouse mouse
Definition glcompdefs.h:263
size_t textureCount
Definition glcompdefs.h:261
glCompTex ** textures
Definition glcompdefs.h:262
char * def
Definition glcompdefs.h:135
uint32_t id
Definition glcompdefs.h:134
unsigned char * data
Definition glcompdefs.h:142
int userCount
Definition glcompdefs.h:140
glCompTexType type
Definition glcompdefs.h:139
char * text
Definition glcompdefs.h:136