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

   scrollbox.g

   styles.g

   tab.g

   tabitem.g

   tabpage.g

   timer.g

   toolbar.g

   tray.g

   url.g

   vis.g

   viswin.g

Данный проект закрыт! Создан новый скриптовый язык с тем же именем. Всё доступно на GitHub.
Также попробуйте нашу open source кроссплатформенную программу для создания и управления скриптами.

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

source\lib\vis\scrollbox.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.form 15.10.07 0.0.A.
 11 *
 12 * Author: Alexander Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 /* Компонента vScrollBox, порождена от vCtrl
 16 События
 17    
 18 */
 19 
 20 
 21 include {
 22    "panel.g"   
 23 }
 24 
 25 type vScrollBox <inherit = vCtrl>
 26 {  
 27    uint     pBorder
 28    uint     pAutoScroll
 29    uint     flgScrolling
 30    //uint     ptest
 31    uint     pHorzRange
 32    uint     pVertRange
 33    //vPanel panel
 34  //  onevent  onScrolled
 35    evQuery OnBeforeScroll
 36    evEvent    OnAfterScroll
 37 }
 38 
 39 extern {
 40    method vScrollBox.mChildPosChanged ( evparEvent ev )
 41    method vScrollBox.UpdateScroll()
 42 }
 43 
 44 /* Свойство str vPanel.AutoScroll - Get Set
 45 Усотанавливает или получает заколовок панели
 46 */
 47 /*property uint vScrollBox.test
 48 {
 49    return this.ptest
 50 }
 51 
 52 property vScrollBox.test( uint val )
 53 {
 54    if this.ptest != val
 55    {
 56       this.ptest = val
 57       SCROLLINFO si
 58       si.fMask = $SIF_POS
 59       si.nPos = val
 60       SetScrollInfo( .hwnd, $SB_HORZ, si, 1 ) 
 61       .UpdateScroll()          
 62    } 
 63 }
 64 */
 65 
 66 method vScrollBox.iSetRange()
 67 {
 68    SCROLLINFO si
 69    si.cbSize = sizeof(SCROLLINFO)
 70    si.fMask = $SIF_RANGE | $SIF_PAGE 
 71    si.nMin = 0
 72    si.nMax = ?( .pHorzRange, .pHorzRange, 1 )
 73    si.nPage = this.clloc.width + 1              
 74    SetScrollInfo( .hwnd, $SB_HORZ, si, 0 )
 75    //SetScrollRange( .hwnd, $SB_HORZ, 0, .pHorzRange, 1 )
 76             
 77    //SCROLLINFO si   
 78    si.cbSize = sizeof(SCROLLINFO)
 79    si.fMask = $SIF_RANGE | $SIF_PAGE 
 80    si.nMin = 0
 81    si.nMax = ?( .pVertRange, .pVertRange, 1 )
 82    si.nPage = this.clloc.height + 1              
 83    SetScrollInfo( .hwnd, $SB_VERT, si, 1 )
 84    
 85    //print( "Set range3 \(.Name) \(.pHorzRange) \(.pVertRange)\n" )
 86 }
 87 
 88 
 89 /* Свойство str vScrollBox.HorzRange - Get Set
 90 Ширина прокручиваемого размера
 91 */
 92 property uint vScrollBox.HorzRange
 93 {
 94    return .pHorzRange
 95 }
 96 
 97 property vScrollBox.HorzRange( uint val )
 98 {
 99    if .pHorzRange != val
100    {
101       .pHorzRange = val 
102       .iSetRange()         
103       .UpdateScroll()          
104    } 
105 }
106 
107 /* Свойство str vScrollBox.VertRange - Get Set
108 Высота прокручиваемого размера
109 */
110 property uint vScrollBox.VertRange
111 {
112    return .pVertRange
113 }
114 
115 property vScrollBox.VertRange( uint val )
116 {
117    if .pVertRange != val
118    {
119       .pVertRange = val 
120       .iSetRange()         
121       .UpdateScroll()          
122    } 
123 }
124 
125 /* Свойство str vPanel.AutoScroll - Get Set
126 Усотанавливает или получает заколовок панели
127 */
128 property uint vScrollBox.AutoScroll
129 {
130    return this.pAutoScroll
131 }
132 
133 property vScrollBox.AutoScroll( uint val )
134 {
135    if this.pAutoScroll != val
136    {
137       this.pAutoScroll = val
138       if val
139       {
140          evparEvent ev
141          .mChildPosChanged( ev )
142       } 
143       //   ShowScrollBar( .hwnd, $SB_VERT | $SB_HORZ, 0 )           
144    } 
145 }
146 
147 
148 /* Свойство uint Border - Get Set
149 Усотанавливает или определяет рамку панели
150 Возможны следующие варианты:
151 brdNone        - нет рамки,
152 brdLowered     - рамка вдавлена,
153 brdDblRaised   - рамка выпуклая,
154 brdDblLowered  - рамка двойная выпуклая
155 */
156 property uint vScrollBox.Border()
157 {
158    return this.pBorder
159 }
160 
161 property vScrollBox.Border( uint val )
162 {  
163    uint style
164    
165    if this.pBorder != val
166    {
167       this.pBorder = val
168       style = GetWindowLong( this.hwnd, $GWL_EXSTYLE )
169       style &= ~( $WS_EX_STATICEDGE | $WS_EX_WINDOWEDGE | $WS_EX_CLIENTEDGE | 
170                   $WS_EX_DLGMODALFRAME)
171       switch val
172       {         
173          case $brdLowered    :  style |= $WS_EX_STATICEDGE             	
174          case $brdDblRaised :  style |= $WS_EX_DLGMODALFRAME   
175          case $brdDblLowered :  style |= $WS_EX_CLIENTEDGE         
176       }
177       SetWindowLong( this.hwnd, $GWL_EXSTYLE, style )      
178       SetWindowPos( this.hwnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED | 
179                   $SWP_NOACTIVATE | $SWP_NOZORDER | $SWP_NOMOVE | $SWP_NOSIZE )      
180    }     
181 }
182 
183 method vScrollBox.UpdateScroll()
184 {
185    SCROLLINFO si
186    si.cbSize = sizeof(SCROLLINFO)
187    si.fMask = $SIF_POS | $SIF_RANGE | $SIF_PAGE           
188    GetScrollInfo( .hwnd, $SB_VERT, si )
189    uint newtop = si.nPos
190    //print( "update scroll \(.Name) 1 \( newtop ) \(si.nMax) \(si.nPage) \n" )
191    GetScrollInfo( .hwnd, $SB_HORZ, si )
192    uint newleft = si.nPos
193      
194    //print( "update scroll \(.Name) 2 \( newleft ) \(si.nMax) \(si.nPage) \n" ) 
195    uint i
196    uint offx = newleft - this.clloc.left
197    uint offy = newtop - this.clloc.top
198    if offx || offy
199    { 
200       evparQuery pq
201       
202       .OnBeforeScroll.run( pq )
203       if !pq.flgCancel
204       { 
205       .flgScrolling = 1
206       //print( "Scroll \(offx) \(offy)\n" )
207       this.clloc.top = newtop
208       this.clloc.left = newleft
209       
210       /*uint r = CreateRectRgn( 0, 0, 1, 1 )
211       uint a = CreateRectRgn( 0, 0, 1, 1 )      
212       fornum i = 0, .pCtrls               
213       {
214          
215          //.Comps[i]->vCtrl.Top = .Comps[i]->vCtrl.Top
216          if .Comps[i]->vCtrl.HorzAlign != $alhLeft || .Comps[i]->vCtrl.VertAlign != $alvTop
217          {
218             GetWindowRgn( .Comps[i]->vCtrl.hwnd, a )
219             //.Comps[i]->vCtrl.Visible = 0
220             CombineRgn( r, r, a, $RGN_OR )
221          }
222          //.Comps[i]->vCtrl.hwnd )
223          //RedrawWindow( this.hwnd, 0->RECT, 0, 0x507)
224          //win_move( .Comps[i]->vCtrl.hwnd, ep.loc.left, ep.loc.top )
225       }*/
226       UpdateWindow( this.hwnd )
227       ScrollWindowEx( this.hwnd, -offx, -offy, 0, 0, 0, 0,  7 )
228       //DeleteObject( r )
229       //UpdateWindow( this.hwnd )
230       //Sleep( 1000 )
231       //for i = .pCtrls-1, i >= 0, i--
232       /*fornum i = 0, .pCtrls               
233       {
234          
235          //.Comps[i]->vCtrl.Top = .Comps[i]->vCtrl.Top
236          if .Comps[i]->vCtrl.HorzAlign != $alhLeft || .Comps[i]->vCtrl.VertAlign != $alvTop
237          {
238          print( "SCROLL \(.Comps[i]->vComp.Name ) \(.Comps[i]->vComp.TypeName )\n" )
239          eventpos ep         
240          ep.loc = .Comps[i]->vCtrl.loc
241          ep.loc.left = ep.loc.left
242          ep.loc.top = ep.loc.top 
243          //ep.loc.left -= offx
244          //ep.loc.top -= offy
245          ep.move = 1
246          ep.code = $e_poschanging      
247          .Comps[i]->vCtrl.Virtual( $mPosChanging, ep )
248          //.Comps[i]->vCtrl.Visible = 1
249          }
250          //UpdateWindow( this.hwnd )//.Comps[i]->vCtrl.hwnd )
251          //RedrawWindow( this.hwnd, 0->RECT, 0, 0x507)
252          //win_move( .Comps[i]->vCtrl.hwnd, ep.loc.left, ep.loc.top )
253       }*/
254       .flgScrolling = 0
255          .OnAfterScroll.run( )
256       }
257       
258    }
259       
260       /*else
261       {
262          if this.clloc.left != newpos
263          { 
264             this.clloc.left = newpos
265             fornum i = 0, .pCtrls               
266             {
267                .Comps[i]->vCtrl.Left = .Comps[i]->vCtrl.Left
268             }
269          }
270       }   */   
271 }
272 
273 method uint vScrollBox.wmscroll <alias=vScrollBox_wmscroll> ( winmsg wmsg )
274 {   
275  
276    uint flag = ?( wmsg.msg == $WM_VSCROLL, $SB_VERT, $SB_HORZ )      
277    int newpos
278    SCROLLINFO si
279    si.cbSize = sizeof(SCROLLINFO)
280    si.fMask = $SIF_POS | $SIF_PAGE | $SIF_RANGE |$SIF_TRACKPOS           
281    GetScrollInfo( .hwnd, flag, si )
282    newpos = si.nPos
283    switch wmsg.wpar & 0xFFFF
284    {
285       case $SB_LINEUP : newpos -= 10
286       case $SB_LINEDOWN : newpos += 10
287       case $SB_PAGEUP : newpos -= si.nPage
288       case $SB_PAGEDOWN : newpos += si.nPage
289       case $SB_TOP    : newpos = si.nMax
290       case $SB_BOTTOM : newpos = si.nMin
291       case $SB_THUMBPOSITION, $SB_THUMBTRACK 
292       {  
293          newpos = si.nTrackPos
294       }
295       default : return 0
296    }            
297    si.fMask = $SIF_POS      
298    newpos = max( si.nMin, min( newpos, si.nMax ) )
299 //   print( "newpos = \(newpos)\n" )      
300    si.nPos = newpos
301    SetScrollInfo( .hwnd, flag, si, 1 )
302    
303    .UpdateScroll()                                      
304                
305    wmsg.flags = 1
306    
307    return 0
308 }
309 
310 method vScrollBox.mPosChanged <alias=vScrollBox_mPosChanged>( evparEvent ev )
311 {
312    //print( "PAGE \(.Name) \(this.clloc.height + 1) \(this.clloc.width + 1)\n" )
313    .iSetRange()
314    /*SCROLLINFO si
315    si.cbSize = sizeof(SCROLLINFO) 
316    si.fMask = $SIF_PAGE 
317    si.nPage = this.clloc.height + 1//min( this.clloc.height + 1, this.pVertRange + 2 )                  
318    SetScrollInfo( .hwnd, $SB_VERT, si, 1 )
319       
320    si.fMask = $SIF_PAGE 
321    si.nPage = this.clloc.width + 1//min( this.clloc.width + 1, this.pHorzRange + 2 ) //?( .pHorzRange, this.clloc.width + 1, 0 )               
322    SetScrollInfo( .hwnd, $SB_HORZ, si, 1 )*/
323    //print( "poschanged \(this.clloc.height) \(this.clloc.width)\n" )
324    this->vCtrl.mPosChanged( ev )   
325    //print( "poschanged\n" )
326    .UpdateScroll()
327    //print( "poschanged end\n" )   
328 }
329 
330 method vScrollBox.mChildPosChanged <alias=vScrollBox_mChildPosChanged>( evparEvent ev )
331 {
332    
333    if .pAutoScroll && !.flgScrolling
334    {      
335       uint i
336       int maxwidth, maxheight
337       fornum i = 0, .pCtrls               
338       {
339          if .Comps[i]->vCtrl.HorzAlign == $alhLeft
340          {
341             maxwidth = max( maxwidth, .Comps[i]->vCtrl.Left + .Comps[i]->vCtrl.Width )
342          }
343          if .Comps[i]->vCtrl.VertAlign == $alvTop
344          {
345             maxheight = max( maxheight, .Comps[i]->vCtrl.Top + .Comps[i]->vCtrl.Height )
346          }
347       }
348       .pHorzRange = maxwidth
349       .pVertRange = maxheight
350       .iSetRange()
351       //print( "Childpos 2\n" )
352       /*SCROLLINFO si
353       si.cbSize = sizeof(SCROLLINFO)
354       si.fMask = $SIF_RANGE 
355       si.nMin = 0
356       si.nMax = maxheight              
357       SetScrollInfo( .hwnd, $SB_VERT, si, 1 )
358       si.nMax = maxwidth
359       SetScrollInfo( .hwnd, $SB_HORZ, si, 1 )*/
360       .UpdateScroll()
361    }      
362 }
363 
364 method vScrollBox vScrollBox.mCreateWin <alias=vScrollBox_mCreateWin>()
365 {
366    uint style = $WS_CHILD | $WS_CLIPCHILDREN | $WS_CLIPSIBLINGS | 
367                 $WS_OVERLAPPED //| $WS_VSCROLL | $WS_HSCROLL 
368    .CreateWin( /*"GvScrollBox".ustr()*/"GvForm".ustr(), 0, style )
369    /*SCROLLINFO si
370    si.cbSize = sizeof(SCROLLINFO)
371    si.fMask = $SIF_RANGE 
372    si.nMin = 0
373    si.nMax = 500              
374    SetScrollInfo( .hwnd, $SB_VERT, si, 1 )
375    si.nMax = 800
376    SetScrollInfo( .hwnd, $SB_HORZ, si, 1 )*/
377    this.prevwndproc = -1      
378    this->vCtrl.mCreateWin()  
379    if this.pBorder 
380    {
381       uint border = this.pBorder 
382       this.pBorder = 0
383       this.Border = border
384    }
385    .iSetRange()
386    .UpdateScroll()
387    //.panel.Owner = this                                                 
388    return this
389 }
390 
391 
392 
393 /*------------------------------------------------------------------------------
394    Registration
395 */
396 method vScrollBox vScrollBox.init( )
397 {
398    this.pTypeId = vScrollBox
399    this.pCanContain = 1
400    //this.pBorder = $brdLowered   
401    this.loc.width = 100
402    this.loc.height = 100
403    //this.panel.pAlign = $alhClient | $alvClient   
404    this.pBorder = $brdLowered
405    return this 
406 }  
407 
408 
409 
410 
411 func init_vScrollBox <entry>()
412 {
413    /*WNDCLASSEX visclass
414    ustr classname = "GvScrollBox"    
415    with visclass
416    {
417       .cbSize      = sizeof( WNDCLASSEX )
418       //.style       = $CS_HREDRAW | $CS_VREDRAW
419       .lpfnWndProc = callback( &myproc, 4 )      
420       .hInstance   = GetModuleHandle( 0 )      
421       .hCursor     = LoadCursor( 0, $IDC_ARROW )
422       .hbrBackground = 1      
423       .lpszClassName = classname.ptr()      
424    } 
425    uint hclass = RegisterClassEx( &visclass )
426 */  
427    regcomp( vScrollBox, "vScrollBox", vCtrl, $vCtrl_last,
428       %{ %{$mCreateWin, vScrollBox_mCreateWin }, 
429          %{$mPosChanged, vScrollBox_mPosChanged },
430          %{$mChildPosChanged, vScrollBox_mChildPosChanged }         
431       },
432       %{ %{$WM_VSCROLL, vScrollBox_wmscroll },
433          %{$WM_HSCROLL, vScrollBox_wmscroll }
434       } )
435       
436 ifdef $DESIGNING {
437    cm.AddComp( vScrollBox, 1, "Windows", "scrollbox" )
438    cm.AddProps( vScrollBox,  %{ 
439 "Caption"  , ustr,  0,
440 "Border",   uint, 0,
441 "AutoScroll", uint, 0,
442 "HorzRange", uint, 0,
443 "VertRange", uint, 0
444    })     
445    cm.AddPropVals( vScrollBox, "Border", %{  
446 "brdNone"         ,  $brdNone      ,
447 "brdLowered"      ,  $brdLowered   ,       
448 "brdDblRaised"    ,  $brdDblRaised ,
449 "brdDblLowered"   ,  $brdDblLowered
450    })
451 }
452       
453 }
454 
455 
Редактировать