EnglishРусский  

   ..

   addustr.g

   app.g

   btn.g

   btnpic.g

   comp.g

   ctrl.g

   ctrlci.g

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

Реклама

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

source\lib\vis\design_tab.g
  1 include {
  2    "form.g"
  3    "listview.g"
  4 }
  5 
  6 
  7 /*define {
  8    mSelectComp = $vForm_last
  9    
 10    vCompEditForm_last 
 11 } 
 12 */
 13 
 14 type vTabDesign <inherit=vForm>
 15 {   
 16    vListView lv
 17    vBtn      bAdd
 18    vBtn      bAddChild
 19    vBtn      bDel
 20    uint      flgnew
 21    uint      curitem
 22    uint      flgediting
 23    
 24    uint      Tab
 25    uint      MainForm
 26    
 27    //eventQueryCreate OnQueryCreate
 28    oneventpos OnQueryCreate
 29    evEvent    OnQuerySelect
 30    evEvent   OnDestroy
 31 }
 32 
 33 
 34 method vTabDesign.NewItem( /*LVRow newitem*/LVRow curitem )
 35 { 
 36    .lv.Selected = .lv.Rows.Insert( *.lv.Rows )//.lv.InsertItem( "New".ustr(), 0, curitem )
 37    .lv.Cells( .lv.Selected.Idx, 0 ) = "New".ustr() 
 38    //.lv.Selected.Tag = 0
 39     
 40    .flgnew = 1
 41    .lv.Edit()   
 42    uint he = FindWindowEx( .lv.hwnd, 0, "Edit".ustr().ptr(), 0 )
 43    if he
 44    {      
 45       .flgediting = 1      
 46       .lv.WinMsg( $WM_COMMAND, $EN_UPDATE << 16, he )       
 47    }   
 48 }
 49 
 50 method vTabDesign.bAdd_click <alias=vTabDesign_bAdd_click> ( evparEvent ev )
 51 {
 52    /*uint curitem 
 53    curitem as this.lv.Selected()
 54    if &curitem
 55    {      
 56       curitem as curitem.Parent            
 57    }   
 58    if !&curitem   
 59    {      
 60       curitem as .lv.Root
 61    }     
 62    .NewItem( curitem.AppendChild( "New".ustr(), 0 ) )*/
 63    .NewItem( 0xFFFFFFFF->LVRow )
 64 }
 65 
 66 method vTabDesign.bIns_click <alias=vTabDesign_bIns_click> ( evparEvent ev )
 67 {
 68    
 69    
 70    uint curitem, previtem as LVRow
 71    curitem as this.lv.Selected()
 72    if &curitem
 73    {
 74       curitem as curitem.Prev               
 75    }   
 76    .NewItem( curitem )     
 77    /*.NewItem( curitem.InsertChild( "New".ustr(), 0, previtem ))*/   
 78 }
 79 
 80 
 81 method vTabDesign.bDel_click <alias=vTabDesign_bDel_click> ( evparEvent ev )
 82 {
 83    uint curitem 
 84    curitem as this.lv.Selected()      
 85    if &curitem
 86    {
 87       uint comp as curitem.Tag->vComp
 88       curitem.Del()
 89       if &comp//curitem.Tag
 90       {
 91          comp.DestroyComp()
 92          //curitem.Tag->vComp.DestroyComp()
 93       }
 94       
 95    }    
 96 }
 97 
 98 method vTabDesign.lv_AfterEdit <alias=vTabDesign_lv_AfterEdit> ( /*vComp sender,*/ evparTVEdit etve )
 99 {  
100    .flgediting = 0
101    uint curLVRow as .lv.Selected
102    
103    if .flgnew 
104    {
105       
106       .flgnew = 0
107       if etve.flgCancel || !*etve.NewLabel
108       {  
109          etve.flgCancel = 1         
110          curLVRow.Del()         
111       }
112       else
113       {
114               
115          /*uint owner as vCustomMenu
116          if (&curLVRow.Parent()) && (&curLVRow.Parent()) != (&.lv.Root()) 
117          {            
118             owner as curLVRow.Parent.Tag
119          }
120          else 
121          {              
122             owner as .Menu
123          }*/
124          
125          evparQueryCreate eQC
126          eQC.Owner = this.Tab
127          eQC.TypeId = vTabItem
128               
129                       
130          .OnQueryCreate.run( eQC )
131                   
132          uint cim as eQC.NewComp->vTabItem
133          //uint cim as this.Tab->vTab.CreateComp( vTabItem )->vTabItem
134                   
135          if &cim
136          {
137             cim.Index = .lv.Selected.Idx                   
138             cim.Caption = etve.NewLabel// curLVRow.Label            
139             curLVRow.Tag = &cim            
140             .lv.Selected = 0->LVRow
141             .lv.Selected = curLVRow
142          }
143          else
144          {            
145             etve.flgCancel = 1         
146             curLVRow.Del()       
147          }                  
148       }
149    }
150    else
151    {
152       if !etve.flgCancel
153       {
154          uint tabitem as .lv.Selected.Tag->vTabItem
155          if &tabitem
156          {
157             tabitem.Caption = etve.NewLabel
158             evparValUint eu
159             eu.val = &tabitem
160             .OnQuerySelect.run( eu )
161          }
162       } 
163    }   
164 }
165 
166 method vTabDesign.lv_Key <alias=vTabDesign_lv_Key>( /*vComp sender,*/ evparKey ek )
167 {
168    if ek.evktype == $evkDown
169    {      
170       switch ek.key 
171       {
172          case $VK_INSERT: .bIns_click( 0->evparEvent )           
173          case $VK_DELETE: .bDel_click( 0->evparEvent )
174          case $VK_DOWN
175          {   
176             if !&(.lv.Selected()) || !&.lv.Selected().Next//( &(.lv.Selected()) == &(.lv.Root.LastChild()))
177             {
178                .bAdd_click( 0->evparEvent )
179             }
180          }            
181       }      
182    }   
183 }
184 
185 /*method vTabDesign.lv_BeforeSelect <alias=TabDesign_lv_BeforeSelect>(  evparTVBefore etvb )
186 {   
187    if ( !etvb.CurItem && *.lv.gttree.root() ) || 
188       .flgediting 
189    {
190       etvb.flgCancel = 1
191    }   
192 }*/
193 
194 method vTabDesign.lv_Select <alias=TabDesign_lv_Select>( /*vComp sender,*/ evparValUint etva )
195 {
196    if etva.val  
197    {    
198       uint comp
199       if comp = etva.val->LVRow.Tag
200       {
201          evparValUint eu
202          eu.val = comp         
203          comp->vTabItem.Owner->vTab.CurIndex = comp->vTabItem.Index         
204          .OnQuerySelect.run( eu )
205       } 
206    }
207 }
208 
209 method vTabDesign.lv_ItemMoved <alias=TabDesign_lv_ItemMoved>( evparAfterMove evpIM )
210 {
211    uint cur as evpIM.CurItem->LVRow.Tag->vTabItem
212    switch evpIM.Flag
213    {
214       case $TREE_FIRST :
215       case $TREE_LAST  
216       {
217          cur.Index = *cur.Owner->vTab.Comps - 1           
218       }
219       case $TREE_AFTER :       
220       case $TREE_BEFORE
221       {  
222          if evpIM.DestItem  
223          {
224             uint next as evpIM.DestItem->LVRow.Tag->vTabItem
225             cur.Index = *cur.Owner->vTab.Comps - 1                       
226             if next
227             {               
228                cur.Index = next.Index //- 1  
229             } 
230          }
231       }                  
232    }
233 }
234 
235 method vTabDesign.CloseQuery <alias=TabDesign_CloseQuery>( evparQuery evpQ )
236 {
237    evpQ.flgCancel = 1
238    this.DestroyComp()
239 }
240 
241 method vTabDesign vTabDesign.mCreateWin <alias=vTabDesign_mCreateWin>( )   
242 {   
243    this->vForm.mCreateWin()
244    ustr ustmp
245    uint comp
246 	comp as this   
247 	with comp
248 	{	
249 		.Caption="Tab Designer".ustr()		
250 		.Height=300				
251 		.Visible=0
252 		.Width=200
253       .OnCloseQuery.Set( this, TabDesign_CloseQuery )
254 	}
255 	comp as this.lv
256 	comp.Owner = this
257 	with comp
258 	{
259 	   .HorzAlign = $alhClient
260       .VertAlign = $alvTopBottom
261       .Bottom = 25
262       .ShowSelection = 1
263       .ListViewStyle = $lvsList
264       .LabelEdit = 1
265       .OnAfterEdit.Set( this, vTabDesign_lv_AfterEdit )
266       .OnKey.Set( this, vTabDesign_lv_Key )
267       //.OnBeforeSelect.Set( this, TabDesign_lv_BeforeSelect )
268       .OnAfterSelect.Set( this, TabDesign_lv_Select )
269       .OnAfterMove.Set( this, TabDesign_lv_ItemMoved )
270 	}
271    uint left = 0
272    uint width = 70
273    comp as this.bAdd
274 	comp.Owner = this
275 	with comp
276 	{	   
277       .VertAlign = $alvBottom
278       .Caption = "New".ustr()
279       .Bottom = 0
280       .Left = left
281       .Width = width
282       left += .Width
283       .OnClick.Set(this,vTabDesign_bAdd_click)
284 	}   
285    comp as this.bDel
286 	comp.Owner = this
287 	with comp
288 	{	   
289       .VertAlign = $alvBottom
290       .Caption = "Delete".ustr()
291       .Bottom = 0
292       .Left = left
293       .Width = width
294       left += .Width
295       .OnClick.Set(this,vTabDesign_bDel_click)
296 	}	
297 	return this
298 }
299 
300 method vTabDesign vTabDesign.init( )
301 {
302    this.pTypeId = vTabDesign         
303    return this
304 }
305 
306 method vTabDesign.mSelectComp <alias=vTabDesign_mSelectComp> ( vComp newcomp )
307 {
308    if &newcomp 
309    {             
310       uint curcomp as newcomp
311       while &curcomp
312       {         
313          if &curcomp == this.Tab 
314          {
315             uint i
316             fornum i = 0, *.lv.Rows 
317             //uint LVRow as .lv.Rows[0]//.Child()            
318             //while &LVRow
319             { 
320                uint row as .lv.Rows[i]              
321                if row.Tag == &newcomp
322                {  
323                   row.Item.Label = newcomp->vTabItem.Caption                   
324                }         
325               // LVRow as LVRow.Next()               
326             }            
327             return
328          } 
329          curcomp as curcomp.Owner
330       }
331       this.DestroyComp()         
332    }
333 }
334 
335 method vTab.ToTabDesign( vTabDesign tdes )
336 {
337    uint i   
338    fornum i, *.Comps
339    {
340       uint tabitem as .Comps[i]->vTabItem     
341       uint row as tdes.lv.Rows.Append()
342       row.Item.Label( tabitem.Caption )
343       row.Tag = &tabitem 
344    }
345 }
346 
347 
348 
349 method vForm vTab.Design( vForm mainform, uint QueryCreate, uint QuerySelect, uint CompEditDelete )
350 {
351    uint win
352    
353    win as 0->vComp.CreateComp( vTabDesign )->vTabDesign
354    win.FormStyle = $fsPopup
355    win.Owner = mainform   
356    
357    win.OnQueryCreate.Set( mainform, QueryCreate )   
358    win.OnQuerySelect.Set( mainform, QuerySelect )
359    
360    win.OnDestroy.Set( mainform, CompEditDelete )
361        
362    win.Visible = 1
363    
364    win.Tab = &this
365    
366    this.ToTabDesign( win)
367    
368    return win   
369 }
370 
371 method vTabDesign.mPreDel <alias=vTabDesign_mPreDel>
372 {
373    .OnDestroy.run( )
374    this->vForm.mPreDel()
375       
376 }
377 
378 func init_vTabDesign <entry>()
379 {
380    regcomp( vTabDesign, "vTabDesign", vForm, $vCompEditForm_last,
381       %{ %{$mCreateWin,     vTabDesign_mCreateWin},
382          %{$mSelectComp,    vTabDesign_mSelectComp},
383          %{$mPreDel,        vTabDesign_mPreDel }},
384       0->collection )     
385 }
Редактировать