EnglishРусский  

   ..

   btnsys.g

   funcs.g

   gena.g

   gfe.g

   main_save.g

   visedit.g

   viseditor.gi

   winedit.g

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

Реклама

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

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