"Fossies" - the Fresh Open Source Software Archive

Member "mapgenerator-1.1.2/src/maininterface.cpp" (26 Oct 2003, 4580 Bytes) of package /linux/www/old/mapgenerator-1.1.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "maininterface.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2                           maininterface.cpp  -  description
    3                              -------------------
    4     begin                : Fri Aug 10 2001
    5     copyright            : (C) 2001 by Gabriel Huber
    6     email                : Gabriel-Huber@gmx.de
    7  ***************************************************************************/
    8 
    9 /***************************************************************************
   10  *                                                                         *
   11  *   This program is free software; you can redistribute it and/or modify  *
   12  *   it under the terms of the GNU General Public License as published by  *
   13  *   the Free Software Foundation; either version 2 of the License, or     *
   14  *   (at your option) any later version.                                   *
   15  *                                                                         *
   16  ***************************************************************************/
   17 
   18 #include "maininterface.h"
   19 #include "circle.xpm"
   20 #include "square.xpm"
   21 #include "polygon.xpm"
   22 #include "selector.xpm"
   23 
   24 MainInterface::MainInterface():Fl_Window(470, 350, "MapGenerator"){
   25     make_window();
   26     Exit->callback(exit_cb,this);
   27     Open->callback(open_cb,this);
   28 }
   29 
   30 MainInterface::~MainInterface(){
   31 }
   32 
   33 void MainInterface::show(){
   34     this->Fl_Window::show();
   35 }
   36 
   37 void MainInterface::make_window(){
   38   Fl_Pixmap *pixmap_polygon=new Fl_Pixmap(polygon);
   39   Fl_Pixmap *pixmap_square=new Fl_Pixmap(square);
   40   Fl_Pixmap *pixmap_circle=new Fl_Pixmap(circle);
   41   Fl_Pixmap *pixmap_selector=new Fl_Pixmap(selector);
   42   this->begin();
   43     Fl_Group *Buttons=new Fl_Group(0,0,65,350);
   44     Open = new Fl_Button(5, 5, 55, 25, "Open");
   45     { Fl_Button* o = Save = new Fl_Button(5, 35, 55, 25, "Save");
   46       o->deactivate();
   47       o->callback(save_cb,this);
   48     }
   49     Exit = new Fl_Button(5, 95, 55, 25, "Exit");
   50     { Fl_Button* o = Close = new Fl_Button(5, 65, 55, 25, "Close");
   51       o->deactivate();
   52       o->callback(close_cb,this);
   53     }
   54     { Fl_Group* o = Selection = new Fl_Group(5,125, 50,175);
   55       o->labeltype(FL_NO_LABEL);
   56       { Fl_Button* o = Circle = new Fl_Button(10, 125, 40, 40);
   57         o->type(FL_RADIO_BUTTON);
   58         o->align(FL_ALIGN_INSIDE);
   59         o->callback(selection_cb,this);
   60         pixmap_circle->label(o);
   61       }
   62       { Fl_Button* o = Square = new Fl_Button(10, 170, 40, 40);
   63         o->type(FL_RADIO_BUTTON);
   64         o->align(FL_ALIGN_INSIDE);
   65         o->callback(selection_cb,this);
   66         pixmap_square->label(o);
   67       }
   68       { Fl_Button* o = Polygon = new Fl_Button(10, 215, 40, 40);
   69         o->type(FL_RADIO_BUTTON);
   70         o->align(FL_ALIGN_INSIDE);
   71         o->callback(selection_cb,this);
   72         pixmap_polygon->label(o);
   73       }
   74       {Fl_Button* o = Selector =new Fl_Button(10,260,40,40);
   75       o->type(FL_RADIO_BUTTON);
   76       o->align(FL_ALIGN_INSIDE);
   77       o->callback(selection_cb,this);
   78       pixmap_selector->label(o);
   79       }
   80       o->end();
   81       Fl_Group *resize=new Fl_Group(0,300,65,50);
   82       resize->end();
   83       Buttons->end();
   84       Buttons->resizable(resize);
   85       Image_box=new Image_scroll_box(65,5,400,340);
   86       Image_box->end();
   87     }
   88   this->end();
   89   this->resizable(Image_box);
   90 }
   91 
   92 void MainInterface::exit_cb(Fl_Widget*,void* o){
   93     ((MainInterface*)o)->exit_call();
   94 }
   95 
   96 void MainInterface::exit_call(){
   97     if(Close->active()){
   98         if(fl_ask("Do you want to save before closing?")) this->save_call();
   99     }
  100     exit(0);
  101 }
  102 
  103 void MainInterface::open_cb(Fl_Widget*,void* o){
  104     ((MainInterface*)o)->open_call();
  105 }
  106 
  107 void MainInterface::selection_cb(Fl_Widget*,void* o){
  108     ((MainInterface*)o)->selection_call();
  109 }
  110 
  111 void MainInterface::selection_call(){
  112     if(Circle->value()==1) Image_box->tool(objCircle);
  113     if(Square->value()==1) Image_box->tool(objSquare);
  114     if(Polygon->value()==1) Image_box->tool(objPolygon);
  115     if(Selector->value()==1) Image_box->tool(objSelector);
  116 }
  117 
  118 void MainInterface::close_cb(Fl_Widget*,void* o){
  119     ((MainInterface*)o)->close_call();
  120 }
  121 
  122 void MainInterface::close_call(){
  123     if(fl_ask("Do you want to save before closing?")) this->save_call();
  124     Image_box->del();
  125 }
  126 
  127 void MainInterface::open_call(){
  128     if(Close->active()){
  129         if(fl_ask("Do you want to save before closing?")) this->save_call();
  130     }
  131     Close->activate();
  132     Save->activate();
  133     Image_box->del();
  134     if(Image_box->open()==false){
  135         Image_box->del();
  136         Close->deactivate();
  137         Save->deactivate();
  138     }
  139 }
  140 
  141 void MainInterface::save_cb(Fl_Widget*,void* o){
  142     ((MainInterface*)o)->save_call();
  143 }
  144 
  145 void MainInterface::save_call(){
  146     Image_box->save();
  147 }