EnglishРусский  

   ..

   addustr.g

   app.g

   btn.g

   btnpic.g

   comp.g

   ctrl.g

   dialogs.g

   edit.g

   events.g

   fonts.g

   form.g

   gray.g

   grey.g

   images.g

   label.g

   labeled.g

   locustr.g

   menu.g

   panel.g

   picture.g

   s.txt

   styles.g

   tab.g

   tabitem.g

   tabpage.g

   toolbar.g

   tray.g

   url.g

   vis.g

   viswin.g

Ads

Perfect Automation tool
All-In-One: Script editor, Launcher, Scheduler, Keyboard & Mouse Recorder. Try now!

CreateInstall
Freeware and commercial installers.

Cell Phone Batteries
Batteries Plus offers batteries for laptop, camcorder, cell phone, camera.

Gentee needs your help!
How to advertise with us
 
laptop battery

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     pMultiLine
 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 .pMultiLine
 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 | ? (.pMultiLine, $DT_WORDBREAK, 0  ))      
 95       ReleaseDC( 0, dc )
 96       
 97       if .pMultiLine :.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.MultiLine - Get Set
179 Усотанавливает или получает автоматическое изменение размеров
180 */
181 property uint vLabel.MultiLine 
182 {
183    return this.pMultiLine
184 }
185 
186 property vLabel.MultiLine( uint val )
187 {
188    if val != this.MultiLine
189    { 
190       this.pMultiLine = 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_VISIBLE | $WS_CLIPSIBLINGS /*| $WS_OVERLAPPED*/
205    if !.pMultiLine : 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    print( "cl \(.flgXPStyle)\n" )
251 
252       SetBkMode( wmsg.wpar, $TRANSPARENT )
253       
254  
255       if .aStyle 
256       {
257          if .aStyle->Style.hTextColor 
258          {
259          //print( 
260             SetTextColor( wmsg.wpar, .aStyle->Style.pTextColor  )
261          }
262          wmsg.flags = 1      
263          if .aStyle->Style.hBrush
264          {
265             return .aStyle->Style.hBrush//GetStockObject(0)
266          }
267       }
268    }
269    return 0
270 }*/
271 /*method uint vLabel.wmclcolorstatic <alias=vLabel_wmclcolorstatic>(winmsg wmsg )
272 {
273 print( "SSSSSSSSSS\n" )
274    if isThemed && .flgXPStyle
275    { 
276    
277       uint hfont = GetCurrentObject( wmsg.wpar, $OBJ_FONT )
278       SetBkMode( wmsg.wpar, $TRANSPARENT )      
279       pDrawThemeParentBackground->stdcall( getctrl(wmsg.lpar).hwnd, wmsg.wpar, 0 )
280       wmsg.flags = 1
281       //SelectBrush(      
282       SelectObject( wmsg.wpar, hfont )
283       SetTextColor( wmsg.wpar, 0xFFFFFF )
284       return GetStockObject(5)
285    }
286    return 0
287 }*/
288 /*------------------------------------------------------------------------------
289    Registration
290 */
291 method vLabel vLabel.init( )
292 {
293    this.pTypeId = vLabel
294    this.flgRePaint = 1
295    this.loc.width = 100
296    this.loc.height = 100
297    return this 
298 }  
299 
300 func init_vLabel <entry>()
301 {  
302    regcomp( vLabel, "vLabel", vCtrl, $vCtrl_last,
303       %{ %{$mCreateWin, vLabel_mCreateWin },
304          %{$mSetName,   vLabel_mSetName },
305          %{$mLangChanged, vLabel_mLangChanged },
306          %{$mSetCaption, vLabel_mSetCaption }/*
307          %{$mClColor,      vLabel_mClColor }*/
308       },      
309       0->collection )
310 
311 ifdef $DESIGNING {      
312    cm.AddComp( vLabel, 1, "Windows", "label" )
313    
314    cm.AddProps( vLabel, %{
315 "Caption"      , ustr, 0,
316 "TextHorzAlign", uint, 0,
317 "TextVertAlign", uint, 0,
318 "AutoSize"     , uint, $PROP_LOADAFTERCHILD,
319 "MultiLine"    , uint, 0
320    })            
321 
322    cm.AddPropVals( vLabel, "TextHorzAlign", %{           
323 "talhLeft"        ,  $talhLeft,      
324 "talhCenter"      ,  $talhCenter,    
325 "talhRight"       ,  $talhRight } )
326 
327    cm.AddPropVals( vLabel, "TextVertAlign", %{           
328 "talvTop"         ,  $talvTop,       
329 "talvCenter"      ,  $talvCenter } )
330 }
331 }
Edit