gcsx_layerlist.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* GCSx
  2. ** LAYERLIST.H
  3. **
  4. ** Listbox for layer selection
  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_LAYERLIST_H_
  24. #define __GCSx_LAYERLIST_H_
  25. // Uses ListEntry class for items-
  26. // code1 = flags (visible, dimmed, editable, sprites, etc.)
  27. // code2 = layer type
  28. class WLayerListBox : public WListBox {
  29. public:
  30. // Flags used in ListEntry class
  31. enum {
  32. FLAG_VISIBLE = 1,
  33. FLAG_DIMMED = 2,
  34. FLAG_EDITABLE = 4,
  35. FLAG_SPRITES_VISIBLE = 8,
  36. FLAG_SPRITES_DIMMED = 16,
  37. };
  38. protected:
  39. // Widgets used
  40. static const std::string wtLayerVisible;
  41. static const std::string wtLayerEditable;
  42. static const std::string wtLayerSprites;
  43. static const std::string wtLayerTile;
  44. static const std::string wtLayerFont;
  45. static const std::string wtLayerImage;
  46. // Position of icon columns and text (last item is text label)
  47. int iconPos[5];
  48. int yAddIcon;
  49. int yAddText;
  50. // Our scene
  51. class SceneEdit* scene;
  52. void selectItem(int id, int select = 1, int alone = 1);
  53. void dblClickItem(int id);
  54. void rtClickItem(int id);
  55. void delClickItem(int id);
  56. public:
  57. // Width in pixels, lines to show vertically
  58. // Allows exactly one selection, stores id
  59. WLayerListBox(int lId, int* lSelection, int lWidth = -1, int lLines = -1);
  60. ~WLayerListBox();
  61. // Which scene to send move/delete notifications to
  62. void setScene(class SceneEdit* lScene);
  63. // Scans code1 to determine which layers are visible, dimmed, affected
  64. // Returns as bitmasks- first in list 1, second 2, 4, 8, etc.
  65. void determineBitMasks(Uint32& layersView, Uint32& layersDim, Uint32& layersAffect) const;
  66. // Updates layers to match the given layersAffect/etc (doesn't call siblingModified)
  67. void setBitMask(Uint32 layersAffect, Uint32 layersView, Uint32 layersDim, int selectedLayer = -1);
  68. // (add/swap doesn't call siblingModified unless selectIt is true)
  69. // (remove doesn't call siblingModified unless selection changes)
  70. void addItem(const ListEntry& item, int selectIt = 0);
  71. void addItem(int position, const ListEntry& item, int selectIt = 0);
  72. void swapItems(int pos1, int pos2);
  73. void removeItem(int position);
  74. void display(SDL_Surface* destSurface, Rect& toDisplay, const Rect& clipArea, int xOffset, int yOffset);
  75. int event(int hasFocus, const SDL_Event* event);
  76. };
  77. #endif