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

   toolbaritem.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\toolbaritem.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.toolbaritem 02.04.08 0.0.A.
 11 *
 12 * Author: Alexander Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 
 16 
 17 /* Компонента vToolBar, порождена от vCtrl
 18 */
 19 /*! В перспективе: 
 20 */
 21 type vToolBarItem <inherit = vVirtCtrl>
 22 {
 23 //Hidden Fields
 24    uint    pTBIStyle
 25    locustr pCaption
 26    ustr    pImageId   
 27    int     pImageIndex
 28    uint    pState
 29    uint    pDropDownMenu
 30    uint    pMenuItem
 31    uint    pChecked
 32    uint    pShowCaption
 33    
 34 //Events   
 35    evEvent OnClick
 36 }
 37 
 38 define <export>{
 39 //TBIStyle values:
 40    tbsButton     = 0 //Кнопка   
 41    tbsSeparator  = 1 //Разделитель
 42    tbsDropDown   = 2 //Выпадающее меню
 43    tbsAsCheckBox = 3 //Кнопка с фиксацией
 44    tbsAsRadioBtn = 4 //Кнопка как radiobutton
 45 }     
 46 
 47 extern {
 48 method vToolBarItem.mPosUpdate()
 49 method vToolBarItem.iUpdateChecked()
 50 property vToolBarItem.Checked( uint val)
 51 property uint vToolBarItem.Checked
 52 }
 53 
 54 /*------------------------------------------------------------------------------
 55    Internal Methods
 56 */
 57 /*Метод vToolBarItem.iUpdate()
 58 Обновить элемент
 59 */
 60 method vToolBarItem.iUpdate()
 61 {
 62    if &this.Owner && this.Owner.TypeIs( vToolBar )
 63    {
 64       TBBUTTONINFO tbi
 65       uint mask
 66       uint state
 67       
 68       switch .pTBIStyle       
 69       {
 70          case $tbsButton : tbi.fsStyle = $TBSTYLE_BUTTON         
 71          case $tbsSeparator {
 72             tbi.fsStyle = $TBSTYLE_SEP
 73             //tbi.iImage = 100
 74             //mask = $TBIF_IMAGE   
 75          }          
 76          case $tbsDropDown  : tbi.fsStyle = $TBSTYLE_DROPDOWN          
 77          case $tbsAsCheckBox : tbi.fsStyle = $TBSTYLE_CHECK         
 78          case $tbsAsRadioBtn : tbi.fsStyle = $TBSTYLE_CHECK | $TBSTYLE_GROUP
 79       }
 80       if .pTBIStyle != $tbsSeparator 
 81       {
 82          if ( this.pTBIStyle == $tbsAsCheckBox ||
 83             this.pTBIStyle == $tbsAsRadioBtn ) && this.pChecked
 84          {
 85             state |= $TBSTATE_CHECKED 
 86          } 
 87          tbi.iImage = .pImageIndex
 88          //print( "IMAGE IDX = \(.pImageIndex)\n" )
 89       }
 90       else
 91       {
 92          tbi.iImage = 10
 93       }
 94       if .pShowCaption 
 95       {
 96          tbi.fsStyle |= $BTNS_SHOWTEXT
 97       }
 98       if !.p_designing 
 99       {
100          if !.pVisible : state |= $TBSTATE_HIDDEN         
101       }
102       else
103       {
104          state |= $TBSTATE_PRESSED 
105       }
106       if .pEnabled : state |= $TBSTATE_ENABLED 
107       tbi.pszText = this.pCaption.Text( this ).ptr()
108     
109         
110       //print( ".pEnabled \(.pEnabled) \(state )\n" )
111       //print( ".pVisible \(.pVisible) \(state )\n" )
112       tbi.fsState = state
113       tbi.cbSize = sizeof( TBBUTTONINFO )
114       tbi.dwMask = mask | $TBIF_STYLE | $TBIF_STATE | $TBIF_TEXT | $TBIF_IMAGE      
115       this.Owner->vToolBar.WinMsg( $TB_SETBUTTONINFO, /*&this*/this.pIndex, &tbi )//cidx, &tbi )
116       .mPosUpdate() 
117       this.Owner->vToolBar.WinMsg( $TB_AUTOSIZE )
118    }
119 }
120 
121 
122 /* Метод iUpdateChecked 
123 Связывает состояние кнопки с визуальным отображением
124 */
125 method vToolBarItem.iUpdateChecked
126 {
127    .iUpdate()
128    if this.pTBIStyle == $tbsAsRadioBtn  
129    {
130       if .pChecked
131       {
132          uint owner as this.Owner->vCtrl
133          uint i
134          if &owner
135          {            
136             //print( "cidx = \(.cidx )\n" )
137             for i = .pIndex - 1, int(i) >= 0, i--//.cidx - 1, int(i) >= 0, i--
138             {  
139                uint item as owner.Comps[i]->vToolBarItem
140                if item.TypeIs( vToolBarItem ) &&
141                   item.pTBIStyle == $tbsAsRadioBtn           
142                {           
143                   //print( "clear \(i)\n" )
144                   item.Checked = 0                  
145                }  
146                else : break
147             }
148             fornum i = .pIndex + 1, owner.pCtrls//.cidx + 1, owner.pCtrls
149             {
150                uint item as owner.Comps[i]->vToolBarItem
151                if item.TypeIs( vToolBarItem ) &&
152                   item.pTBIStyle == $tbsAsRadioBtn           
153                {
154                   //print( "clear \(i)\n" )                  
155                   item.Checked = 0                  
156                }  
157                else : break
158             }
159          }
160       }
161    }   
162 }
163 
164 
165 
166 /*------------------------------------------------------------------------------
167    Properties
168 */
169 /* Свойство uint TBIStyle - Get Set
170 Положение сплиттера (расстояние от левого или верхнего края
171 */
172 property uint vToolBarItem.TBIStyle()
173 {  
174    return this.pTBIStyle
175 }
176 
177 property vToolBarItem.TBIStyle( uint val)
178 {   
179    if this.pTBIStyle!= val
180    {  
181       this.pTBIStyle = val
182       .iUpdate()
183       if &this.Owner
184       {
185          this.Owner->vCtrl.Invalidate()
186       }       
187    }
188 }
189 
190 /* Свойство ustr vToolBarItem.Caption - Get Set
191 Заголовок кнопки
192 */
193 property ustr vToolBarItem.Caption <result>
194 {
195    result = this.pCaption.Value
196 }
197 
198 property vToolBarItem.Caption( ustr val )
199 {  
200    if val != this.pCaption.Value
201    { 
202       this.pCaption.Value = val
203       .iUpdate()
204    }         
205 }
206 
207 
208 /* Свойство uint Checked - Get Set
209 Усотанавливает или определяет, находится ли кнопка в выбранном состоянии
210 Действует только для стилей кнопки $bsAsCheckBox или $bsAsRadioBtn
211 1 - кнопка выбрана
212 0 - кнопка не выбрана
213 */
214 property uint vToolBarItem.Checked()
215 {  
216    return this.pChecked
217 }
218 
219 property vToolBarItem.Checked( uint val)
220 {
221    if this.pChecked != val
222    {    
223       this.pChecked = val
224       .iUpdateChecked()
225    }
226 }
227 
228 /* Метод iUpdateChecked 
229 Связывает состояние кнопки с визуальным отображением
230 */
231 /*method vToolBarItem.iUpdateChecked
232 {
233    if ( this.pTBIStyle == $bsAsCheckBox ||
234       this.pTBIStyle == $bsAsRadioBtn ) 
235    {*/       
236       /*this.WinMsg( $BM_SETCHECK, .pChecked )
237       if .pBtnTBIStyle == $bsAsRadioBtn && .pChecked
238       {
239          uint owner as this.Owner->vCtrl
240          uint i
241          if &owner
242          {
243             fornum i=0, owner.pCtrls
244             {
245                uint btn as owner.Comps[i]->vCustomBtn
246                if &btn != &this && 
247                   btn.TypeIs( vCustomBtn ) &&
248                   btn.pBtnTBIStyle == $bsAsRadioBtn           
249                {                  
250                   btn.Checked = 0//( btn.WinMsg( $BM_GETCHECK ) == $BST_CHECKED )                  
251                }  
252             }
253          }
254       }
255       InvalidateRect( this.hwnd, 0->RECT, 1 )
256       */
257  /*  }
258      
259 }*/
260 
261 /* Свойство ustr vToolBarItem.DropDownMenu - Get Set
262 Заголовок кнопки
263 */
264 property vPopupMenu vToolBarItem.DropDownMenu
265 {
266    return this.pDropDownMenu->vPopupMenu
267 }
268 
269 property vToolBarItem.DropDownMenu( vPopupMenu val )
270 {  
271    if &val != this.pDropDownMenu
272    { 
273       this.pDropDownMenu = &val      
274    }         
275 }
276 
277 /* Свойство ustr vToolBarItem.ImageId - Get Set
278 Устанавливает или получает картинку
279 */
280 property ustr vToolBarItem.ImageId <result>
281 {
282    result = this.pImageId
283 }
284 
285 property vToolBarItem.ImageId( ustr val )
286 {
287    if val != this.pImageId
288    { 
289       this.pImageId = val
290       
291       if &.Owner && .Owner->vToolBar.ptrImageList
292       {
293          //print( "item.image \( val.str())\n")      
294          this.pImageIndex = .Owner->vToolBar.ptrImageList->ImageList.GetImageIdx( .Owner->vToolBar.iNumIml, val, 0 )
295       }
296       else : this.pImageIndex = -1
297 //      print( "item.image \( this.pImageIndex )\n")    
298       .iUpdate()
299       
300    }   
301 }
302 
303 
304 /* Свойство ustr vToolBarItem.ShowCaption - Get Set
305 Устанавливает или получает флаг показывать текст для mixed режима
306 */
307 property uint vToolBarItem.ShowCaption 
308 {
309    return this.pShowCaption
310 }
311 
312 property vToolBarItem.ShowCaption( uint val )
313 {
314    if val != this.pShowCaption
315    { 
316       this.pShowCaption = val       
317       .iUpdate()      
318    }   
319 }
320 
321 /*------------------------------------------------------------------------------
322    Virtual Methods
323 */
324 
325 method vToolBarItem vToolBarItem.mCreateWin <alias=vToolBarItem_mCreateWin>()
326 {
327    
328    return this
329 }
330 
331 method vToolBarItem.mPosUpdate <alias=vToolBarItem_mPosUpdate>()
332 {
333    //print( "posupdate\n" )
334    if &this.Owner && this.Owner.TypeIs( vToolBar )
335    {
336       RECT r
337       this.Owner->vToolBar.WinMsg( $TB_GETITEMRECT, this.Owner->vToolBar.WinMsg( $TB_COMMANDTOINDEX, this.pIndex ), &r )//this.cidx/*&this*/ ), &r )
338       this.loc.left = r.left
339       this.loc.top = r.top
340       this.loc.width = r.right - r.left 
341       this.loc.height = r.bottom - r.top   
342    }
343    
344 }
345 
346 /*Виртуальный метод vToolBarItem.mSetVisible
347 Установка видимости
348 */
349 method vToolBarItem.mSetVisible <alias=vToolBarItem_mSetVisible>()
350 {
351    .iUpdate()
352 }
353 
354 /*Виртуальный метод vToolBarItem.mSetVisible
355 Установка доступности
356 */
357 method vToolBarItem.mSetEnabled <alias=vToolBarItem_mSetEnabled>()
358 {
359    .iUpdate()
360 }
361 
362 /*Виртуальный метод  vToolBarItem.mLangChanged - Изменение текущего языка
363 */
364 method vToolBarItem.mLangChanged <alias=vToolBarItem_mLangChanged>()
365 {
366    //.iUpdateImageList()
367    if &.Owner && .Owner->vToolBar.ptrImageList
368    {
369       this.pImageIndex = .Owner->vToolBar.ptrImageList->ImageList.GetImageIdx( .Owner->vToolBar.iNumIml, .pImageId, 0 )
370    }
371    else : this.pImageIndex = -1
372    .iUpdate()
373    //this->vCtrl.mLangChanged() 
374 }
375 
376 /*Виртуальный метод vToolBarItem.mSetName - Установка заголовка в режиме проектирования
377 */
378 method uint vToolBarItem.mSetName <alias=vToolBarItem_mSetName>( str newname )
379 {
380 ifdef $DESIGNING {   
381    if !.p_loading && .Caption == .Name
382    {
383       .Caption = newname.ustr()
384    }
385 }   
386    return 1
387 }
388 
389 
390 /*Виртуальный метод vToolBarItem.mSetIndex - Установка текущего индекска элемента
391 */
392 method vToolBarItem.mSetIndex <alias=vToolBarItem_mSetIndex>( uint newidx )
393 {
394    if &.Owner 
395    {  
396       uint oldpos = .pIndex      
397       this->vVirtCtrl.mSetIndex( newidx )
398       .Owner->vToolBar.WinMsg( $TB_MOVEBUTTON, oldpos, .pIndex )
399       uint i
400       fornum i=0, *.Owner->vToolBar.Comps
401       {
402          .Owner->vToolBar.WinMsg( $TB_SETCMDID, i, i )   
403       } 
404    }
405 }