Skip to content

Commit 62f309a

Browse files
committed
Extra documentation
1 parent 44090aa commit 62f309a

2 files changed

Lines changed: 47 additions & 11 deletions

File tree

appcui-proc-macro/src/lib.rs

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,13 +708,52 @@ pub fn dropdownlist(input: TokenStream) -> TokenStream {
708708
crate::controls::dropdownlist::create(input)
709709
}
710710

711+
/// Creates a new listbox control. The format is `listbox!("attributes")` where the attributes are pairs of key-value, separated by comma, in the format `key=value` or `key:value`.
712+
/// If the `value` is a string, use single quotes to delimit the value.
713+
/// The following attributes are supported:
714+
/// * `flags` - The flags of the listbox. The following values are supported:
715+
/// - **ScrollBars** - Adds scrollbars to the listbox
716+
/// - **SearchBar** - Adds a search bar for filtering items
717+
/// - **CheckBoxes** - Adds checkboxes for multiple selection
718+
/// - **AutoScroll** - Automatically scrolls to newly added items
719+
/// - **HighlightSelectedItemWhenInactive** - Highlights selected item even when inactive
720+
/// * `items` - A list of strings to populate the listbox with. Format: `['item1', 'item2', ...]`
721+
/// * `index` or `selected_index` - The index of the initially selected item (0-based)
722+
/// * `lsm` or `left-scroll-margin` - Left scroll margin in characters
723+
/// * `tsm` or `top-scroll-margin` - Top scroll margin in characters
724+
/// * `em` or `empty-message` - Message to display when the listbox is empty
725+
/// * Position and size:
726+
/// - `x`, `y` - Position coordinates
727+
/// - `width`/`w`, `height`/`h` - Control dimensions
728+
/// * Layout:
729+
/// - `align`/`a` - Alignment: Left, Right, Top, Bottom, Center, TopLeft, TopRight, BottomLeft, BottomRight
730+
/// - `dock`/`d` - Docking: Left, Right, Top, Bottom, Center, TopLeft, TopRight, BottomLeft, BottomRight
731+
/// * Margins: `left`/`l`, `right`/`r`, `top`/`t`, `bottom`/`b`
732+
/// * State: `enabled`, `visible`
733+
///
734+
/// # Examples
735+
/// ```rust,compile_fail
736+
/// use appcui::prelude::*;
737+
///
738+
/// // Basic listbox with items
739+
/// let lb = listbox!("items=['Red', 'Green', 'Blue'], x=1, y=1, width=20, height=10");
740+
///
741+
/// // Listbox with scrollbars and search
742+
/// let lb = listbox!("flags: ScrollBars+SearchBar, x=0, y=0, width=30, height=15");
743+
///
744+
/// // Listbox with checkboxes and initial selection
745+
/// let lb = listbox!("flags: CheckBoxes, items=['Option 1', 'Option 2'], index: 1, x=2, y=2, width=25, height=8");
746+
/// ```
747+
#[proc_macro]
748+
pub fn listbox(input: TokenStream) -> TokenStream {
749+
crate::controls::listbox::create(input)
750+
}
711751

712752
#[proc_macro]
713753
pub fn numericselector(input: TokenStream) -> TokenStream {
714754
crate::controls::numericselector::create(input)
715755
}
716756

717-
718757
#[proc_macro]
719758
pub fn menuitem(input: TokenStream) -> TokenStream {
720759
crate::menu::menuitem::create(input, None)
@@ -896,12 +935,6 @@ pub fn datepicker(input: TokenStream) -> TokenStream {
896935
crate::controls::datepicker::create(input)
897936
}
898937

899-
900-
#[proc_macro]
901-
pub fn listbox(input: TokenStream) -> TokenStream {
902-
crate::controls::listbox::create(input)
903-
}
904-
905938
/// Creates a new ListView control for displaying a list of items of type T.
906939
/// The format is `listview!("attributes")` where the attributes are pairs of key-value, separated by comma.
907940
///
@@ -936,11 +969,11 @@ pub fn listbox(input: TokenStream) -> TokenStream {
936969
/// "MyType,
937970
/// view: Details,
938971
/// columns: [{Name,10,left}, {Age,5,right}],
939-
/// dock: Fill"
972+
/// x=1, y=1, width=50, height=25"
940973
/// );
941974
///
942975
/// // Multi-column view
943-
/// let lv = listview!("class: MyType, view: Columns(3), width: 100%, height: 100%");
976+
/// let lv = listview!("class: MyType, view: Columns(3), x=2, y=2, width=60, height=30");
944977
/// ```
945978
///
946979
/// The type T must implement the `ListItem` trait. For columns, use the `#[Column]` attribute
@@ -995,4 +1028,4 @@ pub fn markdown(input: TokenStream) -> TokenStream {
9951028
#[proc_macro]
9961029
pub fn progressbar(input: TokenStream) -> TokenStream {
9971030
crate::controls::progressbar::create(input)
998-
}
1031+
}

docs/chapter-6/predefined_themes.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ AppCUI comes with a set of predefined themes that can be used out of the box via
66
<img src="img/default_theme.png" width=500/>
77

88
2. **DarkGray** - a dark gray theme.
9-
<img src="img/darkgray_theme.png" width=500/>
9+
<img src="img/darkgray_theme.png" width=500/>
10+
11+
3. **Light** - a light theme.
12+
<img src="img/light_theme.png" width=500/>

0 commit comments

Comments
 (0)