forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcard.h
More file actions
251 lines (216 loc) · 8.2 KB
/
card.h
File metadata and controls
251 lines (216 loc) · 8.2 KB
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
/* Copyright (C) 2003-2013 Runtime Revolution 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/>. */
#ifndef CARD_H
#define CARD_H
#include "object.h"
class MCCard : public MCObject
{
friend class MCHccard;
protected:
MCObjptr *objptrs;
MCObjptr *kfocused;
MCObjptr *oldkfocused;
MCObjptr *mfocused;
MCButton *defbutton;
MCButton *odefbutton;
Boolean mgrabbed;
MCCdata *savedata;
// MW-2011-08-26: [[ TileCache ]] The layer id of the background.
uint32_t m_bg_layer_id;
// MW-2011-09-23: [[ TileCache ]] The layer id of the foreground (selection rect).
uint32_t m_fg_layer_id;
// MM-2012-11-05: [[ Object selection started/ended message ]]
bool m_selecting_objects : 1;
static MCRectangle selrect;
static int2 startx;
static int2 starty;
static MCObjptr *removedcontrol;
public:
MCCard();
MCCard(const MCCard &cref);
// virtual functions from MCObject
virtual ~MCCard();
virtual Chunk_term gettype() const;
virtual const char *gettypestring();
virtual bool visit(MCVisitStyle p_style, uint32_t p_part, MCObjectVisitor *p_visitor);
virtual void open();
virtual void close();
virtual void kfocus();
virtual Boolean kfocusnext(Boolean top);
virtual Boolean kfocusprev(Boolean bottom);
virtual void kunfocus();
virtual Boolean kdown(const char *string, KeySym key);
virtual Boolean kup(const char *string, KeySym key);
virtual Boolean mfocus(int2 x, int2 y);
virtual void mfocustake(MCControl *target);
virtual void munfocus();
virtual void mdrag(void);
virtual Boolean mdown(uint2 which);
virtual Boolean mup(uint2 which);
virtual Boolean doubledown(uint2 which);
virtual Boolean doubleup(uint2 which);
virtual void timer(MCNameRef mptr, MCParameter *params);
virtual Exec_stat getprop(uint4 parid, Properties which, MCExecPoint &, Boolean effective);
virtual Exec_stat setprop(uint4 parid, Properties which, MCExecPoint &, Boolean effective);
virtual Boolean del();
virtual void paste(void);
virtual Exec_stat handle(Handler_type, MCNameRef, MCParameter *, MCObject *pass_from);
virtual void recompute();
// MW-2011-09-20: [[ Collision ]] Compute shape of card.
virtual bool lockshape(MCObjectShape& r_shape);
virtual void unlockshape(MCObjectShape& shape);
// MW-2012-02-14: [[ FontRefs ]] Recompute the font inheritence hierarchy.
virtual bool recomputefonts(MCFontRef parent_font);
// MW-2012-06-08: [[ Relayer ]] Move a control to before target.
virtual void relayercontrol(MCControl *p_source, MCControl *p_target);
virtual void relayercontrol_remove(MCControl *control);
virtual void relayercontrol_insert(MCControl *control, MCControl *target);
void draw(MCDC *dc, const MCRectangle &dirty, bool p_isolated);
MCObject *hittest(int32_t x, int32_t y);
// MCCard functions
IO_stat load(IO_handle stream, const char *version);
IO_stat extendedload(MCObjectInputStream& p_stream, const char *p_version, uint4 p_length);
IO_stat save(IO_handle stream, uint4 p_part, bool p_force_ext);
IO_stat extendedsave(MCObjectOutputStream& p_stream, uint4 p_part);
IO_stat saveobjects(IO_handle stream, uint4 p_part);
IO_stat loadobjects(IO_handle stream, const char *version);
void kfocusset(MCControl *target);
MCCard *clone(Boolean attach, Boolean controls);
void clonedata(MCCard *source);
void replacedata(MCStack *source);
Exec_stat relayer(MCControl *optr, uint2 newlayer);
MCCard *findname(Chunk_term type, const MCString &);
MCCard *findid(Chunk_term type, uint4 inid, Boolean alt);
Boolean countme(uint4 groupid, Boolean marked);
Boolean count(Chunk_term otype, Chunk_term ptype, MCObject *stop,
uint2 &n, Boolean dohc);
MCControl *getchild(Chunk_term e, const MCString &,
Chunk_term o, Chunk_term p);
Boolean getchildid(uint4 inid);
Exec_stat groupmessage(MCNameRef message, MCCard *other);
void installaccels(MCStack *stack);
void removeaccels(MCStack *stack);
void resize(uint2 width, uint2 height);
MCImage *createimage();
Boolean removecontrol(MCControl *cptr, Boolean needredraw, Boolean cf);
void clearfocus(MCObjptr *oldptr, MCObjptr *newptr);
void erasefocus(MCObject *p_object);
MCObjptr *newcontrol(MCControl *cptr, Boolean needredraw);
void resetid(uint4 oldid, uint4 newid);
Boolean checkid(uint4 controlid);
Boolean find(MCExecPoint &ep, Find_mode mode, const MCString &,
Boolean firstcard, Boolean firstword);
MCObjptr *getrefs();
void clean();
void clear();
void setmark(Boolean newstate);
Boolean getmark()
{
return (flags & F_MARKED) != 0;
}
MCControl *getkfocused();
MCControl *getmfocused();
MCControl *getmousecontrol(void);
MCObjptr *getobjptrs(void) { return objptrs; }
MCObjptr *getobjptrforcontrol(MCControl *control);
void selectedbutton(uint2 n, Boolean bg, MCExecPoint &ep);
void grab()
{
mgrabbed = True;
}
void ungrab()
{
mgrabbed = False;
}
Boolean getgrab()
{
return mgrabbed;
}
void setdefbutton(MCButton *btn)
{
defbutton = btn;
}
MCButton *getodefbutton()
{
return odefbutton;
}
MCButton *getdefbutton()
{
return defbutton == NULL ? odefbutton : defbutton;
}
void freedefbutton(MCButton *btn);
MCRectangle computecrect();
void updateselection(MCControl *cptr, const MCRectangle &oldrect, const MCRectangle &selrect, MCRectangle &drect);
int2 getborderwidth(void);
void drawcardborder(MCDC *dc, const MCRectangle &dirty);
// IM-2013-09-13: [[ RefactorGraphics ]] render the card background
void drawbackground(MCContext *p_context, const MCRectangle &p_dirty);
// IM-2013-09-13: [[ RefactorGraphics ]] render the card selection rect
void drawselectionrect(MCContext *);
Exec_stat openbackgrounds(bool p_is_preopen, MCCard *p_other);
Exec_stat closebackgrounds(MCCard *p_other);
Exec_stat opencontrols(bool p_is_preopen);
Exec_stat closecontrols(void);
// MW-2011-08-19: [[ Layers ]] Dirty the given rect of the viewport.
void layer_dirtyrect(const MCRectangle& dirty_rect);
// MW-2011-08-19: [[ Layers ]] A layer has been added to the card.
void layer_added(MCControl *control, MCObjptr *previous, MCObjptr *next);
// MW-2011-08-19: [[ Layers ]] A layer has been removed from the card.
void layer_removed(MCControl *control, MCObjptr *previous, MCObjptr *next);
// MW-2011-08-19: [[ Layers ]] The viewport displayed in the stack has changed.
void layer_setviewport(int32_t x, int32_t y, int32_t width, int32_t height);
// MW-2011-09-23: [[ Layers ]] The selected rectangle has changed.
void layer_selectedrectchanged(const MCRectangle& old_rect, const MCRectangle& new_rect);
// MW-2011-08-26: [[ TileCache ]] Render all layers into the stack's tilecache.
void render(void);
// IM-2013-09-13: [[ RefactorGraphics ]] add tilecache_ prefix to render methods to make their purpose clearer
// MW-2011-09-23: [[ TileCache ]] Render the card's bg layer.
static bool tilecache_render_background(void *context, MCContext *target, const MCRectangle& dirty);
// MW-2011-09-23: [[ TileCache ]] Render the card's fg layer.
static bool tilecache_render_foreground(void *context, MCContext *target, const MCRectangle& dirty);
// MW-2012-06-08: [[ Relayer ]] This method returns the control on the card with
// the given layer. If nil is returned the control doesn't exist.
MCObject *getobjbylayer(uint32_t layer);
MCCard *next()
{
return (MCCard *)MCDLlist::next();
}
MCCard *prev()
{
return (MCCard *)MCDLlist::prev();
}
void totop(MCCard *&list)
{
MCDLlist::totop((MCDLlist *&)list);
}
void insertto(MCCard *&list)
{
MCDLlist::insertto((MCDLlist *&)list);
}
void appendto(MCCard *&list)
{
MCDLlist::appendto((MCDLlist *&)list);
}
void append(MCCard *node)
{
MCDLlist::append((MCDLlist *)node);
}
void splitat(MCCard *node)
{
MCDLlist::splitat((MCDLlist *)node);
}
MCCard *remove(MCCard *&list)
{
return (MCCard *)MCDLlist::remove((MCDLlist *&)list);
}
};
#endif