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\btn.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.btn 17.07.07 0.0.A.
 11 *
 12 * Author: Alexander Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 
 16 /* Компонента vCustomBtn, порождена от vCtrl
 17 События
 18    onClick - вызывается при нажатии на кнопку
 19 */
 20 type vCustomBtn <inherit = vCtrl>
 21 {
 22 //Hidden Fields
 23    locustr pCaption     
 24    uint    pChecked 
 25    uint    pBtnStyle
 26    uint    flgPushLike
 27    uint    flgOwnerRedraw
 28 //Events   
 29    evEvent   OnClick
 30 }
 31 
 32 /*define {
 33    mUpdateCaption = $vCtrl_last
 34    vCustomBtn_last
 35 }*/
 36 
 37 type vBtn <inherit = vCustomBtn> :
 38 type vCheckBox <inherit = vCustomBtn> :
 39 type vRadioBtn <inherit = vCustomBtn> :
 40 
 41 extern {
 42    method vCustomBtn.iUpdateChecked
 43 }
 44 
 45 
 46 define <export>{
 47 //Стили кнопки BtnStyle
 48    bsClassic    = 0 
 49    bsAsRadioBtn = 3
 50    bsAsCheckBox = 4
 51 }
 52 
 53 /*------------------------------------------------------------------------------
 54    Internal Methods
 55 */
 56 
 57 
 58 /*------------------------------------------------------------------------------
 59    Properties
 60 */
 61 /* Свойство uint Checked - Get Set
 62 Усотанавливает или определяет, находится ли кнопка в выбранном состоянии
 63 Действует только для стилей кнопки $bsAsCheckBox или $bsAsRadioBtn
 64 1 - кнопка выбрана
 65 0 - кнопка не выбрана
 66 */
 67 property uint vCustomBtn.Checked()
 68 {  
 69    return this.pChecked
 70 }
 71 
 72 property vCustomBtn.Checked( uint val)
 73 {
 74    if this.pChecked != val
 75    {    
 76       this.pChecked = val
 77       .iUpdateChecked()
 78    }
 79 }
 80 
 81 /* Метод iUpdateChecked 
 82 Связывает состояние кнопки с визуальным отображением
 83 */
 84 method vCustomBtn.iUpdateChecked
 85 {
 86    if /*!.flgOwnerRedraw &&*/ ( this.pBtnStyle == $bsAsCheckBox ||
 87       this.pBtnStyle == $bsAsRadioBtn ) /*&&
 88       this.pChecked != (this.WinMsg( $BM_GETCHECK ) == $BST_CHECKED)*/
 89    {       
 90       this.WinMsg( $BM_SETCHECK, .pChecked )
 91       if .pBtnStyle == $bsAsRadioBtn && .pChecked
 92       {
 93          uint owner as this.Owner->vCtrl
 94          uint i
 95          if &owner
 96          {
 97             fornum i=0, owner.pCtrls
 98             {
 99                uint btn as owner.Comps[i]->vCustomBtn
100                if &btn != &this && 
101                   btn.TypeIs( vCustomBtn ) &&
102                   btn.pBtnStyle == $bsAsRadioBtn           
103                {                  
104                   btn.Checked = 0//( btn.WinMsg( $BM_GETCHECK ) == $BST_CHECKED )                  
105                }  
106             }
107          }
108       }     
109       /*uint tabstop = GetFocus()      
110       this.WinMsg( $BM_CLICK )
111       SetFocus( tabstop )*/
112       .Invalidate()
113    }
114    else
115    {
116       .Invalidate()
117    }  
118 }
119 
120 /* Свойство uint BtnStyle - Get Set
121 Усотанавливает или определяет стиль кнопки
122 Возможны следующие варианты:
123 bsClassic     - обычный вид,
124 bsAsRadioBtn  - работает как RadioBtn,
125 bsAsCheckBox  - работает как CheckBox
126 */
127 property uint vCustomBtn.BtnStyle()
128 {
129    return this.pBtnStyle
130 }
131 
132 property vCustomBtn.BtnStyle( uint val)
133 {
134    if this.pBtnStyle != val
135    {  
136       this.pBtnStyle = val
137       .Virtual( $mReCreateWin )
138       //this.WinMsg( $BM_SETCHECK, 0 )     
139       /*uint checked = this.Checked
140       uint remstyle = $BS_AUTORADIOBUTTON | $BS_AUTOCHECKBOX | $BS_PUSHLIKE
141       uint addstyle
142       this.WinMsg( $BM_SETCHECK, 0 )
143       this.pChecked = 0
144       if val == $bsAsRadioBtn
145       {
146          addstyle = $BS_AUTORADIOBUTTON | $BS_PUSHLIKE
147       }
148       elif val == $bsAsCheckBox
149       {
150          addstyle = $BS_AUTOCHECKBOX | $BS_PUSHLIKE  
151       }      
152       this.ChangeStyle( addstyle, remstyle ) 
153       this.pBtnStyle = val  
154       .iUpdateChecked()*/
155    }
156 }
157 
158 /* Свойство ustr Caption - Get Set
159 Устанавливает или определяет заголовок кнопки
160 */
161 property ustr vCustomBtn.Caption <result>
162 {
163    result = this.pCaption.Value
164 }
165 
166 property vCustomBtn.Caption( ustr val )
167 {  
168    if val != this.pCaption.Value
169    { 
170       this.pCaption.Value = val
171       //.Virtual( $mUpdateCaption )
172       .Virtual( $mSetCaption, this.pCaption.Text( this ) )
173    }         
174 }
175 
176 
177 /*------------------------------------------------------------------------------
178    Virtual Methods
179 */
180 /*Виртуальный метод vCustomBtn vCustomBtn.mCreateWin - Создание окна
181 */
182 method vCustomBtn vCustomBtn.mCreateWin <alias=vCustomBtn_mCreateWin>()
183 {
184    uint style = $WS_CHILD | $WS_CLIPSIBLINGS 
185    if .pTabStop : style | $WS_TABSTOP//| $BS_BITMAP
186    if .flgOwnerRedraw 
187    {
188       style |= $BS_OWNERDRAW
189    }
190    else
191    {
192       switch .pBtnStyle
193       {
194          case $bsAsRadioBtn :  style |= $BS_AUTORADIOBUTTON | ?( .flgPushLike, $BS_PUSHLIKE, 0 )
195          case $bsAsCheckBox :  style |= $BS_AUTOCHECKBOX | ?( .flgPushLike, $BS_PUSHLIKE, 0 )      
196       }   
197    }
198    this.CreateWin( "BUTTON".ustr(), 0, style )
199    //.WinMsg( $BM_SETIMAGE, $IMAGE_BITMAP, LoadBitmap( 0,  32754 )) 
200    //.Virtual( $mUpdateCaption )
201    .Virtual( $mSetCaption, this.pCaption.Text( this ) )
202    .iUpdateChecked()
203                      
204    this->vCtrl.mCreateWin()  
205                                 
206    return this
207 }
208 
209 /*Виртуальный метод uint vCustomBtn.mWinCmd - Обработка windows сообщения с командой
210 */
211 method uint vCustomBtn.mWinCmd <alias=vCustomBtn_mWinCmd>( uint ntfcmd, uint id )
212 {
213    //print( "click\n" )
214    /*if ntfcmd == $BN_CLICKED 
215    {   
216       if .pBtnStyle == $bsAsRadioBtn 
217       {
218          uint owner as this.Owner->vCtrl
219          uint i
220          if &owner
221          {
222             fornum i=0, owner.pCtrls
223             {
224                uint btn as owner.Comps[i]->vCustomBtn
225                if btn.TypeIs( vCustomBtn ) && btn.pBtnStyle == $bsAsRadioBtn           
226                {
227                   
228                   btn.pChecked = ( btn.WinMsg( $BM_GETCHECK ) == $BST_CHECKED )                  
229                }  
230             }
231          }
232       }
233       elif .pBtnStyle == $bsAsCheckBox 
234       {         
235          .pChecked = ( .WinMsg( $BM_GETCHECK ) == $BST_CHECKED )
236       }      
237       evparEvent ev
238       ev.sender = &this
239       this.OnClick.run( ev )     
240    }*/
241    if ntfcmd == $BN_CLICKED 
242    {         
243       if .pBtnStyle == $bsAsRadioBtn 
244       {
245          .Checked = 1
246        /*  uint owner as this.Owner->vCtrl
247          uint i
248          if &owner
249          {
250             fornum i=0, owner.pCtrls
251             {
252                uint btn as owner.Comps[i]->vCustomBtn
253                if &btn == &this 
254                {
255                   btn.Checked = 1
256                } 
257                elif btn.TypeIs( vCustomBtn ) &&
258                   btn.pBtnStyle == $bsAsRadioBtn           
259                {                  
260                   btn.Checked = 0//( btn.WinMsg( $BM_GETCHECK ) == $BST_CHECKED )                  
261                }  
262             }
263          }*/
264       }
265       elif .pBtnStyle == $bsAsCheckBox 
266       {           
267          .Checked = !.pChecked//( .WinMsg( $BM_GETCHECK ) == $BST_CHECKED )
268       }      
269       evparEvent ev
270       ev.sender = &this      
271       this.OnClick.Run( ev, this )
272    }
273    return 0
274 }
275 
276 /*Виртуальный метод uint vCustomBtn.mLangChanged - Изменение текущего языка
277 */
278 method vCustomBtn.mLangChanged <alias=vCustomBtn_mLangChanged>()
279 {
280    //.Virtual( $mUpdateCaption )
281    .Virtual( $mSetCaption, this.pCaption.Text( this ) ) 
282    this->vCtrl.mLangChanged() 
283 }
284 
285 /*Виртуальный метод vCustomBtn.mSetName - Установка заголовка в режиме проектирования
286 */
287 method uint vCustomBtn.mSetName <alias=vCustomBtn_mSetName>( str newname )
288 {
289 ifdef $DESIGNING {   
290    if !.p_loading && .Caption == .Name
291    {
292       .Caption = newname.ustr()
293    }
294 }   
295    return 1
296 }
297 
298 /*Виртуальный метод vCustomBtn.mUpdateCaption - Обновить заголовок
299 */
300 /*method vCustomBtn.mUpdateCaption <alias=vCustomBtn_mUpdateCaption>()
301 {
302    SetWindowText( this.hwnd, this.pCaption.Text( this ).ptr() )  
303 }*/
304 
305 /*------------------------------------------------------------------------------
306    Registration
307 */
308 /*Системный метод vCustomBtn vCustomBtn.init - Инициализация объекта
309 */   
310 method vCustomBtn vCustomBtn.init( )
311 {   
312    this.pTypeId = vCustomBtn
313      
314    this.pCanFocus = 1
315    this.pTabStop = 1 
316    this.flgXPStyle = 1     
317    this.loc.width = 100
318    this.loc.height = 25   
319    return this 
320 }  
321 
322 method vBtn vBtn.init( )
323 {   
324    this.pTypeId = vBtn     
325    this.flgPushLike = 1   
326    return this 
327 }
328 
329 method vCheckBox vCheckBox.init( )
330 {   
331    this.pTypeId = vCheckBox
332    this.pBtnStyle = $bsAsCheckBox
333    return this 
334 }
335 
336 method vRadioBtn vRadioBtn.init( )
337 {   
338    this.pTypeId = vRadioBtn  
339    this.pBtnStyle = $bsAsRadioBtn
340    return this 
341 }
342 
343 
344 /*method uint vBtn.wmerasebkgnd <alias=vBtn_wmerasebkgnd>( winmsg wmsg )
345 {
346 //if this.Type == vBtn 
347 {      
348    //print( "erase 100000 \(this.Name)\n" )
349  //  pDrawThemeParentBackground->stdcall( this.hwnd, wmsg.wpar, 0 );
350    wmsg.flags = 1
351 }    
352    return 1   
353 }*/
354 
355 func init_vCustomBtn <entry>()
356 {  
357    regcomp( vCustomBtn, "vCustomBtn", vCtrl, $vCtrl_last, 
358       %{ %{$mCreateWin,    vCustomBtn_mCreateWin},
359          %{$mWinCmd,       vCustomBtn_mWinCmd},
360          %{$mLangChanged,  vCustomBtn_mLangChanged },
361          %{$mSetName,      vCustomBtn_mSetName}//, 
362          //%{$mWinDrawItem,  vCustomBtn_mWinDrawItem},
363          //%{$mUpdateCaption,vCustomBtn_mUpdateCaption}
364       }, 
365       0->collection )
366       //%{
367         // %{$WM_ERASEBKGND, vBtn_wmerasebkgnd } } )//, 
368          //%{$WM_PAINT, vBtn_wmpaint } } )
369          //%{$WM_DRAWITEM , vBtn_wmpaint } } )
370       
371    regcomp( vBtn,      "vBtn", vCustomBtn, $vCtrl_last, 
372       0->collection, 0->collection )
373             
374    regcomp( vCheckBox, "vCheckBox", vCustomBtn, $vCtrl_last, 
375       0->collection, 0->collection )
376    
377    regcomp( vRadioBtn, "vRadioBtn", vCustomBtn, $vCtrl_last, 
378       0->collection, 0->collection )
379             
380 ifdef $DESIGNING {
381    cm.AddComp( vCustomBtn )   
382    
383    cm.AddProps( vCustomBtn, %{ 
384 //"TabOrder", uint, 0,
385 "Caption",  ustr, 0,
386 "Checked", uint, 0 
387    }) 
388    
389    cm.AddEvents( vCustomBtn, %{
390 "OnClick"      , "evparEvent"
391    })
392    
393    cm.AddComp( vBtn, 1, "Windows", "btn" )   
394    
395    cm.AddProps( vBtn, %{
396 "BtnStyle", uint, 0
397    }) 
398    
399    cm.AddPropVals( vBtn, "BtnStyle", %{ 
400 "bsClassic",      $bsClassic,
401 "bsAsRadioBtn",   $bsAsRadioBtn,     
402 "bsAsCheckBox",   $bsAsCheckBox
403    })
404    
405    cm.AddComp( vCheckBox, 1, "Windows", "btn" )
406    cm.AddComp( vRadioBtn, 1, "Windows", "btn" )         
407 }
408       
409 }
410