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\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       InvalidateRect( this.hwnd, 0->RECT, 1 )
113    }
114    else
115    {
116       InvalidateRect( this.hwnd, 0->RECT, 1 )
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_VISIBLE | $WS_CLIPSIBLINGS | $WS_TABSTOP//| $BS_BITMAP
185    if .flgOwnerRedraw 
186    {
187       style |= $BS_OWNERDRAW
188    }
189    else
190    {
191       switch .pBtnStyle
192       {
193          case $bsAsRadioBtn :  style |= $BS_AUTORADIOBUTTON | ?( .flgPushLike, $BS_PUSHLIKE, 0 )
194          case $bsAsCheckBox :  style |= $BS_AUTOCHECKBOX | ?( .flgPushLike, $BS_PUSHLIKE, 0 )      
195       }   
196    }
197    this.CreateWin( "BUTTON".ustr(), 0, style )
198    //.WinMsg( $BM_SETIMAGE, $IMAGE_BITMAP, LoadBitmap( 0,  32754 )) 
199    //.Virtual( $mUpdateCaption )
200    .Virtual( $mSetCaption, this.pCaption.Text( this ) )
201    .iUpdateChecked()
202                      
203    this->vCtrl.mCreateWin()  
204                                 
205    return this
206 }
207 
208 /*Виртуальный метод uint vCustomBtn.mWinCmd - Обработка windows сообщения с командой
209 */
210 method uint vCustomBtn.mWinCmd <alias=vCustomBtn_mWinCmd>( uint ntfcmd, uint id )
211 {
212    //print( "click\n" )
213    /*if ntfcmd == $BN_CLICKED 
214    {   
215       if .pBtnStyle == $bsAsRadioBtn 
216       {
217          uint owner as this.Owner->vCtrl
218          uint i
219          if &owner
220          {
221             fornum i=0, owner.pCtrls
222             {
223                uint btn as owner.Comps[i]->vCustomBtn
224                if btn.TypeIs( vCustomBtn ) && btn.pBtnStyle == $bsAsRadioBtn           
225                {
226                   
227                   btn.pChecked = ( btn.WinMsg( $BM_GETCHECK ) == $BST_CHECKED )                  
228                }  
229             }
230          }
231       }
232       elif .pBtnStyle == $bsAsCheckBox 
233       {         
234          .pChecked = ( .WinMsg( $BM_GETCHECK ) == $BST_CHECKED )
235       }      
236       evparEvent ev
237       ev.sender = &this
238       this.OnClick.run( ev )     
239    }*/
240    if ntfcmd == $BN_CLICKED 
241    {         
242       if .pBtnStyle == $bsAsRadioBtn 
243       {
244          .Checked = 1
245        /*  uint owner as this.Owner->vCtrl
246          uint i
247          if &owner
248          {
249             fornum i=0, owner.pCtrls
250             {
251                uint btn as owner.Comps[i]->vCustomBtn
252                if &btn == &this 
253                {
254                   btn.Checked = 1
255                } 
256                elif btn.TypeIs( vCustomBtn ) &&
257                   btn.pBtnStyle == $bsAsRadioBtn           
258                {                  
259                   btn.Checked = 0//( btn.WinMsg( $BM_GETCHECK ) == $BST_CHECKED )                  
260                }  
261             }
262          }*/
263       }
264       elif .pBtnStyle == $bsAsCheckBox 
265       {           
266          .Checked = !.pChecked//( .WinMsg( $BM_GETCHECK ) == $BST_CHECKED )
267       }      
268       evparEvent ev
269       ev.sender = &this      
270       this.OnClick.Run( ev, this )
271    }
272    return 0
273 }
274 
275 /*Виртуальный метод uint vCustomBtn.mLangChanged - Изменение текущего языка
276 */
277 method vCustomBtn.mLangChanged <alias=vCustomBtn_mLangChanged>()
278 {
279    //.Virtual( $mUpdateCaption )
280    .Virtual( $mSetCaption, this.pCaption.Text( this ) ) 
281    this->vCtrl.mLangChanged() 
282 }
283 
284 /*Виртуальный метод vCustomBtn.mSetName - Установка заголовка в режиме проектирования
285 */
286 method uint vCustomBtn.mSetName <alias=vCustomBtn_mSetName>( str newname )
287 {
288 ifdef $DESIGNING {   
289    if !.p_loading && .Caption == .Name
290    {
291       .Caption = newname.ustr()
292    }
293 }   
294    return 1
295 }
296 
297 /*Виртуальный метод vCustomBtn.mUpdateCaption - Обновить заголовок
298 */
299 /*method vCustomBtn.mUpdateCaption <alias=vCustomBtn_mUpdateCaption>()
300 {
301    SetWindowText( this.hwnd, this.pCaption.Text( this ).ptr() )  
302 }*/
303 
304 /*------------------------------------------------------------------------------
305    Registration
306 */
307 /*Системный метод vCustomBtn vCustomBtn.init - Инициализация объекта
308 */   
309 method vCustomBtn vCustomBtn.init( )
310 {   
311    this.pTypeId = vCustomBtn
312      
313    this.pCanFocus = 1
314    this.pTabStop = 1      
315    this.loc.width = 100
316    this.loc.height = 25   
317    return this 
318 }  
319 
320 method vBtn vBtn.init( )
321 {   
322    this.pTypeId = vBtn     
323    this.flgPushLike = 1   
324    return this 
325 }
326 
327 method vCheckBox vCheckBox.init( )
328 {   
329    this.pTypeId = vCheckBox
330    this.pBtnStyle = $bsAsCheckBox
331    return this 
332 }
333 
334 method vRadioBtn vRadioBtn.init( )
335 {   
336    this.pTypeId = vRadioBtn  
337    this.pBtnStyle = $bsAsRadioBtn
338    return this 
339 }
340 
341 
342 /*method uint vBtn.wmerasebkgnd <alias=vBtn_wmerasebkgnd>( winmsg wmsg )
343 {
344 //if this.Type == vBtn 
345 {      
346    //print( "erase 100000 \(this.Name)\n" )
347  //  pDrawThemeParentBackground->stdcall( this.hwnd, wmsg.wpar, 0 );
348    wmsg.flags = 1
349 }    
350    return 1   
351 }*/
352 
353 func init_vCustomBtn <entry>()
354 {  
355    regcomp( vCustomBtn, "vCustomBtn", vCtrl, $vCtrl_last, 
356       %{ %{$mCreateWin,    vCustomBtn_mCreateWin},
357          %{$mWinCmd,       vCustomBtn_mWinCmd},
358          %{$mLangChanged,  vCustomBtn_mLangChanged },
359          %{$mSetName,      vCustomBtn_mSetName}//, 
360          //%{$mWinDrawItem,  vCustomBtn_mWinDrawItem},
361          //%{$mUpdateCaption,vCustomBtn_mUpdateCaption}
362       }, 
363       0->collection )
364       //%{
365         // %{$WM_ERASEBKGND, vBtn_wmerasebkgnd } } )//, 
366          //%{$WM_PAINT, vBtn_wmpaint } } )
367          //%{$WM_DRAWITEM , vBtn_wmpaint } } )
368       
369    regcomp( vBtn,      "vBtn", vCustomBtn, $vCtrl_last, 
370       0->collection, 0->collection )
371             
372    regcomp( vCheckBox, "vCheckBox", vCustomBtn, $vCtrl_last, 
373       0->collection, 0->collection )
374    
375    regcomp( vRadioBtn, "vRadioBtn", vCustomBtn, $vCtrl_last, 
376       0->collection, 0->collection )
377             
378 ifdef $DESIGNING {
379    cm.AddComp( vCustomBtn )   
380    
381    cm.AddProps( vCustomBtn, %{ 
382 "TabOrder", uint, 0,
383 "Caption",  ustr, 0,
384 "Checked", uint, 0 
385    }) 
386    
387    cm.AddEvents( vCustomBtn, %{
388 "OnClick"      , "evparEvent"
389    })
390    
391    cm.AddComp( vBtn, 1, "Windows", "btn" )   
392    
393    cm.AddProps( vBtn, %{
394 "BtnStyle", uint, 0
395    }) 
396    
397    cm.AddPropVals( vBtn, "BtnStyle", %{ 
398 "bsClassic",      $bsClassic,
399 "bsAsRadioBtn",   $bsAsRadioBtn,     
400 "bsAsCheckBox",   $bsAsCheckBox
401    })
402    
403    cm.AddComp( vCheckBox, 1, "Windows", "btn" )
404    cm.AddComp( vRadioBtn, 1, "Windows", "btn" )         
405 }
406       
407 }
Edit