2019-10-23 13:32:13 +02:00
|
|
|
|
2019-10-26 16:39:25 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <Fl/Fl.H>
|
|
|
|
#include <FL/Fl_Box.H>
|
|
|
|
#include <FL/Fl_Window.H>
|
2019-10-28 22:14:42 +01:00
|
|
|
#include <FL/fl_draw.H>
|
|
|
|
|
2019-10-23 13:32:13 +02:00
|
|
|
|
|
|
|
|
2019-10-28 22:14:42 +01:00
|
|
|
#define window_height 600
|
|
|
|
#define window_width 800
|
|
|
|
|
2019-10-26 16:39:25 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* This class provides a view to copy the offscreen surface to */
|
2019-10-28 22:14:42 +01:00
|
|
|
|
|
|
|
int color_map[window_width][window_height];
|
2019-10-26 16:39:25 +02:00
|
|
|
class My_Window : public Fl_Window{
|
|
|
|
int x,y,button;
|
|
|
|
int handle(int e)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (e)
|
|
|
|
{
|
|
|
|
case FL_MOVE:
|
|
|
|
x = Fl::event_x();
|
|
|
|
y = Fl::event_y();
|
|
|
|
std::cout<<"Postion X:"<< x <<" Postion Y:"<< y <<std::endl;
|
|
|
|
return 1;
|
|
|
|
case FL_KEYBOARD:
|
|
|
|
button = Fl::event_button();
|
2019-10-28 22:14:42 +01:00
|
|
|
std::cout<<"Keyboard:"<< (unsigned short)button <<std::endl;
|
2019-10-26 16:39:25 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2019-10-28 22:14:42 +01:00
|
|
|
|
2019-10-26 16:39:25 +02:00
|
|
|
}
|
2019-10-28 22:14:42 +01:00
|
|
|
|
2019-10-26 16:39:25 +02:00
|
|
|
public:
|
|
|
|
My_Window(int x, int y, const char *l ) : Fl_Window(x,y,l){};
|
|
|
|
};
|
2019-10-23 13:32:13 +02:00
|
|
|
|
2019-10-28 22:14:42 +01:00
|
|
|
class Pixel : public Fl_Widget {
|
|
|
|
Fl_Color color;
|
|
|
|
void draw(){
|
|
|
|
fl_draw_box(static_cast<Fl_Boxtype>(1), x(), y(), w(), h(), color);
|
|
|
|
}
|
2019-10-26 16:39:25 +02:00
|
|
|
|
2019-10-28 22:14:42 +01:00
|
|
|
public:
|
|
|
|
Pixel(int x,int y,int w,int h,int RGB) :
|
|
|
|
Fl_Widget(x,y,w,h,0) {
|
|
|
|
this->color = fl_rgb_color((uchar)((RGB&0xff000000)>>24),(uchar)((RGB&0xff0000)>>16),(uchar)((RGB&0xff00)>>8));
|
|
|
|
}
|
|
|
|
};
|
2019-10-26 16:39:25 +02:00
|
|
|
|
2019-10-28 22:14:42 +01:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
for(int i=0;i<100;i++){
|
|
|
|
for (int j = 0; j < 100 ; j++) {
|
|
|
|
color_map[i][j]=0xff000000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
My_Window* window = new My_Window(window_width, window_height, "example");
|
2019-10-26 16:39:25 +02:00
|
|
|
window->begin();
|
2019-10-28 22:14:42 +01:00
|
|
|
for(int i=0;i<100;i++){
|
|
|
|
for (int j = 0; j < 100 ; j++) {
|
|
|
|
new Pixel(i,j,1,1,color_map[i][j]);
|
|
|
|
}
|
|
|
|
}
|
2019-10-26 16:39:25 +02:00
|
|
|
window->end();
|
|
|
|
window->show(argc,argv);
|
|
|
|
return Fl::run();
|
|
|
|
} // main
|