EnglishРусский  

   ..

   btnsys.g

   funcs.g

   gena.g

   gfe.g

   main_save.g

   visedit.g

   visedit.ini

   viseditor.gi

   winedit.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\programs\visedit\main_save.g
  1 include {
  2    "gena.g"   
  3 }
  4 
  5 method vComp.GetCompInclude ( hash h )
  6 {
  7    uint descr as cm.GetCompDescr( this.TypeId )
  8    if &descr 
  9    {
 10       h.create( descr.File )
 11    }   
 12    uint i      
 13    fornum i=0, *this.Comps
 14    {
 15       if this.Comps[i]->vComp.p_designing 
 16       {         
 17          this.Comps[i]->vComp.GetCompInclude( h )
 18       }
 19    }
 20 }
 21 
 22 
 23 method str myform.GetInclude <result> ()
 24 {
 25    hash h
 26    .edform->vComp.GetCompInclude( h )   
 27    result@"include {\n\t\"app.g\"\n"   
 28    h.del( "" )
 29    foreach key, h.keys
 30    {
 31       //print( key + "\n" )
 32       result@"\t\""@key@".g\"\n"
 33    }   
 34  /*  result = "include { 
 35 $\"btn.g\"
 36 $\"panel.g\"
 37 $\"edit.g\"
 38 $\"menu.g\"
 39 $\"scrollbox.g\"
 40 $\"tab.g\"
 41 "*/
 42 }
 43 
 44 method str vComp.GetListComps <result>
 45 {  
 46    uint i   
 47    fornum i=0, *this.Comps
 48    {      
 49       if this.Comps[i]->vComp.p_designing 
 50       {
 51          result@"\t"@this.Comps[i]->vComp.TypeName@"\t"@this.Comps[i]->vComp.Name@"\n"
 52          result@this.Comps[i]->vComp.GetListComps()
 53       }
 54    }
 55 }
 56 
 57 method str myform.GetForm <result> ()
 58 {
 59    result = "type v\(.edform->vComp.Name) <inherit=vForm> {
 60 \(.edform->vComp.GetListComps()) "
 61 }
 62 
 63 method myform.checkgffile
 64 {
 65    //print( "PREPRECHECK  \n" )
 66    
 67    if .flgsaved && !.flggfchanged
 68    {
 69       file f
 70       filetime   ft
 71       //print( "PRECHECK  \n" )
 72       if f.open( .filename + ".gf", 1/*$OP_READONLY*/ )
 73       {
 74          f.gettime( ft ) 
 75          f.close()
 76          //print( "CHECK  \n" )
 77          if ft != .ftgf
 78          {
 79             //print( "CHECK READ \n" )
 80             .gffile.read( .filename + ".gf" )
 81             .ftgf = ft
 82          }
 83       }
 84    }
 85 }
 86 
 87 method myform.GFSetHeader( str src )
 88 {    
 89    
 90    //print( "set1\n" )
 91    //src.read( /*this.srcfile + ".gf"*/"\(.edform->vComp.Name).gf" )   
 92    if !replcode( src, "include", this.GetInclude() ) : print( "ERROR\n" )   
 93    if !replcode( src, "form", this.GetForm() ) : print( "ERROR\n" )
 94    //if !replcode( src, "includeinit", "include { $\"\(.filename).gi" ) : print( "ERROR\n" )   
 95    //print( "set10\n" )
 96    //src.write( /*this.srcfile + ".gf"*/"\(.edform->vComp.Name).gf" )
 97 }
 98 
 99 method myform.GFSetHeaderf()
