EnglishРусский  

   ..

   btnsys.g

   funcs.g

   gena.g

   gfe.g

   proplist.g

   visedit.g

   viseditor.gi

   winedit.g

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

Реклама

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

  1 
  2 /******************************************************************************
  3 *
  4 * Copyright (C) 2004-2007, The Gentee Group. All rights reserved. 
  5 * This file is part of the Gentee open source project - http://www.gentee.com. 
  6 * 
  7 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  8 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  9 * ACCEPTANCE OF THE AGREEMENT.
 10 *
 11 * ID: viseditor.proplist 30.07.07 0.0.A.
 12 *
 13 * Author: Alexander Krivonogov ( gentee )
 14 *
 15 ******************************************************************************/
 16 
 17 /*
 18 define {
 19    PI_SIMPLE = 0x000
 20    PI_UPDOWN = 0x001
 21    PI_DLG    = 0x002
 22    PI_SEL    = 0x100
 23    
 24    PI_DEFVAL = 0x1000000
 25    PI_LIST   = 0x1000
 26 }
 27 */
 28 type evparProp <inherit=evparEvent>
 29 {
 30    ustr name
 31    ustr value
 32 }
 33 
 34 type evProp <inherit=evEvent>
 35 {
 36 }
 37 
 38 method evProp evProp.init
 39 {
 40    this.eventtypeid = evparProp
 41    return this
 42 }
 43 
 44 
 45 type vSDraw <inherit = vCtrl>
 46 {
 47    ustr    pCaption
 48    uint    off 
 49 }
 50 
 51 
 52 method uint vSDraw.wmpaint <alias=vSDraw_wmpaint>( winmsg wmsg )
 53 {
 54    uint         hdc
 55    PAINTSTRUCT  ps
 56    RECT         rect      
 57 
 58    hdc = BeginPaint( this.hwnd, ps )
 59    rect.left = this.clloc.left
 60    rect.right = this.clloc.width
 61    rect.top = this.clloc.top
 62    rect.bottom = this.clloc.height
 63    DrawEdge( hdc,    
 64                rect,
 65                $BDR_SUNKENOUTER,     
 66                $BF_LEFT | $BF_RIGHT | $BF_TOP | $BF_BOTTOM  )         
 67    SelectObject( hdc, GetStockObject( $DEFAULT_GUI_FONT ) )         
 68    SetBkMode( hdc, $TRANSPARENT )
 69    SetTextColor( hdc, GetSysColor( $COLOR_HIGHLIGHT ) )
 70    rect.left +=5
 71    rect.top ++
 72    DrawText( hdc, this.pCaption.ptr(), -1, rect, $DT_LEFT | $DT_SINGLELINE  )   
 73    MoveToEx( hdc, this.off, 0, 0->POINT )
 74    LineTo( hdc, this.off, this.Height )
 75    EndPaint( this.hwnd, ps )
 76    return 0
 77 }
 78 
 79 
 80 
 81 method vSDraw vSDraw.mCreateWin <alias=vSDraw_mCreateWin>()
 82 {
 83    this.CreateWin( "GVForm".ustr(), 0, 
 84 $WS_CHILD | $WS_VISIBLE | $WS_CLIPCHILDREN | $WS_CLIPSIBLINGS | $WS_OVERLAPPED)
 85    this.prevwndproc = -1
 86    this->vCtrl.mCreateWin()
 87    //this.prevwndproc = 0
 88    this.WinMsg( $WM_SETFONT, GetStockObject( $DEFAULT_GUI_FONT ) )                     
 89    return this
 90 }
 91 
 92 property str vSDraw.Caption <result>
 93 {
 94    result = this.pCaption
 95 }
 96 
 97 property vSDraw.Caption( ustr val )
 98 {
 99    this.pCaption = val
100    InvalidateRect( this.hwnd, 0->RECT, 1 ) 
101 }
102 
103 type vPropList <inherit=vCtrl>
104 {
105    uint ncount    //Количество строк
106    uint nfirst    //Первая строка
107    uint nviscount //Количество видимых строк
108    uint nheight   //Высота строки
109    uint ncur      //Номер текущей строки
110    uint nleftwidth//Ширина левой части
111    vSDraw curprop  
112    vEdit  ed   
113    vBtnSys bs
114    uint sysfont
115    uint pen
116    arr ar of PropItem
117    evProp onPropSet
118    evEvent ongetlist   
119    evEvent ondblclick
120    vComboBox cb
121    uint prevcap
122    ustr lastprop
123    //arr 
124 }
125 
126 define {
127    SETFIRST_ABS = 0
128    SETFIRST_OFF = 1
129    SETFIRST_PAGE = 2
130 }
131 
132 method vPropList.calccur( )
133 {
134    this.curprop.Top = ( this.ncur - this.nfirst ) * this.nheight 
135 }
136 
137 method vPropList.setfirst( uint flag, int pos )
138 {
139    int newpos = this.nfirst
140    switch flag {   
141       case $SETFIRST_ABS {
142          if pos == -1 {
143             newpos = this.ncount
144          }         
145          else {
146             newpos = pos
147          }           
148       }
149       case $SETFIRST_OFF {
150          newpos += pos
151       }
152       case $SETFIRST_PAGE {
153          newpos += this.nviscount * pos
154       }
155    }
156    newpos = min( ?(newpos < 0, 0, newpos ), this.ncount - this.nviscount )    
157    if newpos != this.nfirst
158    {
159       this.nfirst = newpos      
160       SetScrollPos( this.hwnd, $SB_VERT, this.nfirst, 1 )
161       InvalidateRect( this.hwnd, 0->RECT, 1 )
162       this.calccur()
163    } 
164 }
165 
166 method vPropList.propset()
167 {
168    evparProp ep
169    ep.name = this.curprop.Caption
170    ep.value = this.ed.Text   
171    this.onPropSet.run( ep )
172 }
173 
174 method vPropList.setcur( uint val, uint flgstate )
175 {
176    if val >= this.ncount : val = -1
177    if val != this.ncur && val != -1
178    {
179       if this.ed.Changed 
180       {      
181          this.ed.Changed = 0
182          this.propset()
183       }
184       
185       this.ncur = val      
186       this.curprop.Visible = 0      
187       this.calccur()      
188       this.curprop.Caption = this.ar[this.ncur].Name//"temp \( this.ncur)"      
189       this.ed.Text = this.ar[this.ncur].Value
190       
191       if this.ar[this.ncur].Flags & $PI_LIST
192       {
193          this.bs.Width = this.nheight
194       }
195       else : this.bs.Width = 0 
196       this.ed.Width = this.clloc.width - this.ed.Left - this.bs.Width
197       this.bs.Left = this.clloc.width - this.bs.Width            
198       if flgstate 
199       {
200          this.lastprop = this.ar[this.ncur].Name
201       }
202       //SetFocus( this.ed.hwnd )
203             
204       this.curprop.Visible = 1
205       //SendMessage( this.ed.hwnd, $EM_SETSEL, 0, -1 )
206       this.ed.SelAll()
207    }
208    if this.ncur < this.nfirst 
209    {
210       this.setfirst( $SETFIRST_ABS, this.ncur )
211    }
212    elif this.ncur >= this.nfirst + this.nviscount
213    {
214       this.setfirst( $SETFIRST_ABS, this.ncur - this.nviscount + 1 )
215    }
216 }
217 
218 
219 method vPropList.calcviscount()
220 {
221    if !this.nheight : return
222    this.nviscount = min( this.clloc.height / this.nheight, this.ncount )
223    
224    
225 //   EnableScrollBar( this.hwnd, $SB_VERT, $ESB_ENABLE_BOTH)   
226    if this.nviscount == this.ncount
227    {  
228       //st.fMask = $SIF_RANGE | $SIF_PAGE;
229       //st.nMax = 0;	
230 		//st.nPage = 0;
231       //ShowScrollBar( this.hwnd, $SB_VERT, 0 )
232       SCROLLINFO si
233       //ShowScrollBar( this.hwnd, $SB_VERT, 1 )
234       si.cbSize = sizeof( SCROLLINFO )
235       si.fMask = $SIF_RANGE | $SIF_PAGE | $SIF_POS
236       si.nMin = 0
237       si.nMax = 0//this.ncount-1// - this.nviscount	
238 		si.nPage = 0//this.nviscount
239       si.nPos = 0;
240       SetScrollInfo( this.hwnd, $SB_VERT, si, 1 )  
241    }
242    else
243    {  
244       
245       SCROLLINFO si
246       //ShowScrollBar( this.hwnd, $SB_VERT, 1 )
247       si.cbSize = sizeof( SCROLLINFO )
248       si.fMask = $SIF_RANGE | $SIF_PAGE | $SIF_POS
249       si.nMin = 0
250       si.nMax = this.ncount-1// - this.nviscount	
251 		si.nPage = this.nviscount
252       si.nPos = this.nfirst//0;
253       SetScrollInfo( this.hwnd, $SB_VERT, si, 1 )   
254       
255    }   
256    this.setfirst( $SETFIRST_ABS, this.nfirst )
257    
258 }
259 
260 method vPropList.setcount( uint new )
261 {
262    this.ncount = new
263    this.nfirst = 0
264    this.calcviscount()
265 }
266 
267 
268 /*method uint vPropList.findprop( str name )
269 {
270    fornum i = 0, *this.ar
271    {
272       if this.ar[i].name == name
273       {  
274          return i
275       }
276    }
277 }*/
278 
279 method vPropList.setar( arr ar of PropItem )
280 {
281    uint i, ncur
282    this.ar.clear()
283    this.ar.expand( *ar )
284    
285    this.ncur = -1      
286    fornum i=0, *ar
287    {
288       //print( "\(ar[i].name) \(this.lastprop) \(ar[i].name >= this.lastprop)\n" )
289       if ar[i].Name == this.lastprop : ncur = i  
290       this.ar[i].Name = ar[i].Name
291       this.ar[i].Value = ar[i].Value
292       this.ar[i].Flags = ar[i].Flags
293    }
294    
295    this.ed.Changed = 0
296    //this.nfirst = 0
297    this.ncount = *ar   
298    this.calcviscount()
299    if this.ncount 
300    {      
301       this.setcur( ncur, 0 )
302       this.curprop.Visible = 1   
303    }
304    else
305    {  
306       this.curprop.Visible = 0
307    }
308    InvalidateRect( this.hwnd, 0->RECT, 1 )
309 } 
310 
311 method uint vPropList.edkey <alias=proplist_edkey>( /*vComp sender,*/ evparKey ek )
312 {  
313    if ek.evktype == $evkDown
314    {      
315       switch ek.key 
316       {
317          case 0x0d 
318          {         
319             if ek.mstate & $mstCtrl :this.ondblclick.run() 
320             else : this.propset()
321             return 0
322          }
323          case 0x1B
324          {
325             this.ed.Text = this.ar[this.ncur].Value
326             SendMessage( this.ed.hwnd, $EM_SETSEL, 0, -1 )
327             return 0
328          }
329          case 0x26//Вверх
330          {
331             this.setcur( this.ncur - 1, 1 )
332             return 0
333          }
334          case 0x28//Вниз
335          {            
336             if ek.mstate & $mstAlt
337             {
338                this.ongetlist.run()
339 //               this.pl.start()
340             }
341             else : this.setcur( this.ncur + 1, 1 )
342             return 0
343          }        
344       }
345    }   
346    return 0
347 }
348 
349 method uint vPropList.edmouse <alias=proplist_edmouse>( /*vComp sender,*/ evparMouse evm )
350 {   
351    if evm.evmtype == $evmLDbl
352    {
353       this.ondblclick.run()
354    } 
355    return 0
356 }
357 
358 method uint vPropList.edfocus <alias=proplist_edfocus>( evparValUint eu )
359 {  
360    if !eu.val && this.ed.Changed: this.propset()
361    return 1
362 }
363 
364 
365 method uint vPropList.bsclick <alias=proplist_bsclick>( evparEvent ev )
366 {
367    this.ongetlist.run()
368    this.cb.DropDown()      
369    return 0
370 }
371 
372 method uint vPropList.cbcloseup<alias=proplist_cbcloseup>( evparEvent ev )
373 {
374    //print( "CLOSE\n" )
375    this.bs.Push = 0
376    return 0
377 }
378 
379 method uint vPropList.plselect <alias=proplist_plselect>( evparValUstr ev )
380 {
381    evparProp ep
382    this.ed.Text = ev.val   
383    ep.name = this.curprop.Caption
384    ep.value = this.ed.Text   
385    this.onPropSet.run( ep )
386    return 0
387 }
388 
389 
390 method vPropList vPropList.mCreateWin <alias=vPropList_mCreateWin>()
391 {
392 
393 //   this->vSDraw.mCreateWin()
394    .CreateWin( "GVForm".ustr(), /*$WS_EX_STATICEDGE*/0,
395 $WS_CHILD | $WS_VISIBLE | $WS_CLIPCHILDREN | $WS_CLIPSIBLINGS | $WS_OVERLAPPED )
396 //   setxpstyle( this.hwnd )   
397    this.prevwndproc = -1
398    this->vCtrl.mCreateWin()
399    //this.prevwndproc = 0
400 
401    this.WinMsg( $WM_SETFONT, GetStockObject( $DEFAULT_GUI_FONT ) )
402    
403    this.sysfont = GetStockObject( $DEFAULT_GUI_FONT )
404    this.pen = CreatePen( $PS_SOLID, 1, GetSysColor($COLOR_INACTIVECAPTION))//$COLOR_WINDOWFRAME) )
405    uint hdc = GetDC( this.hwnd )
406    SelectObject( hdc, this.sysfont )
407    TEXTMETRIC tm
408    GetTextMetrics( hdc, tm )    
409    ReleaseDC( this.hwnd, hdc )
410                                                                        
411    this.nheight = tm.tmHeight + 2
412    this.setcount( 0 )   
413    this.nleftwidth = 90      
414    this.ncur = -1
415    
416 //   this->vPanel.Border = $brdLowered
417                    
418                               
419    this.curprop.Owner = this    
420    this.curprop.Top = 0
421    this.curprop.Width =100
422    this.curprop.Height = this.nheight + 1
423    this.curprop.off = this.nleftwidth
424    
425    
426    this.curprop.VertAlign = $alvTop
427    this.curprop.HorzAlign = $alhClient
428    this.curprop.Name = "x"
429    
430    this.ed.Owner = this.curprop
431    this.ed.Left = this.nleftwidth + 1
432    this.ed.Top = 1//0
433    this.ed.Height = this.nheight          
434    this.ed.VertAlign = $alvTop              
435    this.ed.HorzAlign = $alhLeft
436    this.ed.Border = 0  
437  
438    this.ed.OnKey.Set( this, proplist_edkey )
439    this.ed.OnFocus.Set( this, proplist_edfocus )
440    this.ed.OnMouse.Set( this, proplist_edmouse )
441    this.curprop.OnMouse.Set( this, proplist_edmouse )   
442    
443    this.bs.Owner = this.curprop
444    this.bs.VertAlign = $alvTop
445    this.bs.HorzAlign = $alhLeft
446    this.bs.Width = this.nheight - 1
447    this.bs.Height = this.nheight - 1
448    
449    this.bs.Top = 1 
450    this.bs.onclick.Set( this, proplist_bsclick )
451 //?   this.bs.onmouse.set( this, proplist_bsmouse )
452       
453    this.cb.Owner = this.curprop
454    //this.cb.Height = 10
455    this.cb.Sorted = 1   
456    this.cb.CBStyle = $cbsDropDownList
457    this.cb.Left = this.ed.Left - 1
458    this.cb.Top = this.curprop.Height - this.cb.Height
459    this.cb.OnSelect.Set( this, proplist_plselect )
460    this.cb.oncloseup.Set( this, proplist_cbcloseup )   
461    this.cb.Visible = 0
462    return this
463 }
464 
465 method vPropList.mPosChanged <alias=vPropList_mPosChanged> (evparEvent ev )
466 {   
467    this->vCtrl.mPosChanged( ev )     
468    this.ed.Width = this.clloc.width - this.ed.Left - this.bs.Width
469    this.cb.Width = this.clloc.width - this.cb.Left
470    this.bs.Left = this.clloc.width - this.bs.Width
471    this.calcviscount()
472 }
473 
474 method uint vPropList.wmpaint <alias=vPropList_wmpaint>(winmsg wmsg)
475 {
476    uint         hdc
477    PAINTSTRUCT  ps
478    RECT         rect
479    str          temp
480    
481    hdc = BeginPaint( this.hwnd, ps )
482     
483    SetBkMode( hdc, $TRANSPARENT )
484    uint i
485    SelectObject( hdc, this.sysfont )   
486    SelectObject( hdc, this.pen )
487        
488    rect.top = 0             
489    SetTextColor( hdc, GetSysColor( $COLOR_WINDOWTEXT ) )     
490    fornum i=0, this.nviscount
491    {  
492       rect.right = this.nleftwidth
493       rect.bottom = rect.top + this.nheight 
494       rect.top++ 
495       rect.left = 5                
496       DrawText( hdc, this.ar[i+ this.nfirst].Name.ptr(), -1, rect, $DT_LEFT | $DT_SINGLELINE )                  
497       rect.left = this.nleftwidth + 2      
498       rect.right = this.clloc.width      
499       rect.top++
500       DrawText( hdc, this.ar[i+ this.nfirst].Value.ptr(), -1, rect, $DT_LEFT | $DT_SINGLELINE )
501       rect.top--
502       rect.top--
503       MoveToEx( hdc, 0, rect.bottom, 0->POINT )
504       LineTo( hdc, rect.right, rect.bottom )           
505       rect.top += this.nheight                              
506    }   
507    MoveToEx( hdc, this.nleftwidth, 0, 0->POINT )
508    LineTo( hdc, this.nleftwidth, this.clloc.height )
509    EndPaint( this.hwnd, ps )
510   
511    return 0
512 }
513 
514 method uint vPropList.wmlbuttondown <alias=vPropList_wmlbuttondown>(winmsgmouse wmsg)
515 {
516    uint n = wmsg.y / this.nheight               
517    if n < this.nviscount 
518    {
519       this.setcur( n + this.nfirst, 1 )  
520       SetFocus( this.ed.hwnd )
521    }
522    return 0
523 }
524 
525 method uint vPropList.wmmousewheel <alias=vPropList_wmmousewheel>(winmsg wmsg)
526 {
527    if ((&wmsg->winmsgsh.wparhi)->short ) > 0 : this.setfirst( $SETFIRST_OFF, -3 )
528    else : this.setfirst( $SETFIRST_OFF, 3 )   
529    return 0
530 }
531 
532 method uint vPropList.wmvscroll <alias=vPropList_wmvscroll>(winmsg wmsg)
533 {
534    uint nScrollCode = wmsg->winmsgsh.wparlo
535    uint npos = wmsg->winmsgsh.wparhi
536    switch nScrollCode
537    {
538       case $SB_LINEUP {
539          this.setfirst( $SETFIRST_OFF, -1 )                     
540       }   
541       case $SB_LINEDOWN {
542          this.setfirst( $SETFIRST_OFF, 1 )                     
543       }                    
544       case $SB_PAGEUP {
545          this.setfirst( $SETFIRST_PAGE, -1 )
546       }                                         
547       case $SB_PAGEDOWN {
548          this.setfirst( $SETFIRST_PAGE, 1 )                     
549       }                           
550       case $SB_THUMBTRACK {
551          SCROLLINFO si
552          si.cbSize = sizeof( SCROLLINFO )
553          si.fMask = $SIF_TRACKPOS
554          GetScrollInfo( this.hwnd, $SB_VERT, si )
555          this.setfirst( $SETFIRST_ABS, si.nTrackPos )                     
556       } 
557    }
558    return 0
559 }
560 
561 
562 method vSDraw vSDraw.init( )
563 {        
564    this.pTypeId = vSDraw   
565    this.pCanContain = 1  
566     
567    return this 
568 }  
569 
570 method vPropList vPropList.init( )
571 {     
572 //print( "vPropList.init 1\n" )
573    this.pTypeId = vPropList
574    this.pCanContain = 1
575    //this.flgXPStyle = 1
576 //print( "vPropList.init 2\n" )
577    return this 
578 }  
579 
580 func init_vPropList <entry>()
581 { 
582    regcomp( vSDraw, "vSDraw", vCtrl, $vCtrl_last, 
583       %{ %{$mCreateWin,    vSDraw_mCreateWin}//,
584          //%{$mWinCmd,       vBtn_mWinCmd}
585          }, 
586       %{ %{$WM_PAINT, vSDraw_wmpaint }
587       })                             
588    
589    regcomp( vPropList, "vPropList", vCtrl, $vCtrl_last,       
590       %{ %{$mCreateWin,    vPropList_mCreateWin},
591          %{$mPosChanged,   vPropList_mPosChanged}         
592          }, 
593       %{ %{$WM_PAINT, vPropList_wmpaint },  
594          %{$WM_LBUTTONDOWN, vPropList_wmlbuttondown },
595          %{$WM_MOUSEWHEEL, vPropList_wmmousewheel },
596          %{$WM_VSCROLL, vPropList_wmvscroll }
597       })    
598 }
Редактировать