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.picture 29.01.08 0.0.A.
11 *
12 * Author: Alexander Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15 /* Компонента vPicture, порождена от vCtrl
16 События
17 */
18 type vPicture <inherit = vCtrl>
19 {
20 //Hidden fields
21 ustr pImage
22 uint ptrImage
23 /*locustr pCaption
24 uint pTextHorzAlign
25 uint pTextVertAlign*/
26 uint pAutoSize
27 uint pStretch
28 //uint pBitMap
29 /*uint pMultiLine*/
30 }
31
32 define <export>{
33 /*//Типы выравнивания текста
34 talhLeft = 0
35 talhCenter = 1
36 talhRight = 2
37 talvTop = 0
38 talvCenter = 1*/
39 }
40
41 /*------------------------------------------------------------------------------
42 Internal Methods
43 */
44 /* Метод iUpdateCaption
45 Связывает заголовок панели с визуальным отображением
46 */
47
48
49 /* Метод iUpdateSize
50 Автоматическое определение ширины/высоты текста
51 */
52 method vPicture.iUpdateSize
53 {
54 if .pAutoSize && !.pStretch && .ptrImage
55 {
56 BITMAP b
57 //uint res = GetObject( .ptrImage, sizeof(BITMAP), &b )
58 .Width = .ptrImage->Image.Width//b.bmWidth
59 .Height = .ptrImage->Image.Height//b.bmHeight
60 }
61 }
62
63 method vPicture.iUpdateImage()
64 {
65 .ptrImage = &this.GetImage( .pImage )
66 /*uint im as .GetImage( .pImage )
67 if &im
68 {
69 .pBitMap = im.hImage
70 }
71 else
72 {
73 .pBitMap = 0
74 }*/
75 //.iUpdateImage()
76 InvalidateRect( this.hwnd, 0->RECT, 1 )
77 }
78
79 /*------------------------------------------------------------------------------
80 Properties
81 */
82 /* Свойство str vPicture.Image - Get Set
83 Усотанавливает или получает картинку
84 */
85 property ustr vPicture.Image <result>
86 {
87 result = this.pImage
88 }
89
90 property vPicture.Image( ustr val )
91 {
92 if val != this.pImage
93 {
94 this.pImage = val
95 .iUpdateImage()
96 }
97 //.iUpdateImage()
98 /*
99 this.pCaption.Value = val
100 .iUpdateCaption()
101 .iUpdateSize()
102 }*/
103 }
104
105 /* Свойство str vLabel.AutoSize - Get Set
106 Усотанавливает или получает автоматическое изменение размеров
107 */
108 property uint vPicture.AutoSize
109 {
110 return this.pAutoSize
111 }
112
113 property vPicture.AutoSize( uint val )
114 {
115 if val != this.AutoSize
116 {
117 this.pAutoSize = val
118 .iUpdateSize()
119 }
120 }
121
122 /* Свойство str vLabel.Stretch - Get Set
123 Усотанавливает или получает автоматическое изменение размеров
124 */
125 property uint vPicture.Stretch
126 {
127 return this.pStretch
128 }
129
130 property vPicture.Stretch( uint val )
131 {
132 if val != this.Stretch
133 {
134 this.pStretch = val
135 .SetStyle( $SS_CENTERIMAGE | $SS_REALSIZECONTROL, 0 )
136 if !this.pStretch
137 {
138 .SetStyle( $SS_CENTERIMAGE | $SS_REALSIZECONTROL, 1 )
139 }
140 }
141 }
142
143 /*------------------------------------------------------------------------------
144 Virtual methods
145 */
146 /*Виртуальный метод vPicture vPicture.mCreateWin - Создание окна
147 */
148 method vPicture vPicture.mCreateWin <alias=vPicture_mCreateWin>()
149 {
150 uint style = /*$SS_ENDELLIPSIS | $SS_NOTIFY |*/ $WS_CHILD | $WS_VISIBLE | $WS_CLIPSIBLINGS //| $WS_OVERLAPPED
151 style |= $SS_ICON/*$SS_BITMAP*/ | $SS_CENTERIMAGE | $SS_REALSIZECONTROL //| $SS_RIGHTJUST
152 .CreateWin( "STATIC".ustr(), 0, style )
153 this->vCtrl.mCreateWin()
154 //.pBitMap = LoadBitmap( 0, 32754 )
155 //.pBitMap = LoadImage( 0, "k:\\bitmap2.bmp".ustr().ptr(), $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE | $LR_DEFAULTSIZE/*| $LR_LOADTRANSPARENT*/ )
156 //.pBitMap = LoadBitmap( 0, 32754 )
157 //.pBitMap = LoadImage( 0, "k:\\h_c.ico".ustr().ptr(), $IMAGE_ICON, 0, 0, $LR_LOADFROMFILE | $LR_DEFAULTSIZE/*| $LR_LOADTRANSPARENT*/ )
158 //.iUpdateImage()
159 //print( "bitmap \(.pBitMap)\n" )
160
161 /*.iUpdateAlignment()
162 .iUpdateSize()*/
163 return this
164 }
165
166 method uint vPicture.wmpaint <alias=vPicture_wmpaint>( winmsg wmsg )
167 {
168 uint hdc
169 PAINTSTRUCT lp
170
171 //UpdateWindow( this.Owner->vCtrl.hwnd )
172 //.WinMsg( this.Owner->vCtrl.hwnd, $WM_ERASEBKGND, hdc )
173 hdc = BeginPaint( this.hwnd, lp )
174 uint hbrush = this.Owner->vCtrl.WinMsg( $WM_CTLCOLORSTATIC, hdc, this.hwnd )
175 if !hbrush: hbrush = GetSysColorBrush( $COLOR_BTNFACE )
176 if !isThemed
177 {
178 RECT r
179 r.left = 0
180 r.top = 0
181 r.right = this.loc.width
182 r.bottom = this.loc.height
183 POINT p
184 FillRect( hdc, r, hbrush) //GetCurrentObject( hdc, $OBJ_BRUSH ) )//$COLOR_BTNFACE + 1 )
185 }
186 /*else
187 {
188 pDrawThemeParentBackground->stdcall( this.hwnd, hdc, 0 );
189 }*/
190 SetBkMode( hdc, $TRANSPARENT )
191 //DrawIcon( hdc, 5 , 5 , .pBitMap )
192 uint width, height
193 if this.pStretch
194 {
195 width = this.Width
196 height = this.Height
197 }
198 if .ptrImage
199 {
200 DrawIconEx( hdc, 0, 0, ?( .Enabled, .ptrImage->Image.hImage, .ptrImage->Image.hDisImage ), width, height, 0, 0, $DI_COMPAT | $DI_NORMAL )
201 }
202 /*EndPaint( this.hwnd, lp )
203 UpdateWindow( this.Owner->vCtrl.hwnd )*/
204 //InvalidateRect( this.hwnd, 0->RECT, 0 )
205 //ValidateRect( this.hwnd, 0->RECT )
206
207 wmsg.flags = 1
208 return 0
209 }
210
211 /*Виртуальный метод uint vPicture.mLangChanged - Изменение текущего языка
212 */
213 method vPicture.mLangChanged <alias=vPicture_mLangChanged>()
214 {
215 .iUpdateImage()
216 }
217
218 /*------------------------------------------------------------------------------
219 Registration
220 */
221 method vPicture vPicture.init( )
222 {
223 this.pTypeId = vPicture
224 this.flgRePaint = 1
225 this.loc.width = 100
226 this.loc.height = 100
227 this.flgXPStyle = 1
228 return this
229 }
230
231 func init_vPicture <entry>()
232 {
233 regcomp( vPicture, "vPicture", vCtrl, $vCtrl_last,
234 %{ %{$mCreateWin, vPicture_mCreateWin },
235 %{$mLangChanged, vPicture_mLangChanged }
236 },
237 %{ %{$WM_PAINT, vPicture_wmpaint } } )
238 //0->collection )
239
240 ifdef $DESIGNING {
241 cm.AddComp( vPicture, 1, "Windows", "picture" )
242
243 cm.AddProps( vPicture, %{
244 "Image" , ustr, 0,
245 /*"TextHorzAlign", uint, 0,
246 "TextVertAlign", uint, 0,*/
247 "AutoSize" , uint, $PROP_LOADAFTERCHILD,
248 "Stretch" , uint, 0
249 //"MultiLine" , uint, 0*/
250 })
251
252 /* cm.AddPropVals( vPicture, "TextHorzAlign", %{
253 "talhLeft" , $talhLeft,
254 "talhCenter" , $talhCenter,
255 "talhRight" , $talhRight } )
256
257 cm.AddPropVals( vPicture, "TextVertAlign", %{
258 "talvTop" , $talvTop,
259 "talvCenter" , $talvCenter } )*/
260 }
261 }