Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

maped-mainscreen.h

Go to the documentation of this file.
00001 
00005 /*
00006     This file is part of Advanced Strategic Command; http://www.asc-hq.de
00007     Copyright (C) 1994-1999  Martin Bickel  and  Marc Schellenberger
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with this program; see the file COPYING. If not, write to the
00021     Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00022     Boston, MA  02111-1307  USA
00023 */
00024 
00025 
00026 #ifndef mapedmainscreenH
00027  #define mapedmainscreenH 
00028 
00029 #include "paradialog.h"
00030 #include "edselfnt.h"
00031 #include "graphics/surface.h"
00032 #include "widgets/dropdownselector.h"
00033 #include "mainscreenwidget.h"
00034 
00035 class Menu;
00036 class NewGuiHost;
00037 class MapDisplayPG;
00038 
00039 class SelectionItemWidget : public PG_Widget {
00040       const MapComponent* it;
00041       static const int labelHeight = 15;
00042    public:
00043       SelectionItemWidget( PG_Widget* parent, const PG_Rect& pos ) : PG_Widget( parent, pos, true ), it(NULL)
00044       {
00045       }
00046            
00047       void set( const MapComponent* item) { it = item; Redraw(true); };
00048    protected:
00049       void eventDraw (SDL_Surface *surface, const PG_Rect &rect) 
00050       {
00051          Surface s = Surface::Wrap( surface );
00052          s.Fill( s.GetPixelFormat().MapRGB( DI_Color( 0x73b16a ) ));
00053          if ( it ) {
00054             SPoint pos ( (Width() - it->displayWidth()) / 2, (Height() - it->displayHeight())/2 );
00055             it->display( s, pos );
00056         }    
00057       };
00058 
00059 };
00060 
00061 
00062    class ContextAction {
00063       public:
00064          virtual bool available( const MapCoordinate& pos ) = 0;
00065          virtual ASCString getText( const MapCoordinate& pos ) = 0;
00066          virtual int getActionID() = 0;
00067          virtual ~ContextAction() {};
00068    };
00069       
00070 class Maped_MainScreenWidget : public MainScreenWidget {
00071     PG_Window* vehicleSelector;
00072     PG_Window* buildingSelector;
00073     PG_Window* objectSelector;
00074     PG_Window* terrainSelector;
00075     PG_Window* mineSelector;
00076     DropDownSelector* weatherSelector;
00077     DropDownSelector* playerSelector;
00078     DropDownSelector* brushSelector;
00079     PG_Label* selectionName;
00080     PG_Label* selectionName2;
00081     PG_Label* coordinateDisplay;
00082     SelectionItemWidget* currentSelectionWidget;
00083     deallocating_vector<ContextAction*> contextActions;
00084     PG_PopupMenu* contextMenu;
00085 public:
00086     Maped_MainScreenWidget( PG_Application& application );
00087 
00088     bool clearSelection();
00089     bool selectVehicle();
00090     bool selectBuilding();
00091     bool selectObject();
00092     bool selectObjectList();
00093     bool selectTerrain();
00094     bool selectTerrainList();
00095     bool selectMine();
00096     void updateStatusBar();
00097 
00098     void addContextAction( ContextAction* contextAction );
00099    
00100 protected:
00101 
00102     bool clickOnMap( const MapCoordinate& field, const SPoint& pos, bool changed, int button, int prio);
00103    
00104     NewGuiHost* guiHost;
00105     Menu* menu;
00106     
00107     void brushChanged( int i );
00108     void selectionChanged( const MapComponent* item ); 
00109     bool eventKeyUp(const SDL_KeyboardEvent* key);
00110     bool eventKeyDown(const SDL_KeyboardEvent* key);
00111     void setupStatusBar();
00112     
00113     void playerChanged( int player );
00114 
00115     ASCString getBackgroundImageFilename() { return "mapeditor-background.png"; };
00116     
00117     bool eventMouseButtonDown (const SDL_MouseButtonEvent *button);
00118 
00119     ~Maped_MainScreenWidget() { };
00120    private:
00121       bool runContextAction  (PG_PopupMenu::MenuItem* menuItem );
00122 };
00123 
00125 extern void displaymessage2( const char* formatstring, ... );
00126 
00127 extern Maped_MainScreenWidget*  mainScreenWidget ;
00128 
00129 #endif
00130 

Generated on Tue Jun 24 01:27:45 2008 for Advanced Strategic Command by  doxygen 1.4.2