gcsx_tilesetbrowse.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* GCSx
  2. ** TILESETBROWSE.H
  3. **
  4. ** Tileset browsing
  5. */
  6. /*****************************************************************************
  7. ** Copyright (C) 2003-2006 Janson
  8. **
  9. ** This program is free software; you can redistribute it and/or modify
  10. ** it under the terms of the GNU General Public License as published by
  11. ** the Free Software Foundation; either version 2 of the License, or
  12. ** (at your option) any later version.
  13. **
  14. ** This program is distributed in the hope that it will be useful,
  15. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ** GNU General Public License for more details.
  18. **
  19. ** You should have received a copy of the GNU General Public License
  20. ** along with this program; if not, write to the Free Software
  21. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  22. *****************************************************************************/
  23. #ifndef __GCSx_TILESETBROWSE_H_
  24. #define __GCSx_TILESETBROWSE_H_
  25. class TileSetBrowseToolsMode : public Dialog {
  26. private:
  27. class FrameWindow* myFrame;
  28. class TileSetBrowse* myBrowse;
  29. int font;
  30. int* modePtr;
  31. const int* hasMapsPtr;
  32. public:
  33. enum {
  34. // Controls
  35. ID_MODE = 1,
  36. };
  37. TileSetBrowseToolsMode(class TileSetBrowse* tBrowseArea, int isFont, int* mode, const int* hasMaps);
  38. ~TileSetBrowseToolsMode();
  39. // Widgets adjust to mode change, disable/enable based on hasMaps
  40. void updateTools();
  41. // Creates a FrameWindow and returns, does not add self to desktop (use ->show() to do that)
  42. class FrameWindow* createWindowed();
  43. int event(int hasFocus, const SDL_Event* event);
  44. void childModified(Window* modified);
  45. int wantsToBeDeleted() const;
  46. WindowSort windowSort() const;
  47. };
  48. class TileSetBrowse : public Window {
  49. private:
  50. class TileSetEdit* tileset;
  51. class TileSetBrowseToolsMode* toolsMode;
  52. int numTiles; // or number of collision maps, if in that mode
  53. int tileWidth;
  54. int tileHeight;
  55. int isFont;
  56. int hasMaps;
  57. int zoomWidth;
  58. int zoomHeight;
  59. int zoomRatio;
  60. int gridSize; // 0 or 1 only
  61. int showLetters;
  62. int tilesPerLine;
  63. int fixedTilesPerLine;
  64. int mode; // tiles, collision, or assign
  65. int cursor; // We keep this +selections at -1 to make our calculations easier
  66. int selectFirst; // Endpoints of selection, for dragging
  67. int selectLast;
  68. int selectBegin; // Actual first and last tiles selected, in a box pattern
  69. int selectEnd; // only used when fixedTilesPerLine is enabled
  70. int haveFocus;
  71. int partialFocus;
  72. // Dirty range
  73. Rect dirtyRange;
  74. // Set partial dirties
  75. void setDirtyRange(int first, int last);
  76. void setDirtyBox(int begin, int end);
  77. public:
  78. // Opens the window
  79. TileSetBrowse(TileSetEdit* myTileset) throw_File;
  80. ~TileSetBrowse();
  81. void reloadTileStats();
  82. int cursorState(int newPos = -1, int drag = 0);
  83. void realignSelection(); // Takes first/last and creates begin/end
  84. CommandSupport supportsCommand(int code) const;
  85. int event(int hasFocus, const SDL_Event* event);
  86. void resize(int newWidth, int newHeight, int newViewWidth = -1, int newViewHeight = -1, int fromParent = 0);
  87. void display(SDL_Surface* destSurface, Rect& toDisplay, const Rect& clipArea, int xOffset, int yOffset);
  88. WindowType windowType() const;
  89. };
  90. #endif