Search documentation of wx

# View Source wxGenericDirCtrl (wx v2.4.3)

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

The control contains a `wxTreeCtrl` window representing the directory hierarchy, and optionally, a `wxChoice` window containing a list of filters.

## Styles

This class supports the following styles:

- wxDIRCTRL_DIR_ONLY: Only show directories, and not files.

- wxDIRCTRL_3D_INTERNAL: Use 3D borders for internal controls. This is the default.

- wxDIRCTRL_SELECT_FIRST: When setting the default path, select the first file in the directory.

- wxDIRCTRL_SHOW_FILTERS: Show the drop-down filter list.

- wxDIRCTRL_EDIT_LABELS: Allow the folder and file labels to be editable.

- wxDIRCTRL_MULTIPLE: Allows multiple files and folders to be selected.

This class is derived, and can use functions, from:

- `wxControl`

- `wxWindow`

- `wxEvtHandler`

wxWidgets docs: wxGenericDirCtrl

## Events

Event types emitted from this class:

- `dirctrl_selectionchanged`

- `dirctrl_fileactivated`

# Summary

## Types

wxGenericDirCtrl()

## Functions

collapseTree(This)

Collapses the entire tree.

create(This, Parent)

Equivalent to `create(This, Parent, [])`.

create/3

Create function for two-step construction.

destroy(This)

Destroys the object

expandPath(This, Path)

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

getDefaultPath(This)

Gets the default path.

getFilePath(This)

Gets selected filename path only (else empty string).

getFilter(This)

Returns the filter string.

getFilterIndex(This)

Returns the current filter index (zero-based).

getPath(This)

Gets the currently-selected directory or filename.

getPath(This, ItemId)

Gets the path corresponding to the given tree control item.

getRootId(This)

Returns the root id for the tree control.

getTreeCtrl(This)

Returns a pointer to the tree control.

init(This)

Initializes variables.

new()

Default constructor.

new(Parent)

Equivalent to `new(Parent, [])`.

new/2

Main constructor.

reCreateTree(This)

Collapse and expand the tree, thus re-creating it from scratch.

setDefaultPath(This, Path)

Sets the default path.

setFilter(This, Filter)

Sets the filter string.

setFilterIndex(This, N)

Sets the current filter index (zero-based).

setPath(This, Path)

Sets the current path.

# Types

Link to this type

# wxGenericDirCtrl()

View Source

    -type wxGenericDirCtrl() :: wx:wx_object().

# Functions

Link to this function

# collapseTree(This)

View Source

    -spec collapseTree(This) -> ok when This :: wxGenericDirCtrl().

Collapses the entire tree.

Link to this function

# create(This, Parent)

View Source

    -spec create(This, Parent) -> boolean() when This :: wxGenericDirCtrl(), Parent :: wxWindow:wxWindow().

Equivalent to `create(This, Parent, [])`.

Link to this function

# create/3

View Source

    -spec create(This, Parent, [Option]) -> boolean()
                    when
                        This :: wxGenericDirCtrl(),
                        Parent :: wxWindow:wxWindow(),
                        Option ::
                            {id, integer()} |
                            {dir, unicode:chardata()} |
                            {pos, {X :: integer(), Y :: integer()}} |
                            {size, {W :: integer(), H :: integer()}} |
                            {style, integer()} |
                            {filter, unicode:chardata()} |
                            {defaultFilter, integer()}.

Create function for two-step construction.

See `new/2` for details.

Link to this function

# destroy(This)

View Source

    -spec destroy(This :: wxGenericDirCtrl()) -> ok.

Destroys the object

Link to this function

# expandPath(This, Path)

View Source

    -spec expandPath(This, Path) -> boolean() when This :: wxGenericDirCtrl(), Path :: unicode:chardata().

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

Link to this function

# getDefaultPath(This)

View Source

    -spec getDefaultPath(This) -> unicode:charlist() when This :: wxGenericDirCtrl().

Gets the default path.

Link to this function

# getFilePath(This)

View Source

    -spec getFilePath(This) -> unicode:charlist() when This :: wxGenericDirCtrl().

Gets selected filename path only (else empty string).

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

Link to this function

# getFilter(This)

View Source

    -spec getFilter(This) -> unicode:charlist() when This :: wxGenericDirCtrl().

Returns the filter string.

Link to this function

# getFilterIndex(This)

View Source

    -spec getFilterIndex(This) -> integer() when This :: wxGenericDirCtrl().

Returns the current filter index (zero-based).

Link to this function

# getPath(This)

View Source

    -spec getPath(This) -> unicode:charlist() when This :: wxGenericDirCtrl().

Gets the currently-selected directory or filename.

Link to this function

# getPath(This, ItemId)

View Source

    -spec getPath(This, ItemId) -> unicode:charlist() when This :: wxGenericDirCtrl(), ItemId :: integer().

Gets the path corresponding to the given tree control item.

Since: 2.9.5

Link to this function

# getRootId(This)

View Source

    -spec getRootId(This) -> integer() when This :: wxGenericDirCtrl().

Returns the root id for the tree control.

Link to this function

# getTreeCtrl(This)

View Source

    -spec getTreeCtrl(This) -> wxTreeCtrl:wxTreeCtrl() when This :: wxGenericDirCtrl().

Returns a pointer to the tree control.

Link to this function

# init(This)

View Source

    -spec init(This) -> ok when This :: wxGenericDirCtrl().

Initializes variables.

Link to this function

# new()

View Source

    -spec new() -> wxGenericDirCtrl().

Default constructor.

Link to this function

# new(Parent)

View Source

    -spec new(Parent) -> wxGenericDirCtrl() when Parent :: wxWindow:wxWindow().

Equivalent to `new(Parent, [])`.

Link to this function

# new/2

View Source

    -spec new(Parent, [Option]) -> wxGenericDirCtrl()
                 when
                     Parent :: wxWindow:wxWindow(),
                     Option ::
                         {id, integer()} |
                         {dir, unicode:chardata()} |
                         {pos, {X :: integer(), Y :: integer()}} |
                         {size, {W :: integer(), H :: integer()}} |
                         {style, integer()} |
                         {filter, unicode:chardata()} |
                         {defaultFilter, integer()}.

Main constructor.

Link to this function

# reCreateTree(This)

View Source

    -spec reCreateTree(This) -> ok when This :: wxGenericDirCtrl().

Collapse and expand the tree, thus re-creating it from scratch.

May be used to update the displayed directory content.

Link to this function

# setDefaultPath(This, Path)

View Source

    -spec setDefaultPath(This, Path) -> ok when This :: wxGenericDirCtrl(), Path :: unicode:chardata().

Sets the default path.

Link to this function

# setFilter(This, Filter)

View Source

    -spec setFilter(This, Filter) -> ok when This :: wxGenericDirCtrl(), Filter :: unicode:chardata().

Sets the filter string.

Link to this function

# setFilterIndex(This, N)

View Source

    -spec setFilterIndex(This, N) -> ok when This :: wxGenericDirCtrl(), N :: integer().

Sets the current filter index (zero-based).

Link to this function

# setPath(This, Path)

View Source

    -spec setPath(This, Path) -> ok when This :: wxGenericDirCtrl(), Path :: unicode:chardata().

Sets the current path.