Add an input field example

This commit is contained in:
Markus Gans 2015-05-24 19:15:03 +02:00
parent 1d940dda14
commit 475f1011de
11 changed files with 200 additions and 34 deletions

View File

@ -1,3 +1,6 @@
2015-24-05 Markus Gans <guru.mail@muenster.de>
* Bug fix in FLineEdit (ypos from the label)
2015-15-05 Markus Gans <guru.mail@muenster.de>
* Remove never read value from code
* Add the possibility to use exec() from FMessageBox

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -225,7 +225,7 @@ void FLineEdit::adjustLabel()
label->setGeometry(xpos, ypos-1, label_length, 1);
break;
case label_left:
label->setGeometry(xpos-label_length, ypos-1, label_length, 1);
label->setGeometry(xpos-label_length, ypos, label_length, 1);
break;
}
}

View File

@ -201,8 +201,8 @@ void FWidget::setColorTheme()
wc.label_ellipsis_fg = fc::DarkGray;
wc.inputfield_active_focus_fg = fc::White;
wc.inputfield_active_focus_bg = fc::Cyan;
wc.inputfield_active_fg = fc::LightGray;
wc.inputfield_active_bg = fc::Cyan;
wc.inputfield_active_fg = fc::Black;
wc.inputfield_active_bg = fc::LightGray;
wc.inputfield_inactive_fg = fc::DarkGray;
wc.inputfield_inactive_bg = fc::LightGray;
wc.toggle_button_active_focus_fg = fc::White;

View File

@ -8,12 +8,14 @@ AM_CPPFLAGS = -Wall -Werror -I$(top_srcdir)/src
noinst_PROGRAMS = \
hello \
dialog \
input-dialog \
fstring \
timer \
ui
hello_SOURCES = hello.cpp
dialog_SOURCES = dialog.cpp
input_dialog_SOURCES = input-dialog.cpp
fstring_SOURCES = fstring.cpp
timer_SOURCES = timer.cpp
ui_SOURCES = ui.cpp

View File

@ -12,10 +12,13 @@ MAKEFILE = -f Makefile.clang
LDFLAGS = -L../src -lfinal
INCLUDES = -I../src
RM = rm -f
PROGS = ui fstring timer
OBJS = ui.o
OBJS2 = fstring.o
OBJS3 = timer.o
PROGS = hello dialog input-dialog fstring timer ui
OBJS1 = hello.o
OBJS2 = dialog.o
OBJS3 = input-dialog.o
OBJS4 = fstring.o
OBJS5 = timer.o
OBJS6 = ui.o
ifdef DEBUG
OPTIMIZE = -O0
@ -30,16 +33,25 @@ endif
.cpp.o:
$(CXX) -c $(CCXFLAGS) $(INCLUDES) -o $@ $<
all: dep ui fstring timer
all: dep $(PROGS)
ui: $(OBJS)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o ui $(OBJS)
hello: $(OBJS1)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o hello $(OBJS1)
fstring: $(OBJS2)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o fstring $(OBJS2)
dialog: $(OBJS2)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o dialog $(OBJS2)
timer: $(OBJS3)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o timer $(OBJS3)
input-dialog: $(OBJS3)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o input-dialog $(OBJS3)
fstring: $(OBJS4)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o fstring $(OBJS4)
timer: $(OBJS5)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o timer $(OBJS5)
ui: $(OBJS6)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o ui $(OBJS6)
debug:
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -W -Wall -Weverything -Wpadded -pedantic"
@ -49,7 +61,7 @@ profile:
.PHONY: clean dep
clean:
$(RM) $(PROGS) $(OBJS) $(OBJS2) $(OBJS3) .depend *.gch *.plist *~
$(RM) $(PROGS) $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) .depend *.gch *.plist *~
dep:
$(CXX) -MM $(INCLUDES) *.cpp >.depend

View File

