EnglishРусский  

   ..

   addustr.g

   app.g

   btn.g

   btnpic.g

   comp.g

   ctrl.g

   ctrlci.g

   dialogs.g

   dlgbtns.g

   edit.g

   events.g

   fonts.g

   form.g

   gray.g

   grey.g

   header.g

   images.g

   label.g

   labeled.g

   locustr.g

   menu.g

   panel.g

   picture.g

   styles.g

   tab.g

   tabitem.g

   tabpage.g

   timer.g

   toolbar.g

   tray.g

   url.g

   vis.g

   viswin.g

Данный проект закрыт! Создан новый скриптовый язык с тем же именем. Всё доступно на GitHub.
Также попробуйте нашу open source кроссплатформенную программу для создания и управления скриптами.

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

source\lib\vis\picture.g
  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 
 16 type olepic
 17 {
 18    uint ppv
 19    uint handle
 20    uint width
 21    uint height
 22    uint pixwidth
 23    uint pixheight
 24 }
 25 
 26 define 
 27 {
 28    Release = 8
 29    get_Handle = 12
 30    get_Width = 24
 31    get_Height = 28
 32    Render = 32
 33 }
 34 
 35 method olepic.clear()
 36 {
 37    if .ppv 
 38    {
 39       ((.ppv->uint + $Release )->uint)->stdcall(.ppv)
 40       .ppv = 0
 41    }
 42    .handle = 0
 43    .width = 0
 44    .height = 0
 45 }
 46 
 47 method uint olepic.load( ustr filename )
 48 {
 49    .clear()
 50    OleLoadPicturePath( filename.ptr(), 0, 0, 0, IID_IPicture.ptr(), &.ppv )
 51    if .ppv 
 52    {
 53       ((.ppv->uint + $get_Handle)->uint)->stdcall(.ppv, &.handle)
 54       ((.ppv->uint + $get_Width)->uint)->stdcall(.ppv, &.width) 
 55       ((.ppv->uint + $get_Height)->uint)->stdcall(.ppv, &.height)
 56       uint hdc = CreateCompatibleDC(GetDC(0))
 57       .pixheight = .height * GetDeviceCaps(hdc, 88) /2540
 58       .pixwidth = .width * GetDeviceCaps(hdc, 90) /2540
 59       DeleteDC( hdc )  
 60       return 1
 61    }  
 62    return 0  
 63 }
 64 
 65 method uint olepic.render( uint hdc, uint x, uint y, uint cx, uint cy )
 66 {
 67    if .ppv 
 68    {
 69       return ((.ppv->uint + $Render)->uint)->stdcall( 
 70             .ppv, hdc, x, y, cx, cy, 0, .height, .width, -.height )
 71    }
 72    return 0    
 73 }
 74 
 75 method olepic.delete()
 76 {
 77    .clear()
 78 }
 79 
 80 /* Компонента vPicture, порождена от vCtrl
 81 События   
 82 */
 83 type vPicture <inherit = vCtrl>
 84 {
 85 //Hidden fields
 86    ustr     pImage
 87    uint     ptrImage      
 88    /*locustr  pCaption
 89    uint     pTextHorzAlign
 90    uint     pTextVertAlign*/
 91    uint     pAutoSize
 92    uint     pStretch
 93    
 94    ustr     pImageFile
 95    uint     olepicture
 96    //uint     olewidth
 97    //uint     oleheight
 98    //uint     pBitMap
 99    /*uint     pMultiLine*/
100 }
101 
102 define <export>{
103 /*//Типы выравнивания текста
104    talhLeft       = 0
105    talhCenter     = 1   
106    talhRight      = 2
107    talvTop        = 0
108    talvCenter     = 1*/   
109 }
110 
111 /*------------------------------------------------------------------------------
112    Internal Methods
113 */
114 /* Метод iUpdateCaption
115 Связывает заголовок панели с визуальным отображением
116 */
117 
118 
119 /* Метод iUpdateSize
120 Автоматическое определение ширины/высоты текста
121 */
122 method vPicture.iUpdateSize
123 {
124    if .pAutoSize && !.pStretch && .ptrImage
125    {
126       BITMAP b       
127       //uint res = GetObject( .ptrImage, sizeof(BITMAP), &b )
128       .Width = .ptrImage->Image.Width//b.bmWidth
129       .Height = .ptrImage->Image.Height//b.bmHeight            
130    }
131 }
132 
133 method vPicture.iUpdateImage()
134 {
135    if .olepicture 
136    {
137       .olepicture->olepic.clear()
138    }
139    if *.pImageFile
140    {  
141       if !.olepicture: .olepicture = new( olepic )
142       .olepicture->olepic.load( .pImageFile )
143       //OleLoadPicturePath( .pImageFile.ptr(), 0, 0, 0, IID_IPicture.ptr(), &.olepicture )
144       //if .olepicture
145       //{         
146          //((.olepicture->uint + 52)->uint)->stdcall(.olepicture, 1 )
147          //((.olepicture->uint + 24)->uint)->stdcall(.olepicture, &.olewidth)
148          //((.olepicture->uint + 28)->uint)->stdcall(.olepicture, &.oleheight)
149          //BITMAP bmpinfo
150          //uint handle
151          //((.olepicture->uint + 12)->uint)->stdcall(.olepicture, &handle)         
152          //GetObject(handle,sizeof(BITMAP),&bmpinfo)
153          //.olewidth = bmpinfo.bmWidth
154          //.oleheight = bmpinfo.bmHeight         
155          //DeleteObject( handle )
156       //}
157    }
158    else
159    {
160       .ptrImage = &this.GetImage( .pImage )
161    }
162    /*uint im as .GetImage( .pImage )
163    if &im 
164    {
165       .pBitMap = im.hImage
166    }
167    else
168    {
169       .pBitMap = 0
170    }*/
171    //.iUpdateImage()
172    .Invalidate()
173 }
174 
175 method vPicture.delete( )
176 {
177    if .olepicture : destroy( .olepicture )
178 }
179 
180 /*------------------------------------------------------------------------------
181    Properties
182 */
183 /* Свойство str vPicture.Image - Get Set
184 Усотанавливает или получает картинку
185 */
186 property ustr vPicture.Image <result>
187 {
188    result = this.pImage
189 }
190 
191 property vPicture.Image( ustr val )
192 {
193    if val != this.pImage
194    { 
195       this.pImage = val
196       .iUpdateImage()      
197    }
198    //.iUpdateImage()
199  /*        
200       this.pCaption.Value = val
201       .iUpdateCaption()
202       .iUpdateSize()      
203    }*/ 
204 }
205 
206 /* Свойство str vPicture.ImageFile - Get Set
207 Усотанавливает или получает файл картинку
208 */
209 property ustr vPicture.ImageFile <result>
210 {
211    result = this.pImageFile
212 }
213 
214 property vPicture.ImageFile( ustr val )
215 {
216    if val != this.pImage
217    { 
218       this.pImageFile = val
219       .iUpdateImage()      
220    }
221    //.iUpdateImage()
222  /*        
223       this.pCaption.Value = val
224       .iUpdateCaption()
225       .iUpdateSize()      
226    }*/ 
227 }
228 
229 
230 /* Свойство str vLabel.AutoSize - Get Set
231 Усотанавливает или получает автоматическое изменение размеров
232 */
233 property uint vPicture.AutoSize 
234 {
235    return this.pAutoSize
236 }
237 
238 property vPicture.AutoSize( uint val )
239 {
240    if val != this.AutoSize
241    { 
242       this.pAutoSize = val
243       .iUpdateSize()              
244    } 
245 }
246 
247 /* Свойство str vLabel.Stretch - Get Set
248 Усотанавливает или получает автоматическое изменение размеров
249 */
250 property uint vPicture.Stretch 
251 {
252    return this.pStretch
253 }
254 
255 property vPicture.Stretch( uint val )
256 {
257    if val != this.Stretch
258    { 
259       this.pStretch = val
260       .SetStyle( $SS_CENTERIMAGE | $SS_REALSIZECONTROL, 0 )
261       if !this.pStretch
262       {
263         .SetStyle( $SS_CENTERIMAGE | $SS_REALSIZECONTROL, 1 )
264       }                    
265    } 
266 }
267 
268 /*------------------------------------------------------------------------------
269    Virtual methods
270 */
271 /*Виртуальный метод vPicture vPicture.mCreateWin - Создание окна
272 */
273 method vPicture vPicture.mCreateWin <alias=vPicture_mCreateWin>()
274 {
275    uint style = /*$SS_ENDELLIPSIS | $SS_NOTIFY |*/ $WS_CHILD | $WS_CLIPSIBLINGS //| $WS_OVERLAPPED
276    style |= $SS_ICON/*$SS_BITMAP*/ | $SS_CENTERIMAGE | $SS_REALSIZECONTROL //| $SS_RIGHTJUST
277    .CreateWin( "STATIC".ustr(), 0, style )
278    this->vCtrl.mCreateWin()
279    //.pBitMap = LoadBitmap( 0,  32754 )
280    //.pBitMap = LoadImage( 0, "k:\\bitmap2.bmp".ustr().ptr(), $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE | $LR_DEFAULTSIZE/*| $LR_LOADTRANSPARENT*/ )
281 //.pBitMap = LoadBitmap( 0,  32754 )
282    //.pBitMap = LoadImage( 0, "k:\\h_c.ico".ustr().ptr(), $IMAGE_ICON, 0, 0, $LR_LOADFROMFILE | $LR_DEFAULTSIZE/*| $LR_LOADTRANSPARENT*/ )
283    //.iUpdateImage()
284    //print( "bitmap \(.pBitMap)\n" )
285     
286    /*.iUpdateAlignment() 
287    .iUpdateSize()*/
288    return this
289 }
290 
291 
292 method uint vPicture.wmpaint <alias=vPicture_wmpaint>( winmsg wmsg )
293 {
294       uint hdc
295    	PAINTSTRUCT lp
296       
297       //UpdateWindow( this.Owner->vCtrl.hwnd )
298       //.WinMsg( this.Owner->vCtrl.hwnd, $WM_ERASEBKGND, hdc )   
299       hdc = BeginPaint( this.hwnd, lp )
300       uint hbrush = this.Owner->vCtrl.WinMsg( $WM_CTLCOLORSTATIC, hdc, this.hwnd )
301       if !hbrush: hbrush = GetSysColorBrush( $COLOR_BTNFACE ) 
302       if !isThemed 
303       {         
304          RECT r
305          r.left = 0
306          r.top = 0
307          r.right = this.loc.width
308          r.bottom = this.loc.height   
309          POINT p           
310          FillRect( hdc, r, hbrush) //GetCurrentObject( hdc, $OBJ_BRUSH ) )//$COLOR_BTNFACE + 1 )
311       }
312       /*else
313       {
314          pDrawThemeParentBackground->stdcall( this.hwnd, hdc, 0 );         
315       }*/
316       SetBkMode( hdc, $TRANSPARENT )
317       //DrawIcon( hdc, 5 , 5 , .pBitMap )
318       uint width, height
319       if this.pStretch
320       {
321          width = this.Width
322          height = this.Height 
323       }
324       if .olepicture && .olepicture->olepic.ppv
325       {         
326          uint w = this.Width
327          uint h = this.Height
328          uint ow = .olepicture->olepic.pixwidth
329          uint oh = .olepicture->olepic.pixheight 
330          if  ow <= w && oh <= h  
331          {
332             w = ow
333             h = oh
334          }
335          else
336          {
337             double ph, pw
338             pw = double( ow )/double( w )
339             ph = double( oh )/double( h )
340             if pw > ph
341             {
342                h = uint( double( oh )/pw )
343             }
344             else
345             {
346                w = uint( double( ow )/ph )
347             }
348          }
349          
350          .olepicture->olepic.render( hdc, ( this.Width - w ) >> 1, ( this.Height - h ) >> 1, w, h )     
351       }
352       elif .ptrImage
353       {
354          DrawIconEx( hdc, 0, 0, ?( .Enabled, .ptrImage->Image.hImage, .ptrImage->Image.hDisImage ), width, height, 0, 0, $DI_COMPAT | $DI_NORMAL )
355       }                           
356    	EndPaint( this.hwnd, lp )
357       /*UpdateWindow( this.Owner->vCtrl.hwnd )*/
358       
359       wmsg.flags = 1 
360       return 0
361 }
362 
363 /*Виртуальный метод uint vPicture.mLangChanged - Изменение текущего языка
364 */
365 method vPicture.mLangChanged <alias=vPicture_mLangChanged>()
366 {   
367    .iUpdateImage()  
368 }
369 
370 /*------------------------------------------------------------------------------
371    Registration
372 */
373 method vPicture vPicture.init( )
374 {
375    this.pTypeId = vPicture
376    this.flgRePaint = 1
377    this.loc.width = 100
378    this.loc.height = 100
379    this.flgXPStyle = 1
380    return this 
381 }  
382 
383 func init_vPicture <entry>()
384 {  
385    regcomp( vPicture, "vPicture", vCtrl, $vCtrl_last,
386       %{ %{$mCreateWin, vPicture_mCreateWin },         
387          %{$mLangChanged, vPicture_mLangChanged }
388       },
389       %{ %{$WM_PAINT, vPicture_wmpaint } } )
390       //0->collection )
391 
392 ifdef $DESIGNING {      
393    cm.AddComp( vPicture, 1, "Windows", "picture" )
394    
395    cm.AddProps( vPicture, %{
396 "Image"      , ustr, 0,
397 "ImageFile"  , ustr, 0,
398 /*"TextHorzAlign", uint, 0,
399 "TextVertAlign", uint, 0,*/
400 "AutoSize"     , uint, $PROP_LOADAFTERCHILD,
401 "Stretch"      , uint, 0
402 //"MultiLine"    , uint, 0*/
403    })            
404 
405 /*   cm.AddPropVals( vPicture, "TextHorzAlign", %{           
406 "talhLeft"        ,  $talhLeft,      
407 "talhCenter"      ,  $talhCenter,    
408 "talhRight"       ,  $talhRight } )
409 
410    cm.AddPropVals( vPicture, "TextVertAlign", %{           
411 "talvTop"         ,  $talvTop,       
412 "talvCenter"      ,  $talvCenter } )*/
413 }
414 }
Редактировать