fltk/test/input_choice.cxx
Albrecht Schlosser f09e17c3c5 Remove $Id$ tags, update URL's, and more
- remove obsolete svn '$Id$' tags from all source files
- update .fl files and generated files accordingly
- replace 'http://www.fltk.org' URL's with 'https://...'
- replace bug report URL 'str.php' with 'bugs.php'
- remove trailing whitespace
- fix other whitespace errors flagged by Git
- add and/or fix missing or wrong standard headers
- convert tabs to spaces in all source files

The only relevant code changes are in the fluid/ folder where
some .fl files and other source files were used to generate
the '$Id' headers and footers.
2020-07-06 20:28:20 +02:00

64 lines
1.6 KiB
C++

//
// Test program for Fl_Input_Choice
//
// Copyright 1998-2010 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
#include <stdio.h>
#include <FL/Fl_Button.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Input_Choice.H>
#include <FL/Fl_Simple_Terminal.H>
#define TERMINAL_HEIGHT 120
// Globals
Fl_Simple_Terminal *G_tty = 0;
void buttcb(Fl_Widget*,void*data) {
Fl_Input_Choice *in=(Fl_Input_Choice *)data;
static int flag = 1;
flag ^= 1;
if ( flag ) in->activate();
else in->deactivate();
if (in->changed()) {
G_tty->printf("Callback: changed() is set\n");
in->clear_changed();
}
}
void input_choice_cb(Fl_Widget*,void*data) {
Fl_Input_Choice *in=(Fl_Input_Choice *)data;
G_tty->printf("Value='%s'\n", (const char*)in->value());
}
int main(int argc, char **argv) {
Fl_Double_Window win(300, 200+TERMINAL_HEIGHT);
G_tty = new Fl_Simple_Terminal(0,200,win.w(),TERMINAL_HEIGHT);
Fl_Input_Choice in(40,40,100,28,"Test");
in.callback(input_choice_cb, (void*)&in);
in.add("one");
in.add("two");
in.add("three");
in.value(1);
Fl_Button onoff(40,150,200,28,"Activate/Deactivate");
onoff.callback(buttcb, (void*)&in);
win.end();
win.resizable(win);
win.show(argc, argv);
return Fl::run();
}