[Gcblue-commits] gcb_wx/include/graphics tcContainerGui.h,NONE,1.1 tcContainerItem.h,NONE,1.1 tcDrag
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-06-11 21:02:22
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5785/include/graphics Modified Files: tc3DWindow.h Added Files: tcContainerGui.h tcContainerItem.h tcDragStatus.h tcDraggedIconDisplay.h tcFlightportGui.h tcLauncherContainerItem.h tcPlatformGui.h tcStoresContainerItem.h tcStoresGui.h Log Message: Initial commit for drag and drop icon gui --- NEW FILE: tcStoresContainerItem.h --- /** ** @file tcStoresContainerItem.h */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TCSTORESCONTAINERITEM_H_ #define _TCSTORESCONTAINERITEM_H_ #if _MSC_VER > 1000 #pragma once #endif #include "tcContainerItem.h" #include <string> class tcStores; /** * Item for stores gui */ class tcStoresContainerItem : public tcContainerItem { public: tcStores* GetStores() const; void SetStores(tcStores* stores); tcStoresContainerItem(); virtual ~tcStoresContainerItem(); private: tcStores* parent; ///< stores object that holds this item }; #endif --- NEW FILE: tcPlatformGui.h --- /** ** @file tcPlatformGui.h */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TCPLATFORMGUI_H_ #define _TCPLATFORMGUI_H_ #if _MSC_VER > 1000 #pragma once #endif #include "tcContainerGui.h" #include <osg/ref_ptr> namespace osg { class Geometry; } namespace database { class tcDatabaseObject; }; using database::tcDatabaseObject; class tcPlatformObject; class tcFlightOpsObject; class tcLauncher; /** * GUI class for platform operations * Functions: * Open magazine and flightport guis * Support drag between launchers and magazines (load/unload launchers) */ class tcPlatformGui : public tcContainerGui { public: virtual void Draw(); //virtual void OnChar(wxKeyEvent& event); //virtual void OnEnterWindow(wxMouseEvent& event); //virtual void OnLButtonDown(wxMouseEvent& event); //virtual void OnLButtonUp(wxMouseEvent& event); //virtual void OnLeaveWindow(wxMouseEvent& event); //virtual void OnMouseMove(wxMouseEvent& event); virtual void OnRButtonDown(wxMouseEvent& event); tcPlatformGui(tcPlatformObject* obj, const wxPoint& pos, const wxString& configFile); virtual ~tcPlatformGui(); private: tcPlatformObject* platform; tcFlightOpsObject* flightOps; osg::ref_ptr<osg::Geometry> magazineIcon; osg::ref_ptr<osg::Geometry> flightPortIcon; size_t nLaunchers; ///< number of launchers (first idx = 0) size_t magazineIdx; ///< slot index of first magazine slot size_t nMagazines; ///< number of magazines size_t flightPortIdx; ///< slot index of first flightport size_t nFlightPorts; ///< number of flightports (normally 0 or 1) float slotSize; ///< dimension of (square) slot wxRealPoint launcherLoc; ///< upper-left of first launcher wxRealPoint launcherOffset; ///< (x, y) offset between launchers wxRealPoint magazineLoc; ///< upper-left of first magazine wxRealPoint magazineOffset; ///< (x, y) offset between magazines wxRealPoint flightPortLoc; ///< upper-left of flightport void AddOrUpdateLauncherItem(tcContainerSlot& slot, tcDatabaseObject* child, tcLauncher* launcher, unsigned int launcherIdx, unsigned int quantity); void HandleDrop(size_t slotIdx, tcContainerItem* item); void InitializeGui(); void OpenFlightPortGui(tcContainerItem* item); void OpenMagazineGui(unsigned int idx, tcContainerItem* item); void ReadGuiParameters(); void UpdateGui(); }; #endif --- NEW FILE: tcLauncherContainerItem.h --- /** ** @file tcStoresContainerItem.h */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TCLAUNCHERCONTAINERITEM_H_ #define _TCLAUNCHERCONTAINERITEM_H_ #if _MSC_VER > 1000 #pragma once #endif #include "tcContainerItem.h" #include <string> class tcLauncher; /** * Item for launcher on platform gui or dragged to stores (magazine) gui */ class tcLauncherContainerItem : public tcContainerItem { public: tcLauncher* GetLauncher() const; unsigned int GetLauncherIndex() const; void SetLauncher(tcLauncher* launcher, unsigned int idx); tcLauncherContainerItem(); virtual ~tcLauncherContainerItem(); private: tcLauncher* parent; ///< launcher object that holds this item unsigned int launcherIdx; ///< index of launcher on parent platform }; #endif --- NEW FILE: tcContainerGui.h --- /** ** @file tcContainerGui.h */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TCCONTAINERGUI_H_ #define _TCCONTAINERGUI_H_ #if _MSC_VER > 1000 #pragma once #endif #include "tcXmlWindow.h" #include "tcContainerItem.h" class tcContainerSlot { public: tcRect loc; ///< location of slot within gui window tcContainerItem* item; ///< 0 if slot is empty bool updated; bool isMouseOver; ///< true if mouse is over slot void ClearItem(); osg::Geometry* GetIcon(); tcContainerItem* GetItem() const; bool IsEmpty() const; bool IsMouseOver() const; bool IsUpdated() const; void SetItem(tcContainerItem* item_); void SetMouseOver(bool state); void SetUpdated(bool state); tcContainerSlot(); tcContainerSlot(const tcContainerSlot& src); ~tcContainerSlot(); }; /** * GUI class to drag and drop and do simple operations on iconified objects */ class tcContainerGui : public tcXmlWindow { public: void AddSlot(tcRect& loc); void ClearSlots(); size_t GetNumSlots() const; virtual void DestroyGui(); virtual void Draw(); //virtual void OnChar(wxKeyEvent& event); virtual void OnCloseCommand(wxCommandEvent& event); //virtual void OnEnterWindow(wxMouseEvent& event); virtual void OnLButtonDown(wxMouseEvent& event); virtual void OnLButtonUp(wxMouseEvent& event); virtual void OnLeaveWindow(wxMouseEvent& event); virtual void OnMouseMove(wxMouseEvent& event); //virtual void OnRButtonDown(wxMouseEvent& event); virtual tcContainerItem* GetItem(long id); tcContainerItem* GetParentItem() const; void SetParentItem(tcContainerItem* item); static void SetParent(tc3DWindow* win); tcContainerGui(const wxPoint& pos, const wxString& configFile, const wxString& name = "ContainerGui"); virtual ~tcContainerGui(); protected: std::vector<tcContainerSlot> slots; unsigned int drawCount; bool dragIsArmed; ///< true to start drag when mouse is moved size_t dragSlotIdx; ///< slot idx to drag if armed bool FinishDestroy(); virtual void HandleDrop(size_t slotIdx, tcContainerItem* item); private: bool destroy; ///< workaround to delay destruction of window to safe time tcContainerItem* parentItem; ///< item that was clicked to popup this gui (if applicable) static tc3DWindow* parent; DECLARE_EVENT_TABLE() }; #endif --- NEW FILE: tcStoresGui.h --- /** ** @file tcStoresGui.h */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TCSTORESGUI_H_ #define _TCSTORESGUI_H_ #if _MSC_VER > 1000 #pragma once #endif #include "tcContainerGui.h" #include "tcStoresContainerItem.h" class tcStores; /** * GUI class for stores operations */ class tcStoresGui : public tcContainerGui { public: virtual void Draw(); //virtual void OnChar(wxKeyEvent& event); //virtual void OnEnterWindow(wxMouseEvent& event); //virtual void OnLButtonDown(wxMouseEvent& event); //virtual void OnLButtonUp(wxMouseEvent& event); //virtual void OnLeaveWindow(wxMouseEvent& event); //virtual void OnMouseMove(wxMouseEvent& event); virtual void OnRButtonDown(wxMouseEvent& event); tcStoresGui(tcStores* obj, const wxPoint& pos, const wxString& configFile); virtual ~tcStoresGui(); private: tcStores* stores; float slotSize; ///< dimension of (square) slot wxRealPoint upperLeft; ///< upper-left of first slot float horizontalSpacing; float verticalSpacing; unsigned int rowSize; void AddOrUpdateItem(tcContainerSlot& slot, const std::string& itemName, unsigned int quantity); void HandleDrop(size_t slotIdx, tcContainerItem* item); void InitializeGui(); void ReadGuiParameters(); void UpdateGui(); }; #endif --- NEW FILE: tcContainerItem.h --- /** ** @file tcContainerItem.h */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TCCONTAINERITEM_H_ #define _TCCONTAINERITEM_H_ #if _MSC_VER > 1000 #pragma once #endif #include <osg/ref_ptr> #include <string> namespace osg { class Geometry; } class tcContainerGui; /** * Item for container gui */ class tcContainerItem { public: enum { NORMAL = 0, BLINK = 1, DRAGGING = 2 ///< item is being dragged by user }; osg::ref_ptr<osg::Geometry> icon; int drawState; int GetDrawState() const; tcContainerGui* GetGui() const; osg::Geometry* GetIcon(); long GetId() const; const std::string& GetItemName() const; unsigned int GetQuantity() const; bool IdMatches(long val) const; bool ItemGuiIsActive() const; void SetDrawState(int state); void SetGui(tcContainerGui* gui_); void SetIcon(osg::Geometry* icon_); void SetId(long val); void SetItemName(const std::string& s); void SetQuantity(unsigned int n); tcContainerItem(); virtual ~tcContainerItem(); protected: long id; ///< identifier for item std::string itemName; unsigned int quantity; ///< quantity associated with this item tcContainerGui* gui; ///< for items that pop up an associated gui to allow gui to be closed or moved }; #endif Index: tc3DWindow.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tc3DWindow.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tc3DWindow.h 1 Jun 2005 00:13:26 -0000 1.15 --- tc3DWindow.h 11 Jun 2005 21:01:43 -0000 1.16 *************** *** 87,91 **** --- 87,93 ---- osg::Geometry* CreatePieGeometry(float width, float height, float startAngle, float stopAngle, osg::Vec4& color, int fillMode); + static osg::Geometry* CreateTexturedSymbol(const char* imageName, float width); + virtual void Draw(); virtual void DrawChildren(); // virtual void DrawChildren(Gdiplus::Graphics *graphics); --- NEW FILE: tcFlightportGui.h --- /** ** @file tcFlightPortGui.h */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TCFLIGHTPORTGUI_H_ #define _TCFLIGHTPORTGUI_H_ #if _MSC_VER > 1000 #pragma once #endif #include "tcContainerGui.h" class tcGameObject; /** * Item for container gui */ class tcEntityContainerItem : public tcContainerItem { public: const std::string& GetDescription() const; tcGameObject* GetEntity() const; void SetDescription(const std::string& s); void SetDescription(const char* s); void SetEntity(tcGameObject* obj); tcEntityContainerItem(); virtual ~tcEntityContainerItem(); private: std::string description; tcGameObject* entity; }; class tcAirState; class tcFlightPort; /** * GUI class for flightport operations */ class tcFlightPortGui : public tcContainerGui { public: virtual void Draw(); //virtual void OnChar(wxKeyEvent& event); //virtual void OnEnterWindow(wxMouseEvent& event); //virtual void OnLButtonDown(wxMouseEvent& event); //virtual void OnLButtonUp(wxMouseEvent& event); //virtual void OnLeaveWindow(wxMouseEvent& event); //virtual void OnMouseMove(wxMouseEvent& event); virtual void OnRButtonDown(wxMouseEvent& event); tcFlightPortGui(tcFlightPort* obj, const wxPoint& pos, const wxString& configFile); virtual ~tcFlightPortGui(); protected: virtual void HandleDrop(size_t slotIdx, tcContainerItem* item); private: tcFlightPort* flightPort; size_t launchOffset; ///< slot index of first launch spot (normally 0) size_t readyOffset; ///< slot index of first ready spot size_t hangarOffset; ///< slot index of first hangar spot float slotSize; ///< dimension of (square) slot wxRealPoint launchLoc; ///< upper-left of first launch spot float launchHorizontalSpacing; wxRealPoint readyLoc; float readyHorizontalSpacing; wxRealPoint hangarLoc; float hangarHorizontalSpacing; float hangarVerticalSpacing; ///< spacing between rows unsigned int hangarRowSize; ///< number of hangar spots across void AddOrUpdateItem(tcContainerSlot& slot, tcAirState* airState); void CloseAllPlatformGuis(); void InitializeGui(); void OpenPlatformGui(tcContainerItem* item); void ReadGuiParameters(); void UpdateGui(); }; #endif --- NEW FILE: tcDraggedIconDisplay.h --- /** ** @file tcDraggedIconDisplay.h */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _DRAGGEDICONDISPLAY_H_ #define _DRAGGEDICONDISPLAY_H_ #if _MSC_VER > 1000 #pragma once #endif #include "wx/wx.h" #include "tc3DWindow.h" #include <osg/ref_ptr> namespace osg { class Geometry; } /** * Window class to draw icon behind mouse pointer * Parent should be the main game frame so that upper left corner of * this window is (0, 0) in screen coordinates. */ class tcDraggedIconDisplay : public tc3DWindow { public: void Draw(); osg::Geometry* GetIcon(); void SetIcon(osg::Geometry* icon_); tcDraggedIconDisplay(wxWindow *parent); virtual ~tcDraggedIconDisplay(); private: osg::ref_ptr<osg::Geometry> icon; ///< icon to draw }; #endif --- NEW FILE: tcDragStatus.h --- /** ** @file tcDragStatus.h */ /* Copyright (C) 2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _DRAGSTATUS_H_ #define _DRAGSTATUS_H_ #if _MSC_VER > 1000 #pragma once #endif #include <wx/wx.h> #include <osg/ref_ptr> class tcContainerGui; class tcContainerItem; namespace osg { class Geometry; } /** * Singleton class to support drag and drop of icons across multiple windows. * Acts as a global object for windows to interact with to get * mouse pointer status. */ class tcDragStatus { public: tcContainerItem* GetDraggedItem() const; osg::Geometry* GetIcon(); unsigned int GetQuantity() const; bool IsDragging() const; ///< true if drag is in progress bool IsDraggingItem(tcContainerItem* item) const; void SetIcon(osg::Geometry* icon_); void SetQuantity(unsigned int n); void StartDrag(tcContainerGui* gui, tcContainerItem* item); void StopDrag(); static tcDragStatus* Get(); private: tcContainerGui* itemGui; long itemId; ///< 0 for none unsigned int quantity; ///< if > 0, then draw quantity label while dragging osg::ref_ptr<osg::Geometry> icon; tcDragStatus(); ~tcDragStatus(); }; #endif |