100 {   
101    .checkgffile()
102    .flgchanged = 1
103    .flggfchanged = 1  
104    //str src 
105    //src.read( /*this.srcfile + ".gf"*/"\(.edform->vComp.Name).gf"  )
106    this.GFSetHeader( .gffile )
107    
108    //src.write( /*this.srcfile + ".gf"*/"\(.edform->vComp.Name).gf"  )
109 }  
110 
111 method myform.GFSetInit( str src ) 
112 {
113    delcode( src, "includeinit" )
114    inscode( src, "includeinit", "include { $\"\(.filename).gi\" \l}", "" )
115    /*if !replcode( src, "includeinit", "includeinit", "include { $\"\(.filename).gi\" \l}" )
116    {
117       inscode( src, "includeinit", "include { $\"\(.filename).gi\" \l}", "" )
118    }*/
119 }
120 
121 method myform.GFSetMethod( str src, str oldname, newname, typename )
122 {  
123    str labo = "method \( oldname ) \( typename )"
124    str labn = "method \( newname ) \( typename )"
125    str code = "method uint v\(.edform->vComp.Name).\(newname) <alias=\(.edform->vComp.Name)_\(newname)>( \(typename) evn )"      
126    if !replcode( src, labo, labn, code )  
127    {
128       inscode( src, labn, code, "{\l\lreturn 0\l}" )
129    }
130 }
131 
132 method myform.GFSetMethodf( str oldname, newname, typename )
133 {
134    //str src
135    //src.read( /*this.srcfile + ".gf"*/"\(.edform->vComp.Name).gf" )
136    .checkgffile() 
137    .flgchanged = 1
138    .flggfchanged = 1  
139    this.GFSetMethod( .gffile, oldname, newname, typename )
140    //src.write( /*this.srcfile + ".gf"*/"\(.edform->vComp.Name).gf" )
141 }
142 
143 /*method myform.GFSetAll
144 {
145    str src
146    src.read( this.srcfile + ".gf" )   
147    
148    this.GFSetHeader( src )
149    fornum 
150    {
151       setmethod( ) 
152    }
153    src.write( this.srcfile + ".gf" )
154 }
155  */
156 method myform.GFSetNew
157 {
158  //  str src
159    .gffile = "/*	
160  //!GFG и //!\\GFG  are commentary attributes generated by 
161  the Gentee form editor. You should neither delete them 
162  nor make any changes into the source code from the beginning 
163  of the commentary attribute //!GFG to its end //!\\GFG
164 */
165 "
166    inscode( .gffile, "include", this.GetInclude(), "\l}" )
167    inscode( .gffile, "form", this.GetForm(), "\l}" )
168    //inscode( .gffile, "includeinit", "include { $\"\(.filename).gi\" \l}", "" )
169    //src.write( /*this.srcfile + ".gf"*/"\(.filename).gf" )   
170 }
171 
172 method ustr ustr.doubleslash()
173 {
174    uint off
175    while ( off = this.findch( off, '\' ) ) < *this
176    {
177       this.insert( off, "\\".ustr() )
178       off += 2
179    }
180    return this
181 }
182 
183 method str str.doubleslash()
184 {
185    uint off
186    while ( off = this.findch( off, '\' ) ) < *this
187    { 
188       this.insert( off, "\\".ustr() )
189       off += 2
190    }
191    return this
192 }
193 
194 method str vComp.GetListProps <result>( str ownername, str formname, str indent/*, str aftercreate*//*, myform mf*/ ) 
195 {  
196    //uint x as inspm->vcompman         
197    uint i      
198    str afterchild
199    
200    if *ownername
201    {
202       result@indent@"comp as this."@this.Name@"\l" 
203       result@indent@"comp.Owner = "@ownername@"\l"
204    }
205    else : result@indent@"comp as this\l" 
206    result@indent@"with comp\l"@indent@"{\l"
207    uint descr as cm.GetCompDescr( this.TypeId )
208    if &descr 
209    {        
210       foreach prop, descr.Props
211       {  
212          str curprop
213          //if !( prop.D & $PI_DEFVAL )
214          { 
215             curprop@indent@"\t."@prop.PropName
216             if prop.AddrGet
217             {                  
218                if prop.PropType == ustr 
219                {
220                   curprop@"=ustmp.fromutf8(\""@(prop.AddrGet->func( this, "" ))->ustr.doubleslash().toutf8("")@"\")"         
221                }
222                elif prop.PropType == uint || prop.PropType == int
223                {         
224                   int z = (prop.AddrGet->func( this ))
225                   if prop.Vals
226                   {
227                      curprop@"=$"@prop.GetEnumName(z)
228                   }               
229                   else
230                   {                  
231                      curprop@"=\(z)"
232                   }
233                }
234                elif prop.PropType == str
235                {
236                   curprop@"=\""@(prop.AddrGet->func( this, "" ))->str.doubleslash()@"\"" 
237                }
238                elif prop.PropType == vComp || type_isinherit( prop.PropType, vComp )
239                {
240                   uint link as prop.AddrGet->func( this )->vComp
241                   if &link
242                   {
243                      uint checklink as App.FindComp( link )                  
244                      if &checklink && checklink.TypeIs( prop.PropType )
245                      {
246                         curprop@"=."@link.Name
247                      }
248                   }
249                   else
250                   {
251                      continue
252                   }
253                }
254             }
255             curprop@"\l"
256             //print( "\(prop.PropName) \(prop.PropFlags)\n" )
257             if prop.PropFlags & $PROP_LOADAFTERCHILD
258             {  
259                afterchild@curprop               
260             }
261             /*elif prop.PropFlags & $PROP_LOADAFTERCREATE
262             {               
263                aftercreate@this.Name@curprop
264             } */
265             else 
266             {
267                result@curprop  
268             }
269          }   
270                            
271       }
272       
273       foreach event, descr.Events
274       {         
275          
276          str meth = event.GetVal( this ) 
277          if *meth
278          {
279             result@indent@"\t.\(event.EventName).Set( this, \(formname)_\(meth) )\l"
280          }
281          /*print( "eventname = \(event.EventName)\n" )
282          
283          item.Value = 
284             
285          item.Flags |= $PI_LIST*/ 
286       }      
287       if *this.Comps
288       {
289          result@"\l"@indent@"\tuint comp\l"
290          fornum i=0, *this.Comps
291          {          
292             if this.Comps[i]->vComp.p_designing 
293             {  
294                result@this.Comps[i]->vComp.GetListProps(?(*ownername,"this."@this.Name, "this" ), formname, indent + "\t"/*, aftercreate*//*, mf*/)
295             }      
296          }
297       }
298       result@afterchild
299       result@indent@"}\l"
300    }
301 
302    //uint c as cm.FindCOmp( this.typeid )
303    //if &c 
304    {
305       //fornum i=0, *c.props
306       {    
307          /*if c.props[i].getval(this) != c.props[i].defval
308          {       
309             if c.props[i].addrget
310             {
311                result@"ctrl."@c.props[i].name@"="
312                //print( c.props[i].name+"\n" )             
313                if c.props[i].typeid == str 
314                {
315                   result@(c.props[i].addrget->func( this,"" ))->str.quoted()     
316                }
317                elif c.props[i].typeid == uint || c.props[i].typeid == int
318                {
319                   str r
320                   int2str( r, "0x%X", (c.props[i].addrget->func( this ))) 
321                   //print( r+"\n" )
322                   result@r     
323                }
324                result@"\l"
325             }
326          }*/
327       }
328       /*uint arev as this.des1->arr of uint
329       uint desc
330       fornum i=0, *c.events
331       {    
332          if arev[i]
333          {  
334             desc as mf.evlist[mf.finddesc( arev[i] )] 
335             result@"ctrl."@c.events[i].name@".set(this,\""@desc.name@"\")\l"
336          }
337       }*/
338    }
339 }
340 
341 method vComp.Save( gtitem gi, uint level )
342 {
343    str slevel
344    uint i
345    fornum i, level
346    {
347       slevel@"  "
348    } 
349    gi.set( "TypeName", this.TypeName )
350    uint descr as cm.GetCompDescr( this.TypeId )
351    if &descr 
352    {  
353       uint gp as gi.appendchild( "Properties" )
354       uint gpa as gi.appendchild( "PropertiesAfter" )  
355       uint ge as gi.appendchild( "Events" )  
356       uint i
357       ustr val
358       fornum i, *descr.Props
359       {         
360          uint prop as descr.Props[i]
361          val = prop.GetVal( this )                   
362          if val != prop.DefVal
363          {
364             if prop.PropFlags & $PROP_LOADAFTERCHILD
365             {
366                val.toutf8(gpa.appendchild( prop.PropName ).value)
367             }
368 /*            elif prop.PropFlags & $PROP_LOADAFTERCREATE
369             {
370                val.toutf8(gpac.appendchild( prop.PropName ).value)
371             }*/
372             else
373             {
374                val.toutf8(gp.appendchild( prop.PropName ).value)
375             } 
376          }                 
377       }            
378       fornum i = 0, *descr.Events
379       {         
380          uint event as descr.Events[i]
381          val = event.GetVal( this )
382          val.toutf8(ge.appendchild( event.EventName ).value)
383       }      
384    }
385    
386    uint gc as gi.appendchild( "Children" )
387    foreach comp, .Comps
388    {
389       comp as vComp    
390       if comp.p_designing
391       {  
392          comp.Save( gc.appendchild(""), level + 1 )
393       }
394    }
395 }
396 method myform.GFSave( uint flgsaveas )
397 {   
398    if !.flggfchanged 
399    { 
400       .checkgffile()
401    }
402    if !.flgchanged /*&& !flgsaveas*/
403    {       
404       return
405    }   
406    if !.flgsaved || flgsaveas
407    {  
408       .dlgOpen.FileName = ?( *.filename, .filename.ustr(), .edform->vForm.Name.ustr())
409       .dlgOpen.DefExt = ".gf".ustr()     
410       .dlgOpen.Filters[0]= "Gentee form (*.gf)\\*.gf".ustr()
411       if !.dlgOpen.ShowSaveFile()
412       {
413          return
414       }
415       str dir, fname
416       this.dlgOpen.FileName.str().fgetparts( dir, fname, 0->str )
417       .filename = dir + "\\" + fname 
418    }
419    //print( "s10\n" )       
420    
421    gt g
422    g.utf8 = 1
423    //print( "s11\n" )
424    .edform->vForm.Save( g.root().appendchild(""), 0 )
425    ///print( "s12\n" )      
426    str stemp
427    gtsave gts
428    gts.offstep = 1
429    gts.inside = 1
430    gts.endname = 1
431    //print( "s13\n" )   
432    g.root().save( stemp, gts )
433    //print( "s14\n" )
434    stemp.write( .filename + ".frm" )
435    //print( "s15\n" )     
436  
437    //str aftercreate
438    str r = .edform->vComp.GetListProps( "", .edform->vComp.Name, "\t"/*, aftercreate*/ )
439    //\(aftercreate)
440    r ="method v\(.edform->vComp.Name) v\(.edform->vComp.Name).mLoad <alias=v\(.edform->vComp.Name)_mLoad>( )   
441 {   
442 //\tthis->vForm.mCreateWin()
443 \tustr ustmp
444 \tuint comp
445 "@r@"
446 \treturn this
447 }
448 
449 method v\(.edform->vComp.Name) v\(.edform->vComp.Name).init( )
450 {
451    this.pTypeId = v\(.edform->vComp.Name)         
452    return this
453 }
454 func init_v\(.edform->vComp.Name) <entry>()
455 {   
456 
457    regcomp( v\(.edform->vComp.Name), \"v\(.edform->vComp.Name)\", vForm, $vForm_last,
458       %{ %{$mLoad,     v\(.edform->vComp.Name)_mLoad}},
459       0->collection )
460       
461 }
462 "
463    
464    r.write( "\(.filename).gi" )
465    
466    "#!gentee.exe -s -p vis \"%1\"
467 define
468 {
469 	DESIGNING = 0
470    COMP = 0   
471 }
472 include {   
473    $\"\(.filename).gf\"
474    //$\"\(.filename).gi\"
475 }
476 global {
477    v\(.edform->vComp.Name) \(.edform->vComp.Name)
478 }
479 
480 func run<main>
481 {
482    \(.edform->vComp.Name).Owner = App
483    App.Run()
484 }
485 ".write( "\(.filename).g" )
486    //.checkgffile()
487    .GFSetInit( .gffile )   
488    .gffile.write( "\(.filename).gf" )   
489    .flgchanged = 0
490    file f
491    if f.open( .filename + ".gf", 1/*$OP_READONLY*/ )
492    {   
493       f.gettime( .ftgf ) 
494       f.close()      
495       .flgsaved = 1
496       .flggfchanged = 0
497    }      
498    .Caption = .filename.ustr() + ".gf"
499 }
500 
Edit