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\label.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.label 10.12.07 0.0.A.
 11 *
 12 * Author: Alexander Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 /* Компонента vLabel, порождена от vCtrl
 16 События   
 17 */
 18 type vLabel <inherit = vCtrl>
 19 {
 20 //Hidden fields
 21    locustr  pCaption
 22    ustr     pResCaption
 23    uint     pTextHorzAlign
 24    uint     pTextVertAlign
 25    uint     pAutoSize
 26    uint     pWordWrap
 27    uint     brush
 28 }
 29 
 30 define <export>{
 31 //Типы выравнивания текста
 32    talhLeft       = 0
 33    talhCenter     = 1   
 34    talhRight      = 2
 35    talvTop        = 0
 36    talvCenter     = 1   
 37 }
 38 
 39 /*------------------------------------------------------------------------------
 40    Internal Methods
 41 */
 42 /* Метод iUpdateCaption
 43 Связывает заголовок панели с визуальным отображением
 44 */
 45 //method vLabel.iUpdateCaption
 46 method vLabel.mSetCaption <alias=vLabel_mSetCaption>( ustr caption )
 47 {  
 48    .pResCaption = caption   
 49    //SetWindowText( this.hwnd, .pResCaption.ptr() )
 50    this->vCtrl.mSetCaption( caption )  
 51 }
 52 
 53 /* Метод iUpdateAlignment
 54 Связывает выравнивание текста 
 55 */
 56 method vLabel.iUpdateAlignment
 57 {
 58    uint style
 59    .SetStyle( $SS_RIGHT | $SS_CENTER | $SS_CENTERIMAGE, 0 )
 60    if .pWordWrap
 61    {
 62       switch .pTextHorzAlign
 63       {  
 64          case $talhLeft:
 65          case $talhCenter: style = $SS_CENTER 
 66          case $talhRight: style = $SS_RIGHT
 67          
 68       }
 69    }
 70    switch .pTextVertAlign 
 71    {  
 72       case $talvTop: 
 73       case $talvCenter: style |= $SS_CENTERIMAGE    
 74    }
 75    .SetStyle( style, 1 )   
 76    
 77 }
 78 
 79 /* Метод iUpdateSize
 80 Автоматическое определение ширины/высоты текста
 81 */
 82 method vLabel.iUpdateSize
 83 {
 84    if .pAutoSize
 85    {      
 86       RECT r
 87       uint dc = GetDC( 0 )
 88       
 89       r.right = .clloc.width
 90       r.bottom = .clloc.height 
 91       
 92       SelectObject( dc, this.WinMsg( $WM_GETFONT ) ) 
 93       DrawText( dc, .pResCaption.ptr(), *.pResCaption, r, 
 94             $DT_CALCRECT | ? (.pWordWrap, $DT_WORDBREAK, 0  ))      
 95       ReleaseDC( 0, dc )
 96       
 97       if .pWordWrap :.Height = r.bottom      
 98       else 
 99       {
100          .Height = r.bottom
101          .Width = r.right
102       }          
103    }
104 }
105 /*------------------------------------------------------------------------------
106    Properties
107 */
108 /* Свойство str vLabel.Caption - Get Set
109 Усотанавливает или получает заколовок панели
110 */
111 property ustr vLabel.Caption <result>
112 {
113    result = this.pCaption.Value
114 }
115 
116 property vLabel.Caption( ustr val )
117 {
118    if val != this.pCaption.Value
119    {       
120       this.pCaption.Value = val
121       //.iUpdateCaption()      
122       .Virtual( $mSetCaption, this.pCaption.Text(this) )
123       .iUpdateSize()      
124    } 
125 }
126 
127 /* Свойство str vLabel.TextHorzAlign - Get Set
128 Усотанавливает или получает выравнивание текста
129 */
130 property uint vLabel.TextHorzAlign 
131 {
132    return this.pTextHorzAlign
133 }
134 
135 property vLabel.TextHorzAlign( uint val )
136 {
137    if val != this.pTextHorzAlign
138    { 
139       this.pTextHorzAlign = val
140       .iUpdateAlignment()
141    } 
142 }
143 
144 /* Свойство str vLabel.TextVertAlign - Get Set
145 Усотанавливает или получает выравнивание текста
146 */
147 property uint vLabel.TextVertAlign 
148 {
149    return this.pTextVertAlign
150 }
151 
152 property vLabel.TextVertAlign( uint val )
153 {
154    if val != this.pTextVertAlign
155    { 
156       this.pTextVertAlign = val
157       .iUpdateAlignment()
158    } 
159 }
160 
161 /* Свойство str vLabel.AutoSize - Get Set
162 Усотанавливает или получает автоматическое изменение размеров
163 */
164 property uint vLabel.AutoSize 
165 {
166    return this.pAutoSize
167 }
168 
169 property vLabel.AutoSize( uint val )
170 {
171    if val != this.AutoSize
172    { 
173       this.pAutoSize = val
174       .iUpdateSize()              
175    } 
176 }
177 
178 /* Свойство str vLabel.WordWrap - Get Set
179 Усотанавливает или получает автоматическое изменение размеров
180 */
181 property uint vLabel.WordWrap 
182 {
183    return this.pWordWrap
184 }
185 
186 property vLabel.WordWrap( uint val )
187 {
188    if val != this.WordWrap
189    { 
190       this.pWordWrap = val
191       .iUpdateAlignment()
192       .iUpdateSize() 
193       .SetStyle( $SS_LEFTNOWORDWRAP, !val )
194    } 
195 }
196 
197 /*------------------------------------------------------------------------------
198    Virtual methods
199 */
200 /*Виртуальный метод vLabel vLabel.mCreateWin - Создание окна
201 */
202 method vLabel vLabel.mCreateWin <alias=vLabel_mCreateWin>()
203 {
204    uint style = /*$SS_ENDELLIPSIS |*/ /*$WS_CLIPCHILDREN | */$SS_NOTIFY | $WS_CHILD  | $WS_CLIPSIBLINGS /*| $WS_OVERLAPPED*/
205    if !.pWordWrap : style |= $SS_LEFTNOWORDWRAP 
206    style |= $SS_CENTER | $SS_CENTERIMAGE
207    .CreateWin( "STATIC".ustr(), 0, style )
208    this->vCtrl.mCreateWin()
209    //.iUpdateCaption()
210    .Virtual( $mSetCaption, this.pCaption.Text(this) ) 
211    .iUpdateAlignment()
212    .iUpdateSize()
213    //this.WinMsg( $WM_SETFONT, GetStockObject( $DEFAULT_GUI_FONT ) )
214    
215    /*LOGBRUSH lb
216    lb.lbColor = 0x02000000
217    .brush = CreateBrushIndirect( lb )*/
218    return this
219 }
220 
221 /*Виртуальный метод vLabel.mSetName - Установка заголовка в режиме проектирования
222 */
223 method uint vLabel.mSetName <alias=vLabel_mSetName>( str newname )
224 {
225 ifdef $DESIGNING {   
226    if !.p_loading && .Caption == .Name
227    {
228       .Caption = newname.ustr()
229    }
230 }   
231    return 1 
232 }
233 
234 /*Виртуальный метод uint vLabel.mLangChanged - Изменение текущего языка
235 */
236 method vLabel.mLangChanged <alias=vLabel_mLangChanged>()
237 {   
238    //.iUpdateCaption()
239    .Virtual( $mSetCaption, this.pCaption.Text(this) )
240    .iUpdateSize()
241 }
242 
243 /*
244 method uint vLabel.mClColor <alias=vLabel_mClColor>( winmsg wmsg )
245 {
246 
247 
248    if isThemed //&& .flgXPStyle
249    {
250 
251       SetBkMode( wmsg.wpar, $TRANSPARENT )
252       
253  
254       if .aStyle 
255       {
256          if .aStyle->Style.hTextColor 
257          {
258             SetTextColor( wmsg.wpar, .aStyle->Style.pTextColor  )
259          }
260          wmsg.flags = 1      
261          if .aStyle->Style.hBrush
262          {
263             return .aStyle->Style.hBrush//GetStockObject(0)
264          }
265       }
266    }
267    return 0
268 }*/
269 /*method uint vLabel.wmclcolorstatic <alias=vLabel_wmclcolorstatic>(winmsg wmsg )
270 {
271    if isThemed && .flgXPStyle
272    { 
273    
274       uint hfont = GetCurrentObject( wmsg.wpar, $OBJ_FONT )
275       SetBkMode( wmsg.wpar, $TRANSPARENT )      
276       pDrawThemeParentBackground->stdcall( getctrl(wmsg.lpar).hwnd, wmsg.wpar, 0 )
277       wmsg.flags = 1
278       //SelectBrush(      
279       SelectObject( wmsg.wpar, hfont )
280       SetTextColor( wmsg.wpar, 0xFFFFFF )
281       return GetStockObject(5)
282    }
283    return 0
284 }*/
285 /*------------------------------------------------------------------------------
286    Registration
287 */
288 method vLabel vLabel.init( )
289 {
290    this.pTypeId = vLabel
291    this.flgRePaint = 1
292    this.flgXPStyle = 1
293    this.loc.width = 100
294    this.loc.height = 100
295    return this 
296 }  
297 
298 func init_vLabel <entry>()
299 {  
300    regcomp( vLabel, "vLabel", vCtrl, $vCtrl_last,
301       %{ %{$mCreateWin, vLabel_mCreateWin },
302          %{$mSetName,   vLabel_mSetName },
303          %{$mLangChanged, vLabel_mLangChanged },
304          %{$mSetCaption, vLabel_mSetCaption }/*
305          %{$mClColor,      vLabel_mClColor }*/
306       },      
307       0->collection )
308 
309 ifdef $DESIGNING {      
310    cm.AddComp( vLabel, 1, "Windows", "label" )
311    
312    cm.AddProps( vLabel, %{
313 "Caption"      , ustr, 0,
314 "TextHorzAlign", uint, 0,
315 "TextVertAlign", uint, 0,
316 "AutoSize"     , uint, $PROP_LOADAFTERCHILD,
317 "WordWrap"    , uint, 0
318    })            
319 
320    cm.AddPropVals( vLabel, "TextHorzAlign", %{           
321 "talhLeft"        ,  $talhLeft,      
322 "talhCenter"      ,  $talhCenter,    
323 "talhRight"       ,  $talhRight } )
324 
325    cm.AddPropVals( vLabel, "TextVertAlign", %{           
326 "talvTop"         ,  $talvTop,       
327 "talvCenter"      ,  $talvCenter } )
328 }
329 }