on-demand scroll bars for FButtonGroup

This commit is contained in:
Markus Gans 2017-03-12 00:29:56 +01:00
parent 56df867ef7
commit 4107227119
23 changed files with 339 additions and 48 deletions

1
.gitignore vendored
View File

@ -35,6 +35,7 @@ test/windows
test/term-attributes test/term-attributes
test/transparent test/transparent
test/input-dialog test/input-dialog
test/choice
test/mandelbrot test/mandelbrot
test/keyboard test/keyboard
test/timer test/timer

View File

@ -1,3 +1,12 @@
2017-03-12 Markus Gans <guru.mail@muenster.de>
* The FButtonGroup now has a scrolling area
with on-demand scroll bars
* Add the "choice" example to demonstrate the FButtonGroup
auto-adjusting with on-demand scroll bars
* FRect can now combine two FRect objects
* The FButtonGroup got the possibility of index access
to a child button.
2017-03-08 Markus Gans <guru.mail@muenster.de> 2017-03-08 Markus Gans <guru.mail@muenster.de>
* Improve input cursor positioning in FScrollView * Improve input cursor positioning in FScrollView

View File

@ -20,7 +20,6 @@ Missing Features
└──► tmp └──► tmp
--------------------------------------- ---------------------------------------
- Add a scrolling area with on-demand scroll bars for FButtonGroup
- Adding for flexible layouts a FGrid widget container that organizes - Adding for flexible layouts a FGrid widget container that organizes
its child widgets in rows and columns its child widgets in rows and columns

View File

