-
Notifications
You must be signed in to change notification settings - Fork 3
/
colourPicker.e
110 lines (93 loc) · 2.9 KB
/
colourPicker.e
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
96
97
98
99
100
101
102
103
104
105
106
107
108
OPT MODULE, OSVERSION=37
MODULE 'reaction/reaction_macros',
'window','classes/window',
'gadgets/layout','layout',
'reaction/reaction_lib',
'button','gadgets/button',
'palette','gadgets/palette',
'images/bevel',
'amigalib/boopsi',
'intuition/intuition',
'intuition/imageclass',
'intuition/gadgetclass'
MODULE '*reactionForm'
EXPORT ENUM COLOURPICK_SELECTOR, COLOURPICK_OK, COLOURPICK_CANCEL
CONST NUMGADS=COLOURPICK_CANCEL+1
EXPORT OBJECT colourPickerForm OF reactionForm
PRIVATE
selectedColour:LONG
ENDOBJECT
EXPORT PROC create() OF colourPickerForm
DEF gads:PTR TO LONG
DEF i
NEW gads[NUMGADS]
self.gadgetList:=gads
NEW gads[NUMGADS]
self.gadgetActions:=gads
self.windowObj:=WindowObject,
WA_TITLE, 'Select a Colour',
WA_LEFT, 0,
WA_TOP, 0,
WA_HEIGHT, 180,
WA_WIDTH, 250,
WA_MINWIDTH, 150,
WA_MAXWIDTH, 8192,
WA_MINHEIGHT, 80,
WA_MAXHEIGHT, 8192,
WA_ACTIVATE, TRUE,
WA_PUBSCREEN, 0,
WINDOW_POSITION, WPOS_CENTERSCREEN,
->WA_CustomScreen, gScreen,
->WINDOW_AppPort, gApp_port,
WA_CLOSEGADGET, TRUE,
WA_DEPTHGADGET, TRUE,
WA_SIZEGADGET, TRUE,
WA_DRAGBAR, TRUE,
WA_NOCAREREFRESH, TRUE,
WA_IDCMP,IDCMP_GADGETDOWN OR IDCMP_GADGETUP OR IDCMP_CLOSEWINDOW OR 0,
WINDOW_PARENTGROUP, VLayoutObject,
LAYOUT_SPACEOUTER, TRUE,
LAYOUT_DEFERLAYOUT, TRUE,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_VERT,
LAYOUT_ADDCHILD,self.gadgetList[COLOURPICK_SELECTOR]:=PaletteObject,
GA_ID, COLOURPICK_SELECTOR,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
PALETTE_COLOUR, 0,
PALETTE_COLOUROFFSET, 0,
PALETTE_NUMCOLOURS, 256,
PaletteEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD,self.gadgetList[COLOURPICK_OK]:=ButtonObject,
GA_ID, COLOURPICK_OK,
GA_TEXT, '_OK',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD,self.gadgetList[COLOURPICK_CANCEL]:=ButtonObject,
GA_ID, COLOURPICK_CANCEL,
GA_TEXT, '_Cancel',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
CHILD_WEIGHTEDHEIGHT, 0,
LayoutEnd,
LayoutEnd,
WindowEnd
self.gadgetActions[COLOURPICK_OK]:=MR_OK
self.gadgetActions[COLOURPICK_CANCEL]:=MR_CANCEL
ENDPROC
PROC end() OF colourPickerForm
END self.gadgetList[NUMGADS]
END self.gadgetActions[NUMGADS]
DisposeObject(self.windowObj)
ENDPROC
EXPORT PROC selectColour(current) OF colourPickerForm
SetGadgetAttrsA(self.gadgetList[ COLOURPICK_SELECTOR ],0,0,[PALETTE_COLOUR,current,0])
IF self.showModal()=MR_OK
RETURN Gets(self.gadgetList[ COLOURPICK_SELECTOR ],PALETTE_COLOUR)
ENDIF
ENDPROC -1