'dim iconbardir = wxGetWorkingDirectory()



'wxmessagebox(wxGetWorkingDirectory()) 

dim ifs_picturefile = {} 


 dim ifs_listcontrol1
 dim ifs_imagelist
 dim ifs_bmp = {}
 dim ifs_texts = {}

 dim imge = {}
 dim imge2 = {}

create_ifs() 

dim filecounter = 0 

connect (  ifs_listcontrol1 , -1 , wxEVT_LEFT_UP , "set_icon") 

dim i=0
dim ifs_currentdir
dim filetype



ifs_button_get_defaultdirectory ( event ) 


sub create_ifs() 



//-- dummy-button to grab backgroundcolor -- 
ifs_button = new wxButton(me_frame, -1, "") 
ifs_button.Show(0) 
'me_frame.SetBackgroundColour(ifs_button.GetBackgroundColour()) 


ifs_listcontrol1= new wxListCtrl(me_frame,1,wxPoint(-1,-1),wxSize(200,400), wxLC_REPORT) 
ifs_listcontrol1.InsertColumnInfo(0, "icons") 

ifs_listcontrol1.SetColumnWidth(0,200) 

me_iconsizer.AddWindow( ifs_listcontrol1,1,wxALL|wxGROW,2) 


ifs_dirbutton=new wxButton(me_frame, -1, "change folder")
connect(ifs_dirbutton,wxEVT_COMMAND_BUTTON_CLICKED,"ifs_button_get_directory") 
me_iconsizer.AddWindow(ifs_dirbutton,0,wxGROW|wxLEFT|wxBOTTOM|wxRIGHT,8)


ifs_dirdefaultbutton=new wxButton(me_frame, -1, "default folder")
connect(ifs_dirdefaultbutton,wxEVT_COMMAND_BUTTON_CLICKED,"ifs_button_get_defaultdirectory") 
me_iconsizer.AddWindow(ifs_dirdefaultbutton,0,wxGROW|wxLEFT|wxBOTTOM|wxRIGHT,8)


end sub 



sub ifs_button_get_defaultdirectory ( event ) 

     ifs_imagelist = new wxImageList() 
     ifs_imagelist.Create(64,64,1,1) 
     ifs_listcontrol1.SetImageList(ifs_imagelist,1)    
     standardbmp = New wxEmptyBitmap(64,64) 
     ifs_imagelist.Add( standardbmp ) 
     ifs_listcontrol1.DeleteAllItems() 
     me_frame.settitle("wxB-Menue-Editor  --- please wait, loading Icons ---")
     me_frame.layout()
     i=0
     filecounter = 0 

  wxSetworkingdirectory(picturedir)
  ifs_currentdir = wxGetWorkingDirectory()
  ifs_Show_files() 

  wxSetworkingdirectory(picturedir2)
  ifs_currentdir = wxGetWorkingDirectory()
  ifs_Show_files() 

  wxSetworkingdirectory(picturedir3)
  ifs_currentdir = wxGetWorkingDirectory()
  ifs_Show_files() 


  ifs_imagelist.remove( 0 ) 
me_frame.settitle("wxB-Menue-Editor")
  ifs_currentdir = ""



end sub

//------------- show a Directory-Selector-- 

sub ifs_button_get_directory ( event ) 

  'Pull up a window to choose what folder. 
   dim folders =new wxDirDialog(myparent) 

   folders.setPath(ifs_currentdir)

   If folders.ShowModal() = wxID_OK Then 
     ifs_currentdir = folders.GetPath() 


     ifs_imagelist = new wxImageList() 
     ifs_imagelist.Create(64,64,1,1) 
     ifs_listcontrol1.SetImageList(ifs_imagelist,1)    
     standardbmp = New wxEmptyBitmap(64,64) 
     ifs_imagelist.Add( standardbmp ) 
     ifs_listcontrol1.DeleteAllItems() 
