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

   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\comp.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.comp 17.07.07 0.0.A.
 11 *
 12 * Author: Alexander Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 /* Компонента vComp, корневая
 16 События
 17 Необходимо определять режим работы компоненты p_designing
 18 Доработать присваивание хозяина mSetOwner mInsert
 19    
 20 */
 21 include {
 22    "vis.g"   
 23  //  "events.g" 
 24    "..\\language\\language.g"
 25 }
 26 type vComp <index = this>
 27 {   
 28 //Hidden Fields
 29    uint pTypeDef //Указатель на tTypeDef с описанием типа компоненты
 30    uint pTypeId  //Тип компонента     
 31    str  pName    //Имя компонента
 32    uint pOwner   //Указатель на компонент владельца
 33    uint pIndex   //Номер компонента в списке владельца
 34    uint fDynamic //Компонент создан динамически, через функцию newcomp
 35    uint pTag     //Пользовательские данные
 36             
 37    uint form
 38    uint p_designing
 39    uint p_loading
 40    uint des1// Используется дизайнером
 41    
 42 //Public Fields
 43    arr  Comps of uint //Список дочерних компонентов  
 44    
 45 }
 46 include {
 47    "events.g"
 48 }
 49 
 50 
 51 //Virtual Method Identifiers
 52 define <export>{
 53    mNull      = 0
 54    mInsert       //method vComp.mInsert( vComp newcomp )
 55    mRemove       //method vComp.mRemove( vComp remcomp )
 56    mPreDel       
 57    mSetOwner     //method vComp.mSetOwner( vComp newowner )
 58    mLangChanged  //method vComp.mLangChanged()
 59    mRegProps     //method vComp.mRegProps( uint typeid, compMan cm )
 60    mSetName
 61    mMenuClick 
 62    mLoad     
 63        
 64    vComp_last    
 65 }
 66 
 67 
 68 extern {
 69 method uint vComp.GetForm()
 70 method vComp vComp.FindComp( str name )
 71 property vComp.Name( str val )
 72 property str vComp.Name<result>( )
 73 property vComp.Owner( vComp comp )
 74 property vComp vComp.Owner
 75 property str vComp.TypeName<result>
 76 }
 77 
 78 
 79 /*------------------------------------------------------------------------------
 80    Internal Methods
 81 */
 82 /*Метод uint vComp.iSetName( str name )
 83 Установить новое имя компоненты
 84 name - новое имя
 85 Возвращает 1 - если имя успешно установлено, 0 - в случае ошибки 
 86 */
 87 func uint checkname( str s )
 88 {
 89    uint i
 90    uint ch
 91    if !*s : return 0
 92    ch = s[i++]
 93    if ( ch >= 'a' && ch <= 'z' ) ||
 94       ( ch >= 'A' && ch <= 'Z' ) ||      
 95       ch == '_' || 
 96       ch >= 0x80 
 97    {    
 98       fornum i, *s
 99       {
100          ch = s[i]
101          if ( ch >= 'a' && ch <= 'z' ) ||
102             ( ch >= 'A' && ch <= 'Z' ) ||            
103             ( ch >= '0' && ch <= '9' ) ||
104             ch == '_' ||
105             ch >= 0x80 : continue
106          return 0            
107       }
108       return 1
109    }
110    return 0
111 }
112 
113 
114 /*Метод uint vComp.Virtual( uint id )
115 Предназначен для получения адреса виртуального метода по его идентификатору
116 id - идентификатор метода 
117 */
118 method uint vComp.mNull <alias=vComp_mNull>
119 {
120    //print( "Null Method\n" )
121    return 0
122 }
123 
124 method uint vComp.GetVirtual( uint id )
125 {
126    //print( "Virtual \(this.p_typename) \(id) \((this.VirtTbl + (id<<2))->uint)\n" )
127    //return (this.VirtTbl + (id<<2))->uint
128    //print( "v1 \(&this) \(this.pTypeId)\n" )
129   //print( "v2 \(this.pTypeDef)\n" )
130    if this.pTypeDef
131    {         
132       with this.pTypeDef->tTypeDef
133       {          
134          if *(.VirtTbl ) > id
135          {
136          //print( "Virtual \(.TypeName) \(id) \((.VirtTbl.data + (id<<2))->uint)\n" )
137          uint addr = (.VirtTbl.data + (id<<2))->uint
138          if addr
139          { 
140             return addr 
141          }
142          }
143          return  (.VirtTbl.data)->uint
144       }
145    }
146    return vComp_mNull
147 }
148 
149 method uint vComp.GetInherited( uint id )
150 {  
151    uint inherittypeid   
152    if this.pTypeDef && ( inherittypeid = this.pTypeDef->tTypeDef.InheritTypeId )  
153    {         
154       //print( "inherit \(inherittypeid)\n" )
155       uint ptypedef as gettypedef( inherittypeid )      
156       if &ptypedef      
157       {
158          if *(ptypedef.VirtTbl ) > id
159          {         
160             uint addr = (ptypedef.VirtTbl.data + (id<<2))->uint
161             if addr
162             { 
163                return addr 
164             }
165          }
166          return  (ptypedef.VirtTbl.data)->uint
167       }
168    }
169    return vComp_mNull
170 }
171 
172 method uint vComp.Virtual( uint idfunc )
173 {     
174    return this.GetVirtual( idfunc )->func( &this )
175 }
176 
177 method uint vComp.Virtual( uint idfunc, any par1 )
178 {   
179    return this.GetVirtual( idfunc )->func( &this, par1 )
180 }
181 
182 method uint vComp.Virtual( uint idfunc, any par1, par2 )
183 {   
184    return this.GetVirtual( idfunc )->func( &this, par1, par2 )
185 }
186 
187 method uint vComp.Virtual( uint idfunc, any par1, par2, par3 )
188 {   
189    return this.GetVirtual( idfunc )->func( &this, par1, par2, par3 )
190 }
191 
192 method uint vComp.Virtual( uint idfunc, any par1, par2, par3, par4 )
193 {   
194    return this.GetVirtual( idfunc )->func( &this, par1, par2, par3, par4 )
195 }
196 
197 method uint vComp.Inherited( uint idfunc )
198 {     
199    return this.GetInherited( idfunc )->func( &this )
200 }
201 
202 method uint vComp.Inherited( uint idfunc, any par1 )
203 {   
204    return this.GetInherited( idfunc )->func( &this, par1 )
205 }
206 
207 method uint vComp.Inherited( uint idfunc, any par1, par2 )
208 {   
209    return this.GetInherited( idfunc )->func( &this, par1, par2 )
210 }
211 
212 method uint vComp.Inherited( uint idfunc, any par1, par2, par3 )
213 {   
214    return this.GetInherited( idfunc )->func( &this, par1, par2, par3 )
215 }
216 
217 method uint vComp.Inherited( uint idfunc, any par1, par2, par3, par4 )
218 {   
219    return this.GetInherited( idfunc )->func( &this, par1, par2, par3, par4 )
220 }
221 
222 method uint vComp.iSetName( str name )
223 {
224 //print( "NAME=\(name)\n")
225    if this.pName != name
226    {
227       if this.p_designing 
228       {
229          if !checkname( name ) : return 0
230          uint comp as this     
231          while comp.pOwner && comp.pOwner->vComp.p_designing
232          {
233             comp as comp.pOwner->vComp
234          }
235          if &comp.FindComp( name ) : return 0
236       }
237       .Virtual( $mSetName, name )
238       this.pName = name
239       /*if .Virtual( $mSetName, name )
240       {
241          this.pName = name
242       }*/
243    }
244    return 1
245 }
246 /*------------------------------------------------------------------------------
247    Public Methods
248 */
249 /*Метод vComp vComp.CreateComp( uint typeid )
250 Создать новый дочерний компонент
251 typeid - тип нового компонента
252 Возращает созданный компонент или 0 - в случае ошибки
253 */
254 method vComp vComp.CreateComp( uint typeid, uint pDesigning )
255 {   
256    uint comp as new( typeid )->vComp
257    comp.p_designing = pDesigning  
258    comp.fDynamic = 1
259    
260    comp.Owner = this
261    
262    /*if &this && comp.pOwner != &this  
263    {      
264       destroy( &comp )
265       comp as 0
266    } */ 
267    //print( "newcomp end \n" )
268    return comp
269 }
270 
271 method vComp vComp.CreateComp( uint typeid )
272 {   
273    uint comp as new( typeid )->vComp   
274    comp.fDynamic = 1
275    
276    comp.Owner = this
277    
278    /*if &this && comp.pOwner != &this  
279    {      
280       destroy( &comp )
281       comp as 0
282    } */ 
283    //print( "newcomp end \n" )
284    return comp
285 }
286 
287 /*Метод vComp.DestroyComp()
288 Уничтожить данную компоненту
289 */
290 method vComp.DestroyComp()
291 {
292 //print("dest1 \(this.TypeName) \(this.Name)\n" )
293    .Virtual( $mPreDel )
294 //print("dest2\n" )  
295    .pTypeDef = 0    
296    if this.fDynamic : destroy( &this )
297 //print("dest3\n" )      
298 }
299 
300 
301 /*Метод TypeIs( uint inhtypeid )
302 Определяет имеет ли компонент указанный тип или порожден от него
303 inhtypeid - тип 
304 Возращает:
305    1 - компонент имеет указанный тип или порожден от него
306    0 - компонент не совместим с указанным типом
307 */    
308 method uint vComp.TypeIs( uint inhtypeid )
309 {
310    //print( "typeis \(this.pTypeDef)\n" )
311    if this.pTypeId == inhtypeid : return 1
312    return type_isinherit( this.pTypeId, inhtypeid )
313 }
314 
315 /*Метод vComp vComp.FindComp( str name )
316 Найти дочерний компонент с указанным именем
317 name - имя компонента
318 Возвращает 1 если компонент найден, иначе 0
319 */
320 method vComp vComp.FindComp( str name )
321 {
322    uint i
323    uint comp   
324    fornum i = 0, *this.Comps
325    {
326       comp as this.Comps[i]->vComp
327       if comp.Name == name : return comp 
328       if comp as comp.FindComp( name ) : return comp  
329    }   
330    return 0->vComp
331 }
332 
333 method vComp vComp.FindComp( vComp srccomp )
334 {
335    uint i
336    uint comp   
337    fornum i = 0, *this.Comps
338    {
339       comp as this.Comps[i]->vComp
340       if &comp == &srccomp : return comp 
341       if comp as comp.FindComp( srccomp ) : return comp  
342    }   
343    return 0->vComp
344 }
345 
346 /*------------------------------------------------------------------------------
347    Properties
348 */
349 /* Свойство uint Tag - Get Set
350 Можно указывать любые пользовательские данные  
351 */
352 property uint vComp.Tag
353 {   
354    return this.pTag 
355 }
356 
357 property vComp.Tag( uint val )
358 {
359    this.pTag = val   
360 }
361 
362 /* Свойство vComp Owner - Get Set
363 Получить, изменить владельца компонента
364 */
365 
366 
367 property vComp.Owner( vComp newowner )
368 {
369 //print( "Owner 1 \(&newowner) \(&this)\n" )
370    if this.pOwner != &newowner
371    {
372    //print( "Owner 2\n" )   
373       if &newowner 
374       {   
375       //print( "Owner 3 \(this.pTypeId)\n" )
376          if !this.pTypeDef
377          {                 
378             this.pTypeDef = &gettypedef( this.pTypeId )
379          }         
380          //print( "Owner 4\n" )
381          //print( "Owner \(&newowner) \(&this) "  )                         
382          newowner.Virtual( $mInsert, &this )           
383       }     
384       else
385       {
386          .pOwner->vComp.Virtual( $mRemove, &this )
387       }       
388    }   
389 }
390 
391 property vComp vComp.Owner
392 {
393    return this.pOwner->vComp
394 }
395 
396 /* Свойство uint TypeId - Get
397 Получить тип компонента
398 */
399 property uint vComp.TypeId
400 {
401    //return this.p_typeid
402    return this.pTypeId//pTypeDef->tTypeDef.typeid
403 }
404 
405 /* Свойство str TypeName - Get
406 Получить имя типа компонента
407 */
408 property str vComp.TypeName<result>
409 {
410    result = this.pTypeDef->tTypeDef.TypeName
411 }
412 
413 /* Свойство str Name - Get Set
414 Получить, изменить имя компонента
415 */
416 property str vComp.Name<result>
417 {   
418    result = this.pName 
419 }
420 
421 property vComp.Name( str val )
422 {
423    //print( "-----------------------name\(val) \n" )
424    .iSetName( val )   
425 }
426 
427 /* Свойство uint CompIndex - Get Set
428 Получить, изменить позицию компонента в списке владельца
429 */
430 property uint vComp.CompIndex
431 {
432    return .pIndex  
433 }
434 
435 property vComp.CompIndex( uint newidx )
436 {
437    if this.pOwner && .pIndex != newidx
438    {  
439       uint Comps as this.pOwner->vComp.Comps
440       uint oldidx, i
441       newidx = min( max( -0, int( newidx )), *Comps - 1 )          
442       if newidx != this.pIndex
443       {           
444          oldidx = this.pIndex
445          if newidx > oldidx
446          {            
447             fornum i = oldidx + 1, newidx + 1 
448             {
449                Comps[i]->vComp.pIndex--
450                Comps[i-1] = Comps[i]
451             }            
452          }
453          else
454          {            
455             for i = oldidx - 1, int(i) >= newidx, i--
456             {
457                Comps[i]->vComp.pIndex++
458                Comps[i+1] = Comps[i]
459             }
460          }       
461          Comps[newidx] = &this
462          this.pIndex = newidx          
463       }
464    }
465 }
466 
467 /*------------------------------------------------------------------------------
468    Virtual Methods
469 */
470 
471 
472 method vComp.mInsert <alias=vComp_mInsert> ( vComp newcomp )
473 {   
474    //print( "vComp.insert\n" )
475    if newcomp.pOwner 
476    {
477       newcomp.pOwner->vComp.Virtual( $mRemove, &newcomp )
478    }
479    newcomp.pIndex = *this.Comps
480    .Comps += &newcomp
481    newcomp.Virtual( $mSetOwner, &this )      
482 }
483 
484 method vComp.mRemove <alias=vComp_mRemove>( vComp remcomp )
485 {  
486 //   print( "Comp Remove 1\n ")
487    uint ar as this.Comps
488    uint i   
489    if ar[remcomp.pIndex] == &remcomp
490    {
491       ar.del(remcomp.pIndex,1)
492       fornum i = remcomp.pIndex, *ar 
493       {
494          ar[i]->vComp.pIndex--
495       }
496    }
497 //   print( "Comp Remove 2\n ")
498    remcomp.Virtual( $mSetOwner, 0 )
499 //   print( "Comp Remove 3\n ")
500 }
501 
502 method vComp.mSetOwner <alias=vComp_mSetOwner>( vComp newowner )
503 {   
504    this.pOwner = &newowner 
505 }
506 
507 method vComp.mPreDel <alias=vComp_mPreDel>
508 {
509 //   print( "vComp predel1 \(this.TypeName)\n" )
510    uint i  
511    if this.p_designing && this.des1
512    {     
513       destroy( this.des1 )
514       this.des1 = 0
515    }   
516 //   print( "vComp predel2 \(this.TypeName)\n" )   
517    for i=*this.Comps - 1, i != -1, i--
518    {    
519    //print( "vComp predel3 \(this.Comps[i]->vComp.TypeName)\n" )
520       this.Comps[i]->vComp.DestroyComp()  
521    }
522 //   print( "vComp predel3\n" )
523    this.Comps.clear()
524 //   print( "vComp predel4\n" )   
525    if &this.Owner
526    {
527 //      print( "vComp predel5\n" )
528       this.Owner = 0->vComp
529    }
530 //   print( "vComp predel6\n" )
531    //print( "vComp predel3 \(this.TypeName)\n" )    
532    //print( "pd30\n" ) 
533    //this.pTypeDef = 0
534    //print( "pd31\n" )
535 }
536 
537 method vComp.mLangChanged <alias=vComp_mLangChanged> ( )
538 {
539    uint i
540    fornum i, *this.Comps
541    {    
542       this.Comps[i]->vComp.Virtual( $mLangChanged )
543       //print( "Change \( this.Comps[i]->vComp.Name )\n" )  
544    }
545 } 
546 
547 
548 method uint vComp.eof( fordata tfd )
549 {
550    return ?( tfd.icur < *this.Comps, 0,  1 )
551 }
552 
553 method uint vComp.next( fordata tfd )
554 {
555    tfd.icur++
556    if tfd.icur < *this.Comps
557    { 
558       return this.Comps[tfd.icur]
559    }
560    return 0
561 }
562 
563 method uint vComp.first( fordata tfd )
564 {   
565    tfd.icur = 0
566    if tfd.icur < *this.Comps
567    { 
568       return this.Comps[tfd.icur]
569    }
570    return 0
571 }
572 
573 
574 /*------------------------------------------------------------------------------
575    Registration
576 */
577 method vComp vComp.init()
578 {
579    //print( "vComp.init start\n" )
580    this.pTypeId = vComp
581    //print( "vComp.init stop\n" )
582    return this
583 }
584 
585 method vComp.delete()
586 {
587    //print( "Comp Delete \(&this) \(.Name) \(.pTypeDef)\n" )
588    if .pTypeDef
589    {
590    //   print( "dddddddddddddd1 \(this.TypeName)\n" )   
591       .Virtual( $mPreDel )
592    }
593 }
594 
595 /*ifdef $DESIGNING
596 {
597 include{
598 $"../visedit/manprops.g"
599 }
600 }*/
601 /*
602 func init_vComp <entry>
603 {  
604    regcomp( vComp, "vComp", 0, $vComp_last,
605       %{ %{$mNull,   vComp_mNull},
606          %{$mInsert, vComp_mInsert },
607          %{$mRemove, vComp_mRemove },
608          %{$mPreDel, vComp_mPreDel },
609          %{$mSetOwner, vComp_mSetOwner },
610          %{$mLangChanged, vComp_mLangChanged }
611          
612       },        
613       0->collection )
614       
615 ifdef $DESIGNING {
616    cm.AddComp( vComp )
617          
618    cm.AddProps( vComp, %{ 
619 "Name"     , str,  0,
620 "Tag"      , uint, 0      
621    })
622 }      
623 }
624 */
625 /*
626 method uint onevent.set( vComp obj, str methodname )
627 {
628    print( "SET \n " + " \(this.eventtypeid ) \(methodname)\n" )
629    str m = methodname
630    this.id = 0
631    this.obj = &obj
632    if this.eventtypeid
633    {      
634       //collection xx 
635       //xx = xx+%{obj.typeid, this.eventtypeid}      
636       this.id = getid( m, 1, %{obj.TypeId, this.eventtypeid})
637       print( "xxxxxxx \(&this) \(m) \(obj.TypeId) \(this.eventtypeid)\n" )    
638       
639    }
640    if !this.id 
641    {
642       if !( this.id = getid( m, 1, %{obj.TypeId, eventn } ) )
643       {
644          this.id = getid( m, 1, %{obj.TypeId, uint } )
645       }
646    }  
647    //print( "thid.id=\(this.id)\n" )
648    return 1
649 }
650 */
651 /*
652 method uint vComp.event( eventn ev )
653 {
654    if &ev 
655    {      
656       if this.f_defproc
657       {         
658          return this.f_defproc->func( this, ev )
659           
660       }
661    }
662    return 1
663 }
664 
665 method uint vComp.event( uint code )
666 {
667    eventn ev
668    ev.code = code 
669    if this.f_defproc
670    {      
671       return this.f_defproc->func( this, ev )
672    }
673    return 1
674 }*/
Edit