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.app 17.07.07 0.0.A.
11 *
12 * Author: Alexander Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15 /* Компонента vApp, порождена от vComp, существует только одна глобальная
16 переменная этого типа
17 События
18
19 */
20
21 define {
22 VIRTMAX = 100
23 }
24
25 include {
26 "viswin.g"
27 "images.g"
28 "comp.g"
29 "fonts.g"
30 "styles.g"
31 }
32
33 type vApp <inherit=vComp>{
34 uint cursorArrow
35 uint cursorDrag
36 uint cursorNoDrag
37 uint cursorSizeNS
38 uint cursorSizeWE
39 language Lng
40 ImageManager ImgM
41 FontManager FntM
42 Styles StyleM
43 }
44
45 global {
46 vApp App
47 vApp DesApp
48 }
49 ifdef $DESIGNING {
50 global {
51
52 }
53 }
54
55 ifdef $DESIGNING
56 {
57 include{
58 $"../../programs/visedit/manprops.g"
59 }
60 }
61
62 func init_vComp <entry>
63 {
64 regcomp( vComp, "vComp", 0, $vComp_last,
65 %{ %{$mNull, vComp_mNull},
66 %{$mInsert, vComp_mInsert },
67 %{$mRemove, vComp_mRemove },
68 %{$mPreDel, vComp_mPreDel },
69 %{$mSetOwner, vComp_mSetOwner },
70 %{$mLangChanged, vComp_mLangChanged }
71
72 },
73 0->collection )
74
75
76
77 ifdef $DESIGNING {
78 cm.AddComp( vComp )
79
80 cm.AddProps( vComp, %{
81 "Name" , str, 0,
82 "Tag" , uint, 0
83 })
84 }
85 }
86
87 extern {
88 method Image vComp.GetImage( ustr pImage )
89 //method Image vComp.GetImage( ustr pImage, uint disabled )
90 method vApp.SettingChange()
91 }
92
93 include {
94 "locustr.g"
95 "form.g"
96 }
97
98
99
100 /*------------------------------------------------------------------------------
101 Public methods
102 */
103
104 /*Метод Run
105 Запустить визуальное приложение
106 */
107 method vApp.Run( /*vform form*/ )
108 {
109 MSG msg
110
111 themeinit()
112
113 while GetMessage( &msg, 0, 0, 0 )
114 {
115 TranslateMessage( &msg )
116 DispatchMessage( &msg )
117 }
118 }
119
120 /*------------------------------------------------------------------------------
121 Virtual methods
122 */
123
124 method vApp.mInsert <alias=vApp_mInsert>( vForm form )
125 {
126 if form.TypeIs( vForm )
127 {
128 this->vComp.mInsert( form )
129 /*form.pOwner = 0*/
130 //form.Virtual( $mSetOwner, &this )
131 form.Virtual( $mCreateWin )
132 }
133 }
134
135 /*------------------------------------------------------------------------------
136 Registration
137 */
138
139 method vApp vApp.init()
140 {
141 this.pTypeId = vApp
142
143 .cursorArrow = LoadCursor( 0, $IDC_ARROW )
144 .cursorNoDrag = LoadCursor( 0, $IDC_NO )
145 .cursorSizeNS = LoadCursor( 0, $IDC_SIZENS )
146 .cursorSizeWE = LoadCursor( 0, $IDC_SIZEWE )
147
148 ICONINFO pi
149 RECT r
150 uint hdc = CreateCompatibleDC( 0 )
151 GetIconInfo( this.cursorArrow, pi )
152 uint osb = SelectObject( hdc, pi.hbmMask )
153
154 uint i
155 fornum i= 0,2
156 {
157 r.left = 15 + i
158 r.right = 32 - i
159 r.top = 15 + i
160 r.bottom = 32 - i
161 FrameRect( hdc, r, CreateSolidBrush( 0 ))
162 }
163 SelectObject( hdc, osb )
164 DeleteDC( hdc )
165 .cursorDrag = CreateIconIndirect( pi )
166 DeleteObject( pi.hbmMask )
167 DeleteObject( pi.hbmColor )
168
169 .FntM.Default()
170
171
172 /* fornum i=0, 64
173 {
174 fornum j=0, 32
175 {
176 //print ( "\(hex2strl( GetPixel( sdc, i, j) )) " )
177 switch GetPixel( sdc, j, i)
178 {
179 case 0 : print( "0" )
180 case 0xFFFFFF : print( "X" )
181 case 0xFFFFFFFF: print( "F" )
182 default : print( "." )
183 }
184
185 }
186 print( "\n" )
187 }*/
188
189
190 return this
191 }
192
193 method vApp.SettingChange()
194 {
195 loadthemefuncs()
196 themeinit()
197 .StyleM.Update()
198 return
199 }
200
201 method vApp.delete()
202 {
203 //print( "app delete\n" )
204 }
205
206 method Image vComp.GetImage( ustr pImage/*, uint disabled*/ )
207 {
208 ifdef $DESIGNING {
209 uint curcomp as this
210 while !curcomp.p_designing && &curcomp.Owner
211 {
212 curcomp as curcomp.Owner
213 if &curcomp == &App || &curcomp == &DesApp: break
214 }
215 if ( curcomp.p_designing )
216 {
217 return DesApp.ImgM.GetImage( pImage )
218 }
219 }
220 return App.ImgM.GetImage( pImage )
221 }
222 /*
223 method Image vComp.GetImage( ustr pImage )
224 {
225 return GetImage( pImage, 0 )
226 }*/
227
228 method ImageList vComp.GetImageList( ustr pImage, uint ptrNumIml )
229 {
230 ifdef $DESIGNING {
231 if ( this.p_designing ) {
232 return DesApp.ImgM.GetImageList( pImage, ptrNumIml )
233
234 }
235 }
236 return App.ImgM.GetImageList( pImage, ptrNumIml )
237 }
238
239 func init_vApp <entry>()
240 {
241 regcomp( vApp, "vApp", vComp, $vComp_last,
242 %{ %{$mInsert, vApp_mInsert}
243 },
244 0->collection )
245 App.pTypeDef = &gettypedef( App.pTypeId )
246 //InitCommonControls()
247 INITCOMMONCONTROLSEX iccex
248 iccex.dwICC = 0xFF//ICC_WIN95_CLASSES;
249 iccex.dwSize = sizeof(INITCOMMONCONTROLSEX)
250 InitCommonControlsEx( iccex )
251 }