me_frame.settitle("wxB-Menue-Editor  --- please wait, loading Icons ---")
me_frame.layout()
     i=0
     filecounter = 0 
     wxSetworkingdirectory(ifs_currentdir)
     ifs_Show_files() 
     ifs_imagelist.remove( 0 ) 
me_frame.settitle("wxB-Menue-Editor")
   End If 
end sub 
//-------------------------------------------- 
//-- load filelist ---------------------------------------------------------- 

sub  ifs_Show_files() 

 '  ifs_listcontrol1.DeleteAllItems() 

  //-------------------------------------------- 
  //-- here you can use a customized Bitmap -- 
  //-------------------------------------------- 
    
       'standardbmp.LoadFile(startdir & slash & "resource" & slash & "image.gif",wxBITMAP_TYPE_GIF) 


   //-- read in directory 

   dim directory = ifs_currentdir 
   dim ifs_theDirectory=new wxDir() 

   dim ifs_dir = ifs_theDirectory.Open(directory) 

   dim ifs_get = ifs_theDirectory.GetFirst() 
'i=0
   while ifs_get != "" 

   if ifs_get = "" then 
      break 
   end if 

   //-- is it a file? 

   if wxfileexists(directory & "/" & ifs_get) and ifs_checkfile(ifs_get) = 1 then 
    ifs_texts[filecounter] = ifs_get 
    ifs_bmp[filecounter] = standardbmp 
    filecounter += 1 
 
    imge[i] =nothing
    imge[i] =nothing
    ifs_bmp[i] =nothing
  '  imge[i] = wxEmptyImage(48,48) 

myBMP = new wxEmptybitmap(48,48)
myBMP.Loadfile(directory & "/" & ifs_texts[i], filetype)

 imge[i] = wxImageFromBitmap( myBMP )

' imge[i].LoadFile(directory & "/" & ifs_texts[i], filetype)


 check = 0
 if imge[i].GetWidth() > 64 then
  check = 1
  if imge[i].GetHeight() > 64 then
    check = 1
  end if
 end if
'check=1
 if check = 1 then
    imge2[i] = imge[i].Scale(64,64)
 else
    imge2[i] = imge[i]
 end if

    ifs_bmp[i] = imge2[i].ConvertToBitmap()

    ifs_imagelist.Add( ifs_bmp[i] ) 

     ifs_listcontrol1.InsertImageStringItem(i, ifs_texts[i] ,i) '-- add the Imagestring 
me_frame.layout()
    i+=1
   end if 
   ifs_get = ifs_theDirectory.GetNext() 
  wend 



end sub  


function ifs_checkfile(fileName) 


extension =  ucase(right(fileName,4)) 
if extension != "JPEG" then 
  extension =  ucase(right(fileName,3)) 
end if 
check = 0 
if extension = "BMP" then : filetype = wxBITMAP_TYPE_BMP : check=1 : end if 
if extension = "PNG" then : filetype = wxBITMAP_TYPE_PNG : check=1 : end if 
if extension = "XPM" then : filetype = wxBITMAP_TYPE_XPM : check=1 : end if 
if extension = "JPG" then : filetype = wxBITMAP_TYPE_JPEG : check=1 : end if 
if extension = "JPEG" then : filetype = wxBITMAP_TYPE_JPEG : check=1 : end if 
if extension = "ICO" then : filetype = wxBITMAP_TYPE_ICO : check=1 : end if 
if extension = "PCX" then : filetype = wxBITMAP_TYPE_PCX : check=1 : end if 
if extension = "PNM" then : filetype = wxBITMAP_TYPE_PNM : check=1 : end if 
if extension = "TIF" then : filetype = wxBITMAP_TYPE_TIF : check=0 : end if 
if extension = "CUR" then : filetype = wxBITMAP_TYPE_CUR : check=1 : end if 
if extension = "GIF" then : filetype = wxBITMAP_TYPE_GIF : check=1 : end if 


  return check

End function


