Skip to content

propertyGrid

James Bremner edited this page Oct 24, 2019 · 8 revisions

A collection of widgets where user can edit name-value pairs.

Demo code

    #include "wex.h"
    #include "propertygrid.h"

    // reference the windex gui framework
    windex& W = windex::get();

    // construct top level window
    window& form = W.MakeWindow();
    form.move({ 50,50,400,400});
    form.text("A windex property grid");

    // construct propertygrid
    propertyGrid pg( form );
    pg.move( { 50,50, 200, 0});
    pg.labelWidth( 50 );
    pg.bgcolor( 0xFFA0A0 );

    // add properties
    pg.category("Strings");
    pg.string( "A", "72" );
    pg.string( "B", "4600" );
    pg.category("Others");
    pg.choice( "Choose", { "X", "Y", "Z"} );
    pg.check( "Enable", false );

    // display a button
    button& btn = W.make<button>( form );
    btn.move( {20, 250, 150, 30 } );
    btn.text( "Show values entered" );

    // popup a message box when button is clicked
    // showing the values entered
    btn.events().click([&]
    {
        std::string msg =
        "A is " + pg.value("A") +
        ", B is " + pg.value("B") +
        ", choice is " + pg.value("Choose") +
        ", enabled is ";
        if( pg.value("Enable") == "1" )
            msg += "true";
        else
            msg += "false";
        msgbox(
            form,
            msg );
    });

    form.showModal();

propertygrid

Methods

void move( const std::vector<int>& v ) locate and size. v specifies left, top, width, height in pixels

void labelWidth( int w ) specify width of label column in pixels

void update() force every property label to be redrawn, used if window resizing does not update labels correctly

void string( const std::string& name, const std::string& value ) Add a name name-value pair where user can edit value string

void choice( const std::string& name, const std::vector<std::string>& choice ) Add a name-value pair where the user can select between string options for the value

void check( const std::string& name, bool f ) Add a name-value pair where the user can set true/false with checkbox

void category( const std::string& name ) Add a category, which will group the following properties under a heading with the name of the category

void expand( const std::string name, bool fexpand = true ) Expand or collapse the properties in a category

std::string value( const std::string& name ) returns value of name

Clone this wiki locally