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\images.g
  1 include 
  2 {
  3    "grey.g"
  4 }
  5 type ICONDIRENTRY
  6 {
  7    byte   bWidth
  8    byte   bHeight
  9    byte   bColorCount
 10    byte   bReserved
 11    ushort wPlanes
 12    ushort wBitCount
 13    uint   dwBytesInRes
 14    uint   dwImageOffset
 15 }
 16 
 17 type ICONDIR
 18 {
 19    ushort idReserved//0 всегда 
 20    ushort idType   //1 для иконки, 2 для курсора
 21    ushort idCount  
 22    ICONDIRENTRY idEntries
 23 }
 24 
 25 type icsize
 26 {
 27    uint Width
 28    uint Height
 29 }
 30 
 31 type Image
 32 {
 33    uint hImage   
 34    uint hDisImage
 35    uint Width
 36    uint Height
 37    int  NumIml  
 38    int  PosInIml
 39    int  DisPosInIml
 40 }
 41 
 42 type ImageListIml
 43 {
 44    uint hIml
 45    uint Width
 46    uint Height  
 47    uint pImageList 
 48 }
 49 
 50 type ImageList <inherit=hash> //index=Image
 51 {
 52    arr arrIml of ImageListIml  
 53 }
 54 
 55 
 56 type ImageManager <inherit=hash index=ImageList>
 57 {
 58    str pMainDir
 59    str pCurName         
 60 }
 61 
 62 method ImageManager.init()
 63 {
 64    this->hash.oftype( ImageList )
 65 }
 66 
 67 
 68 method ImageList ImageList.init
 69 {   
 70    return this
 71 }
 72 
 73 method Image.ReadFromFile( str filename )
 74 {
 75    /*uint hbmp 
 76    hbmp = LoadImage( 0, filename.ptr(), $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE | $LR_LOADTRANSPARENT )
 77    if hbmp 
 78    {
 79       .hbmp = hbmp
 80    }  */
 81 }
 82 
 83 method Image.Clear()
 84 {
 85  //  if .hbmp : DeleteObject( .hbmp )
 86 }
 87 
 88 method Image.delete()
 89 {
 90 //   print( "Image.Delete\n" )
 91    DestroyIcon( .hImage )
 92 }
 93 
 94 
 95 
 96 method ImageListIml.delete()
 97 {  
 98    ImageList_Destroy( .hIml )
 99 }
