1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
[#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Browser.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Widget.H>
#include <FL/names.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <FL/Fl_Text_Editor.H>
#include <FL/Fl_Timer.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Round_Button.H>
#include <FL/Fl_Menu_Bar.H>
//Vanessa Wood 3 July 2012
//----------------------
Fl_Box* box1;
int radio;
static void cb_radio(Fl_Widget *b, void *d)
{
char msg[64];
radio=(int)d;
}
// exit function
void myexit(Fl_Widget*o) // borrowed from GetProgCounts
{
exit(0);
}
// change color function
void mystart(Fl_Widget*b)
{
if (box1->color() == FL_RED)
{
box1->color(FL_GREEN); //toggle
}
else
{
box1->color(FL_RED);//toggle
}
}
// Main
int main()
{
Fl_Window win(240, 300," logger");//240, 300
win.begin();
// change button color
//Create a button - x , y , width, height, label
box1 = new Fl_Box(FL_FLAT_BOX,25,15,20,20,"");
box1->color(FL_RED);
Fl_Box* led2 = new Fl_Box(FL_FLAT_BOX,25,45,20,20,"");//35,15,20,20
led2->color(FL_GREEN);
// radio buttons in window
Fl_Group* rb_group = new Fl_Group(20, 90, 200, 105);//40
rb_group->box(FL_UP_FRAME);
{
Fl_Round_Button* rb1 = new Fl_Round_Button(25, 95, 70, 30, "&HS GM LAN");
rb1->type(102);
rb1->down_box(FL_ROUND_DOWN_BOX);
}
{
Fl_Round_Button* rb2 = new Fl_Round_Button(25, 125, 70, 30, "&LS GM LAN");
rb2->type(102);
rb2->down_box(FL_ROUND_DOWN_BOX);
;
}
{
Fl_Round_Button* rb3 = new Fl_Round_Button(25, 155, 70, 30, "& Both");
rb3->type(102);
rb3->setonly();
}
rb_group->end();
// add start and exit button
Fl_Button *exitButton;
Fl_Button *startButton;
exitButton = new Fl_Button (120, 250, 100, 40, "Exit");
startButton = new Fl_Button (20, 250, 100, 40, "Start");
exitButton->callback(myexit);
startButton->callback(mystart); // button to change color of box
win.end();
win.show();
return Fl::run();
}
|