wxGenericDirCtrl(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’– NAME πŸ’–

okay so bestie, wxGenericDirCtrl is that control β€” the one you drop on any random window when you want a whole directory listing up in there (with optional files, because sometimes we want the files and sometimes we literally don't πŸ“). It's giving file-browser main character energy. Periodt.


✨ DESCRIPTION ✨

So like, inside this control there's a wxTreeCtrl window doing the absolute most β€” it's the whole directory hierarchy, okay? The tree. The vibe. And then, optionally, there's a wxChoice window chilling right next to it holding a list of filters. Two besties, one control. No cap. πŸ¦‹

🌸 Styles 🌸

This class supports the following styles, and yes you should read all of them because they all matter:

  • wxDIRCTRL_DIR_ONLY β€” directories ONLY. no files. we said what we said. πŸ’…
  • wxDIRCTRL_3D_INTERNAL β€” gives the internal controls 3D borders. this one is the default, so it's already slaying unless you say otherwise.
  • wxDIRCTRL_SELECT_FIRST β€” when you set the default path, it selects the first file in the directory. first place energy πŸ‘‘
  • wxDIRCTRL_SHOW_FILTERS β€” shows that drop-down filter list. the little menu moment.
  • wxDIRCTRL_EDIT_LABELS β€” lets the folder and file labels be editable. yes you can rename things, go off ✏️
  • wxDIRCTRL_MULTIPLE β€” allows multiple files and folders to be selected. polyamorous selection, we love to see it πŸ’œ

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

  • wxControl
  • wxWindow
  • wxEvtHandler

Inherited the whole family tree fr fr πŸ’€

wxWidgets docs: wxGenericDirCtrl

πŸŽ€ Events πŸŽ€

Event types emitted from this class, and honestly they're iconic:

  • dirctrl_selectionchanged
  • dirctrl_fileactivated

🌈 DATA TYPES 🌈

wxGenericDirCtrl() :: wx:wx_object().

that's it. that's the type. simple. elegant. πŸ’«


πŸ”₯ FUNCTIONS πŸ”₯

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

Collapses the entire tree. just β€” whole thing, gone, folded up. bye tree πŸŒ³πŸ’€

  • 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()}.

The create function for two-step construction, bestie. If you're doing the build-it-in-stages thing, this is your girl.

Peep new/2 for the details, okay? πŸ‘€

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

Destroys the object. it's over. it's giving closure πŸ₯€

  • 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 ends up visible in the tree control. like opening all the little folders to find your fave. so satisfying ✨

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

Gets the default path. that's the whole thing.

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

Gets the selected filename path only β€” and if there isn't one, you get an empty string, sorry babe 😭

Real talk: this function doesn't count a directory as a selection. So if a folder is selected, it's not gonna give you that path. nope. πŸ’€
  • getFilter(This) -> unicode:charlist() when This :: wxGenericDirCtrl().

Returns the filter string.

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

Returns the current filter index. and it's zero-based, keep that in mind or you WILL be off by one, iykyk 😭

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

Gets the currently-selected directory or filename. the one you're on rn 🫢

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

Gets the path corresponding to the given tree control item.

Since: 2.9.5 ⭐

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

Returns the root id for the tree control. the source. the origin. the mother of the tree πŸ‘‘

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

Returns a pointer to the tree control.

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

Initializes variables. just setting the stage, bestie 🎬

  • new() -> wxGenericDirCtrl().

Default constructor. no args, no stress πŸ’…

  • 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!! this is the one you'll actually be using. go off πŸŽ€

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

Collapse and expand the tree, thus re-creating it from scratch. it's like a little glow-up for the tree ✨

May be used to update the displayed directory content. so if the directory changed and the control needs to know β€” this. yes.

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

Sets the default path.

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

Sets the filter string.

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

Sets the current filter index. and yes, it's zero-based again, don't forget, bestie 😌

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

Sets the current path. that's it, you're moved in 🏑


🧚 okay that's the whole page!! you ate that fr fr. go build something cute with your directory listing. mwah πŸ’‹

This was brought to you by Ericsson AB πŸ’–, the wx 2.6 era 🌸, and the one and only wxGenericDirCtrl(3) β€” stay iconic, bestie πŸ‘‘βœ¨πŸ¦‹

πŸ“¦ where this page comes from