1 /******************************************************************************
2 *
3 * Copyright (C) 2004-2007, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * ID: vis.vis 17.07.07 0.0.A.
11 *
12 * Author: Alexander Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15
16 /*Основа для визуальных компонент
17
18 */
19
20
21 //
22 type tTypeDef
23 {
24 str TypeName
25 arr VirtTbl of uint
26 arr ProcTbl[$WM_USER] of uint
27 arr ProcUserTbl[0] of uint
28 //arr ProcTbl/*[200]*//*[129]*/ of uint
29 uint InheritTypeId
30 }
31
32 method uint tTypeDef.findprocuser( uint msg )
33 {
34 uint i
35 for i = 0, i < *.ProcUserTbl, i += 2
36 {
37 if .ProcUserTbl[i] == msg
38 {
39 return i
40 }
41 }
42 return 0
43 }
44
45 method uint tTypeDef.setproc( uint msg newproc )
46 {
47 uint oldproc
48 if msg < $WM_USER
49 {
50 oldproc = .ProcTbl[msg]
51 .ProcTbl[msg] = newproc
52 }
53 else
54 {
55 uint i
56 if i = .findprocuser( msg )
57 {
58 oldproc = .ProcUserTbl[i]
59 }
60 else
61 {
62 i = .ProcUserTbl.expand( 2 )
63 .ProcUserTbl[i++] = msg
64 }
65 .ProcUserTbl[i] = newproc
66 }
67 return oldproc
68 }
69
70 method tTypeDef.delproc( uint msg oldproc )
71 {
72 if msg < $WM_USER
73 {
74 .ProcTbl[msg] = oldproc
75 }
76 else
77 {
78 uint i
79 if i = .findprocuser( msg )
80 {
81 if oldproc : .ProcUserTbl[i] = oldproc
82 else {
83 .ProcUserTbl.del( i, 2 )
84 }
85 }
86 }
87 }
88
89 method uint tTypeDef.getproc( uint msg )
90 {
91 if msg < $WM_USER
92 {
93 .ProcTbl[msg]
94 }
95 else
96 {
97 uint i
98 if i = .findprocuser( msg )
99 {
100 return .ProcUserTbl[i]
101 }
102 }
103 return 0
104 }
105
106 method tTypeDef.delete()
107 {
108 /*print( "tTypeDef.Delete\n" )
109 getch()*/
110 }
111 /*method tTypeDef tTypeDef.init()
112 {
113 print( "reseeeeee\n" )
114 if 0 :this.ProcTbl->buf.expand( 129*4 )
115 //this.ProcTbl.data = buf_alloc( pb, size );
116 //this.ProcTbl.use=129
117 return this
118 }*/
119
120 global {
121 arr tbltypedef[0,2] of uint
122 }
123
124 func tTypeDef gettypedef( uint typeid )
125 {
126 uint i
127 fornum i = 0, *tbltypedef
128 {
129 if typeid == tbltypedef[i,0]
130 {
131 return tbltypedef[i,1]->tTypeDef
132 }
133 }
134 return 0->tTypeDef
135 }
136
137 func uint gettypeid( str typename )
138 {
139 uint i
140 fornum i = 0, *tbltypedef
141 {
142 if tbltypedef[i,1]->tTypeDef.TypeName == typename
143 {
144 return tbltypedef[i,0]
145 }
146 }
147 return 0
148 }
149
150 func uint regcomp( uint typeid, str typename, uint inherit, uint maxvirt, collection virt, collection proc)
151 {
152
153 uint td as new( tTypeDef )->tTypeDef
154 uint i
155 //td.typeid = typeid
156 td.TypeName = typename
157 td.InheritTypeId = inherit
158 uint ptd as gettypedef(inherit)
159 //td.ProcTbl->buf.expand( 129*4 )
160 if &ptd
161 {
162 td.VirtTbl = ptd.VirtTbl
163 //print( "- \(td.VirtTbl.itype) \(ptd.VirtTbl.itype)\n" )
164 td.ProcTbl = ptd.ProcTbl
165 td.ProcUserTbl = ptd.ProcUserTbl
166 td.VirtTbl.expand( max( 0, int( maxvirt ) - *ptd.VirtTbl ) )
167 }
168 else
169 {
170 td.VirtTbl.expand( maxvirt )
171 }
172
173
174 if &virt
175 {
176 fornum i = 0, *virt
177 {
178 uint fdef as virt[i]->collection
179 td.VirtTbl[fdef[0]] = fdef[1]
180 }
181
182 }
183
184 if &proc
185 {
186 fornum i = 0, *proc
187 {
188 uint fdef as proc[i]->collection
189 //print( "fdef \(fdef[0]) \(*td.ProcTbl)\n" )
190 //td.ProcTbl[fdef[0]] = fdef[1]
191 td.setproc(fdef[0],fdef[1])
192 }
193 }
194 //return &td
195 uint cur = tbltypedef.expand( 2 ) / 2
196 tbltypedef[ cur, 0 ] = typeid
197 tbltypedef[ cur, 1 ] = &td
198 //print( "reg \(cur) \(typeid) \(tbltypedef[ cur, 1 ])\n" )
199 /*print( "x5\n" )*/
200 return &td
201 //%{ %{$id_insert, vComp_insert}, %{$id_predel, vComp_predel }, %{$id_remove, vComp_remove} }
202 }