GIDForums  

Go Back   GIDForums > Computer Programming Forums > FLTK Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Jan-2006, 20:19
toaster toaster is offline
New Member
 
Join Date: Jan 2006
Posts: 1
toaster is on a distinguished road
Arrow

Group Round buttons (radio buttons)


Hi,
What is the most efficient way to implement a group of several round buttons (radio buttons) together such that if one is selected all the other round buttons are deselected?
Frank
  #2  
Old 03-Jan-2006, 07:57
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: Group Round buttons (radio buttons)


Quote:
Originally Posted by toaster
Hi
Hello and Welcome to GIDForums™ Frank.
Quote:
Originally Posted by toaster
What is the most efficient way to implement a group of several round buttons (radio buttons) together such that if one is selected all the other round buttons are deselected?
Frank

Here is a small program that shows how to have 3 radio groups. The trick with radio buttons is to contain them in a group and set them all to radio. I also like to set the default button with setonly() or you get a radio group with nothing selected on startup.

The program was generated by fluid and then I just compacted it into a single file for ease of use.

CPP / C++ / C Code:
// generated by Fast Light User Interface Designer (fluid) version 1.0107

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Round_Button.H>

int main(int argc, char **argv) {
  Fl_Double_Window* w;
  { Fl_Double_Window* o = new Fl_Double_Window(367, 198);
    w = o;
    { Fl_Group* o = new Fl_Group(10, 10, 347, 73);
      o->box(FL_DOWN_BOX);
      { Fl_Round_Button* o = new Fl_Round_Button(32, 20, 64, 15, "button");
        o->type(102);
        o->down_box(FL_ROUND_DOWN_BOX);
        o->setonly();
      }
      { Fl_Round_Button* o = new Fl_Round_Button(32, 45, 64, 15, "button");
        o->type(102);
        o->down_box(FL_ROUND_DOWN_BOX);
      }
      { Fl_Round_Button* o = new Fl_Round_Button(106, 34, 64, 15, "button");
        o->type(102);
        o->down_box(FL_ROUND_DOWN_BOX);
      }
      { Fl_Round_Button* o = new Fl_Round_Button(175, 20, 64, 15, "button");
        o->type(102);
        o->down_box(FL_ROUND_DOWN_BOX);
      }
      { Fl_Round_Button* o = new Fl_Round_Button(175, 58, 64, 15, "button");
        o->type(102);
        o->down_box(FL_ROUND_DOWN_BOX);
      }
      { Fl_Round_Button* o = new Fl_Round_Button(261, 34, 64, 15, "button");
        o->type(102);
        o->down_box(FL_ROUND_DOWN_BOX);
      }
      o->end();
    }
    { Fl_Group* o = new Fl_Group(10, 93, 349, 93);
      o->box(FL_DOWN_BOX);
      { Fl_Round_Button* o = new Fl_Round_Button(280, 103, 64, 20, "button");
        o->type(102);
        o->down_box(FL_ROUND_DOWN_BOX);
        o->setonly();
      }
      { Fl_Round_Button* o = new Fl_Round_Button(280, 133, 64, 15, "button");
        o->type(102);
        o->down_box(FL_ROUND_DOWN_BOX);
      }
      { Fl_Round_Button* o = new Fl_Round_Button(280, 161, 64, 15, "button");
        o->type(102);
        o->down_box(FL_ROUND_DOWN_BOX);
      }
      { Fl_Group* o = new Fl_Group(10, 93, 89, 93);
        { Fl_Round_Button* o = new Fl_Round_Button(20, 103, 64, 15, "button");
          o->type(102);
          o->down_box(FL_ROUND_DOWN_BOX);
          o->setonly();
        }
        { Fl_Round_Button* o = new Fl_Round_Button(20, 128, 64, 15, "button");
          o->type(102);
          o->down_box(FL_ROUND_DOWN_BOX);
        }
        { Fl_Round_Button* o = new Fl_Round_Button(20, 152, 64, 15, "button");
          o->type(102);
          o->down_box(FL_ROUND_DOWN_BOX);
        }
        o->end();
      }
      o->end();
    }
    o->end();
  }
  w->show(argc, argv);
  return Fl::run();
}

To compile that I ...
Code:
g++ -Wall radio_test.cxx `fltk-config --cxxflags --ldflags` -o RadioTest

Just in case you are interested, here is the fluid project file for the above.
Code:
# data file for the Fltk User Interface Designer (fluid) version 1.0107 header_name {.h} code_name {.cxx} Function {} {open } { Fl_Window {} {open xywh {510 123 367 198} type Double hide } { Fl_Group {} {open xywh {10 10 347 73} box DOWN_BOX } { Fl_Round_Button {} { label button xywh {32 20 64 15} type Radio down_box ROUND_DOWN_BOX code0 {o->setonly();} } Fl_Round_Button {} { label button xywh {32 45 64 15} type Radio down_box ROUND_DOWN_BOX } Fl_Round_Button {} { label button xywh {106 34 64 15} type Radio down_box ROUND_DOWN_BOX } Fl_Round_Button {} { label button xywh {175 20 64 15} type Radio down_box ROUND_DOWN_BOX } Fl_Round_Button {} { label button xywh {175 58 64 15} type Radio down_box ROUND_DOWN_BOX } Fl_Round_Button {} { label button xywh {261 34 64 15} type Radio down_box ROUND_DOWN_BOX } } Fl_Group {} {open xywh {10 93 349 93} box DOWN_BOX } { Fl_Round_Button {} { label button xywh {280 103 64 20} type Radio down_box ROUND_DOWN_BOX code0 {o->setonly();} } Fl_Round_Button {} { label button xywh {280 133 64 15} type Radio down_box ROUND_DOWN_BOX } Fl_Round_Button {} { label button xywh {280 161 64 15} type Radio down_box ROUND_DOWN_BOX } Fl_Group {} {open xywh {10 93 89 93} } { Fl_Round_Button {} { label button selected xywh {20 103 64 15} type Radio down_box ROUND_DOWN_BOX code0 {o->setonly();} } Fl_Round_Button {} { label button xywh {20 128 64 15} type Radio down_box ROUND_DOWN_BOX } Fl_Round_Button {} { label button xywh {20 152 64 15} type Radio down_box ROUND_DOWN_BOX } } } } }

HTH
Mark
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FLTK && fluid In Motion cable_guy_67 FLTK Forum 4 20-Mar-2008 04:52
radio buttons drewdaman MS Visual C++ / MFC Forum 4 04-Dec-2005 10:49
Simple FLTK dialog box sample cable_guy_67 FLTK Forum 4 02-Nov-2004 09:46
collecting user input from radio buttons. Adelle29 Web Design Forum 1 31-May-2004 17:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:46.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.