// -*-c++-*- //------------------------------------------------------------------------------ // xword - (http://xword.sourceforge.net) // Copyright 2001 Patrick Crosby //------------------------------------------------------------------------------ // GridWidget.h // // $Id: GridWidget.h,v 1.10 2002/01/23 19:43:03 pcrosby Exp $ //------------------------------------------------------------------------------ // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) any later // version. // // This program 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 // this program; if not, write to the Free Software Foundation, Inc., 59 Temple // Place, Suite 330, Boston, MA 02111-1307 USA //------------------------------------------------------------------------------ #ifndef __GridWidget__ #define __GridWidget__ #include #include "Puzzle.h" #include "Namespace.h" NAMESPACE_OPEN //------------------------------------------------------------------------------ class GridWidget: public Gtk::DrawingArea { // Constants private: static const int s_nGridSize; static const int s_nBackColorRed; static const int s_nBackColorGreen; static const int s_nBackColorBlue; static const int s_nOffset; // Types // typedef std::vector StringVec; // Variables private: Gdk_Pixmap m_pixBack; // Puzzle::SquareGrid m_Grid; int m_nSizeX; int m_nSizeY; int m_nCursorX; int m_nCursorY; // StringVec m_vecLetters; bool m_bAcross; Puzzle* m_pPuzzle; // Methods public: GridWidget(); ~GridWidget(); gint expose_event_impl(GdkEventExpose* pEvent); gint key_press_event_impl(GdkEventKey* pEvent); gint button_press_event_impl(GdkEventButton* pEvent); void SetGrid(/*const Puzzle::SquareGrid& grid*/); void SetPuzzle(Puzzle* pPuzzle); SigC::Signal0 CursorMoved; int GetCursorX() const { return m_nCursorX; } int GetCursorY() const { return m_nCursorY; } int GetWidth() const; int GetHeight() const; private: void Draw(); void DrawGrid(); void DrawCursor(); void DrawLetters(); void SetColor(Gdk_GC& gc, int nRed, int nGreen, int nBlue); void GetFont(Gdk_Font& font); int GetCenterX(); int GetCenterY(); int GetMaxX(); int GetMaxY(); bool MoveRight(bool bBlank); bool MoveLeft(bool bBlank); bool MoveDown(bool bBlank); bool MoveUp(bool bBlank); bool PrevClue(bool bAcross); bool NextClue(bool bAcross); }; //------------------------------------------------------------------------------ NAMESPACE_CLOSE #endif //------------------------------------------------------------------------------