Here's "my" code...
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_JPEG_Image.H>
#include <FL/fl_draw.H>
static Fl_Double_Window *main_win=(Fl_Double_Window *)0;
static Fl_Box *a_map=(Fl_Box *)0;
static Fl_Button *exit_bt=(Fl_Button *)0;
static Fl_Button *clear_bt=(Fl_Button *)0;
static Fl_JPEG_Image *map_background=(Fl_JPEG_Image *)0;
class C_MapView : public Fl_Scroll
{
protected:
void draw(void);
public:
int m_ShowCompass;
double m_NorthOffset;
int m_clear;
C_MapView(int X, int Y, int W, int H, const char *L=0) :
Fl_Scroll(X,Y,W,H,L) {
m_ShowCompass = 1;
m_NorthOffset = 0.0;
m_clear = 0;
}
};
void C_MapView::draw(void)
{
Fl_Scroll::draw();
if (m_ShowCompass)
{
fl_push_clip(x(), y(), w()-20, h()-20);
if(m_clear)
{
Fl_Color bg = this->color();
fl_color(bg);
fl_rectf(x(), y(), w()-20, h()-20);
}
fl_color(FL_DARK_GREEN);
fl_line_style(FL_SOLID, 3);
fl_push_matrix();
fl_translate(x()+100,y()+100);
fl_scale(1,-1);
fl_rotate(m_NorthOffset);
fl_begin_line();
fl_vertex(0,0);
fl_vertex(0,100);
fl_end_line();
fl_begin_line();
fl_vertex(-5,95);
fl_vertex(0,100);
fl_vertex(5,95);
fl_end_line();
fl_pop_matrix();
fl_line_style(0);
fl_pop_clip();
}
}
static C_MapView *scroll=(C_MapView *)0;
static void cb_exit_bt(Fl_Button*, void*) {
main_win->hide();
}
static void cb_clear_bt(Fl_Button*, void*) {
scroll->m_clear = clear_bt->value();
}
int main(int argc, char **argv)
{
map_background = new Fl_JPEG_Image("../Data/map_background.jpg");
main_win = new Fl_Double_Window(461, 425);
scroll = new C_MapView(25, 25, 350, 355);
scroll->type(7);
scroll->box(FL_THIN_DOWN_BOX);
scroll->color(FL_FOREGROUND_COLOR);
a_map = new Fl_Box(20, 20, 512, 512);
a_map->size(map_background->w(),map_background->h());
a_map->image(map_background);
scroll->end();
clear_bt = new Fl_Button(315, 385, 64, 25, "Clear");
clear_bt->callback((Fl_Callback*)cb_clear_bt);
clear_bt->type(FL_TOGGLE_BUTTON);
exit_bt = new Fl_Button(385, 385, 64, 25, "Quit");
exit_bt->callback((Fl_Callback*)cb_exit_bt);
main_win->end();
main_win->show(argc, argv);
return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk