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

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

source\lib\vis\header.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.headerpic 22.07.08 0.0.A.
 11 *
 12 * Author: Alexander Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 
 16 include { "ctrlci.g" }
 17 
 18 /* Компонента vHeader, порождена от vCtrl
 19 */
 20 type vHeader <inherit = vCtrlCI>
 21 {
 22 //Hidden Fields   
 23 //   uint     pLayout  
 24 //   uint     pContVertAlign
 25 //   uint     pContHorzAlign   
 26 //   uint     pIndent
 27 //   uint     pSpacing
 28 //   uint     pWordWrap
 29 //   uint     pAutoSize
 30      
 31 //   uint     imgleft 
 32 //   uint     imgtop
 33 //   uint     txtleft
 34 //   uint     txttop   
 35 //Events      
 36 }
 37 
 38 
 39 
 40 /*define <export>{
 41 //Расположение картинки и текста
 42    lPicLeft     = 0 
 43    lPicTop      = 1
 44    lPicRight    = 2
 45    lPicBottom   = 3
 46    lPicBack     = 4
 47    lPicSimple   = 5
 48    
 49    ptLeft       = 0
 50    ptCenter     = 1   
 51    ptRight      = 2
 52    
 53    ptTop        = 0
 54    ptVertCenter = 1
 55    ptBottom     = 2         
 56 }*/
 57 
 58 /*------------------------------------------------------------------------------
 59    Internal Methods
 60 */
 61 /*Внутренний метод vHeader.iUpdateLayout 
 62 Связывает взаимное расположение текста и картинки с визуальным отображением
 63 */
 64 /*method vHeader.iUpdateLayout
 65 {
 66    int pw, ph, pt, pl
 67    int tw, th, tt, tl
 68    int cw, ch
 69    int hoff, voff
 70    int maxw, maxh
 71    
 72    int spc = .pSpacing
 73    int off = .pIndent
 74    
 75    RECT r
 76    uint dc = GetDC( 0 )
 77    
 78    if .ptrImage
 79    {   
 80       pw = .ptrImage->Image.Width
 81       ph = .ptrImage->Image.Height                  
 82    }
 83    hoff = voff = off * 2
 84    if pw && ph
 85    {
 86       switch .pLayout 
 87       {
 88          case $lPicTop, $lPicBottom:  voff += ph + spc    
 89          case $lPicBack: 
 90          default : hoff += pw + spc
 91       }
 92    }
 93                                  
 94    r.right = maxw = max( .clloc.width - hoff, 10 )
 95    r.bottom = maxh = max( .clloc.height - voff, 10 )
 96    
 97    SelectObject( dc, this.WinMsg( $WM_GETFONT ) )
 98    DrawText( dc, this.pLangCaption.ptr(), *this.pLangCaption, r, 
 99          $DT_TOP | $DT_LEFT | $DT_CALCRECT | ?( .pWordWrap, $DT_WORDBREAK, 0 ) |
100          $DT_NOPREFIX )
101    
102    ReleaseDC( 0, dc )
103    tw = r.right
104    th = r.bottom
105    
106    switch .pLayout
107    {
108       case $lPicTop
109       {
110          pt = 0
111          if ph : tt = ph + spc
112          cw = min( max( tw, pw ), maxw )
113          ch = tt + th 
114          pl = (cw - pw) / 2
115          tl = (cw - tw) / 2        
116       }
117       case $lPicBottom
118       {         
119          tt = 0
120          if th : pt = th + spc
121          cw = min( max( tw, pw ), maxw )
122          ch = pt + ph
123          pl = (cw - pw) / 2
124          tl = (cw - tw) / 2          
125       }
126       case $lPicLeft
127       {
128          pl = 0 
129          if pw : tl = pw + spc
130          cw = tl + tw 
131          ch = min( max( th, ph ), maxh )  
132          tt = (ch - th) / 2
133          pt = (ch - ph) / 2
134       }
135       case $lPicRight
136       {  
137          tl = 0 
138          if tw : pl = tw + spc         
139          cw = pl + pw
140          ch = min( max( th, ph ), maxh )
141          tt = (ch - th) / 2
142          pt = (ch - ph) / 2      
143       }          
144       case $lPicBack
145       {         
146          cw = min( max( tw, pw ), maxw )
147          ch = min( max( th, ph ), maxh )
148          pl = (cw - pw) / 2
149          pt = (ch - ph) / 2
150          tl = (cw - tw) / 2
151          tt = (ch - th) / 2         
152       }
153       default
154       {   
155          pl = 0
156          if pw : tl = pw + spc
157          pt = 0 
158          tt = 0
159          cw = tl + tw
160          ch = max( th, ph )                  
161       }
162    }
163    
164    if .pAutoSize
165    {
166       .Width = cw + 2 * off //tw + hoff
167       .Height = ch + 2 * off //th + voff
168    }
169    switch .pContHorzAlign
170    {
171       case $ptRight : hoff = .clloc.width - cw - off
172       case $ptCenter : hoff = ( .clloc.width - cw )/2
173       default : hoff = off 
174    }
175    switch .pContVertAlign
176    {
177       case $ptBottom : voff = .clloc.height - ch - off
178       case $ptVertCenter : voff = ( .clloc.height - ch )/2
179       default : voff = off
180    }   
181    hoff = max( hoff, off )
182    voff = max( voff, off )
183    //print( "tw \(tw) \(th) \(pw) \(ph) \n" )
184    //print( "i \(pl) \(pt) \(tl) \(tt ) \(hoff ) \(voff)\n" )
185    .imgleft = max( pl + hoff, 0 )
186    .imgtop = max( pt + voff, 0 )
187    .txtleft = max( tl + hoff, 0 )
188    .txttop = max( tt + voff, 0 )
189    
190    .Invalidate()  
191 }*/
192 
193 
194 /*------------------------------------------------------------------------------
195    Properties
196 */
197 /* Свойство str vHeader.Layout - Get Set
198 Усотанавливает или получает взаимное расположение картинки текста
199 */
200 property uint vHeader.Layout
201 {
202    //return this.pLayout
203    return .pPicText.Layout
204 }
205 
206 property vHeader.Layout( uint val )
207 {
208    .pPicText.Layout = val
209    /*if val != this.pLayout
210    {
211       this.pLayout = val
212       .iUpdateLayout()
213    }*/
214 }
215 
216 /* Свойство str vHeader.ContHorzAlign - Get Set
217 Устанавливает или получает расположение содежимого по горизонтали
218 */
219 property uint vHeader.ContHorzAlign 
220 {
221    //return this.pContHorzAlign
222    return .pPicText.ContHorzAlign
223 }
224 
225 property vHeader.ContHorzAlign( uint val )
226 {
227 /*   if val != .pContHorzAlign
228    { 
229       .pContHorzAlign = val
230       .iUpdateLayout()
231    }*/
232    .pPicText.ContHorzAlign = val 
233 }
234 
235 /* Свойство str vHeader.ContVertAlign - Get Set
236 Устанавливает или получает расположение содежимого по вертикали
237 */
238 property uint vHeader.ContVertAlign 
239 {
240    //return this.pContVertAlign
241    return .pPicText.ContVertAlign
242 }
243 
244 property vHeader.ContVertAlign( uint val )
245 {
246    /*if val != .pContVertAlign
247    { 
248       .pContVertAlign = val
249       .iUpdateLayout()
250    } */
251    .pPicText.ContVertAlign = val
252 }
253 
254 /* Свойство str vHeader.Indent - Get Set
255 Устанавливает или получает отступ от края
256 */
257 property uint vHeader.Indent
258 {
259 //   return this.pIndent
260    return .pPicText.Indent
261 }
262 
263 property vHeader.Indent( uint val )
264 {
265    /*if val != .pIndent
266    { 
267       .pIndent = max( min( val, 25 ), 0 )
268       .iUpdateLayout()
269    } */
270    .pPicText.Indent = val
271 }
272 
273 /* Свойство str vHeader.Spacing - Get Set
274 Устанавливает или получает отступ между картинкой и текстом
275 */
276 property uint vHeader.Spacing 
277 {
278    //return this.pSpacing
279    return .pPicText.Spacing 
280 }
281 
282 property vHeader.Spacing( uint val )
283 {
284    /*if val != .pSpacing 
285    { 
286       .pSpacing = max( min( val, 25 ), 0 )
287       .iUpdateLayout()
288    } */
289    .pPicText.Spacing = val
290 }
291 
292 
293 /* Свойство str vHeader.WordWrap - Get Set
294 Режим переноса по словам
295 */
296 property uint vHeader.WordWrap
297 {
298    //return this.pWordWrap
299    return .pPicText.WordWrap
300 }
301 
302 property vHeader.WordWrap( uint val )
303 {
304    /*if val != .pWordWrap
305    { 
306       .pWordWrap = val
307       .iUpdateLayout()
308    } */
309    .pPicText.WordWrap = val
310 }
311 
312 /* Свойство str vHeader.AutoSize - Get Set
313 Автоматическое изменение размеров
314 */
315 property uint vHeader.AutoSize
316 {
317    //return this.pAutoSize
318    return .pPicText.AutoSize
319 }
320 
321 property vHeader.AutoSize( uint val )
322 {
323    /*if val != .pAutoSize
324    { 
325       .pAutoSize = val
326       .iUpdateLayout()
327    } */
328    .pPicText.AutoSize = val
329 }
330  
331 /*------------------------------------------------------------------------------
332    Windows messages 
333 */
334 /*Метод обработки сообщений uint vPanel.wmpaint 
335 Отрисовка заголовка 
336 */
337 method uint vHeader.wmpaint <alias=vHeader_wmpaint>(winmsg wmsg)
338 {  
339    uint hdc
340    PAINTSTRUCT lp
341    RECT r
342    uint hbrush
343       
344    hdc = BeginPaint( this.hwnd, lp )   
345    winmsg msg
346    msg.wpar = hdc
347    SelectObject( hdc, .pPicText.hFont )//this.WinMsg( $WM_GETFONT ) )      
348    hbrush = .Virtual( $mClColor, &msg )
349    
350    if hbrush || !isThemed
351    {
352       if !hbrush : hbrush = $COLOR_BTNFACE + 1   
353       r.left = 0
354       r.top = 0
355       r.right = this.loc.width
356       r.bottom = this.loc.height   
357       FillRect( hdc, r, hbrush )
358    } 
359    
360    .pPicText.Draw( hdc, 0, 0 )
361    /*SetBkMode( hdc, $TRANSPARENT )  
362    if .ptrImage
363    {  
364       DrawIconEx( hdc, .imgleft, .imgtop , 
365          ?( .Enabled, .ptrImage->Image.hImage, .ptrImage->Image.hDisImage ),
366          .ptrImage->Image.Width, .ptrImage->Image.Height, 0, 0,
367          $DI_COMPAT | $DI_NORMAL )      
368    }
369    
370    r.left = .txtleft 
371    r.top = .txttop 
372    r.right = .clloc.width 
373    r.bottom = .clloc.height     
374    if !.Enabled
375    {
376       SetTextColor( hdc, GetSysColor(16) )
377    }
378    DrawText(hdc, .pLangCaption.ptr(), *.pLangCaption, r, $DT_TOP | $DT_LEFT | 
379                ?( .pWordWrap, $DT_WORDBREAK, 0 ) | $DT_NOPREFIX )
380    */                                                
381    EndPaint( this.hwnd, lp )                        
382    
383 	return 0	   
384 }
385 
386 /*------------------------------------------------------------------------------
387    Virtual Methods
388 */
389 /*Виртуальный метод vHeader vHeader.mCreateWin - Создание окна
390 */
391 method vHeader vHeader.mCreateWin <alias=vHeader_mCreateWin>()
392 {
393    .CreateWin( "STATIC".ustr(), 0, 
394          $SS_NOTIFY | $WS_CHILD | $WS_CLIPCHILDREN | 
395          $WS_CLIPSIBLINGS | $WS_OVERLAPPED )   
396    this->vCtrl.mCreateWin()   
397    
398    //.pPicText.hFont = .WinMsg( $WM_GETFONT )
399    //this.pPicText.Ctrl = this
400    //.iUpdateLayout()                                                        
401    return this
402 }
403 
404 
405 //Виртуальный метод vHeader.mSetCaption - Обновить заголовок
406 
407 /*method vHeader.mSetCaption <alias=vHeader_mSetCaption>( ustr caption )
408 {
409    .iUpdateLayout()  
410 }
411 
412 //Виртуальный метод vHeader.mSetImage - Обновить картинку
413 
414 method vHeader.mSetImage <alias=vHeader_mSetImage>( Image img )
415 {
416    .iUpdateLayout()     
417 }*/
418 
419 /*Виртуальный метод vHeader.mPosChanged - Изменились размеры
420 */
421 method vHeader.mPosChanged <alias=vHeader_mPosChanged>(evparEvent ev)
422 {
423    this->vCtrl.mPosChanged(ev)
424    .pPicText.Width = .clloc.width
425    .pPicText.Height = .clloc.height
426    /*if !.pAutoSize
427    {
428       .iUpdateLayout()
429    }*/
430 }
431 
432 /*Виртуальный метод vHeader.mFontChanged - Изменился шрифт
433 */
434 method vHeader.mFontChanged <alias=vHeader_mFontChanged>()
435 {
436    this->vCtrl.mFontChanged()
437    .pPicText.FontChanged()   
438 }
439 
440 /*------------------------------------------------------------------------------
441    Registration
442 */
443 /*Системный метод vHeader vHeader.init - Инициализация объекта
444 */   
445 method vHeader vHeader.init( )
446 {   
447    this.pTypeId = vHeader   
448    this.loc.width = 100
449    this.loc.height = 25
450    this.flgXPStyle = 1 
451    
452    this.pPicText.Ctrl = this
453 /*   this.pPicText.pIndent = 5
454    this.pPicText.pSpacing = 5*/
455    return this 
456 } 
457 
458 func init_vHeader <entry>()
459 {  
460    regcomp( vHeader, "vHeader", vCtrlCI, $vCtrl_last, 
461       %{ %{$mCreateWin,      vHeader_mCreateWin },
462          %{$mPosChanged,     vHeader_mPosChanged },
463          %{$mFontChanged,     vHeader_mFontChanged }          
464          //%{$mSetCaption,     vHeader_mSetCaption},
465          //%{$mSetImage  ,     vHeader_mSetImage}
466       }, 
467       %{
468          %{$WM_PAINT, vHeader_wmpaint } } )
469 
470             
471 ifdef $DESIGNING {
472    cm.AddComp( vHeader, 1, "Additional", "header" )   
473    
474    cm.AddProps( vHeader, %{ 
475 "Image"   , ustr, 0,
476 "Caption" , ustr, 0,
477 "Layout"  , uint, 0,
478 "ContVertAlign", uint, 0,
479 "ContHorzAlign", uint, 0,
480 "Indent"  , uint, 0,
481 "Spacing" , uint, 0,
482 "WordWrap", uint, 0,
483 "AutoSize", uint, 0
484    }) 
485 
486    cm.AddPropVals( vHeader, "Layout", %{ 
487 "lPicLeft",   $lPicLeft,  
488 "lPicTop",    $lPicTop,   
489 "lPicRight",  $lPicRight, 
490 "lPicBottom", $lPicBottom,
491 "lPicBack",   $lPicBack,
492 "lPicSimple", $lPicSimple
493    })
494    
495    cm.AddPropVals( vHeader, "ContHorzAlign", %{
496 "ptLeft",    $ptLeft,     
497 "ptCenter",  $ptCenter,   
498 "ptRight",   $ptRight
499    })    
500    
501    cm.AddPropVals( vHeader, "ContVertAlign", %{      
502 "ptTop",        $ptTop,                        
503 "ptVertCenter", $ptVertCenter,          
504 "ptBottom",     $ptBottom
505    })    
506 }
507       
508 }
509