1 /* $Id$Revision: */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 
5 /*************************************************************************
6  * Copyright (c) 2011 AT&T Intellectual Property
7  * All rights reserved. This program and the accompanying materials
8  * are made available under the terms of the Eclipse Public License v1.0
9  * which accompanies this distribution, and is available at
10  * http://www.eclipse.org/legal/epl-v10.html
11  *
12  * Contributors: See CVS logs. Details at http://www.graphviz.org/
13  *************************************************************************/
14 
15 #include "glcomppanel.h"
16 #include "glcompfont.h"
17 #include "glcompset.h"
18 #include "glcomptexture.h"
19 #include "glutils.h"
20 #include "memory.h"
21 
glCompPanelNew(glCompObj * parentObj,GLfloat x,GLfloat y,GLfloat w,GLfloat h)22 glCompPanel *glCompPanelNew(glCompObj * parentObj, GLfloat x, GLfloat y,
23 			    GLfloat w, GLfloat h)
24 {
25     glCompPanel *p;
26 //      glCompCommon* parent=&parentObj->common;
27     p = NEW(glCompPanel);
28     glCompInitCommon((glCompObj *) p, parentObj, (GLfloat) x, (GLfloat) y);
29 
30     p->shadowcolor.R = GLCOMPSET_PANEL_SHADOW_COLOR_R;
31     p->shadowcolor.G = GLCOMPSET_PANEL_SHADOW_COLOR_G;
32     p->shadowcolor.B = GLCOMPSET_PANEL_SHADOW_COLOR_B;
33     p->shadowcolor.A = GLCOMPSET_PANEL_SHADOW_COLOR_A;
34     p->shadowwidth = GLCOMPSET_PANEL_SHADOW_WIDTH;
35     p->common.borderWidth = GLCOMPSET_PANEL_BORDERWIDTH;
36 
37 
38     p->common.width = w;
39     p->common.height = h;
40 
41     p->common.font = glNewFontFromParent((glCompObj *) p, NULL);
42     p->text = (char *) 0;
43     p->common.functions.draw = (glcompdrawfunc_t)glCompPanelDraw;
44     p->image = (glCompImage *) 0;
45     return p;
46 }
glCompSetPanelText(glCompPanel * p,char * t)47 void glCompSetPanelText(glCompPanel * p, char *t)
48 {
49     replacestr(t, &p->text);
50     glCompDeleteTexture(p->common.font->tex);
51     p->common.font->tex =
52 	glCompSetAddNewTexLabel(p->common.compset,
53 				p->common.font->fontdesc,
54 				p->common.font->size, p->text, 1);
55 }
56 
glCompPanelDraw(glCompObj * o)57 int glCompPanelDraw(glCompObj * o)
58 {
59     glCompPanel *p;
60     glCompCommon ref;
61     glCompRect r;
62     p = (glCompPanel *) o;
63     ref = p->common;
64     glCompCalcWidget((glCompCommon *) p->common.parent, &p->common, &ref);
65     p->objType = glPanelObj;
66     //typedef enum {glPanelObj,glbuttonObj,glLabelObj,glImageObj}glObjType;
67 
68 
69     if (!p->common.visible)
70 	return 0;
71     /*draw shadow */
72     glColor4f((GLfloat) p->shadowcolor.R, (GLfloat) p->shadowcolor.G,
73 	      (GLfloat) p->shadowcolor.B, (GLfloat) p->shadowcolor.A);
74     r.h = p->shadowwidth;
75     r.w = ref.width;
76     r.pos.x = ref.pos.x + p->shadowwidth;
77     r.pos.y = ref.pos.y - p->shadowwidth;
78     r.pos.z = -0.001;
79     glCompDrawRectangle(&r);
80     r.h = ref.height;
81     r.w = p->shadowwidth;
82     r.pos.x = ref.pos.x + ref.width;
83     r.pos.y = ref.pos.y - p->shadowwidth;
84     r.pos.z = -0.001;
85     glCompDrawRectangle(&r);
86     /*draw panel */
87     glCompDrawRectPrism(&(ref.pos), ref.width, ref.height,
88 			p->common.borderWidth, 0.01, &(ref.color), 1);
89     /*draw image if there is */
90     if (p->image) {
91 	p->image->common.callbacks.draw((void *) p->image);
92     }
93     if (p->text) {
94 
95 
96     }
97     return 1;
98 }
99 
100 
glCompPanelHide(glCompPanel * p)101 int glCompPanelHide(glCompPanel * p)
102 {
103     /* int ind = 0; */
104     p->common.visible = 0;
105     return 1;
106 
107 
108 }
109 
glCompPanelShow(glCompPanel * p)110 int glCompPanelShow(glCompPanel * p)
111 {
112     /* int ind = 0; */
113     p->common.visible = 1;
114     return 1;
115 
116 }
117 
glCompPanelClick(glCompObj * o,GLfloat x,GLfloat y,glMouseButtonType t)118 void glCompPanelClick(glCompObj * o, GLfloat x, GLfloat y,
119 		      glMouseButtonType t)
120 {
121     if (o->common.callbacks.click)
122 	o->common.callbacks.click(o, x, y, t);
123 }
124 
glCompPanelDoubleClick(glCompObj * obj,GLfloat x,GLfloat y,glMouseButtonType t)125 void glCompPanelDoubleClick(glCompObj * obj, GLfloat x, GLfloat y,
126 			    glMouseButtonType t)
127 {
128     /*Put your internal code here */
129     if (((glCompPanel *) obj)->common.callbacks.doubleclick)
130 	((glCompPanel *) obj)->common.callbacks.doubleclick(obj, x, y, t);
131 }
132 
glCompPanelMouseDown(glCompObj * obj,GLfloat x,GLfloat y,glMouseButtonType t)133 void glCompPanelMouseDown(glCompObj * obj, GLfloat x, GLfloat y,
134 			  glMouseButtonType t)
135 {
136     /*Put your internal code here */
137     if (((glCompPanel *) obj)->common.callbacks.mousedown)
138 	((glCompPanel *) obj)->common.callbacks.mousedown(obj, x, y, t);
139 }
140 
glCompPanelMouseIn(glCompObj * obj,GLfloat x,GLfloat y)141 void glCompPanelMouseIn(glCompObj * obj, GLfloat x, GLfloat y)
142 {
143     /*Put your internal code here */
144     if (((glCompPanel *) obj)->common.callbacks.mousein)
145 	((glCompPanel *) obj)->common.callbacks.mousein(obj, x, y);
146 }
147 
glCompPanelMouseOut(glCompObj * obj,GLfloat x,GLfloat y)148 void glCompPanelMouseOut(glCompObj * obj, GLfloat x, GLfloat y)
149 {
150     /*Put your internal code here */
151     if (((glCompPanel *) obj)->common.callbacks.mouseout)
152 	((glCompPanel *) obj)->common.callbacks.mouseout(obj, x, y);
153 }
154 
glCompPanelMouseOver(glCompObj * obj,GLfloat x,GLfloat y)155 void glCompPanelMouseOver(glCompObj * obj, GLfloat x, GLfloat y)
156 {
157     /*Put your internal code here */
158     if (((glCompPanel *) obj)->common.callbacks.mouseover)
159 	((glCompPanel *) obj)->common.callbacks.mouseover(obj, x, y);
160 }
161 
glCompPanelMouseUp(glCompObj * obj,GLfloat x,GLfloat y,glMouseButtonType t)162 void glCompPanelMouseUp(glCompObj * obj, GLfloat x, GLfloat y,
163 			glMouseButtonType t)
164 {
165     /*Put your internal code here */
166     if (((glCompPanel *) obj)->common.callbacks.mouseup)
167 	((glCompPanel *) obj)->common.callbacks.mouseup(obj, x, y, t);
168 }
169 
170 
171 #if 0
172 
173 void glCompPanelSetText(glCompPanel * p, char *str)
174 {
175 //    replacestr(str, &p->text);
176 }
177 #endif
178