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 _SAVE3D_C
37
#include "openaxiom-c-macros.h"
38
39
#include <stdio.h>
40
#include <string.h>
41
#include "header.h"
42
#include "cpanel.h"
43
#include "volume.h"
44
#include "../include/purty/volume.bitmap"
45
#include "../include/purty/volume.mask"
46
47
#include "Gfun.H1"
48
#include "XSpadFill.h"
49
#include "all_3d.H1"
50
51
#define saveMASK ExposureMask
52
#define saveCursorForeground monoColor(55)
53
#define saveCursorBackground monoColor(197)
54
#define saveTitleColor monoColor(70)
55
#define saveButtonColor monoColor(195)
56
#define saveFontHeight (saveFont->max_bounds.ascent+saveFont->max_bounds.descent)
57
58
59
/***************************
60
* int makeSavePanel() *
61
***************************/
62
63
int
64
makeSavePanel(void)
65
{
66
67
int i;
68
XSetWindowAttributes saver,SaverAttrib;
69
XSizeHints sizeh;
70
Pixmap savebits, savemask;
71
XColor saveColor,sColor;
72
73
savebits = XCreateBitmapFromData(dsply,rtWindow,
74
(const char*) volumeBitmap_bits,
75
volumeBitmap_width,volumeBitmap_height);
76
savemask = XCreateBitmapFromData(dsply,rtWindow,
77
(const char*) volumeMask_bits,
78
volumeMask_width,volumeMask_height);
79
saver.background_pixel = backgroundColor;
80
saver.border_pixel = foregroundColor;
81
saver.event_mask = saveMASK;
82
saver.colormap = colorMap;
83
saver.override_redirect = overrideManager;
84
saveColor.pixel = saveCursorForeground;
85
XQueryColor(dsply,colorMap,&saveColor);
86
sColor.pixel = saveCursorBackground;
87
XQueryColor(dsply,colorMap,&sColor);
88
saver.cursor = XCreatePixmapCursor(dsply,savebits,savemask,
89
&saveColor,&sColor,
90
volumeBitmap_x_hot,volumeBitmap_y_hot);
91
92
saveWindow = XCreateWindow(dsply,control->controlWindow,
93
controlWidth-saveWidth-2, controlHeight-saveHeight-2,
94
saveWidth-2,saveHeight-2,2,
95
CopyFromParent,InputOutput,CopyFromParent,
96
controlCreateMASK,&saver);
97
98
sizeh.flags = USPosition | USSize;
99
sizeh.x = 0;
100
sizeh.y = 0;
101
sizeh.width = saveWidth-2;
102
sizeh.height = saveHeight-2;
103
104
XSetNormalHints(dsply,saveWindow,&sizeh);
105
XSetStandardProperties(dsply,saveWindow,"Save Panel","Save Panel",
106
None,NULL,0,&sizeh);
107
108
/*** Create save buttons ***/
109
initSaveButtons(control->buttonQueue);
110
for (i=saveButtonsStart; i<(saveButtonsEnd); i++) {
111
SaverAttrib.event_mask = (control->buttonQueue[i]).mask;
112
(control->buttonQueue[i]).self =
113
XCreateWindow(dsply,saveWindow,
114
(control->buttonQueue[i]).buttonX,
115
(control->buttonQueue[i]).buttonY,
116
(control->buttonQueue[i]).buttonWidth,
117
(control->buttonQueue[i]).buttonHeight,
118
0,0,InputOnly,CopyFromParent,
119
buttonCreateMASK,&SaverAttrib);
120
XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
121
&((control->buttonQueue[i]).buttonKey));
122
XMapWindow(dsply,(control->buttonQueue[i]).self);
123
}
124
125
return(0);
126
127
} /* makeSavePanel() */
128
129
130
/****************************
131
* void drawSavePanel() *
132
****************************/
133
134
void
135
drawSavePanel(void)
136
{
137
138
const char* s;
139
int i,strlength;
140
141
GSetForeground(saveGC,(float)saveButtonColor,Xoption);
142
for (i=saveButtonsStart; i<(saveButtonsEnd); i++) {
143
GDraw3DButtonOut(saveGC,saveWindow,
144
(control->buttonQueue[i]).buttonX,
145
(control->buttonQueue[i]).buttonY,
146
(control->buttonQueue[i]).buttonWidth,
147
(control->buttonQueue[i]).buttonHeight,Xoption);
148
s = (control->buttonQueue[i]).text;
149
strlength = strlen(s);
150
GSetForeground(trashGC,
151
(float)monoColor((control->buttonQueue[i]).textColor),Xoption);
152
GDrawString(trashGC,saveWindow,
153
(control->buttonQueue[i]).buttonX +
154
centerX(processGC,s,strlength,
155
(control->buttonQueue[i]).buttonWidth),
156
(control->buttonQueue[i]).buttonY +
157
centerY(processGC,(control->buttonQueue[i]).buttonHeight),
158
s,strlen(s),Xoption);
159
} /* for i in control->buttonQueue */
160
161
} /* drawSavePanel */
162
163