wxRuby Documentation Home

# Wx::GenericDirCtrl

This control can be used to place a directory listing (with optional files) on an arbitrary window.

The control contains a TreeCtrl window representing the directory
hierarchy, and optionally, a Choice window containing a list of filters.

## Derived from

Control

Window

EvtHandler

Object

## Window styles

DIRCTRL_DIR_ONLY | Only show directories, and not files.
DIRCTRL_3D_INTERNAL | Use 3D borders for internal controls.
DIRCTRL_SELECT_FIRST | When setting the default path, select the first file in the directory.
DIRCTRL_SHOW_FILTERS | Show the drop-down filter list.
DIRCTRL_EDIT_LABELS | Allow the folder and file labels to be editable.

See also Generic window styles.

## Data structures

## Methods

- GenericDirCtrl.new
- GenericDirCtrl#create
- GenericDirCtrl#init
- GenericDirCtrl#collapse_tree
- GenericDirCtrl#expand_path
- GenericDirCtrl#collapse_path
- GenericDirCtrl#get_default_path
- GenericDirCtrl#get_path
- GenericDirCtrl#get_file_path
- GenericDirCtrl#get_filter
- GenericDirCtrl#get_filter_index
- GenericDirCtrl#get_filter_list_ctrl
- GenericDirCtrl#get_root_id
- GenericDirCtrl#get_tree_ctrl
- GenericDirCtrl#re_create_tree
- GenericDirCtrl#set_default_path
- GenericDirCtrl#set_filter
- GenericDirCtrl#set_filter_index
- GenericDirCtrl#set_path
- GenericDirCtrl#show_hidden

### GenericDirCtrl.new

GenericDirCtrl.new(%(arg-type)Window% parent, Integer id = -1, String dir = DirDialogDefaultFolderStr, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = DIRCTRL_3D_INTERNAL|SUNKEN_BORDER, String filter = ’’, Integer defaultFilter = 0, String name = TreeCtrlNameStr)

Main constructor.

#### Parameters

- parent Parent window.
- id Window identifier.
- dir Initial folder.
- pos Position.
- size Size.
- style Window style. Please see GenericDirCtrl for a list of possible styles.
- filter A filter string, using the same syntax as that for FileDialog. This may be empty if filters
  are not being used.

Example: ``All files (.)|.|JPEG files (.jpg)|.jpg"

- defaultFilter The zero-indexed default filter setting.
- name The window name.

destructor()

Destructor.

### GenericDirCtrl#create

Boolean create(%(arg-type)Window% parent, Integer id = -1, String dir = DirDialogDefaultFolderStr, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = DIRCTRL_3D_INTERNAL|SUNKEN_BORDER, String filter = ’’, Integer defaultFilter = 0, String name = TreeCtrlNameStr)

Create function for two-step construction. See GenericDirCtrl.new for details.

### GenericDirCtrl#init

init()

Initializes variables.

### GenericDirCtrl#collapse_tree

collapse_tree()

Collapses the entire tree.

### GenericDirCtrl#expand_path

Boolean expand_path(%(arg-type)String% path)

Tries to expand as much of the given path as possible, so that the filename or directory is visible in the tree control.

### GenericDirCtrl#collapse_path

Boolean collapse_path(%(arg-type)String% path)

Collapse the given path.

### GenericDirCtrl#get_default_path

String get_default_path()

Gets the default path.

### GenericDirCtrl#get_path

String get_path()

Gets the currently-selected directory or filename.

### GenericDirCtrl#get_file_path

String get_file_path()

Gets selected filename path only (else empty string).

This function doesn’t count a directory as a selection.

### GenericDirCtrl#get_filter

String get_filter()

Returns the filter string.

### GenericDirCtrl#get_filter_index

Integer get_filter_index()

Returns the current filter index (zero-based).

### GenericDirCtrl#get_filter_list_ctrl

DirFilterListCtrl get_filter_list_ctrl()

Returns the filter list control (if present).

### GenericDirCtrl#get_root_id

TreeItemId get_root_id()

Returns the root id for the tree control.

### GenericDirCtrl#get_tree_ctrl

TreeCtrl get_tree_ctrl()

Returns the TreeCtrl used to display the items in the
tree. Normal TreeCtrl methods may be used on this tree. The text for
each item is the name of the corresponding directory or file. The
data (which can be retrieved by calling get_item_data) for each item is
a String containing the full path of the directory or file.

### GenericDirCtrl#re_create_tree

re_create_tree()

Collapse and expand the tree, thus re-creating it from scratch. May be
used to update the displayed directory content.

### GenericDirCtrl#set_default_path

set_default_path(%(arg-type)String% path)

Sets the default path.

### GenericDirCtrl#set_filter

set_filter(%(arg-type)String% filter)

Sets the filter string.

### GenericDirCtrl#set_filter_index

set_filter_index(%(arg-type)Integer% n)

Sets the current filter index (zero-based).

### GenericDirCtrl#set_path

set_path(%(arg-type)String% path)

Sets the current path.

### GenericDirCtrl#show_hidden

show_hidden(%(arg-type)Boolean% show)

#### Parameters

- show If true, hidden folders and files will be displayed by the
  control. If false, they will not be displayed.

[This page automatically generated from the Textile source at 2023-06-09 00:45:33 +0000]