
BBjFileChooser
Description
In BBj 7.0 and higher, the BBjFileChooser object provides methods for manipulating a GUI file chooser control, similar to the FILEOPEN Mnemonic or FILEOPEN() Function.
Implemented Interfaces
DragSource, DropTarget, Focusable, TabTraversable
Creation
BBjAPI > BBjSysGui > BBjWindow > BBjFileChooser
A BBjFileChooser object is created through the following BBjWindow methods:
Return Value |
Method |
---|---|
BBjFileChooser |
addFileChooser(int ID, int x, int y, int width, int height, string directory) |
BBjFileChooser |
addFileChooser(int ID, int x, int y, int width, int height, string directory, string flags) |
BBjFileChooser | addFileChooser(int ID, string directory) |
BBjFileChooser | addFileChooser(int ID, string directory, String flags) |
BBjFileChooser | addFileChooser(string directory) |
BBjFileChooser |
addFileChooser(string directory, String flags) |
Methods of BBjFileChooser
Return Value |
Method |
---|---|
void |
addFileFilter(string name, BBjVector filters!) |
void |
addFileFilter(string name, string filter) |
void |
|
void |
|
void |
|
void |
ensureFileNameIsVisible(string name) |
string |
|
string |
|
string | getCancelButtonText() |
boolean |
|
string |
|
boolean |
|
getFileFilterContents(string name) |
|
int |
|
string |
|
string |
|
boolean |
|
boolean |
|
boolean |
|
void |
removeFileFilter(string name) |
void |
|
void |
setAcceptAllFileFilterUsed(boolean used) |
void |
setActiveFileFilter(string name) |
void |
setApproveButtonText(string text) |
void | setCancelButtonText(string text) |
void |
setControlButtonsAreShown(boolean shown) |
void |
setCurrentDirectory(string name) |
void |
setDropZoneVisible(boolean visible) |
void |
setFileSelectionMode(int mode) |
void |
setMultiSelectionEnabled(boolean enabled) |
void |
setNewFolderEnabled(boolean enabled) |
void |
setRestrictedDirectory(string directory) |
void |
setSelectedFile(string file) |
void |
setSelectedFiles(BBjVector files!) |
void | setView(boolean detail, int column, int order) |
Methods of BBjFileChooser implemented for DragSource
Return Value |
Method |
---|---|
int |
|
string |
|
void |
setDragActions(int actions) |
void |
setDragType(string type) |
Methods of BBjFileChooser implemented for DropTarget
Return Value |
Method |
---|---|
int |
|
void |
setDropActions(int actions) |
void |
setDropTypes(BBjVector types) |
Methods of BBjFileChooser implemented for Focusable
Return Value |
Method |
---|---|
boolean |
|
void |
setFocusable(boolean focus) |
Methods of BBjFileChooser implemented for TabTraversable
Return Value |
Method |
---|---|
boolean |
|
void |
setTabTraversable(boolean trav) |
Methods of BBjFileChooser inherited from BBjControl
Events
Callback Code |
Object-oriented Event |
Read Record Event |
Code |
---|---|---|---|
ON_DROP_TARGET_DROP |
D |
||
ON_FILECHOOSER_APPROVE |
x |
||
ON_FILECHOOSER_CANCEL |
x |
||
ON_FILECHOOSER_CHANGE |
x |
||
ON_FILECHOOSER_FILTER |
x |
||
ON_GAINED_FOCUS |
f |
||
ON_LOST_FOCUS |
f |
||
ON_MOUSE_ENTER |
E |
||
ON_MOUSE_EXIT |
E |
||
ON_POPUP_REQUEST |
r |
||
ON_RIGHT_MOUSE_DOWN |
R |
CSS
The visual appearance of BUI controls is defined using CSS (cascading style sheets) rules. Easily change the default colors, border, and other settings by customizing these rules, all without changing any application code. See CSS API for a high-level overview of BUI CSS.
The BUI BBjFileChooser is really several different kinds of control, depending on the selected version: Open or save a client file, open or save a server file, or select a server directory. See BUI: Interacting with client files for a detailed discussion of the BUI client-side file choosers. The BBjFileChooser defines the following CSS style names:
.BBjChooser
.BBjFileChooser
.BBjFileChooser.bbj-client
.BBjFileChooser.bbj-directories
.BBjFileChooser.bbj-disabled
.BBjFileChooser.bbj-focused
.BBjFileChooser .bbj-selected (note the space between .BBjFileChooser and .bbj-selected)
.BBjFileChooser.bbj-server
.BBjChooser-button-panel
.BBjChooser-button
.BBjChooser-approveButton
.BBjChooser-cancelButton
Individual components of the .BBjFileChooser.bbj-client dialog:
.BBjFileChooser-chooseClientFileLabel
.BBjFileChooser-chooseClientFile
.BBjFileChooser-fileTypeLabel
.BBjFileChooser-fileTypeList
.BBjFileChooser-uploadProgressBar
.BBjFileChooser-uploadStatusMessage
.BBjFileChooser-dropzone
Individual components of the .BBjFileChooser.bbj-server dialog:
.BBjFileChooser-directoryList
.BBjFileChooser-directoryUpButton
.BBjFileChooser-directoryDownButton
.BBjFileChooser-summaryViewButton
.BBjFileChooser-detailViewButton
.BBjFileChooser-fileGridPanel
.BBjFileChooser-detailFileGrid
.BBjFileChooser-summaryFileGrid
.BBjFileChooser-fileNameLabel
.BBjFileChooser-fileName
.BBjFileChooser-fileTypeLabel
.BBjFileChooser-fileTypeList
Individual components of the .BBjFileChooser.bbj-directories dialog:
.BBjFileChooser-directoryTree
.BBjFileChooser-directoryTreeItem
The sample program can produce any of the different BBjFileChooser styles:
BBjFileChooser Example
rem ' filechooser.txt
flags$ = $0000$
width = 400
height = 300
if msgbox("Client filesystem?",4+32+256)=6 then
flags$ = ior(flags$,$0004$)
title$ = "Client"
if info(3,6) = "5" then height = 150
else
title$ = "Server"
endif
if msgbox("Save-style dialog?",4+32+256)=6 then
flags$ = ior(flags$,$0100$)
title$ = title$ + " Save"
else
title$ = title$ + " Open"
endif
if info(3,6) = "5" and pos("Client"=title$) then
directory=0
else
directory=msgbox("Directory chooser?",4+32+256)=6
endif
if directory then
flags$ = ior(flags$,$0008$)
title$ = title$ + " Directory"
else
title$ = title$ + " File"
if info(3,6) = "5" and flags$ = $0004$ then
if msgbox("Show Drop Zone?",4+32+256)=6 then
flags$ = ior(flags$,$0002$)
title$ = title$ + " with Drop Zone"
height = height + 100
endif
else
endif
endif
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(100,100,width+50,height+50,title$,$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
directory$ = dsk("") + dir("")
chooser! = window!.addFileChooser(101,25,25,width,height,directory$,flags$)
vector! = bbjapi().makeVector()
vector!.add("*.gif")
vector!.add("*.jpg")
vector!.add("*.png")
vector!.add("*.bmp")
vector!.add("*.ico")
chooser!.addFileFilter("Image Files", vector!)
chooser!.addFileFilter("Text Files", "*.txt")
chooser!.setActiveFileFilter("Text Files")
process_events
eoj:
release
Remarks
The BBjFileChooser is a complex control provided as-is from a GUI control library. As such, the installed LookAndFeel determines much of its presentation and behavior, attempting to adhere to the platform expectations as much as possible. Developers should avoid depending on specific functionality in the choosers.
Also, when using a filechooser connected to the server filesystem, the remote representation of the filesystem may not support all of the functionality available from the displayed filechooser.
Constants of BBjFileChooser
File Selection Mode Constants: | |
| FILES_ONLY |
| FILES_AND_DIRECTORIES |
| DIRECTORIES_ONLY |
Constants inherited from BBjControl
Example
BBjFileChooser Example
REM Open SYSGUI channel
sg = unt
open(sg)"X0"
REM Get BBj objects
api! = BBjAPI()
sg! = api!.getSysGui()
REM Create main window
mainWindow! = sg!.addWindow(100, 100, 300, 500, "File Chooser Demo", $00010083$, $$)
REM Button for normal file chooser
fileChooserButton! = mainWindow!.addButton(101, 50, 10, 120, 30, "File Chooser", $$)
REM Button for directory chooser
dirChooserButton! = mainWindow!.addButton(102, 50, 50, 120, 30, "Directory Chooser", $$)
REM Set callbacks to create the choosers
fileChooserButton!.setCallback(api!.ON_BUTTON_PUSH, "OPEN_FILECHOOSER")
dirChooserButton!.setCallback(api!.ON_BUTTON_PUSH, "OPEN_DIRCHOOSER")
REM Set close callback on mainWindow!
mainWindow!.setCallback(api!.ON_CLOSE, "DO_CLOSE")
PROCESS_EVENTS
REM Callback for BBjButton fileChooserButton!
OPEN_FILECHOOSER:
flags$ = $0000$
GOSUB CREATE_FC
RETURN
REM Callback for BBjButton dirChooserButton!
OPEN_DIRCHOOSER:
flags$ = $0008$
GOSUB CREATE_FC
RETURN
REM Utility subroutine to create the appropriate chooser type with flags$
CREATE_FC:
FOR i = 0 TO idx
mainWindow!.getControl(201 + i,ERR=*BREAK).destroy()
NEXT i
REM Create new window for the file chooser.
sg!.setContext(1)
window! = sg!.addWindow(110, 110, 500, 300, "File Chooser", $00090002$, $$)
REM Create new file chooser with appropriate flags
fc! = window!.addFileChooser(101, 0, 0, 500, 300, $$, flags$)
REM Set the callbacks for interaction with the File Chooser.
window!.setCallback(api!.ON_CLOSE, "DO_DIALOG_CANCEL")
fc!.setCallback(api!.ON_FILECHOOSER_APPROVE, "DO_APPROVE")
fc!.setCallback(api!.ON_FILECHOOSER_CANCEL, "DO_CANCEL")
RETURN
REM Callback for mainWindow! ON_CLOSE
DO_CLOSE:
RELEASE
REM Callback for FileChooser approve event
DO_APPROVE:
REM add a static text for each selected file
window!.destroy()
ev! = BBjAPI().getLastEvent()
vec! = ev!.getSelectedFiles()
for idx = 0 to vec!.size() - 1
if (vec!.size() > 0)
file$ = vec!.get(idx)
mainWindow!.addStaticText(201 + idx, 10, 80 + (25 * idx), 200, 25, file$)
endif
next idx
RETURN
REM Callback for FileChooser cancel event
DO_CANCEL:
REM Destroy the window with the file chooser
window!.destroy()
REM add a static text with the selected files
mainWindow!.addStaticText(201, 10, 80, 200, 30, "File selection cancelled")
idx = 0
RETURN
REM Callback for dialog close box
DO_DIALOG_CANCEL:
fc!.cancelSelection()
RETURN
See Also
CALLBACK Verb - Register BBj Subroutine
See the BBj Object Diagram for an illustration of the relationship between BBj Objects.