UPLOAD - DOSUIT07.ZIP - RADIO.HPP

 
Output of file : RADIO.HPP contained in archive : DOSUIT07.ZIP

// Radio Buttons
#ifndef RADIO_HPP
#define RADIO_HPP
#ifndef BUTTON_HPP
#include "button.hpp"
#endif
#ifndef CLUSTER_HPP
#include "cluster.hpp"
#endif
#ifndef EDITCTRL_HPP
#include "editctrl.hpp"
#endif

/*
Basic radio button. These are usually created automatically in a
RadioHCluster or RadioVCluster.
As with all Buttons, the name of the Button may contain a tilde (~)
character to indicate that the following character is the quick selection
key for the Button. The tilde is not shown on the screen, and the quick
key is highlighted.
*/
class RadioButton : public Button {
public:
RadioButton(const char *name, Keys hotkey = Knone);

virtual coord minwidth() const;
virtual int setfocus(int tabstop = 1);
virtual void paint(Rectangle r);
};

declare(OCollection,RadioButton);
declare(OIterator,RadioButton);

// A ButtonController for RadioButtons.
class RadioButtonControl : public EditControl, public OneButtonController {
public:
RadioButtonControl(int &result, int hintSize = 0);
RadioButtonControl(int &result,const OCollection(Button) &buttons);

virtual void read();
virtual int writeback();
virtual VObject *inheritingVObject() = 0;

private:
int &res;
};

#ifdef __TURBOC__
typedef char constchar/*!*/;
#else
typedef const char constchar;
#endif
declare(GCollection,constchar);
declare(GIterator,constchar);

/*
A group of RadioButtons, arranged horizontally (one beside the other).
The names of the RadioButtons to be laid out are passed in a
GCollection(constchar). GCollection(constchar) has an addition
operator provided which enables a list of RadioButton names to be
created during the call to the constructor.
*/
class RadioHCluster : public HCluster, public RadioButtonControl {
public:
// vararg constructors are obsolete
RadioHCluster(int &result,const char *b,...)/*!*/;
RadioHCluster(const char *name,BorderFlag f,int &result,
const char *b,...)/*!*/;
RadioHCluster(int &result,const char *name = "RadioHCluster",
BorderFlag f = BFtabstop);
RadioHCluster(int &result,const GCollection(constchar)& c,
const char *name = "RadioHCluster",BorderFlag f = BFtabstop);
virtual int setfocus(int tabstop = 1);
void add(Button *button);
void add(const char *buttonName) { add(new RadioButton(buttonName)); }
void add(VObject *v) { HCluster::add(v); }
virtual VObject *inheritingVObject();
virtual int kbdevent(KeyboardEvent& e);
};

/*
A group of RadioButtons, arranged vertically (one above the other).
The names of the RadioButtons to be laid out are passed in a
GCollection(constchar). GCollection(constchar) has an addition
operator provided which enables a list of RadioButton names to be
created during the call to the constructor.
*/
class RadioVCluster : public VCluster, public RadioButtonControl {
public:
// vararg constructors are obsolete
RadioVCluster(int &result,const char *b,...)/*!*/;
RadioVCluster(const char *name,BorderFlag f,int &result,
const char *b,...)/*!*/;
RadioVCluster(int &result,const GCollection(constchar)& c,
const char *name = "RadioVCluster",BorderFlag f = BFtabstop);
RadioVCluster(int &result,const char *name = "RadioVCluster",
BorderFlag f = BFtabstop);
virtual int setfocus(int tabstop = 1);
void add(Button *button);
void add(const char *buttonName) { add(new RadioButton(buttonName)); }
void add(VObject *v) { VCluster::add(v); }
virtual VObject *inheritingVObject();
virtual int kbdevent(KeyboardEvent& e);
};

/*
A Cluster of RadioButtons automatically laid out in columns. The
names of the RadioButtons to be laid out are passed in a
GCollection(constchar). GCollection(constchar) has an addition
operator provided which enables a list of RadioButton names to be
created during the call to the constructor.
*/
class RadioCCluster : public CCluster, public RadioButtonControl {
public:
RadioCCluster(int &result,int rowsPerColumn = 2,
const char *name = "RadioCCluster",BorderFlag f = BFtabstop);
RadioCCluster(int &result,const GCollection(constchar)& c,
int rowsPerColumn = 2,const char *name = "RadioCCluster",
BorderFlag f = BFtabstop);
virtual int setfocus(int tabstop = 1);
void add(Button *button);
void add(const char *buttonName) { add(new RadioButton(buttonName)); }
void add(VObject *v) { CCluster::add(v); }
virtual VObject *inheritingVObject();
virtual int kbdevent(KeyboardEvent& e);
};

#endif