WINDEX
Public Member Functions | List of all members
wex::radiobutton Class Reference

A widget that user can click to select one of an exclusive set of options. More...

#include <wex.h>

Inheritance diagram for wex::radiobutton:
wex::gui

Public Member Functions

 radiobutton (gui *parent)
 
void first ()
 Make this button first of a new group. More...
 
bool isChecked ()
 true if checked
 
int checkedOffset ()
 Which button in group is checked. More...
 
void check (bool f=true)
 set value true( default ) or false
 
virtual void draw (PAINTSTRUCT &ps)
 
- Public Member Functions inherited from wex::gui
 gui ()
 Construct top level window with no parent. More...
 
 gui (gui *parent, const char *window_class="windex", unsigned long style=WS_CHILD, unsigned long exstyle=WS_EX_CONTROLPARENT)
 Construct child of a parent. More...
 
void child (gui *w)
 register child on this window
 
children_t & children ()
 get vector of children
 
guiparent ()
 
guifind (int id)
 find child window with specified id
 
void focus ()
 
void bgcolor (int color)
 Change background color. More...
 
void nobgerase ()
 
void enable (bool f=true)
 Enable/Disable, default enable.
 
bool isEnabled () const
 
void fontHeight (int h)
 Change font height for this and all child windows.
 
void fontName (const std::string &name)
 
void icon (const std::string &iconfilename)
 Change icon. More...
 
void cursor (char *cursorID)
 
int id ()
 
int bgcolor () const
 
void textColor (int c)
 Set text color. More...
 
void text (const std::string &text)
 
std::string text () const
 
void scroll (bool fHoriz=true)
 Add scrollbars. More...
 
void scrollRange (int width, int height)
 Set the scrolling range. More...
 
sMouse getMouseStatus ()
 Get mouse status. More...
 
void run ()
 Run the windows message loop. More...
 
void tooltip (const std::string &text, int width=0)
 Add tooltip that pops up helpfully when mouse cursor hovers over widget. More...
 
virtual LRESULT WindowMessageHandler (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
virtual void show (bool f=true)
 Show window and all children.
 
void showModal (gui &appWindow)
 Show this window and suspend all other windows interactions until this is closed. More...
 
void endModal ()
 Stop modal interaction and close window.
 
void update ()
 force widget to redraw completely More...
 
void move (const std::vector< int > &r)
 Move the window. More...
 
void size (int w, int h)
 Change size without moving top left corner. More...
 
void move (int x, int y)
 Change position without changing size. More...
 
void move (int x, int y, int w, int h)
 
std::vector< int > size ()
 Size of window client area. More...
 
std::vector< int > lefttop ()
 
eventhandlerevents ()
 Get event handler.
 
HWND handle ()
 get window handle
 
void delete_list (std::vector< HWND > *list)
 set delete list for when gui is detroyed
 
void setfont (LOGFONT &logfont, HFONT &font)
 change font for this and all child windows
 
void setAsyncReadCompleteMsgID (int id)
 

Additional Inherited Members

- Protected Member Functions inherited from wex::gui
void Create (HWND parent, const char *window_class, DWORD style, DWORD exstyle=0, int id=0)
 Create the managed window. More...
 
void font (LOGFONT &logfont, HFONT &font)
 get font details More...
 
void createNewFont ()
 Replace font used by this and child windows from logfont.
 
int NewID ()
 Create new, unique ID for gui element. More...
 
int scrollMove (SCROLLINFO &si, int code)
 
- Protected Attributes inherited from wex::gui
HWND myHandle
 
guimyParent
 
eventhandler myEvents
 
int myBGColor
 
int myTextColor
 
HBRUSH myBGBrush
 
LOGFONT myLogFont
 
HFONT myFont
 
std::vector< HWND > * myDeleteList
 
std::string myText
 
int myID
 
std::vector< gui * > myChild
 gui elements to be displayed in this window
 
bool myfModal
 true if element is being shown as modal
 
bool myfEnabled
 true if not disabled
 
bool myfnobgerase
 
HWND myToolTip
 
unsigned int myAsyncReadCompleteMsgID
 handle to tooltip control for this gui element
 
char * myCursorID
 
bool myfScrollHoriz
 

Detailed Description

A widget that user can click to select one of an exclusive set of options.

// construct top level window
gui& form = wex::maker::make();
form.move({ 50,50,400,400});
form.text("A windex radiobutton");

wex::groupbox& P = wex::maker::make<wex::groupbox>( form );
P.move( 5, 5, 350,200 );

// use laypout to atomatically arrange buttons in columns
wex::layout& L = wex::maker::make<wex::layout>(P  );
L.move( 50, 50,300,190);
L.grid( 2 );                // specify 2 columns
L.colfirst();               // specify column first order

// first group of radiobuttons
radiobutton& rb1 = wex::maker::make<radiobutton>(L);
rb1.first();                // first in group of interacting buttons
rb1.move( {20,20,100,30} );
rb1.text("Alpha");
radiobutton& rb2 = wex::maker::make<radiobutton>(L);
rb2.move( {20,60,100,30} );
rb2.text("Beta");
radiobutton& rb3 = wex::maker::make<radiobutton>(L);
rb3.move( {20,100,100,30} );
rb3.text("Gamma");

// second group of radio buttons
radiobutton& rb4 = wex::maker::make<radiobutton>(L);
rb4.first();                // first in group of interacting buttons
rb4.size( 80,30 );
rb4.text("X");
radiobutton& rb5 = wex::maker::make<radiobutton>(L);
rb5.size( 80,30 );
rb5.text("Y");
radiobutton& rb6 = wex::maker::make<radiobutton>(L);
rb6.size( 80,30 );
rb6.text("Z");

// display a button
button& btn = wex::maker::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;
    if( rb1.isChecked() )
        msg = "Alpha";
    else if( rb2.isChecked() )
        msg = "Beta";
    else if( rb3.isChecked() )
        msg = "Gamma";
    else
        msg = "Nothing";
    msg += " is checked";
    msgbox(
        form,
        msg );
});

// show the application
form.show();

Member Function Documentation

◆ checkedOffset()

int wex::radiobutton::checkedOffset ( )
inline

Which button in group is checked.

Returns
zero-based offset of checked button in group this button belongs to, -1 if none checked

◆ first()

void wex::radiobutton::first ( )
inline

Make this button first of a new group.

The other buttons in a group will become false when one is clicked but buttons in different groups will not be changed.

All succeeding buttons, those that were constructed after this button and remain in the same group, are also moved to the new group.


The documentation for this class was generated from the following file: