-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathezwinput.c
95 lines (82 loc) · 2.54 KB
/
ezwinput.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* ezwinput.c
*
* Routines related to the EZ input widget for xdisp
* (imlemented using EZwgl).
*
* Initialize_Input_Widget()
* Open_Input_Widget()
* Close_Input_Widget()
* Input_Widget_CallBack()
*
* Copyright Bruce Pike, 1993-2000
*/
#include "xdisp.h"
/*------------------- Initialize_Input_Widget() ---------------------*/
void Initialize_Input_Widget()
{
/* create and configure the input widget */
Input_Widget = EZ_CreateFrame(NULL, fname);
EZ_ConfigureWidget(Input_Widget,
EZ_PADX, 5,
EZ_PADY, 5,
EZ_LABEL_STRING, "",
0);
Input_Widget_Label = EZ_CreateLabel(Input_Widget, "Upper:");
Input_Text_Widget = EZ_CreateEntry(Input_Widget, NULL);
EZ_ConfigureWidget(Input_Text_Widget,
EZ_WIDTH, 100,
EZ_HEIGHT, 20,
0);
/* set WM hints for user placement */
EZ_SetWMHintsAndSizeHints(Input_Widget, 0);
}
/*------------------- Input_Widget_CallBack() -----------------------*/
void Input_Widget_CallBack(EZ_Widget *widget, void *label)
{
char *str;
int i, tmp;
/* get the input string */
str = EZ_GetEntryString(Input_Text_Widget);
/* close the widget */
Close_Input_Widget();
/* set the upper/lower value */
if (strcmp(label,"Upper:")==0) {
Upper = (int) ((double) I_Min + ((atof(str)-rw_offset)/rw_scale));
}
else if (strcmp(label,"Lower:")==0) {
Lower = (int) ((double) I_Min + ((atof(str)-rw_offset)/rw_scale));
}
else if (strcmp(label,"Gamma:")==0) {
Gamma = atof(str)>0.0 ? atof(str) : 1.0;
for (i=0; i<256; i++) {
tmp = (int) (pow(((float)i/255.0), (1.0/Gamma)) * 255.0 + 0.5);
Gamma_Table[i] = (byte) ((tmp <= 255) ? tmp : 255);
}
}
Window_Level(Lower, Upper);
update_sliders();
update_msgs();
}
/*---------------------- Open_Input_Widget() ------------------------*/
int Open_Input_Widget(char *label)
{
/* set the input label */
EZ_ConfigureWidget(Input_Widget_Label,
EZ_LABEL_STRING, label,
0);
/* clear the input string */
EZ_SetEntryString(Input_Text_Widget, NULL);
/* register the callback with label data */
EZ_SetWidgetCallBack(Input_Text_Widget, Input_Widget_CallBack, label);
/* activate and display the widget */
EZ_ActivateWidget(Input_Widget);
EZ_DisplayWidget(Input_Widget);
/* force the title we want */
XStoreName(theDisp,EZ_GetWidgetWindow(Input_Widget),"xdisp\0");
}
/*-------------------- Close_Input_Widget() --------------------------*/
void Close_Input_Widget()
{
EZ_DeActivateWidget(Input_Widget);
}