@ -207,6 +207,7 @@ class FApplication : public FWidget
// Friend functions from FWindow // Friend functions from FWindow
friend bool FWindow::activateWindow (bool); friend bool FWindow::activateWindow (bool);
friend FWindow* FWindow::getActiveWindow(); friend FWindow* FWindow::getActiveWindow();
friend void FWindow::unsetActiveWindow();
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -51,6 +51,23 @@ FButtonGroup::~FButtonGroup() // destructor
// public methods of FButtonGroup // public methods of FButtonGroup
//----------------------------------------------------------------------
FToggleButton* FButtonGroup::getButton(int index) const
{
FObjectList::const_iterator iter;
index--;
if ( buttonlist.empty() )
return 0;
if ( index < 0 || index >= int(getCount()) )
return 0;
iter = buttonlist.begin();
std::advance (iter, index);
return static_cast<FToggleButton*>(*iter);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FToggleButton* FButtonGroup::getFirstButton() FToggleButton* FButtonGroup::getFirstButton()
{ {
@ -99,7 +116,18 @@ void FButtonGroup::setText (const FString& txt)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FButtonGroup::hasFocusedButton() bool FButtonGroup::isChecked (int index) const
{
FToggleButton* button = getButton(index);
if ( button )
return button->isChecked();
else
return false;
}
//----------------------------------------------------------------------
bool FButtonGroup::hasFocusedButton() const
{ {
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return false; return false;
@ -122,7 +150,7 @@ bool FButtonGroup::hasFocusedButton()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FButtonGroup::hasCheckedButton() bool FButtonGroup::hasCheckedButton() const
{ {
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return false; return false;
@ -223,6 +251,8 @@ void FButtonGroup::insert (FToggleButton* button)
"toggled", "toggled",
_METHOD_CALLBACK (this, &FButtonGroup::cb_buttonToggled) _METHOD_CALLBACK (this, &FButtonGroup::cb_buttonToggled)
); );
//checkScrollSize (button);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -251,6 +281,28 @@ void FButtonGroup::remove (FToggleButton* button)
} }
} }
//----------------------------------------------------------------------
void FButtonGroup::checkScrollSize (FToggleButton* button)
{
// Check and adjust the scroll size
checkScrollSize (button->getGeometry());
}
//----------------------------------------------------------------------
void FButtonGroup::checkScrollSize (const FRect& r)
{
// Check and adjust the scroll size
FRect scrollgeometry (1, 1, getScrollWidth(), getScrollHeight());
if ( ! scrollgeometry.contains(r) )
{
FRect new_size = scrollgeometry.combined(r);
setScrollSize (new_size.getWidth(), new_size.getHeight());
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::onMouseDown (FMouseEvent* ev) void FButtonGroup::onMouseDown (FMouseEvent* ev)
{ {
@ -283,10 +335,16 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
{ {
if ( isRadioButton(toggle_button) ) if ( isRadioButton(toggle_button) )
{ {
in_ev->ignore();
FWidget* prev_element = getFocusWidget(); FWidget* prev_element = getFocusWidget();
in_ev->ignore();
toggle_button->setFocus(); toggle_button->setFocus();
FFocusEvent cfi (fc::ChildFocusIn_Event);
FApplication::sendEvent(this, &cfi);
FFocusEvent in (fc::FocusIn_Event);
FApplication::sendEvent(toggle_button, &in);
if ( prev_element ) if ( prev_element )
prev_element->redraw(); prev_element->redraw();

View File

@ -55,6 +55,8 @@ class FButtonGroup : public FScrollView
const char* getClassName() const; const char* getClassName() const;
FToggleButton* getFirstButton(); FToggleButton* getFirstButton();
FToggleButton* getLastButton(); FToggleButton* getLastButton();
FToggleButton* getButton (int) const;
uInt getCount() const;
FString& getText(); FString& getText();
// Mutator // Mutator
@ -65,13 +67,16 @@ class FButtonGroup : public FScrollView
void setText (const FString&); void setText (const FString&);
// Inquiries // Inquiries
bool hasFocusedButton(); bool isChecked(int) const;
bool hasCheckedButton(); bool hasFocusedButton() const;
bool hasCheckedButton() const;
// Methods // Methods
void hide(); void hide();
void insert (FToggleButton*); void insert (FToggleButton*);
void remove (FToggleButton*); void remove (FToggleButton*);
void checkScrollSize (FToggleButton*);
void checkScrollSize (const FRect&);
// Event handlers // Event handlers
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
@ -100,15 +105,15 @@ class FButtonGroup : public FScrollView
FButtonGroup& operator = (const FButtonGroup&); FButtonGroup& operator = (const FButtonGroup&);
// Inquiries // Inquiries
bool isRadioButton (FToggleButton*) const; bool isRadioButton (FToggleButton*) const;
// Methods // Methods
void init(); void init();
void directFocus(); void directFocus();
// Data Members // Data Members
FString text; FString text;
FObjectList buttonlist; FObjectList buttonlist;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -130,6 +135,10 @@ inline bool FButtonGroup::unsetEnable()
inline bool FButtonGroup::setDisable() inline bool FButtonGroup::setDisable()
{ return setEnable(false); } { return setEnable(false); }
//----------------------------------------------------------------------
inline uInt FButtonGroup::getCount() const
{ return uInt(buttonlist.size()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString& FButtonGroup::getText() inline FString& FButtonGroup::getText()
{ return text; } { return text; }

View File

@ -22,7 +22,7 @@
class fc class fc
{ {
public: public:
// event types // Event types
enum events enum events
{ {
None_Event, // invalid event None_Event, // invalid event
@ -50,7 +50,7 @@ class fc
Timer_Event // timer event occur Timer_Event // timer event occur
}; };
// properties of a widget // Properties of a widget
enum widget_flags enum widget_flags
{ {
shadow = 0x00000001, shadow = 0x00000001,
@ -68,7 +68,7 @@ class fc
no_underline = 0x00001000 no_underline = 0x00001000
}; };
// internal character encoding // Internal character encoding
enum encoding enum encoding
{ {
UTF8, UTF8,
@ -121,7 +121,7 @@ class fc
vt100_key_bullet = '~' // · - bullet vt100_key_bullet = '~' // · - bullet
}; };
// unicode characters // Unicode characters
enum SpecialCharacter enum SpecialCharacter
{ {
Euro = 0x20ac, // € Euro = 0x20ac, // €
@ -403,7 +403,7 @@ class fc
Fkey_f63 = 0x1000194 Fkey_f63 = 0x1000194
}; };
// keyboard - modifier key combinations // Keyboard - modifier key combinations
enum metakeys enum metakeys
{ {
Fmkey_ic = 0x1500100, // M-insert Fmkey_ic = 0x1500100, // M-insert
@ -614,7 +614,7 @@ class fc
Fmkey_tilde = 0x200015e // M-~ Fmkey_tilde = 0x200015e // M-~
}; };
// console color names // Console color names
enum colornames enum colornames
{ {
Default = -1, Default = -1,
@ -877,7 +877,7 @@ class fc
Grey93 = 255 // #eeeeee Grey93 = 255 // #eeeeee
}; };
// mouse/keyboard state values // Mouse/keyboard state values
enum ButtonState enum ButtonState
{ {
NoButton = 0x00, NoButton = 0x00,
@ -891,7 +891,7 @@ class fc
KeyButtonMask = 0x38 KeyButtonMask = 0x38
}; };
// wheel state values // Wheel state values
enum WheelState enum WheelState
{ {
NoWheel = 0x00, NoWheel = 0x00,
@ -900,15 +900,15 @@ class fc
WheelMask = 0x03 WheelMask = 0x03
}; };
// type of focus // Type of focus
enum FocusTypes enum FocusTypes
{ {
FocusNextWidget = 0x00, FocusNextWidget = 0x00,
FocusPreviousWidget = 0x01, FocusPreviousWidget = 0x01,
FocusDefiniteWidget = 0x03 FocusDefiniteWidget = 0x03 // event default
}; };
// scroll bar visibility mode // Scroll bar visibility mode
enum scrollBarMode enum scrollBarMode
{ {
Auto = 0, // Shows a scroll bar when area is larger than viewport Auto = 0, // Shows a scroll bar when area is larger than viewport
@ -916,7 +916,7 @@ class fc
Scroll = 2 // Always shows a scroll bar Scroll = 2 // Always shows a scroll bar
}; };
// xterm cursor style // Xterm cursor style
enum xtermCursorStyle enum xtermCursorStyle
{ {
blinking_block = 0, blinking_block = 0,
@ -928,7 +928,7 @@ class fc
steady_bar_xterm = 6 steady_bar_xterm = 6
}; };
// linux console and framebuffer cursor style // Linux console and framebuffer cursor style
enum consoleCursorStyle enum consoleCursorStyle
{ {
default_cursor = 0, default_cursor = 0,

View File

@ -310,7 +310,7 @@ inline bool FListBox::unsetFocus()
{ return setFocus(false); } { return setFocus(false); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FListBox::isSelected(int index) const inline bool FListBox::isSelected (int index) const
{ return data[uInt(index-1)].selected; } { return data[uInt(index-1)].selected; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -653,7 +653,6 @@ void FMenu::onMouseMove (FMouseEvent* ev)
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = getStatusBar()->getMessage(); FString curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
if ( curMsg != msg ) if ( curMsg != msg )
{ {
getStatusBar()->setMessage(msg); getStatusBar()->setMessage(msg);

View File

@ -67,6 +67,23 @@ FObject::~FObject() // destructor
} }
// public methods of FObject // public methods of FObject
//----------------------------------------------------------------------
FObject* FObject::getChild (int index) const
{
index--;
if ( children_list.empty() )
return 0;
if ( index < 0 || index >= numOfChildren() )
return 0;
FObjectList::const_iterator iter;
iter = children_list.begin();
std::advance (iter, index);
return *iter;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FObject::isChild (FObject* obj) const bool FObject::isChild (FObject* obj) const
{ {

View File

@ -69,6 +69,7 @@ class FObject
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
FObject* getParent() const; FObject* getParent() const;
FObject* getChild (int) const;
FObjectList getChildren() const; FObjectList getChildren() const;
int numOfChildren() const; int numOfChildren() const;

View File

@ -196,6 +196,17 @@ FRect FRect::intersect (const FRect& r) const
return new_rect; return new_rect;
} }
//----------------------------------------------------------------------
FRect FRect::combined (const FRect& r) const
{
// Union: this r
FRect new_rect;
new_rect.X1 = std::min(X1, r.X1);
new_rect.Y1 = std::min(Y1, r.Y1);
new_rect.X2 = std::max(X2, r.X2);
new_rect.Y2 = std::max(Y2, r.Y2);
return new_rect;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FRect& FRect::operator = (const FRect& r) FRect& FRect::operator = (const FRect& r)
{ {

View File

@ -91,6 +91,7 @@ class FRect
bool contains (const FRect&) const; bool contains (const FRect&) const;
bool overlap (const FRect&) const; bool overlap (const FRect&) const;
FRect intersect (const FRect&) const; FRect intersect (const FRect&) const;
FRect combined (const FRect&) const;
private: private:
// Data Members // Data Members

View File

@ -736,6 +736,7 @@ inline FPoint FScrollView::getViewportCursorPos()
{ {
int x, y; int x, y;
FWidget* window = FWindow::getWindowWidget(this); FWidget* window = FWindow::getWindowWidget(this);
if ( window ) if ( window )
{ {
int widget_offsetX = getTermX() - window->getTermX(); int widget_offsetX = getTermX() - window->getTermX();

View File

@ -29,7 +29,7 @@ FToggleButton::FToggleButton (FWidget* parent)
{ {
setGroup( static_cast<FButtonGroup*>(parent) ); setGroup( static_cast<FButtonGroup*>(parent) );
if ( getGroup() ) if ( hasGroup() )
getGroup()->insert(this); // insert into button group getGroup()->insert(this); // insert into button group
} }
} }
@ -52,8 +52,8 @@ FToggleButton::FToggleButton (const FString& txt, FWidget* parent)
{ {
setGroup( static_cast<FButtonGroup*>(parent) ); setGroup( static_cast<FButtonGroup*>(parent) );
if ( getGroup() ) if ( hasGroup() )
getGroup()->insert( this ); // insert into button group getGroup()->insert(this); // insert into button group
} }
} }
@ -62,7 +62,7 @@ FToggleButton::~FToggleButton() // destructor
{ {
delAccelerator(); delAccelerator();
if ( getGroup() ) if ( hasGroup() )
getGroup()->remove(this); getGroup()->remove(this);
} }
@ -76,6 +76,11 @@ void FToggleButton::setGeometry (int x, int y, int w, int h, bool adjust)
if ( w < min_width ) if ( w < min_width )
w = min_width; w = min_width;
const FRect geometry(x, y, w, h);
if ( hasGroup() )
getGroup()->checkScrollSize(geometry);
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(x, y, w, h, adjust);
} }
@ -280,6 +285,15 @@ void FToggleButton::onMouseUp (FMouseEvent* ev)
processClick(); processClick();
} }
//----------------------------------------------------------------------
void FToggleButton::onWheel (FWheelEvent* ev)
{
if ( ! hasGroup() )
return;
getGroup()->onWheel(ev);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::onAccel (FAccelEvent* ev) void FToggleButton::onAccel (FAccelEvent* ev)
{ {
@ -340,7 +354,7 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
getStatusBar()->drawMessage(); getStatusBar()->drawMessage();
} }
if ( ! getGroup() ) if ( ! hasGroup() )
return; return;
if ( ! focus_inside_group && isRadioButton() ) if ( ! focus_inside_group && isRadioButton() )

View File

@ -84,6 +84,7 @@ class FToggleButton : public FWidget
// Event handlers // Event handlers
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onWheel (FWheelEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
@ -99,6 +100,7 @@ class FToggleButton : public FWidget
// Inquiries // Inquiries
bool isRadioButton() const; bool isRadioButton() const;
bool isCheckboxButton() const; bool isCheckboxButton() const;
bool hasGroup() const;
// Methods // Methods
virtual void draw(); virtual void draw();
@ -191,4 +193,8 @@ inline bool FToggleButton::isChecked()
inline FButtonGroup* FToggleButton::getGroup() const inline FButtonGroup* FToggleButton::getGroup() const
{ return button_group; } { return button_group; }
//----------------------------------------------------------------------
inline bool FToggleButton::hasGroup() const
{ return button_group; }
#endif // _FTOGGLEBUTTON_H #endif // _FTOGGLEBUTTON_H

View File

@ -41,6 +41,10 @@ FWindow::~FWindow() // destructor
if ( isAlwaysOnTop() ) if ( isAlwaysOnTop() )
deleteFromAlwaysOnTopList (this); deleteFromAlwaysOnTopList (this);
// unset the global active window
if ( this == FWindow::getActiveWindow() )
unsetActiveWindow();
delWindow (this); delWindow (this);
if ( ! fapp->isQuit() ) if ( ! fapp->isQuit() )
@ -151,6 +155,13 @@ bool FWindow::activateWindow (bool on)
return window_active = (on) ? true : false; return window_active = (on) ? true : false;
} }
//----------------------------------------------------------------------
void FWindow::unsetActiveWindow()
{
// unset the active FWindow object
FApplication::active_window = 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWindow::setResizeable (bool on) bool FWindow::setResizeable (bool on)
{ {

View File

@ -76,6 +76,7 @@ class FWindow : public FWidget
void setWindowFocusWidget (FWidget*); void setWindowFocusWidget (FWidget*);
bool activateWindow (bool); bool activateWindow (bool);
bool activateWindow(); bool activateWindow();
void unsetActiveWindow();
bool deactivateWindow(); bool deactivateWindow();
virtual bool setResizeable (bool); virtual bool setResizeable (bool);
virtual bool setResizeable(); virtual bool setResizeable();

View File

@ -9,6 +9,7 @@ noinst_PROGRAMS = \
hello \ hello \
dialog \ dialog \
input-dialog \ input-dialog \
choice \
opti-move \ opti-move \
string-operations \ string-operations \
mandelbrot \ mandelbrot \
@ -26,6 +27,7 @@ noinst_PROGRAMS = \
hello_SOURCES = hello.cpp hello_SOURCES = hello.cpp
dialog_SOURCES = dialog.cpp dialog_SOURCES = dialog.cpp
input_dialog_SOURCES = input-dialog.cpp input_dialog_SOURCES = input-dialog.cpp
choice_SOURCES = choice.cpp
opti_move_SOURCES = opti-move.cpp opti_move_SOURCES = opti-move.cpp
string_operations_SOURCES = string-operations.cpp string_operations_SOURCES = string-operations.cpp
mandelbrot_SOURCES = mandelbrot.cpp mandelbrot_SOURCES = mandelbrot.cpp

View File

@ -83,7 +83,7 @@ POST_UNINSTALL = :
build_triplet = @build@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \ noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \
opti-move$(EXEEXT) string-operations$(EXEEXT) \ choice$(EXEEXT) opti-move$(EXEEXT) string-operations$(EXEEXT) \
mandelbrot$(EXEEXT) calculator$(EXEEXT) watch$(EXEEXT) \ mandelbrot$(EXEEXT) calculator$(EXEEXT) watch$(EXEEXT) \
term-attributes$(EXEEXT) transparent$(EXEEXT) \ term-attributes$(EXEEXT) transparent$(EXEEXT) \
keyboard$(EXEEXT) timer$(EXEEXT) scrollview$(EXEEXT) \ keyboard$(EXEEXT) timer$(EXEEXT) scrollview$(EXEEXT) \
@ -110,6 +110,9 @@ AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent am__v_lt_0 = --silent
am__v_lt_1 = am__v_lt_1 =
am_choice_OBJECTS = choice.$(OBJEXT)
choice_OBJECTS = $(am_choice_OBJECTS)
choice_LDADD = $(LDADD)
am_dialog_OBJECTS = dialog.$(OBJEXT) am_dialog_OBJECTS = dialog.$(OBJEXT)
dialog_OBJECTS = $(am_dialog_OBJECTS) dialog_OBJECTS = $(am_dialog_OBJECTS)
dialog_LDADD = $(LDADD) dialog_LDADD = $(LDADD)
@ -189,20 +192,20 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 = am__v_CXXLD_1 =
SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) $(hello_SOURCES) \ SOURCES = $(calculator_SOURCES) $(choice_SOURCES) $(dialog_SOURCES) \
$(input_dialog_SOURCES) $(keyboard_SOURCES) \
$(mandelbrot_SOURCES) $(menu_SOURCES) $(opti_move_SOURCES) \
$(scrollview_SOURCES) $(string_operations_SOURCES) \
$(term_attributes_SOURCES) $(timer_SOURCES) \
$(transparent_SOURCES) $(ui_SOURCES) $(watch_SOURCES) \
$(windows_SOURCES)
DIST_SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) \
$(hello_SOURCES) $(input_dialog_SOURCES) $(keyboard_SOURCES) \ $(hello_SOURCES) $(input_dialog_SOURCES) $(keyboard_SOURCES) \
$(mandelbrot_SOURCES) $(menu_SOURCES) $(opti_move_SOURCES) \ $(mandelbrot_SOURCES) $(menu_SOURCES) $(opti_move_SOURCES) \
$(scrollview_SOURCES) $(string_operations_SOURCES) \ $(scrollview_SOURCES) $(string_operations_SOURCES) \
$(term_attributes_SOURCES) $(timer_SOURCES) \ $(term_attributes_SOURCES) $(timer_SOURCES) \
$(transparent_SOURCES) $(ui_SOURCES) $(watch_SOURCES) \ $(transparent_SOURCES) $(ui_SOURCES) $(watch_SOURCES) \
$(windows_SOURCES) $(windows_SOURCES)
DIST_SOURCES = $(calculator_SOURCES) $(choice_SOURCES) \
$(dialog_SOURCES) $(hello_SOURCES) $(input_dialog_SOURCES) \
$(keyboard_SOURCES) $(mandelbrot_SOURCES) $(menu_SOURCES) \
$(opti_move_SOURCES) $(scrollview_SOURCES) \
$(string_operations_SOURCES) $(term_attributes_SOURCES) \
$(timer_SOURCES) $(transparent_SOURCES) $(ui_SOURCES) \
$(watch_SOURCES) $(windows_SOURCES)
am__can_run_installinfo = \ am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \ case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \ n|no|NO) false;; \
@ -354,6 +357,7 @@ AM_CPPFLAGS = -Wall -Werror -I$(top_srcdir)/src
hello_SOURCES = hello.cpp hello_SOURCES = hello.cpp
dialog_SOURCES = dialog.cpp dialog_SOURCES = dialog.cpp
input_dialog_SOURCES = input-dialog.cpp input_dialog_SOURCES = input-dialog.cpp
choice_SOURCES = choice.cpp
opti_move_SOURCES = opti-move.cpp opti_move_SOURCES = opti-move.cpp
string_operations_SOURCES = string-operations.cpp string_operations_SOURCES = string-operations.cpp
mandelbrot_SOURCES = mandelbrot.cpp mandelbrot_SOURCES = mandelbrot.cpp
@ -415,6 +419,10 @@ calculator$(EXEEXT): $(calculator_OBJECTS) $(calculator_DEPENDENCIES) $(EXTRA_ca
@rm -f calculator$(EXEEXT) @rm -f calculator$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(calculator_OBJECTS) $(calculator_LDADD) $(LIBS) $(AM_V_CXXLD)$(CXXLINK) $(calculator_OBJECTS) $(calculator_LDADD) $(LIBS)
choice$(EXEEXT): $(choice_OBJECTS) $(choice_DEPENDENCIES) $(EXTRA_choice_DEPENDENCIES)
@rm -f choice$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(choice_OBJECTS) $(choice_LDADD) $(LIBS)
dialog$(EXEEXT): $(dialog_OBJECTS) $(dialog_DEPENDENCIES) $(EXTRA_dialog_DEPENDENCIES) dialog$(EXEEXT): $(dialog_OBJECTS) $(dialog_DEPENDENCIES) $(EXTRA_dialog_DEPENDENCIES)
@rm -f dialog$(EXEEXT) @rm -f dialog$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(dialog_OBJECTS) $(dialog_LDADD) $(LIBS) $(AM_V_CXXLD)$(CXXLINK) $(dialog_OBJECTS) $(dialog_LDADD) $(LIBS)
@ -482,6 +490,7 @@ distclean-compile:
-rm -f *.tab.c -rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/calculator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/calculator.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/choice.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hello.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hello.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/input-dialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/input-dialog.Po@am__quote@

141
test/choice.cpp Normal file
View File

@ -0,0 +1,141 @@
// File: os-choice.cpp
#include "fapp.h"
#include "fbutton.h"
#include "fbuttongroup.h"
#include "fdialog.h"
#include "fradiobutton.h"
#include "ftooltip.h"
// function prototypes
void cb_quit (FWidget*, FWidget::data_ptr);
//----------------------------------------------------------------------
// callback functions
//----------------------------------------------------------------------
void cb_quit (FWidget*, FWidget::data_ptr data)
{
FDialog* dlg = static_cast<FDialog*>(data);
dlg->close();
}
//----------------------------------------------------------------------
// main part
//----------------------------------------------------------------------
int main (int argc, char* argv[])
{
int x,y,w,h;
FString label_text = "no OS";
// Create the application object
FApplication app(argc, argv);
// Create a simple dialog box
FDialog* dgl = new FDialog(&app);
dgl->setModal();
dgl->setText ("UNIX select");
w = 20;
h = 13;
x = (app.getColumnNumber() - w) / 2;
y = (app.getLineNumber() - h) / 2;
dgl->setGeometry (x, y, w, h);
dgl->setShadow();
// Create another button group
FButtonGroup* checkButtonGroup = new FButtonGroup("choice", dgl);
checkButtonGroup->setGeometry (2, 1, 16, 7);
// Create radio buttons
FRadioButton* os1 = new FRadioButton("AIX", checkButtonGroup);
FRadioButton* os2 = new FRadioButton("Cygwin", checkButtonGroup);
FRadioButton* os3 = new FRadioButton("FreeBSD", checkButtonGroup);
FRadioButton* os4 = new FRadioButton("HP-UX", checkButtonGroup);
FRadioButton* os5 = new FRadioButton("Linux", checkButtonGroup);
FRadioButton* os6 = new FRadioButton("Mac OS X", checkButtonGroup);
FRadioButton* os7 = new FRadioButton("NetBSD", checkButtonGroup);
FRadioButton* os8 = new FRadioButton("OpenBSD", checkButtonGroup);
FRadioButton* os9 = new FRadioButton("Solaris", checkButtonGroup);
// Set the radio button geometry
// => checkButtonGroup->setScrollSize(...) is not required
// because a FButtonGroup is self-adjusting
os1->setGeometry(1, 1, 12, 1);
os2->setGeometry(1, 2, 12, 1);
os3->setGeometry(1, 3, 12, 1);
os4->setGeometry(1, 4, 12, 1);
os5->setGeometry(1, 5, 12, 1);
os6->setGeometry(1, 6, 12, 1);
os7->setGeometry(1, 7, 12, 1);
os8->setGeometry(1, 8, 12, 1);
os9->setGeometry(1, 9, 12, 1);
#if defined(_AIX)
os1->setChecked();
os1->setFocus();
#elif defined(__CYGWIN__)
os2->setChecked();
os2->setFocus();
#elif defined(__FreeBSD__)
os3->setChecked();
os3->setFocus();
#elif defined(__hpux)
os4->setChecked();
os4->setFocus();
#elif defined(__linux__)
os5->setChecked();
os5->setFocus();
#elif defined(__APPLE__) && defined(__MACH__)
os6->setChecked();
os6->setFocus();
#elif defined(__NetBSD__)
os7->setChecked();
os7->setFocus();
#elif defined(__OpenBSD__)
os8->setChecked();
os8->setFocus();
#elif defined(__sun) && defined(__SVR4)
os9->setChecked();
os9->setFocus();
#endif
// Scroll to the focused child element
FFocusEvent cfi (fc::ChildFocusIn_Event);
FApplication::sendEvent(checkButtonGroup, &cfi);
// Create a OK button
FButton* ok = new FButton("&OK", dgl);
ok->setGeometry (10, 9, 8, 1);
// Connect the button signal "clicked" with the callback function
ok->addCallback
(
"clicked",
_FUNCTION_CALLBACK (&cb_quit),
dgl
);
// Show the dialog
dgl->show();
// Get the checked radio button text
for (int n=1; n <= int(checkButtonGroup->getCount()); n++)
{
if ( checkButtonGroup->isChecked(n) )
{
label_text = checkButtonGroup->getButton(n)->getText();
break;
}
}
// Hide and destroy the dialog object
delete dgl;
// Create and show tooltip for two seconds
FToolTip* tooltip = new FToolTip(&app);
tooltip->setText ("You have chosen " + label_text);
tooltip->show();
sleep(2);
delete tooltip;
}

View File

@ -79,8 +79,8 @@ int main (int argc, char* argv[])
// Create radio buttons // Create radio buttons
FRadioButton* male = new FRadioButton("&Male", radioButtonGroup); FRadioButton* male = new FRadioButton("&Male", radioButtonGroup);
FRadioButton* female = new FRadioButton("&Female", radioButtonGroup); FRadioButton* female = new FRadioButton("&Female", radioButtonGroup);
male->setGeometry(1, 1, 7, 1); male->setGeometry(1, 1, 8, 1);
female->setGeometry(1, 2, 7, 1); female->setGeometry(1, 2, 10, 1);
// Create another button group // Create another button group
FButtonGroup* checkButtonGroup = new FButtonGroup("&Data options", &dgl); FButtonGroup* checkButtonGroup = new FButtonGroup("&Data options", &dgl);
@ -89,8 +89,8 @@ int main (int argc, char* argv[])
// Create checkbox buttons // Create checkbox buttons
FCheckBox* check1 = new FCheckBox("Save data", checkButtonGroup); FCheckBox* check1 = new FCheckBox("Save data", checkButtonGroup);
FCheckBox* check2 = new FCheckBox("Encrypt data", checkButtonGroup); FCheckBox* check2 = new FCheckBox("Encrypt data", checkButtonGroup);
check1->setGeometry(1, 1, 7, 1); check1->setGeometry(1, 1, 13, 1);
check2->setGeometry(1, 2, 7, 1); check2->setGeometry(1, 2, 16, 1);
check2->setDisable(); check2->setDisable();
// Create a OK button // Create a OK button

View File

@ -452,11 +452,11 @@ MyDialog::MyDialog (FWidget* parent)
//radioButtonGroup->unsetBorder(); //radioButtonGroup->unsetBorder();
FRadioButton* radio1 = new FRadioButton ("E&nable", radioButtonGroup); FRadioButton* radio1 = new FRadioButton ("E&nable", radioButtonGroup);
radio1->setGeometry(1, 1, 7, 1); radio1->setGeometry(1, 1, 10, 1);
radio1->setStatusbarMessage ("Enable button Test"); radio1->setStatusbarMessage ("Enable button Test");
FRadioButton* radio2 = new FRadioButton (radioButtonGroup); FRadioButton* radio2 = new FRadioButton (radioButtonGroup);
radio2->setGeometry(1, 2, 7, 1); radio2->setGeometry(1, 2, 11, 1);
radio2->setText ("&Disable"); radio2->setText ("&Disable");
radio2->setStatusbarMessage ("Disable button Test"); radio2->setStatusbarMessage ("Disable button Test");
radio2->setChecked(); radio2->setChecked();
@ -467,11 +467,11 @@ MyDialog::MyDialog (FWidget* parent)
checkButtonGroup->setGeometry(3, 12, 14, 4); checkButtonGroup->setGeometry(3, 12, 14, 4);
FCheckBox* check1 = new FCheckBox ("&Bitmode", checkButtonGroup); FCheckBox* check1 = new FCheckBox ("&Bitmode", checkButtonGroup);
check1->setGeometry(1, 1, 7, 1); check1->setGeometry(1, 1, 11, 1);
check1->setNoUnderline(); check1->setNoUnderline();
FCheckBox* check2 = new FCheckBox ("&8-Bit", checkButtonGroup); FCheckBox* check2 = new FCheckBox ("&8-Bit", checkButtonGroup);
check2->setGeometry(1, 2, 7, 1); check2->setGeometry(1, 2, 9, 1);
check2->setChecked(); check2->setChecked();
check2->setNoUnderline(); check2->setNoUnderline();