@ -12,11 +12,13 @@ MAKEFILE = -f Makefile.gcc
LDFLAGS = -L../src -lfinal
INCLUDES = -I../src
RM = rm -f
PROGS = ui fstring timer
OBJS0 = hello.o
OBJS1 = ui.o
OBJS2 = fstring.o
OBJS3 = timer.o
PROGS = hello dialog input-dialog fstring timer ui
OBJS1 = hello.o
OBJS2 = dialog.o
OBJS3 = input-dialog.o
OBJS4 = fstring.o
OBJS5 = timer.o
OBJS6 = ui.o
ifdef DEBUG
OPTIMIZE = -O0
@ -31,19 +33,25 @@ endif
.cpp.o:
$(CXX) -c $(CCXFLAGS) $(INCLUDES) -o $@ $<
all: dep hello ui fstring timer
all: dep $(PROGS)
hello: $(OBJS0)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o hello $(OBJS0)
hello: $(OBJS1)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o hello $(OBJS1)
ui: $(OBJS1)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o ui $(OBJS1)
dialog: $(OBJS2)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o dialog $(OBJS2)
fstring: $(OBJS2)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o fstring $(OBJS2)
input-dialog: $(OBJS3)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o input-dialog $(OBJS3)
timer: $(OBJS3)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o timer $(OBJS3)
fstring: $(OBJS4)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o fstring $(OBJS4)
timer: $(OBJS5)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o timer $(OBJS5)
ui: $(OBJS6)
$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o ui $(OBJS6)
debug:
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -W -Wall -pedantic"
@ -53,7 +61,7 @@ profile:
.PHONY: clean dep
clean:
$(RM) $(PROGS) $(OBJS0) $(OBJS1) $(OBJS2) $(OBJS3) .depend *~
$(RM) $(PROGS) $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) .depend *~
dep:
$(CXX) -MM $(INCLUDES) *.cpp >.depend

View File

