EnglishРусский  

   ..

   addustr.g

   app.g

   btn.g

   btnpic.g

   comp.g

   ctrl.g

   ctrlci.g

   design_menu.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

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

Реклама

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

source\lib\vis\design_menu.g
  1 include {
  2    "form.g"
  3    "treeview.g"
  4 }
  5 
  6 
  7 define {
  8    mSelectComp = $vForm_last
  9    
 10    vCompEditForm_last 
 11 } 
 12 
 13 
 14 type vMenuDesign <inherit=vForm>
 15 {   
 16    vTreeView tv
 17    vBtn      bAdd
 18    vBtn      bAddChild
 19    vBtn      bDel
 20    uint      flgnew
 21    uint      curitem
 22    uint      flgediting
 23    
 24    uint      Menu
 25    uint      MainForm
 26    
 27    //eventQueryCreate OnQueryCreate
 28    oneventpos OnQueryCreate
 29    evEvent    OnQuerySelect
 30    evEvent   OnDestroy
 31 }
 32 
 33 
 34 method vMenuDesign.NewItem( TVItem newitem )
 35 { 
 36    .tv.Selected = newitem   
 37    .flgnew = 1
 38    .tv.Edit()
 39    uint he = FindWindowEx( .tv.hwnd, 0, "Edit".ustr().ptr(), 0 )
 40    if he
 41    {      
 42       .flgediting = 1
 43       //SendMessage( he, $EM_SETMODIFY, 1, 0 )
 44       .tv.WinMsg( $WM_COMMAND, $EN_UPDATE << 16, he )
 45       //SendMessage( .tv.hwnd, $WM_COMMAND, ($EN_CHANGE << 16) /*| 0x01*/, he ) 
 46    }
 47    //print( "Newitem 2\n" )
 48 }
 49 
 50 method vMenuDesign.bAdd_click <alias=vMenuDesign_bAdd_click> ( evparEvent ev )
 51 {
 52    uint curitem 
 53    curitem as this.tv.Selected()
 54    if &curitem
 55    {
 56       //previtem as curitem.Prev
 57       curitem as curitem.Parent
 58       //print( "previtem =\( &previtem )\n" )      
 59    }   
 60    if !&curitem   
 61    {      
 62       curitem as .tv.Root
 63    }     
 64    .NewItem( curitem.AppendChild( "New".ustr(), 0 ) )   
 65 }
 66 
 67 method vMenuDesign.bIns_click <alias=vMenuDesign_bIns_click> ( evparEvent ev )
 68 {
 69    uint curitem, previtem as TVItem
 70    curitem as this.tv.Selected()
 71    if &curitem
 72    {
 73       previtem as curitem.Prev
 74       curitem as curitem.Parent
 75      // print( "previtem =\( &previtem )\n" )      
 76    }   
 77    if !&curitem   
 78    {      
 79       curitem as .tv.Root
 80    }     
 81    .NewItem( curitem.InsertChild( "New".ustr(), 0, 0->ustr, previtem ))   
 82 }
 83 
 84 method vMenuDesign.bAddChild_click <alias=vMenuDesign_bAddChild_click> ( evparEvent ev )
 85 {
 86    uint curitem 
 87    curitem as this.tv.Selected()      
 88    if !&curitem   
 89    {      
 90       curitem as .tv.Root
 91    }     
 92    curitem.Expanded = 1
 93    .NewItem( curitem.AppendChild( "New child".ustr(), 0 ) )    
 94 }
 95 
 96 method vMenuDesign.bDel_click <alias=vMenuDesign_bDel_click> ( evparEvent ev )
 97 {
 98    uint curitem 
 99    curitem as this.tv.Selected()      
100    if &curitem
101    {
102       if curitem.Tag
103       {
104          curitem.Tag->vComp.DestroyComp()
105       }
106       curitem.Del()
107    }   
108     
109 }
110 
111 method vMenuDesign.tv_AfterEdit <alias=MenuDesign_tv_AfterEdit> ( /*vComp sender,*/ evparTVEdit etve )
112 {  
113    .flgediting = 0
114    uint curtvitem as etve.Item->TVItem//.tv.Selected
115    if .flgnew 
116    {
117       .flgnew = 0
118       if etve.flgCancel || !*etve.NewLabel
119       {  
120          etve.flgCancel = 1         
121          curtvitem.Del()         
122       }
123       else
124       {
125          uint owner as vCustomMenu
126          if (&curtvitem.Parent()) && (&curtvitem.Parent()) != (&.tv.Root()) 
127          {            
128             owner as curtvitem.Parent.Tag
129          }
130          else 
131          {              
132             owner as .Menu
133          } 
134          //uint cim as .Owner->newcompdes( vMenuItem, owner )->vMenuItem
135          evparQueryCreate eQC
136          eQC.Owner = &owner
137          eQC.TypeId = vMenuItem
138          //print( "1a \(eQC.Owner) \(eQC.TypeId)\n" )         
139          .OnQueryCreate.run( eQC )
140          //print( "1b\n" )
141          uint cim as eQC.NewComp->vMenuItem
142          //print( "1c\n" )
143          if &cim
144          {
145             //print( "2 \(curtvitem.Label.str())\n" )
146             cim.Caption = etve.NewLabel// curtvitem.Label
147             curtvitem.Tag = &cim
148             .tv.Selected = 0->TVItem
149             .tv.Selected = curtvitem
150          }
151          else
152          {
153             //print( "3\n" )
154             etve.flgCancel = 1         
155             curtvitem.Del()       
156          }         
157       }
158    }
159    else
160    {
161       if !etve.flgCancel
162       {
163          uint menuitem as .tv.Selected.Tag->vMenuItem
164          if &menuitem
165          {
166             menuitem.Caption = etve.NewLabel
167             evparValUint eu
168             eu.val = &menuitem
169             .OnQuerySelect.run( eu )
170          }
171       } 
172    }
173    
174 }
175 
176 method vMenuDesign.tv_Key <alias=MenuDesign_tv_Key>( /*vComp sender,*/ evparKey ek )
177 {
178    if ek.evktype == $evkDown
179    {      
180       switch ek.key 
181       {
182          case $VK_INSERT: .bIns_click( 0->evparEvent )           
183          case $VK_DELETE: .bDel_click( 0->evparEvent )
184          case $VK_DOWN
185          {           
186             //print( "KEY\n" ) 
187             if (ek.mstate == $mstShift) || !&(.tv.Selected()) || ( &(.tv.Selected()) == &(.tv.Root.LastChild()) && !&.tv.Root.LastChild.Child() )
188             {
189                .bAdd_click( 0->evparEvent )
190             }
191          }
192          case $VK_RIGHT
193          {            
194             if  /*(ek.mstate == $mstCtrl) ||*/ !&(.tv.Selected()) || ( &(.tv.Selected()) && !&(.tv.Selected.Child()) )
195             {
196                .bAddChild_click( 0->evparEvent )   
197             }
198          }                  
199       }      
200    }  
201     
202 }
203 
204 method vMenuDesign.tv_BeforeSelect <alias=MenuDesign_tv_BeforeSelect>( /*vComp sender,*/ evparQuery etvb )
205 {
206    if .flgediting 
207    {
208       etvb.flgCancel = 1
209    }   
210 }
211 
212 method vMenuDesign.tv_Select <alias=MenuDesign_tv_Select>( /*vComp sender,*/ evparValUint etva )
213 {
214    
215    //print( "sel 1 \(etva.CurItem) \n" )
216    if etva.val 
217    {
218    //print( "sel 2\n" )
219       uint comp
220       if comp = etva.val->TVItem.Tag
221       {
222       //print( "sel \(comp)3\n" )
223          evparValUint eu
224          eu.val = comp
225          .OnQuerySelect.run( eu )
226       } 
227    }
228 }
229 
230 method vMenuDesign.tv_ItemMoved <alias=MenuDesign_tv_ItemMoved>( evparAfterMove evpIM )
231 {
232    uint cur as evpIM.CurItem->TVItem.Tag->vMenuItem
233    switch evpIM.Flag
234    {
235       case $TREE_FIRST :
236       case $TREE_LAST  
237       {         
238          if evpIM.DestItem  
239          {          
240             uint owner as evpIM.DestItem->TVItem.Tag->vMenuItem            
241             if &owner && &owner != &cur.Owner()
242             {
243                cur.Owner = owner
244             }
245             else
246             {
247                cur.CompIndex = *cur.Owner.Comps - 1
248             }                       
249             
250          }
251       }
252       case $TREE_AFTER :       
253       case $TREE_BEFORE
254       {         
255          if evpIM.DestItem  
256          {
257             uint next as evpIM.DestItem->TVItem.Tag->vMenuItem
258             //uint newidx = next.CompIndex
259             uint owner as next.Owner->vMenuItem
260             cur.Owner = 0->vComp
261             //if &owner && &owner != &cur.Owner()
262             //print( "
263             {
264                cur.Owner = owner
265             }
266             //else            
267             //if next
268             {               
269                cur.CompIndex = next.CompIndex//newidx 
270             } 
271          }
272       }                  
273    }
274 }
275 
276 method vMenuDesign.MenuDesign_CloseQuery <alias=MenuDesign_CloseQuery>( evparQuery evpQ )
277 {
278    //print( "CLOSEQUERY\n" )   
279    evpQ.flgCancel = 1
280    this.DestroyComp()
281 }
282 
283 method vMenuDesign vMenuDesign.mCreateWin <alias=vMenuDesign_mCreateWin>( )   
284 {   
285    this->vForm.mCreateWin()
286    ustr ustmp
287    uint comp
288 	comp as this
289    //print( "create des 1\n" )
290 	with comp
291 	{	
292 		.Caption="Menu Designer".ustr()		
293 		.Height=300				
294 		.Visible=0
295 		.Width=200
296       .OnCloseQuery.Set( this, MenuDesign_CloseQuery )
297 	}
298 	comp as this.tv
299 	comp.Owner = this
300 	with comp
301 	{
302 	   .HorzAlign = $alhClient
303       .VertAlign = $alvTopBottom
304       .Bottom = 25
305       .ShowSelection = 1      
306       .RowSelect = 1
307       .LabelEdit = 1
308       .AutoDrag = 1
309       .OnAfterEdit.Set( this, MenuDesign_tv_AfterEdit )
310       .OnKey.Set( this, MenuDesign_tv_Key )
311       .OnBeforeSelect.Set( this, MenuDesign_tv_BeforeSelect )
312       .OnAfterSelect.Set( this, MenuDesign_tv_Select )
313       .OnBeforeMove.Set( this, MenuDesign_tv_ItemMoved )      
314 	}
315    uint left = 0
316    uint width = 70
317    comp as this.bAdd
318 	comp.Owner = this
319 	with comp
320 	{	   
321       .VertAlign = $alvBottom
322       .Caption = "New".ustr()
323       .Bottom = 0
324       .Left = left
325       .Width = width
326       left += .Width
327       .OnClick.Set(this,vMenuDesign_bAdd_click)
328 	}
329    comp as this.bAddChild
330 	comp.Owner = this
331 	with comp
332 	{	   
333       .VertAlign = $alvBottom
334       .Caption = "New child".ustr()
335       .Bottom = 0
336       .Left = left
337       .Width = width
338       left += .Width
339       .OnClick.Set(this,vMenuDesign_bAddChild_click)
340 	}
341    comp as this.bDel
342 	comp.Owner = this
343 	with comp
344 	{	   
345       .VertAlign = $alvBottom
346       .Caption = "Delete".ustr()
347       .Bottom = 0
348       .Left = left
349       .Width = width
350       left += .Width
351       .OnClick.Set(this,vMenuDesign_bDel_click)
352 	}
353 	//print( "create des 10\n" )
354 	return this
355 }
356 
357 method vMenuDesign vMenuDesign.init( )
358 {
359    this.pTypeId = vMenuDesign         
360    return this
361 }
362 
363 method vMenuDesign.mSelectComp <alias=vMenuDesign_mSelectComp> ( vComp newcomp )
364 {
365 //print( "menudes 0 \(&this)\n" )
366    if &newcomp 
367    {      
368    //print( "menudes 1\n" )
369       uint tvitem as .tv.Root()       
370       while tvitem
371       {
372       //print( "menudes 2\n" )         
373          if tvitem.Tag == &newcomp
374          {       
375             tvitem.Label = newcomp->vMenuItem.Caption
376             return 
377          }         
378          tvitem as tvitem.NextInList         
379       
380       }         
381       this.DestroyComp()         
382    }
383 }
384 
385 method vCustomMenu.ToMenuDesign( TVItem ownertvitem )
386 {
387    uint i
388    //print( "tomenu \(*.Comps)\n" )
389    fornum i, *.Comps
390    {
391       uint submenu as .Comps[i]->vMenuItem
392       //print( "submenu \(.Comps[i]->vComp.Name)\n" )
393       submenu.ToMenuDesign( ownertvitem.AppendChild( submenu.Caption, &submenu ) )
394    }
395 }
396 
397 
398 
399 method vForm vCustomMenu.Design( vForm mainform, uint QueryCreate, uint QuerySelect, uint CompEditDelete )
400 {
401    uint win
402    //print( "zdes 1\n" )
403    /*win as new( vMenuDesign )->vMenuDesign   
404    win.fDynamic = 1  
405    win.flgpopup = 1*/   
406    win as 0->vComp.CreateComp( vMenuDesign )->vMenuDesign   
407    //win.flgpopup = 1
408    //win.Owner = mainform
409    
410    //win as mainform.CreateComp( vMenuDesign )->vMenuDesign
411    //SetParent( win.hwnd, 0 ) 
412    //SetWindowPos(win.hwnd, $HWND_TOPMOST, 0, 0, 0, 0, $SWP_NOMOVE |
413    //       $SWP_NOSIZE | $SWP_NOACTIVATE);
414    //print( "zdes 2\(&mainform), \(QueryCreate) \n" )
415    win.OnQueryCreate.Set( mainform, QueryCreate )   
416    win.OnQuerySelect.Set( mainform, QuerySelect )
417    //print( "zdes 4\n" )
418    win.OnDestroy.Set( mainform, CompEditDelete )
419    //print( "zdes 5\n" )
420       
421    
422    //print( "zdes 6 \(&this)\n" )
423    win.Menu = &this
424    //print( "zdes 7 \( &win.tv->vTreeView.Root() )\n" )   
425    win.ShowPopup( mainform )
426    
427    this->vMenuItem.ToMenuDesign( win.tv->vTreeView.Root )
428    
429    
430    //win.ShowModal()
431    //win.Visible = 1   
432    //print( "zdes 8\n" )
433    return win   
434 }
435 
436 method vMenuDesign.mPreDel <alias=vMenuDesign_mPreDel>
437 {
438 //print( "mPreDel menudesign 1\n" )
439    .OnDestroy.run( )
440    this->vForm.mPreDel()
441 //print( "mPreDel menudesign 2\n" )      
442 }
443 
444 func init_vMenuDesign <entry>()
445 {
446    regcomp( vMenuDesign, "vMenuDesign", vForm, $vCompEditForm_last,
447       %{ %{$mCreateWin,     vMenuDesign_mCreateWin},
448          %{$mSelectComp,    vMenuDesign_mSelectComp},
449          %{$mPreDel,        vMenuDesign_mPreDel }},
450       0->collection )     
451 }
Редактировать