100 
101 method ImageList.delete()
102 {
103    //print( "ImageList \(&this) .Delete 1\n" )
104    foreach arrim, this
105    {      
106      //arrim as arr of Image
107      //print( "ImgList destroy \(arrim->uint)\n" )
108      if arrim->uint : destroy( arrim->uint )     
109      //getch() 
110    }
111    //print( "ImageList.Delete 2\n" )
112 }
113 
114 method ImageManager.delete
115 {
116    //print( "ImageManager.Delete \(&this)\n" )
117   // destroy( ImageList
118 }
119 
120 method ImageManager.LoadDir( str dir, str listname, uint flgclear )
121 {
122    uint il as this[listname]//->ImageList
123    
124       ffind fdi
125       fdi.init( "\( dir )\\*.ico", $FIND_FILE )      
126       foreach finfo ico, fdi
127       {         
128          uint arrim as ( il[ico.name]->arr of Image )
129          if !&arrim 
130          {
131             str name
132             ico.fullname.fgetparts( 0->str, name, 0->str )
133             arrim as new( arr, Image, 0 )->arr of Image
134             //print( "NEW ARRIM \(&il) \( &arrim ) )\n" )
135             //arrim.itype = Image
136             //arrim.isize = sizeof( Image )
137             arr arrim2 of Image
138             il[name] = &arrim
139          }
140          elif flgclear
141          {            
142             arrim.clear()
143          }         
144          buf bicon
145          bicon.read( ico.fullname )
146          uint header as bicon.data->ICONDIR
147          if !header.idReserved && header.idType == 1 
148          {
149             uint count = header.idCount
150             uint entry as header.idEntries
151             uint i, j
152             arr sizes of icsize                                    
153             fornum i=0, count 
154             {  //                
155                fornum j=0, *sizes
156                {
157                   if sizes[j].Width > entry.bWidth &&
158                      sizes[j].Height > entry.bHeight : break                     
159                }
160                sizes.insert( j )
161                sizes[j].Width = entry.bWidth
162                sizes[j].Height = entry.bHeight
163                entry as uint
164                entry += sizeof(ICONDIRENTRY)    
165             }            
166             
167             if !*il.arrIml
168             {
169                il.arrIml.expand(*sizes)               
170                fornum i=0, *sizes
171                {
172                   il.arrIml[i].hIml = ImageList_Create (
173                      sizes[i].Width, sizes[i].Height, 0x000000FF, 10, 10 )
174                   il.arrIml[i].Width = sizes[i].Width
175                   il.arrIml[i].Height = sizes[i].Height
176                   il.arrIml[i].pImageList = &il   
177                }
178             }
179             if *sizes > *arrim
180             {  
181                arrim.expand( *sizes - *arrim )
182             }            
183             fornum i=0, *sizes
184             {
185                if arrim[i].hImage : DestroyIcon( arrim[i].hImage )
186                
187                arrim[i].Width = sizes[i].Width
188                arrim[i].Height = sizes[i].Height                           
189                arrim[i].hImage = LoadImage( 0, ico.fullname.ustr().ptr(), $IMAGE_ICON, 
190                   sizes[i].Width, sizes[i].Height, $LR_LOADFROMFILE /*| $LR_DEFAULTSIZE */| $LR_DEFAULTCOLOR/* | $LR_LOADMAP3DCOLORS| $LR_LOADTRANSPARENT*/ )
191                
192                ICONINFO II
193                GetIconInfo( arrim[i].hImage, II )                  
194                BitmapColorsToGrey( II.hbmColor, II.hbmMask, arrim[i].Width,arrim[i].Height)                  
195                arrim[i].hDisImage = CreateIconIndirect( II )                    
196                
197 //               print( "load image \(arrim.itype) \(arrim.isize) \(arrim[i].hImage) \( ico.fullname ) \(  arrim[i].Width ), \( arrim[i].Height)\n" )
198                arrim[i].PosInIml = -1                  
199                fornum j=0, *il.arrIml
200                {
201                   if il.arrIml[j].Width == sizes[i].Width &&
202                      il.arrIml[j].Height == sizes[i].Height 
203                   {                     
204                      arrim[i].PosInIml = 
205                         ImageList_ReplaceIcon( il.arrIml[j].hIml, -1, arrim[i].hImage )
206                      arrim[i].DisPosInIml = 
207                         ImageList_ReplaceIcon( il.arrIml[j].hIml, -1, arrim[i].hDisImage )                        
208                      arrim[i].NumIml = j                      
209                   }                       
210                }                                                                                       
211             }
212          }
213       }
214 }
215 
216 
217 method ImageManager.Load( str name, uint flgclear )
218 {
219    ffind fd
220    fd.init( "\(.pMainDir)\\\(name)\\*.*", $FIND_DIR )
221    foreach finfo cur, fd
222    {
223       .LoadDir( cur.fullname, cur.name, flgclear )
224       /*if !&il 
225       {         
226          il as new( ImageList )->ImageList    
227          this[cur.name] = &il
228       }
229       el*/      
230       /*if flgclear
231       {      
232          
233          il.arrIml.clear()
234       }  */    
235       
236       /*foreach arrim, il
237       {         
238         //arrim as arr of Image
239         uint x = arrim->uint
240         print( "ImgList Check \(arrim->uint) \(x)\n" )
241         //destroy( &arrim )     
242         getch() 
243       }*/
244    }   
245 }
246 
247 property str ImageManager.CurName <result>
248 {
249    result = .pCurName
250 }
251 
252 property ImageManager.CurName( str value )
253 {
254    if value != .pCurName
255    {
256       //this.Clear()
257       .Load( "default", 1 )
258       //.Load( value, 0 )
259    }
260 }
261 
262 property str ImageManager.MainDir <result>
263 {
264    result = .pMainDir
265 }
266 
267 property ImageManager.MainDir( str value )
268 {
269    if value != .pMainDir
270    {
271       //this.Clear()
272       .pMainDir = value
273    }
274 }
275 
276 method Image ImageManager.GetImage( ustr name )
277 {
278 //   print( "GetImage\n" )
279    arrstr path 
280    str sname = name
281    sname.split( path, '\', 0 )   
282    if *path == 2
283    {  
284 //   print( "b \(path[0])\n" )
285       uint il as this.find(path[0])->ImageList      
286       if &il
287       {  
288          sname = path[1]
289          sname.split( path, '[', 0 ) 
290          uint im as il[path[0]]->arr of Image
291          if &im
292          {     
293             uint idx  
294             if *path == 2
295             {                 
296                idx = min( max( 0, int( path[1] ) ), *im )
297             }  
298             return im[idx]
299          }
300       }      
301    }
302    return 0->Image
303 }
304 
305 method int ImageList.GetImageIdx( uint numiml, ustr name, uint disabled )
306 {
307 //print( "GetImageIdx\n" )
308    if &this && *name
309    {        
310       uint arrim as this[name.str()]->arr of Image      
311       if &arrim 
312       {  
313          if numiml < *arrim
314          { 
315             uint i
316             fornum i = 0, *arrim
317             {
318                if arrim[i].NumIml == numiml
319                {           
320                   if disabled : return arrim[i].DisPosInIml
321                   else : return arrim[i].PosInIml
322                }
323             }
324          }         
325       }
326    }
327    return -1
328 }
329 
330 method ImageList ImageManager.GetImageList( ustr name, uint pnumiml )
331 {
332 //print( "GetImageList\n" )
333    arrstr path
334    str sname = name   
335    sname.split( path, '\', 0 )
336    if *path == 1
337    {      
338       sname = path[0]
339       sname.split( path, '[', 0 )      
340       uint il as this.find(path[0])->ImageList      
341       if &il
342       {   
343          uint num 
344          if *path > 1 : num= min( uint( path[1] ), *il.arrIml - 1 )
345          if pnumiml: pnumiml->uint = num
346          return il
347       }
348    }
349    return 0->ImageList
350 }
Edit