FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
livecode/engine/src/cpalette.cpp at develop · livecodeali/livecode · GitHub
livecodeali
/
livecode
Public
forked from
livecode/livecode
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
livecode
/
engine
/
src
/
cpalette.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
270 lines (239 loc) · 5.63 KB
Breadcrumbs
livecode
/
engine
/
src
/
cpalette.cpp
Copy path
File metadata and controls
270 lines (239 loc) · 5.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/*
Copyright (C) 2003-2015 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>.
*/
#
include
"
prefix.h
"
#
include
"
globdefs.h
"
#
include
"
filedefs.h
"
#
include
"
objdefs.h
"
#
include
"
parsedef.h
"
#
include
"
mcio.h
"
#
include
"
util.h
"
#
include
"
sellst.h
"
#
include
"
stack.h
"
#
include
"
cpalette.h
"
#
include
"
mcerror.h
"
#
include
"
globals.h
"
#
include
"
context.h
"
MCColors::MCColors
()
{
selectedcolor =
0
;
}
MCColors::MCColors
(
const
MCColors &cref) : MCControl(cref)
{
selectedcolor =
0
;
}
MCColors::~MCColors
()
{}
Chunk_term
MCColors::gettype
()
const
{
return
CT_COLOR_PALETTE
;
}
const
char
*
MCColors::gettypestring
()
{
return
MCcolorstring;
}
bool
MCColors::visit_self
(MCObjectVisitor* p_visitor)
{
return
p_visitor ->
OnControl
(
this
);
}
static
void
getcells
(uint2 &xcells, uint2 &ycells)
{
switch
(MCscreen->
getdepth
())
{
case
1
:
xcells =
2
;
ycells =
1
;
break
;
case
2
:
xcells =
2
;
ycells =
2
;
break
;
case
4
:
xcells =
4
;
ycells =
4
;
break
;
case
6
:
xcells =
8
;
ycells =
8
;
break
;
default
:
xcells =
16
;
ycells =
16
;
break
;
}
}
Boolean
MCColors::mfocus
(int2 x, int2 y)
{
if
(!(flags &
F_VISIBLE
||
showinvisible
()))
return
False;
if
(state &
CS_MOVE
|| state &
CS_SIZE
)
return
MCControl::mfocus
(x, y);
mx = x;
my = y;
if
(
MCU_point_in_rect
(rect, x, y))
{
switch
(
getstack
()->
gettool
(
this
))
{
case
T_BROWSE
:
case
T_POINTER
:
return
True;
default
:
return
False;
}
}
else
if
(state &
CS_MFOCUSED
)
return
True;
else
return
False;
}
Boolean
MCColors::mdown
(uint2 which)
{
if
(state &
CS_MFOCUSED
)
return
False;
state |=
CS_MFOCUSED
;
MCColor color;
switch
(which)
{
case
Button1:
switch
(
getstack
()->
gettool
(
this
))
{
case
T_BROWSE
:
uint2 xcells;
uint2 ycells;
getcells
(xcells, ycells);
MCscreen->
getpaletteentry
((my - rect.
y
) * ycells / rect.
height
* xcells
+ (mx - rect.
x
) * xcells / rect.
width
, color);
selectedcolor =
MCColorGetPixel
(color);
//
MW-2011-08-18: [[ Layers ]] Invalidate the whole object.
layer_redrawall
();
message_with_valueref_args
(MCM_mouse_down,
MCSTR
(
"
1
"
));
break
;
case
T_POINTER
:
start
(True);
break
;
default
:
return
False;
}
break
;
case
Button2:
case
Button3:
message_with_args
(MCM_mouse_down, which);
break
;
}
return
True;
}
Boolean
MCColors::mup
(uint2 which,
bool
p_release)
{
if
(!(state &
CS_MFOCUSED
))
return
False;
state &= ~
CS_MFOCUSED
;
switch
(which)
{
case
Button1:
switch
(
getstack
()->
gettool
(
this
))
{
case
T_BROWSE
:
message_with_valueref_args
(MCM_mouse_up,
MCSTR
(
"
1
"
));
break
;
case
T_POINTER
:
end
(
true
, p_release);
break
;
default
:
return
False;
}
break
;
case
Button2:
case
Button3:
message_with_args
(MCM_mouse_up, which);
break
;
}
return
True;
}
Boolean
MCColors::count
(Chunk_term type, MCObject *stop, uint2 &num)
{
if
(type ==
CT_COLOR_PALETTE
|| type ==
CT_LAYER
)
num++;
if
(stop ==
this
)
return
True;
return
False;
}
MCControl *
MCColors::clone
(Boolean attach, Object_pos p,
bool
invisible)
{
MCColors *newcolors =
new
(nothrow)
MCColors
(*
this
);
if
(attach)
newcolors->
attach
(p, invisible);
return
newcolors;
}
//
MW-2011-09-06: [[ Redraw ]] Added 'sprite' option - if true, ink and opacity are not set.
void
MCColors::draw
(
MCDC
*dc,
const
MCRectangle &dirty,
bool
p_isolated,
bool
p_sprite)
{
uint2 xcells;
uint2 ycells;
getcells
(xcells, ycells);
uint2 i;
uint2 j;
MCRectangle rrect =
MCU_reduce_rect
(rect, borderwidth);
MCRectangle trect;
MCColor c;
c = dc->
getwhite
();
dc->
setfillstyle
(FillSolid, nil,
0
,
0
);
for
(i =
0
; i < ycells ; i++)
for
(j =
0
; j < xcells ; j++)
{
trect.
x
= j * rrect.
width
/ xcells;
trect.
y
= i * rrect.
height
/ ycells;
trect.
width
= (j +
1
) * rrect.
width
/ xcells - trect.
x
;
trect.
height
= (i +
1
) * rrect.
height
/ ycells - trect.
y
;
trect.
x
+= rrect.
x
;
trect.
y
+= rrect.
y
;
MCscreen->
getpaletteentry
(i * xcells + j, c);
dc->
setforeground
(c);
dc->
fillrect
(trect);
if
(
MCColorGetPixel
(c) == selectedcolor)
draw3d
(dc, trect,
ETCH_SUNKEN
, borderwidth);
}
if
(flags &
F_SHOW_BORDER
)
{
if
(flags &
F_3D
)
draw3d
(dc, rect,
ETCH_SUNKEN
, borderwidth);
else
drawborder
(dc, rect, borderwidth);
}
}
//
/////////////////////////////////////////////////////////////////////////////
//
//
SAVING AND LOADING
//
IO_stat
MCColors::extendedsave
(MCObjectOutputStream& p_stream, uint4 p_part,
uint32_t
p_version)
{
return
MCObject::defaultextendedsave
(p_stream, p_part, p_version);
}
IO_stat
MCColors::extendedload
(MCObjectInputStream& p_stream,
uint32_t
p_version, uint4 p_length)
{
return
MCObject::defaultextendedload
(p_stream, p_version, p_length);
}
IO_stat
MCColors::save
(IO_handle stream, uint4 p_part,
bool
p_force_ext,
uint32_t
p_version)
{
IO_stat stat;
if
((stat =
IO_write_uint1
(
OT_COLORS
, stream)) !=
IO_NORMAL
)
return
stat;
if
((stat =
MCObject::save
(stream, p_part, p_force_ext, p_version)) !=
IO_NORMAL
)
return
stat;
return
savepropsets
(stream, p_version);
}
IO_stat
MCColors::load
(IO_handle stream,
uint32_t
version)
{
IO_stat stat;
if
((stat =
MCObject::load
(stream, version)) !=
IO_NORMAL
)
return
checkloadstat
(stat);
return
loadpropsets
(stream, version);
}
Back
|
FazBrowse Home
|
New Git URL