[Gcblue-commits] gcb_wx/include/graphics tcWindow.h,NONE,1.1 tcwindow.h,1.19,NONE
Status: Alpha
Brought to you by:
ddcforge
|
From: Xavi <xr...@us...> - 2004-04-04 21:34:26
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19767 Added Files: tcWindow.h Removed Files: tcwindow.h Log Message: + changed lowercase tcwindow.h to tcWindow.h, according to the includes from other files and the name of the class --- NEW FILE: tcWindow.h --- /* ** tcWindow.h ** ** Copyright (C) 2003 Dewitt "Cole" 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 */ #if !defined _TCWINDOW_H_ #define _TCWINDOW_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "wx/wx.h" #include "wx/msw/private.h" // for MS Windows specific definitions #include "gdiplus.h" #include <vector> class tcGraphicsEngine; // forward declaration for better encapsulation class tc2DGraphicsSurface; #define IMAGE_PATH "images\\" /** * Window class for drawing to a tc2DGraphicsSurface (bitmap) * with GDI+. */ class tcWindow : public wxWindow { public: bool mbActive; Gdiplus::RectF mrectDisplay; void AddChild(tcWindow* child); bool IsBackgroundLoaded() {return mpiBackground != NULL;} virtual int Draw(); virtual void Draw(Gdiplus::Graphics *graphics); virtual void DrawChildren(Gdiplus::Graphics *graphics); virtual int DrawTest(); void DrawBackground(Gdiplus::Graphics *apGraphics); void DrawBorder(void); void DrawText(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, float afX, float afY); void DrawText(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, float afX, float afY, Gdiplus::RectF& r); // returns bounding box in r void DrawTextCentered(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, float afX, float afY); void DrawTextCenteredHV(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, float x, float y); void DrawTextInRect(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, Gdiplus::RectF& rect); void DrawTextInRectWrap(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, Gdiplus::RectF& rect); void MeasureText(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, const char* azstr, Gdiplus::SizeF& size); void Erase(void); void EraseOpaque(void); virtual void Freeze(); wxBitmap* GetBitmap(); bool IsSurfaceModified(); void LoadBackgroundImage(char *azFileName); Gdiplus::Image* LoadImage(const char *fileName); void MoveToTop(); ///< moves window to top void SetBackground(UINT32 anColor); bool GetBlend(); void SetBlend(bool blendingOn); void SetOpaque(void); void SetPixel(int x, int y, unsigned int value); void GetWindow(RECT& r) {r = mrectWindow;} void SetDisplayRegion(Gdiplus::RectF r); tc2DGraphicsSurface* GetSurface() const {return mp2DSurface;} void MoveWindow(int ax, int ay); bool GetDrawDC(HDC& hdc); bool ReleaseDrawDC(HDC hdc); bool GetGraphics(Gdiplus::Graphics*& rpGraphics); // GDI+ bool GetLowQualityGraphics(Gdiplus::Graphics*& rpGraphics); // GDI+ bool ReleaseGraphics(Gdiplus::Graphics* apGraphics); // GDI+ virtual void SetActive(bool abActive); void SetRenderTexture(bool abState); void SetResizeable2D(bool abState) {resizeable2DSurface = abState;} ///< @see tcWindow::OnSize void SetSkipCount(unsigned skipCount); virtual void SetYMirror(int y) {yMirror = y;} virtual void Thaw(); tcWindow(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name = "tcWindow", tcWindow *sharedSurfaceHost = NULL); virtual ~tcWindow(); protected: std::vector<tcWindow*> children; tc2DGraphicsSurface* mp2DSurface; RECT mrectWindow; // location for map in back buffer int mnWidth; ///< window dimension--tried to make const, but problem in tcTerrainView int mnHeight; int yMirror; ///< workaround for opposite y directions of OpenGL vs. wxWindows /// true if 2DSurface should be resized with window, normally false for zoomed surfaces /// such as with the tcTerrainView /// @see tcWindow::OnSize view OnSize method code to see how this is used bool resizeable2DSurface; HFONT mhFontDefault; Gdiplus::Font *mpFontDefault; // GDI+ font Gdiplus::SolidBrush *mpBrushDefault; Gdiplus::Image *mpiBackground; // background image WCHAR mzwchar[255]; // for GDI+ DrawString conversion bool mbCloned; bool mbFrozen; virtual int CreateSurfaces(tcGraphicsEngine* apGraphicsEngine); virtual int DeleteSurfaces(tcGraphicsEngine* apGraphicsEngine); WCHAR* PrependImagePath(const char *azFileName); virtual void OnChar(wxKeyEvent& event); virtual void OnEnterWindow(wxMouseEvent& event); void OnEraseBackground(wxEraseEvent& event); virtual void OnKeyDown(wxKeyEvent& event); virtual void OnKillFocus(wxFocusEvent& event); virtual void OnLButtonDown(wxMouseEvent& event); virtual void OnLButtonUp(wxMouseEvent& event); virtual void OnLeaveWindow(wxMouseEvent& event); virtual void OnMouseMove(wxMouseEvent& event); virtual void OnMouseWheel(wxMouseEvent& event); virtual void OnMove(wxMoveEvent& event); void OnPaint(wxPaintEvent& event); virtual void OnRButtonDown(wxMouseEvent& event); virtual void OnSetFocus(wxFocusEvent& event); virtual void OnShow(wxShowEvent& event); virtual void OnSize(wxSizeEvent& event); void SkipMouseEvent(wxMouseEvent& event); ///< adjusts position to parent frame long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); private: HDC mhdc; Gdiplus::StringFormat stringformatleftalign; Gdiplus::StringFormat stringformatwrap; Gdiplus::StringFormat stringformatcentered; void ShareSurfaceWith(const tcWindow* apWindow); // shares 2D surface with apWindow DECLARE_EVENT_TABLE() }; #endif --- tcwindow.h DELETED --- |