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

   styles.g

   tab.g

   tabitem.g

   tabpage.g

   timer.g

   toolbar.g

   tray.g

   url.g

   vis.g

   viswin.g

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

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