Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

open-axiom repository from github

24005 views
1
/*
2
Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd.
3
All rights reserved.
4
Copyright (C) 2007-2010, Gabriel Dos Reis.
5
All rights reserved.
6
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions are
9
met:
10
11
- Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
14
- Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the following disclaimer in
16
the documentation and/or other materials provided with the
17
distribution.
18
19
- Neither the name of The Numerical Algorithms Group Ltd. nor the
20
names of its contributors may be used to endorse or promote products
21
derived from this software without specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
#define _QUIT3D_C
37
#include "openaxiom-c-macros.h"
38
39
#include <string.h>
40
#include "header.h"
41
#include "cpanel.h"
42
#include "volume.h"
43
#include "../include/purty/volume.bitmap"
44
#include "../include/purty/volume.mask"
45
46
#include "util.H1"
47
#include "Gfun.H1"
48
#include "XSpadFill.h"
49
#include "all_3d.H1"
50
51
#define quitMASK ExposureMask
52
#define quitCursorForeground monoColor(55)
53
#define quitCursorBackground monoColor(197)
54
#define quitTitleColor monoColor(69)
55
#define quitButtonColor monoColor(195)
56
#define quitFontHeight (quitFont->max_bounds.ascent+quitFont->max_bounds.descent)
57
58
59
/***************************
60
* int makeQuitPanel() *
61
***************************/
62
63
int
64
makeQuitPanel(void)
65
{
66
67
int i;
68
XSetWindowAttributes quitter,QuitterAttrib;
69
XSizeHints sizeh;
70
Pixmap quitbits, quitmask;
71
XColor quitterColor,qColor;
72
73
quitbits = XCreateBitmapFromData(dsply,rtWindow,
74
(const char*) volumeBitmap_bits,
75
volumeBitmap_width,volumeBitmap_height);
76
quitmask = XCreateBitmapFromData(dsply,rtWindow,
77
(const char*) volumeMask_bits,
78
volumeMask_width,volumeMask_height);
79
quitter.background_pixel = backgroundColor;
80
quitter.border_pixel = foregroundColor;
81
quitter.event_mask = quitMASK;
82
quitter.colormap = colorMap;
83
quitter.override_redirect = overrideManager;
84
quitterColor.pixel = quitCursorForeground;
85
XQueryColor(dsply,colorMap,&quitterColor);
86
qColor.pixel = quitCursorBackground;
87
XQueryColor(dsply,colorMap,&qColor);
88
quitter.cursor = XCreatePixmapCursor(dsply,quitbits,quitmask,
89
&quitterColor,&qColor,
90
volumeBitmap_x_hot,volumeBitmap_y_hot);
91
quitWindow = XCreateWindow(dsply,control->controlWindow,
92
controlWidth-quitWidth-2,controlHeight-quitHeight-2,
93
quitWidth-2,quitHeight-2,2,
94
CopyFromParent,InputOutput,CopyFromParent,
95
controlCreateMASK,&quitter);
96
97
sizeh.flags = USPosition | USSize;
98
sizeh.x = 0;
99
sizeh.y = 0;
100
sizeh.width = quitWidth-2;
101
sizeh.height = quitHeight-2;
102
103
XSetNormalHints(dsply,quitWindow,&sizeh);
104
XSetStandardProperties(dsply,quitWindow,"Quit Panel","Quit Panel",
105
None,NULL,0,&sizeh);
106
107
/*** do quit buttons ***/
108
initQuitButtons(control->buttonQueue);
109
for (i=quitButtonsStart; i<(quitButtonsEnd); i++) {
110
QuitterAttrib.event_mask = (control->buttonQueue[i]).mask;
111
(control->buttonQueue[i]).self =
112
XCreateWindow(dsply,quitWindow,
113
(control->buttonQueue[i]).buttonX,
114
(control->buttonQueue[i]).buttonY,
115
(control->buttonQueue[i]).buttonWidth,
116
(control->buttonQueue[i]).buttonHeight,
117
0,0,InputOnly,CopyFromParent,
118
buttonCreateMASK,&QuitterAttrib);
119
XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
120
&((control->buttonQueue[i]).buttonKey));
121
XMapWindow(dsply,(control->buttonQueue[i]).self);
122
}
123
124
return(0);
125
126
} /* makeQuitPanel() */
127
128
129
/****************************
130
* void drawQuitPanel() *
131
****************************/
132
133
void
134
drawQuitPanel(void)
135
{
136
137
const char* s;
138
int i,strlength;
139
140
s = "Really?";
141
strlength = strlen(s);
142
GSetForeground(anotherGC,(float)quitTitleColor,Xoption);
143
GDrawString(anotherGC,quitWindow,
144
centerX(anotherGC,s,strlength,quitWidth),centerY(anotherGC,39),s,strlength,Xoption);
145
146
GSetForeground(anotherGC,(float)quitButtonColor,Xoption);
147
for (i=quitButtonsStart; i<(quitButtonsEnd); i++) {
148
GDraw3DButtonOut(quitGC,quitWindow,
149
(control->buttonQueue[i]).buttonX,
150
(control->buttonQueue[i]).buttonY,
151
(control->buttonQueue[i]).buttonWidth,
152
(control->buttonQueue[i]).buttonHeight,Xoption);
153
s = (control->buttonQueue[i]).text;
154
strlength = strlen(s);
155
GSetForeground(trashGC,
156
(float)monoColor((control->buttonQueue[i]).textColor),Xoption);
157
GDrawString(trashGC,quitWindow,
158
(control->buttonQueue[i]).buttonX +
159
centerX(processGC,s,strlength,
160
(control->buttonQueue[i]).buttonWidth),
161
(control->buttonQueue[i]).buttonY +
162
centerY(processGC,(control->buttonQueue[i]).buttonHeight),
163
s,strlen(s),Xoption);
164
} /* for i in control->buttonQueue */
165
166
} /* drawQuitPanel */
167
168