forked from cappuccino/cappuccino
/
CPDOMDisplayServer.h
125 lines (109 loc) · 5.8 KB
/
CPDOMDisplayServer.h
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
/*
* CPDOMDisplayServer.h
* AppKit
*
* Created by Francisco Tolmasky.
* Copyright 2008, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define SetStyleOrigin 0
#define SetStyleLeftTop 0
#define SetStyleRightTop 1
#define SetStyleLeftBottom 2
#define SetStyleRightBottom 3
#define SetStyleSize 4
#define SetSize 5
#define AppendChild 6
#define InsertBefore 7
#define RemoveChild 8
#define CPDOMDisplayServerSetStyleOrigin(anInstruction, aDOMElement, aTransform, x, y)\
if (!aDOMElement.CPDOMDisplayContext)\
aDOMElement.CPDOMDisplayContext = [];\
var __index = aDOMElement.CPDOMDisplayContext[SetStyleOrigin];\
if (!(__index >= 0))\
{\
__index = aDOMElement.CPDOMDisplayContext[SetStyleOrigin] = CPDOMDisplayServerInstructionCount;\
CPDOMDisplayServerInstructionCount += 5;\
}\
CPDOMDisplayServerInstructions[__index] = anInstruction;\
CPDOMDisplayServerInstructions[__index + 1] = aDOMElement;\
CPDOMDisplayServerInstructions[__index + 2] = aTransform;\
CPDOMDisplayServerInstructions[__index + 3] = x;\
CPDOMDisplayServerInstructions[__index + 4] = y;
#define CPDOMDisplayServerSetStyleLeftTop(aDOMElement, aTransform, aLeft, aTop) CPDOMDisplayServerSetStyleOrigin(SetStyleLeftTop, aDOMElement, aTransform, aLeft, aTop)
#define CPDOMDisplayServerSetStyleRightTop(aDOMElement, aTransform, aRight, aTop) CPDOMDisplayServerSetStyleOrigin(SetStyleRightTop, aDOMElement, aTransform, aRight, aTop)
#define CPDOMDisplayServerSetStyleLeftBottom(aDOMElement, aTransform, aLeft, aBottom) CPDOMDisplayServerSetStyleOrigin(SetStyleLeftBottom, aDOMElement, aTransform, aLeft, aBottom)
#define CPDOMDisplayServerSetStyleRightBottom(aDOMElement, aTransform, aRight, aBottom) CPDOMDisplayServerSetStyleOrigin(SetStyleRightBottom, aDOMElement, aTransform, aRight, aBottom)
#define CPDOMDisplayServerSetStyleSize(aDOMElement, aWidth, aHeight)\
if (!aDOMElement.CPDOMDisplayContext)\
aDOMElement.CPDOMDisplayContext = [];\
var __index = aDOMElement.CPDOMDisplayContext[SetStyleSize];\
if (!(__index >= 0))\
{\
__index = aDOMElement.CPDOMDisplayContext[SetStyleSize] = CPDOMDisplayServerInstructionCount;\
CPDOMDisplayServerInstructionCount += 4;\
}\
CPDOMDisplayServerInstructions[__index] = SetStyleSize;\
CPDOMDisplayServerInstructions[__index + 1] = aDOMElement;\
CPDOMDisplayServerInstructions[__index + 2] = aWidth;\
CPDOMDisplayServerInstructions[__index + 3] = aHeight;
#define CPDOMDisplayServerSetSize(aDOMElement, aWidth, aHeight)\
if (!aDOMElement.CPDOMDisplayContext)\
aDOMElement.CPDOMDisplayContext = [];\
var __index = aDOMElement.CPDOMDisplayContext[SetSize];\
if (!(__index >= 0))\
{\
__index = aDOMElement.CPDOMDisplayContext[SetSize] = CPDOMDisplayServerInstructionCount;\
CPDOMDisplayServerInstructionCount += 4;\
}\
CPDOMDisplayServerInstructions[__index] = SetSize;\
CPDOMDisplayServerInstructions[__index + 1] = aDOMElement;\
CPDOMDisplayServerInstructions[__index + 2] = aWidth;\
CPDOMDisplayServerInstructions[__index + 3] = aHeight;
#define CPDOMDisplayServerAppendChild(aParentElement, aChildElement)\
if (aChildElement.CPDOMDisplayContext) aChildElement.CPDOMDisplayContext[SetStyleOrigin] = -1;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = AppendChild;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = aParentElement;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = aChildElement;
#define CPDOMDisplayServerInsertBefore(aParentElement, aChildElement, aBeforeElement)\
if (aChildElement.CPDOMDisplayContext) aChildElement.CPDOMDisplayContext[SetStyleOrigin] = -1;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = InsertBefore;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = aParentElement;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = aChildElement;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = aBeforeElement;
#define CPDOMDisplayServerRemoveChild(aParentElement, aChildElement)\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = RemoveChild;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = aParentElement;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = aChildElement;
//#dfeine CPDOMDisplayServerCustomAction()
#define CPDOMDisplayServerAddView(aView)\
{\
var ___hash = [aView hash];\
if (typeof (CPDOMDisplayServerViewsContext[___hash]) == "undefined")\
{\
CPDOMDisplayServerViews[CPDOMDisplayServerViewsCount++] = aView;\
CPDOMDisplayServerViewsContext[___hash] = aView;\
}\
}\
#define CPDOMDisplayServerRemoveView(aView)\
{\
var index = CPDOMDisplayServerViewsContext[[aView hash]];\
if (typeof index != "undefined") \
{\
CPDOMDisplayServerViewsContext[[aView hash]];\
CPDOMDisplayServerViews[index] = NULL;\
}\
}\