@ -82,8 +82,8 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) fstring$(EXEEXT) \
timer$(EXEEXT) ui$(EXEEXT)
noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \
fstring$(EXEEXT) timer$(EXEEXT) ui$(EXEEXT)
subdir = test
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp
@ -111,6 +111,9 @@ fstring_LDADD = $(LDADD)
am_hello_OBJECTS = hello.$(OBJEXT)
hello_OBJECTS = $(am_hello_OBJECTS)
hello_LDADD = $(LDADD)
am_input_dialog_OBJECTS = input-dialog.$(OBJEXT)
input_dialog_OBJECTS = $(am_input_dialog_OBJECTS)
input_dialog_LDADD = $(LDADD)
am_timer_OBJECTS = timer.$(OBJEXT)
timer_OBJECTS = $(am_timer_OBJECTS)
timer_LDADD = $(LDADD)
@ -152,9 +155,9 @@ am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
SOURCES = $(dialog_SOURCES) $(fstring_SOURCES) $(hello_SOURCES) \
$(timer_SOURCES) $(ui_SOURCES)
$(input_dialog_SOURCES) $(timer_SOURCES) $(ui_SOURCES)
DIST_SOURCES = $(dialog_SOURCES) $(fstring_SOURCES) $(hello_SOURCES) \
$(timer_SOURCES) $(ui_SOURCES)
$(input_dialog_SOURCES) $(timer_SOURCES) $(ui_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -305,6 +308,7 @@ AM_LDFLAGS = -L$(top_builddir)/src/.libs -lfinal
AM_CPPFLAGS = -Wall -Werror -I$(top_srcdir)/src
hello_SOURCES = hello.cpp
dialog_SOURCES = dialog.cpp
input_dialog_SOURCES = input-dialog.cpp
fstring_SOURCES = fstring.cpp
timer_SOURCES = timer.cpp
ui_SOURCES = ui.cpp
@ -364,6 +368,10 @@ hello$(EXEEXT): $(hello_OBJECTS) $(hello_DEPENDENCIES) $(EXTRA_hello_DEPENDENCIE
@rm -f hello$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(hello_OBJECTS) $(hello_LDADD) $(LIBS)
input-dialog$(EXEEXT): $(input_dialog_OBJECTS) $(input_dialog_DEPENDENCIES) $(EXTRA_input_dialog_DEPENDENCIES)
@rm -f input-dialog$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(input_dialog_OBJECTS) $(input_dialog_LDADD) $(LIBS)
timer$(EXEEXT): $(timer_OBJECTS) $(timer_DEPENDENCIES) $(EXTRA_timer_DEPENDENCIES)
@rm -f timer$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(timer_OBJECTS) $(timer_LDADD) $(LIBS)
@ -381,6 +389,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstring.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)/timer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@

View File

@ -5,6 +5,9 @@
#include "fdialog.h"
#include "flabel.h"
// function prototype
void cb_quit (FWidget*, void* data_ptr);
//----------------------------------------------------------------------
// callback function
//----------------------------------------------------------------------

129
test/input-dialog.cpp Normal file
View File

@ -0,0 +1,129 @@
// dialog.cpp
#include "fapp.h"
#include "fbutton.h"
#include "fbuttongroup.h"
#include "fcheckbox.h"
#include "fdialog.h"
#include "flineedit.h"
#include "fradiobutton.h"
// function prototypes
void cb_quit (FWidget*, void* data_ptr);
void cb_publish (FWidget* widget, void* data_ptr);
//----------------------------------------------------------------------
// callback functions
//----------------------------------------------------------------------
void cb_quit (FWidget*, void* data_ptr)
{
FApplication* app = static_cast<FApplication*>(data_ptr);
app->quit();
}
void cb_publish (FWidget* widget, void* data_ptr)
{
FCheckBox* cbox1 = static_cast<FCheckBox*>(widget);
FCheckBox* cbox2 = static_cast<FCheckBox*>(data_ptr);
if ( cbox1->isChecked() )
cbox2->setEnable();
else
{
cbox2->unsetChecked();
cbox2->setDisable();
}
cbox2->redraw();
}
//----------------------------------------------------------------------
// main part
//----------------------------------------------------------------------
int main (int argc, char* argv[])
{
// Create the application object
FApplication app(argc, argv);
// Create a simple dialog box
FDialog dgl(&app);
dgl.setText ("Data input");
dgl.setGeometry (4, 3, 37, 22);
dgl.setShadow();
// Create input fields
FLineEdit* name_field = new FLineEdit(&dgl);
FLineEdit* email_field = new FLineEdit(&dgl);
FLineEdit* org_field = new FLineEdit(&dgl);
FLineEdit* city_field = new FLineEdit(&dgl);
FLineEdit* st_field = new FLineEdit(&dgl);
FLineEdit* c_field = new FLineEdit(&dgl);
name_field->setLabelText(L"&Name:");
email_field->setLabelText(L"&Email:");
org_field->setLabelText(L"Or&ganization:");
city_field->setLabelText(L"&City:");
st_field->setLabelText(L"&State:");
c_field->setLabelText(L"&Country:");
name_field->setGeometry(15, 1, 19, 1);
email_field->setGeometry(15, 3, 19, 1);
org_field->setGeometry(15, 5, 19, 1);
city_field->setGeometry(15, 7, 19, 1);
st_field->setGeometry(15, 9, 19, 1);
c_field->setGeometry(15, 11, 4, 1);
name_field->setShadow();
email_field->setShadow();
org_field->setShadow();
city_field->setShadow();
st_field->setShadow();
c_field->setShadow();
name_field->setFocus();
// Create the button group
FButtonGroup* radioButtonGroup = new FButtonGroup("Sex", &dgl);
radioButtonGroup->setGeometry(2, 13, 13, 4);
// Create radio buttons
FRadioButton* male = new FRadioButton("&Male", radioButtonGroup);
FRadioButton* female = new FRadioButton("&Female",radioButtonGroup);
male->setGeometry(1, 1, 7, 1);
female->setGeometry(1, 2, 7, 1);
// Create another button group
FButtonGroup* checkButtonGroup = new FButtonGroup("&Data options", &dgl);
checkButtonGroup->setGeometry(16, 13, 19, 4);
// Create checkbox buttons
FCheckBox* check1 = new FCheckBox("Save data", checkButtonGroup);
FCheckBox* check2 = new FCheckBox("Encrypt data", checkButtonGroup);
check1->setGeometry(1, 1, 7, 1);
check2->setGeometry(1, 2, 7, 1);
check2->setDisable();
// Create a OK button
FButton btn("&OK", &dgl);
btn.setGeometry (24, 18, 10, 1);
btn.setShadow();
// Connect checkbox signal "clicked" with a callback function
check1->addCallback
(
"clicked",
reinterpret_cast<FWidget::FCallback>(&cb_publish),
check2
);
// Connect the button signal "clicked" with the callback function
btn.addCallback
(
"clicked",
reinterpret_cast<FWidget::FCallback>(&cb_quit),
&app
);
app.setMainWidget(&dgl);
dgl.show();
return app.exec();
}