Named as 'FileRequestere2' temporary..
Adding to WizDizzy 0.3b in a next days I hope due swapped macros, other mechanism for flickerfree & designer bugfix (Dim groups output).
Code: Select all
declare function FileRequester2(PosX as integer,PosY as integer,akcion as string,Path as string, File as string="",FExistMode as integer=0) as string
declare sub FindContent(gad as Gadget ptr,t as string )
#macro rrrActionSelector()
'rearrange ActionSelector FileRequester...
mbX+=difX:mbY+=difY
rem stayInScene()
rrrLTGad(labelp)
rrrLTGad(labelf)
rrrLTGad(lablMask)
rrrComboGad(doit)
rrrComboGad(aFileMask)
rrrStringGad(strpath)
rrrStringGad(strfile)
rrrListBoxGad(contlist)
rrrLTGad(gogo)
rrrLTGad(cancel)
rrrLTGad(cdparent)
#endmacro
'strictly action
'function FileRequester(posx as integer,posy as integer,BtnText as string,Path as string, File as string="",FExistMode as integer=0) as string
'selectable action
function FileRequester2(PosX as integer,PosY as integer,akcion as string,Path as string, File as string="",FExistMode as integer=0) as string
function=""
dim as integer i,boxw,boxh
dim as string noCh=string(10,219)
dim as integer scrW, scrH,mbX,mbY,difX,difY,msgBoxMove=0
ScreenInfo scrW, scrH
dim as string akce(1 to 5)={phrase_open,phrase_save,phrase_edit,phrase_search,phrase_delete}
'Sichern des vom Requester bedeckten Hintergrundes
dim as FB.Image ptr gfxbackup,messBoxBackup
boxw=400: boxh=300
gfxbackup=imagecreate(boxw,boxh)
messBoxBackup=imagecreate(boxw,boxh)
mbX=PosX:mbY=PosY
stayInScene() 'correction if needed
PosX=mbX:PosY=mbY 'calling coord corrected
get (mbX,mbY)-(mbX+boxw-1,mbY+boxh-1),gfxbackup
FillA(PosX,PosY,400,300,GadgetColor,0)
FrameB(PosX+2,PosY+21,396,277,1)
ClearBox(PosX+3,PosY+22,394,275)
draw string (mbX+8,mbY+3),akce(1) & "...",TextColor 'synchronize dialog action title
draw string (mbX+80,mbY+3)," action ",TextColor
if messBoxBackup then
get (mbX,mbY)-(mbX+boxw-1,mbY+boxh-1),messBoxBackup
end if
dim as string sep,drive,originpath=curdir
'Windows Variante
#ifdef __fb_win32__
sep="\"
#endif
'Tux Variante
#ifdef __FB_LINUX__
sep="/"
#endif
dim as integer rows
if fontheight=8 then rows=22
if fontheight=14 then rows=12
if fontheight=16 then rows=11
dim as string entry,GoToFolder,full
GoToFolder=""
entry=""
chdir Path
Path=curdir
if right(Path,1)<>sep then Path+=sep 'fix path slash if missing
drive=left(Path,1) 'win
'drive= 'lin !! different
dim as EventHandle ptr event=new EventHandle
dim as Gadget ptr labelp,labelf,doit,cancel,strpath,strfile,contlist,cdparent,aFileMask,lablMask,gogo
labelp =AddLabel(event,PosX+5, PosY+28,phrase_path & ":",TextColor)
strpath =AddStringGadget(event,PosX+50,PosY+25,38,Path,,,1)
contlist=AddListBox(event,PosX+5,PosY+54,46,rows)
labelf =AddLabel(event,PosX+5, PosY+245,phrase_file & ":",TextColor)
lablMask=AddLabel(event,PosX+5, PosY+271,phrase_mask & ":",TextColor)
'doit =AddSimpleGadget(event,PosX+309,PosY+242,85,23,akcion) 'strictly passed action only
doit =AddComboBox (event,PosX+230,PosY+271,7,5) 'select action
for i=1 to ubound(akce)
TO_AppendLine(doit,akce(i))
next i
SetComboBoxVal(doit,1)
gogo =AddSimpleGadget(event,PosX+325,PosY+242,70,23,akce(1))
cancel =AddSimpleGadget(event,PosX+325,PosY+271,70,23,phrase_cancel)
strfile =AddStringGadget(event,PosX+50,PosY+242,31,File,,,1)
aFileMask=AddComboBox (event,PosX+50,PosY+271,10,4)
TO_AppendLine(aFileMask,"*.*")
TO_AppendLine(aFileMask,"*.audio")
TO_AppendLine(aFileMask,"*.video")
TO_AppendLine(aFileMask,"*.text")
SetComboBoxVal(aFileMask,1)
cdparent=AddSimpleGadget(event,PosX+362,PosY+25,32,23,"..")
TO_ClearText(contlist)
FindContent(contlist,"D")
FindContent(contlist,"F")
UpdateGadget(contlist)
GadgetOn(labelp,cdparent)
do
event->xSleep(1,0)
if event->GADGETMESSAGE then
select case event->GADGETMESSAGE
'Pfadeingabe
case strpath
chdir GetString(strpath) 'Wechsel ins Directory
Path=curdir 'Setze aktuellen Pfad
if right(Path,1)<>sep then Path+=sep 'fix path slash if missing
TO_ClearText(contlist)
FindContent(contlist,"D")
FindContent(contlist,"F")
UpdateGadget(contlist)
SetString(strpath,Path) 'Aktualisiere die Pfadanzeige
case contlist
entry=TO_GetLineContent(contlist,GetListBoxVal(contlist))
if entry<>"" then
if left(entry,6)="<DIR> " then 'wenn entry ein Directory
GadgetSleep(aFileMask)
GoToFolder=right(entry,len(entry)-6)
chdir GoToFolder 'Wechsel ins Directory
Path=curdir 'Setze aktuellen Pfad
if right(Path,1)<>sep then Path+=sep 'fix path slash if missing
TO_ClearText(contlist)
FindContent(contlist,"D")
FindContent(contlist,"F")
UpdateGadget(contlist)
SetString(strpath,Path) 'Aktualisiere die Pfadanzeige
else 'non-directory
GadgetOn(aFileMask)
end if
File=entry
SetString(strfile,File)
end if
case cdparent
chdir ".." 'Wechsel ins übergeordnete Directory
Path=curdir 'Setze aktuellen Pfad
if right(Path,1)<>sep then Path+=sep 'fix path slash if missing
TO_ClearText(contlist)
FindContent(contlist,"D")
FindContent(contlist,"F")
UpdateGadget(contlist)
SetString(strpath,Path) 'Aktualisiere die Pfadanzeige
'Beenden und Rückabe eines Strings
case doit
if akce(GetComboBoxVal(doit))<>akcion then
akcion=akce(GetComboBoxVal(doit))
draw string (mbX+5,mbY+3),noCh,GadgetColor
draw string (mbX+8,mbY+3),akcion & "...",TextColor 'synchronize dialog action title
SetCaption(gogo,akcion)
end if
case gogo
File=GetString(strfile)
if File<>"" then
if instr(entry,"<DIR> ") then
full=Path
File=GoToFolder
else
full=Path & File
end if
if FExistMode then
if fileexists(full) then
function=full
event->EXITEVENT=1
else
GadgetSleep(labelp,cdparent)
MessageBoxMove(PosX+20,PosY+100,phrase_fileaccessdenied,phrase_error,MBType_OK)
RestoreActivation(labelp,cdparent)
end if
else
function=full
event->EXITEVENT=1
end if
end if
'Abbruch des FileRequesters
case cancel
event->EXITEVENT=1
function=""
end select
end if
'moving
if LMB=HOLD and (MOUSEX>=mbX) and (MOUSEX<mbX+boxw) and (MOUSEY>=mbY) and (MOUSEY<mbY+30) and msgBoxMove=0 then
msgBoxMove=1
sGS(labelp,cdparent,2) 'gadsShot
GadgetOff(labelp,cdparent)
end if
if LMB=HOLD and msgBoxMove=1 and mouseMoved=1 then
screenlock
put (mbX,mbY),gfxbackup,pset
if MOUSEX>-1 and MOUSEY>-1 then
difX=MOUSEX-OLDMOUSEX:difY=MOUSEY-OLDMOUSEY
rrrActionSelector()
'cls? flickering
end if
get (mbX,mbY)-(mbX+boxw-1,mbY+boxh-1),gfxbackup
put (mbX,mbY),messBoxBackup,pset
screenunlock
end if
if LMB=RELEASED and msgBoxMove=1 then
msgBoxMove=0
put (mbX,mbY),gfxbackup,pset
if MOUSEX>-1 and MOUSEY>-1 then
difX=MOUSEX-OLDMOUSEX:difY=MOUSEY-OLDMOUSEY
rrrActionSelector()
end if
put (mbX,mbY),messBoxBackup,pset
rGS(labelp,cdparent,2) 'restore gadsShot
end if
loop until event->EXITEVENT
delete event
chdir originpath
put (mbX,mbY),gfxbackup,pset
imagedestroy gfxbackup
imagedestroy messBoxBackup
end function