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

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