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\btnpic.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.btnpic 07.02.07 0.0.A.
 11 *
 12 * Author: Alexander Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 
 16 include {
 17    "btn.g"
 18    "ctrlci.g"
 19 }
 20 /* Компонента vBtnPic, порождена от vBtn
 21 События
 22 */
 23 type vBtnPic <inherit = vBtn>
 24 {
 25 //Hidden Fields
 26    ustr     pImage
 27    uint     pFlat   
 28    PicText  pPicText
 29    uint     flgEnter
 30    uint     flgDown
 31    uint     pNoFocus
 32 //Events      
 33 }
 34 
 35 
 36 //Устаревшее 
 37 define <export>{
 38 //Расположение картинки и текста
 39    bplPicLeft = 0 
 40    bplPicTop  = 1   
 41 }
 42 
 43 /*------------------------------------------------------------------------------
 44    Internal Methods
 45 */
 46 
 47 
 48 method vBtnPic.iUpdateImage()
 49 {  
 50    .pPicText.PtrImage = &this.GetImage( .pImage )
 51 }
 52 
 53 /*------------------------------------------------------------------------------
 54    Properties
 55 */
 56 /* Свойство ustr vBtnPic.Image - Get Set
 57 Устанавливает или получает картинку
 58 */
 59 property ustr vBtnPic.Image <result>
 60 {
 61    result = this.pImage
 62 }
 63 
 64 property vBtnPic.Image( ustr val )
 65 {
 66    if val != this.pImage
 67    { 
 68       this.pImage = val      
 69       .iUpdateImage()      
 70    }
 71 }
 72 
 73 /* Свойство str vBtnPic.Layout - Get Set
 74 Усотанавливает или получает взаимное расположение картинки текста
 75 */
 76 property uint vBtnPic.Layout
 77 {   
 78    return .pPicText.Layout
 79 }
 80 
 81 property vBtnPic.Layout( uint val )
 82 {  
 83    .pPicText.Layout = val
 84 }
 85 
 86 /* Свойство str vPicture.Flat - Get Set
 87 Всплывающая кнопка как в toolbar
 88 */
 89 property uint vBtnPic.Flat
 90 {
 91    return this.pFlat
 92 }
 93 
 94 property vBtnPic.Flat( uint val )
 95 {
 96    if val != this.pFlat
 97    {
 98       this.pFlat = val      
 99       .Invalidate()
100    }
101 }
102 
103 /* Свойство str vBtnPic.ContHorzAlign - Get Set
104 Устанавливает или получает расположение содежимого по горизонтали
105 */
106 property uint vBtnPic.ContHorzAlign 
107 {   
108    return .pPicText.ContHorzAlign
109 }
110 
111 property vBtnPic.ContHorzAlign( uint val )
112 {
113    .pPicText.ContHorzAlign = val 
114 }
115 
116 /* Свойство uint vBtnPic.ContVertAlign - Get Set
117 Устанавливает или получает расположение содежимого по вертикали
118 */
119 property uint vBtnPic.ContVertAlign 
120 {   
121    return .pPicText.ContVertAlign
122 }
123 
124 property vBtnPic.ContVertAlign( uint val )
125 {
126    .pPicText.ContVertAlign = val
127 }
128 
129 /* Свойство uin vBtnPic.NoFocus - Get Set
130 Устанавливает или получает режим без фокуса ввода
131 */
132 property uint vBtnPic.NoFocus 
133 {   
134    return .pNoFocus
135 }
136 
137 property vBtnPic.NoFocus( uint val )
138 {
139    if .pNoFocus != val
140    {
141       .pNoFocus = val
142       if val : .TabStop = 0
143       .Invalidate()
144    }
145 }
146 
147 /*------------------------------------------------------------------------------
148    Registration
149 */
150 /*Системный метод vBtnPic vBtnPic.init - Инициализация объекта
151 */   
152 method vBtnPic vBtnPic.init( )
153 {   
154    this.pTypeId = vBtnPic
155      
156    this.pCanFocus = 1
157    this.pTabStop = 1      
158    this.loc.width = 100   
159    this.loc.height = 25
160    this.flgOwnerRedraw = 1   
161    
162    this.pPicText.Ctrl = this
163    return this 
164 }  
165 define {
166   BSTATE_NORMAL = $TS_NORMAL
167   BSTATE_PRESSED = $TS_PRESSED
168   BSTATE_CHECKED = $TS_CHECKED
169   BSTATE_HOT     = $TS_HOT
170   BSTATE_HOTCHECKED = $TS_HOTCHECKED
171   BSTATE_DISABLED = $TS_DISABLED 
172 }
173 
174 //method uint vBtn.wmpaint <alias=vBtn_wmpaint>( winmsg wmsg )
175 method vBtnPic.mWinDrawItem <alias=vBtnPic_mWinDrawItem>( DRAWITEMSTRUCT ds )
176 {
177    uint off   
178    if ds.itemState & $ODS_SELECTED : off = 1
179    
180    uint state
181    if .pEnabled
182    {
183       if ds.itemState & $ODS_SELECTED || ( .flgDown && .flgEnter )
184       {
185          state = $BSTATE_PRESSED
186       }
187       else 
188       {
189          if .pChecked && ( this.pBtnStyle == $bsAsCheckBox ||
190                   this.pBtnStyle == $bsAsRadioBtn )
191          {
192             if .flgEnter : state = $BSTATE_HOTCHECKED
193             else : state = $BSTATE_CHECKED
194          }
195          else
196          {
197             if .flgEnter : state = $BSTATE_HOT
198             else : state = $BSTATE_NORMAL
199          }         
200          
201       }     
202    }
203    else
204    {
205       state = $PBS_DISABLED
206    }
207    if isThemed 
208    {
209       if !.pFlat
210       {
211          if state == $BSTATE_CHECKED : state = $PBS_PRESSED 
212          elif state == $BSTATE_HOTCHECKED : state = $PBS_HOT         
213       }            
214 ifdef $DESIGNING {
215       if .p_designing && .pFlat && state == $BSTATE_NORMAL : state = $TS_HOT
216 }      
217       pDrawThemeParentBackground->stdcall( this.hwnd, ds.hDC, 0 );
218       pDrawThemeBackground->stdcall( 
219             ThemeData[?( .pFlat, $theme_toolbar, $theme_button )], 
220             ds.hDC, $BP_PUSHBUTTON, state, ds.rcItem, 0 )
221    }   
222    else
223    {
224       
225       if .pFlat
226       {
227          FillRect( ds.hDC, ds.rcItem, ?( state == $BSTATE_CHECKED, 
228                $COLOR_BTNHIGHLIGHT, $COLOR_BTNFACE) + 1 )               
229          if state == $BSTATE_CHECKED || state == $BSTATE_HOTCHECKED || 
230             state == $BSTATE_PRESSED
231          {
232             state = 2
233          } 
234          elif state == $BSTATE_HOT :  state = 4
235          else 
236          {
237             state = 0
238 ifdef $DESIGNING {
239             if .p_designing: state = 4  
240 }
241             
242          }
243          
244          if state 
245          {            
246             DrawEdge( ds.hDC, ds.rcItem, state, 0xf )
247          }   
248       }   
249       else
250       {
251          if state == $BSTATE_CHECKED || state == $BSTATE_HOTCHECKED
252          {
253             state = 0x410
254          } 
255          elif state == $BSTATE_PRESSED 
256          {
257             state = 0x210
258          }
259          else : state = 0x010         
260          DrawFrameControl( ds.hDC, ds.rcItem, 4, state )
261       }
262    }   
263    RECT r
264    .pPicText.Draw( ds.hDC, off, off )   
265    
266    if GetFocus() == this.hwnd 
267    {
268       r.left = 3 
269       r.top = 3
270       r.right = .clloc.width - 3
271       r.bottom = .clloc.height - 3
272       DrawFocusRect( ds.hDC, r )      
273    }    
274    //wmsg.flags = 1   
275    return 
276 }
277 
278 /*Виртуальный метод vBtnPic.mSetCaption - Обновить заголовок
279 */
280 method vBtnPic.mSetCaption <alias=vBtnPic_mSetCaption>( ustr caption )
281 { 
282    this->vBtn.mSetCaption( caption )
283    .pPicText.LangCaption = this.pCaption.Text( this )
284 }
285 
286 /*Виртуальный метод vBtnPic.mPosChanged - Изменились размеры
287 */
288 method vBtnPic.mPosChanged <alias=vBtnPic_mPosChanged>(evparEvent ev)
289 {
290    this->vCtrl.mPosChanged(ev)
291    .pPicText.Width = .clloc.width
292    .pPicText.Height = .clloc.height
293 }
294 
295 /*Виртуальный метод vURL.mMouse - События от мыши
296 */
297 method uint vBtnPic.mMouse <alias=vBtnPic_mMouse>( evparMouse em )
298 {  
299    switch em.evmtype
300    {
301       case $evmLDown
302       {
303          if .pNoFocus
304          {
305             SetCapture(.hwnd)
306             .flgDown = 1
307             .Invalidate()            
308             return 1
309          }
310       }
311       case $evmLUp
312       {
313          if .pNoFocus
314          {
315             ReleaseCapture()
316             if .flgDown
317             {
318                .flgDown = 0
319                .Invalidate()
320                if .flgEnter 
321                {
322                   .Owner->vCtrl.WinMsg( $WM_COMMAND, $BN_CLICKED << 16, .hwnd )
323                } 
324             }
325             return 1
326          }
327       }
328       case $evmMove 
329       {  
330          if .pNoFocus && .flgDown
331          {
332             POINT pnt
333             GetCursorPos( pnt )
334             if WindowFromPoint( pnt.x, pnt.y ) != .hwnd
335             {
336                if .flgEnter
337                {
338                   .flgEnter = 0
339                   .Invalidate()
340                }   
341             }
342             elif !.flgEnter
343             {            
344                .flgEnter = 1
345                .Invalidate()
346             }            
347          }
348          elif !.flgEnter
349          {
350             .flgEnter = 1      
351             TRACKMOUSEEVENT tm
352              
353             tm.cbSize    = sizeof( TRACKMOUSEEVENT )    
354             tm.dwFlags   = $TME_LEAVE
355             tm.hwndTrack = .hwnd
356             tm.dwHoverTime = 40   
357             TrackMouseEvent(tm)      
358             .Invalidate()
359          }
360       }
361       case $evmLeave
362       {  
363          .flgEnter = 0
364          .Invalidate()
365       }
366       /*case $evmActivate
367       {
368       print( "NOACT 1\n" ) 
369          em.ret = 3//$MA_NOACTIVATE
370          return 1
371       }*/ 
372    }
373    return 0
374 }
375 
376 /*Виртуальный метод uint vBtnPic.mWinCmd - Обработка windows сообщения с командой
377 */
378 method uint vBtnPic.mWinCmd <alias=vBtnPic_mWinCmd>( uint ntfcmd, uint id )
379 {
380    if ntfcmd == $BN_CLICKED 
381    {        
382       if .pBtnStyle == $bsAsRadioBtn 
383       {
384          uint owner as this.Owner->vCtrl
385          uint i
386          if &owner
387          {
388             fornum i=0, owner.pCtrls
389             {
390                uint btn as owner.Comps[i]->vCustomBtn
391                if &btn == &this 
392                {
393                   btn.Checked = 1
394                } 
395                elif btn.TypeIs( vCustomBtn ) &&
396                   btn.pBtnStyle == $bsAsRadioBtn           
397                {                  
398                   btn.Checked = 0                  
399                }  
400             }
401          }
402       }
403       elif .pBtnStyle == $bsAsCheckBox 
404       {           
405          .Checked = !.pChecked
406       }      
407       evparEvent ev
408       ev.sender = &this
409       this.OnClick.Run( ev, this )     
410    }
411    return 0
412 }
413 
414 /*Виртуальный метод uint vCustomBtn.mLangChanged - Изменение текущего языка
415 */
416 method vBtnPic.mLangChanged <alias=vBtnPic_mLangChanged>()
417 {
418    this->vBtn.mLangChanged()
419    .iUpdateImage()  
420 }
421 
422 /*Виртуальный метод vBtnPic.mFontChanged - Изменился шрифт
423 */
424 method vBtnPic.mFontChanged <alias=vBtnPic_mFontChanged>()
425 {
426    this->vCtrl.mFontChanged()
427    .pPicText.FontChanged()   
428 }
429 
430 /*Виртуальный метод vBtnPic.mFocus - Установка фокуса
431 */
432 /*method uint vBtnPic.mFocus <alias=vBtnPic_mFocus>( evparValUint eu )
433 {
434    this->vCtrl.mFocus( eu )
435    return 1
436 }
437 */
438 func init_vBtnPic <entry>()
439 {  
440    regcomp( vBtnPic, "vBtnPic", vBtn, $vCtrl_last, 
441       %{ //%{$mCreateWin,    vBtnPic_mCreateWin},         
442          %{$mPosChanged,     vBtnPic_mPosChanged },          
443          %{$mSetCaption,     vBtnPic_mSetCaption},
444          %{$mWinDrawItem,    vBtnPic_mWinDrawItem},
445          %{$mLangChanged,    vBtnPic_mLangChanged},
446          %{$mMouse,          vBtnPic_mMouse},
447          %{$mFontChanged,     vBtnPic_mFontChanged }/*,
448          %{$mFocus,          vBtnPic_mFocus}*/
449       },       
450       0->collection )      
451 
452             
453 ifdef $DESIGNING {
454    cm.AddComp( vBtnPic, 1, "Additional", "btnpic" )   
455    
456    cm.AddProps( vBtnPic, %{ 
457 "Image"  , ustr, 0,
458 "Layout"   , uint, 0,
459 "Flat"     , uint, 0,
460 "ContVertAlign", uint, 0,
461 "ContHorzAlign", uint, 0,
462 "TabStop", uint, 0,
463 "NoFocus", uint, 0
464    }) 
465    
466    cm.AddPropVals( vBtnPic, "Layout", %{ 
467 "lPicLeft", $lPicLeft,  
468 "lPicTop",  $lPicTop  
469    })
470    
471    cm.AddPropVals( vBtnPic, "ContHorzAlign", %{
472 "ptLeft",    $ptLeft,     
473 "ptCenter",  $ptCenter,   
474 "ptRight",   $ptRight
475    })    
476    
477    cm.AddPropVals( vBtnPic, "ContVertAlign", %{      
478 "ptTop",        $ptTop,                        
479 "ptVertCenter", $ptVertCenter,          
480 "ptBottom",     $ptBottom
481    })    
482       
483             
484 }
485       
486 }
487