Hi everybody
I have a problem with writing with "Fl_Multiline_Output"
when i use a "message" function it does not work, i do not know why ???
also anybody have an idea about how i can use FL_aler FL_message
how can i use these if i have a specific conditions ???
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Multiline_Output.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Shared_Image.H>
#include <string.h>
#include <errno.h>
#include <FL/Fl_File_Chooser.H>
#include <FL/fl_message.H>
#include <FL/Fl_Input.H>
Fl_Box *b;
Fl_Input *input;
Fl_Window *w;
Fl_Shared_Image *img;
Fl_Button *button;
static char name[1024];
Fl_Multiline_Output *text_output;
void load_file(const char *n) {
if (img) {
img->release();
img = 0L;
}
if (fl_filename_isdir(n)) {
b->label("@fileopen"); // show a generic folder
b->labelsize(64);
b->labelcolor(FL_LIGHT2);
b->image(0);
b->redraw();
return;
}
img = Fl_Shared_Image::get(n);
if (!img) {
b->label("@filenew"); // show an empty document
b->labelsize(64);
b->labelcolor(FL_LIGHT2);
b->image(0);
b->redraw();
return;
}
if (img->w() > b->w() || img->h() > b->h()) {
Fl_Image *temp;
if (img->w() > img->h()) temp = img->copy(b->w(), b->h() * img->h() /
img->w());
else temp = img->copy(b->w() * img->w() / img->h(), b->h());
img->release();
img = (Fl_Shared_Image *)temp;
}
b->label(name);
b->labelsize(14);
b->labelcolor(FL_FOREGROUND_COLOR);
b->image(img);
b->redraw();
}
void file_cb(const char *n) {
if (!strcmp(name,n)) return;
load_file(n);
strcpy(name,n);
w->label(name);
}
void clear_text()
{
extern Fl_Multiline_Output *text_output;
text_output->value(" ");
}
/*====Message will write the history of all pressed commands=========*/
void message()
{
extern Fl_Multiline_Output *text_output;
extern Fl_Button *button;
extern void clear_text();
//here need to write that the robot sart--------------in the case of start
connection
if (button->value()==1){
printf("good Try");
text_output->value("Load start work \n\n Don't worry this is only a test ");
}
else
{
clear_text();
}
}
/*=============================================================*/
#if 1
#include <FL/fl_ask.H>
#include <stdlib.h>
void window_callback(Fl_Widget*, void*) {
if (!fl_ask("Are you sure you want to quit?")) return;
exit(0);
}
#endif
/*=======================test input ==============================*/
void callback(void *) {
float count=1.0;
printf("TICK\n");
Fl::add_timeout(count,callback);
}
void button_cb(Fl_Widget *,void *) {
fl_file_chooser_callback(file_cb);
fl_file_chooser("Image file?","*.{bm,bmp,gif,jpg,pbm,pgm,png,ppm,xbm,xpm}",
name);
fl_file_chooser_callback(0);
}
int dvisual = 0;
int arg(int, char **argv, int &i) {
if (argv[i][1] == '8') {dvisual = 1; i++; return 1;}
return 0;
}
int main(int argc, char **argv) {
int i = 1;
extern Fl_Multiline_Output *text_output;
fl_register_images();
Fl::args(argc,argv,i,arg);
int window_width = GetSystemMetrics(SM_CXFULLSCREEN); // this is the area
available for the window on the screen
int window_height = GetSystemMetrics(SM_CYFULLSCREEN);
int border_width = GetSystemMetrics(SM_CXSIZEFRAME);
int border_height = GetSystemMetrics(SM_CYSIZEFRAME);
printf("%d %d",window_width,border_width);
Fl_Window window(window_width-border_width,window_height-border_height); ::w
= &window;
Fl_Box b(10,45,380,380); ::b = &b;
b.box(FL_THIN_DOWN_BOX);
b.align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
text_output = new Fl_Multiline_Output(10,440,380,60);
extern Fl_Button *button;
button =new Fl_Button(150,5,100,30,"load");
button->value(0);
button->callback(button_cb);
if (!dvisual) Fl::visual(FL_RGB);
if (argv[1]) load_file(argv[1]);
extern Fl_Input *input;
input= new Fl_Input(60, 540, 380, 35, "Input:");
window.callback(window_callback);
window.resizable(window);
window.show(argc,argv);
Fl::add_timeout(1.0,callback);
return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk