gcsx_wpreview.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* GCSx
  2. ** WPREVIEW.H
  3. **
  4. ** Widget that previews an image (tile, map, etc.)
  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_WPREVIEW_H_
  24. #define __GCSx_WPREVIEW_H_
  25. // Shows a scaled (if needed) preview of an image
  26. // Call load() when the image updates
  27. class WPreview : public Widget {
  28. private:
  29. enum {
  30. PREVIEW_BORDER_SIZE = 1,
  31. };
  32. SDL_Surface* const* source;
  33. SDL_Surface* scaled; // Scaled version, OR copy of src
  34. int scaledIsSource;
  35. int displayW;
  36. int displayH;
  37. int showMultiple;
  38. int allowDistort;
  39. int imageX;
  40. int imageY;
  41. int imageFullX; // If fullsize in X (safer than floating comparison to 1.0)
  42. int imageFullY;
  43. float imageScaleX;
  44. float imageScaleY;
  45. // Location of copy on white background; 0 if none
  46. int imageWhiteX;
  47. int imageWhiteY;
  48. // Location of tiled copy; 0 if none
  49. int imageTiledX;
  50. int imageTiledY; // (can be negative)
  51. int imageTiledQty;
  52. public:
  53. // Width doesn't include border
  54. // A width or height <= 0 hides the control
  55. WPreview(int pId, SDL_Surface* const* src, int myWidth, int myHeight, int pShowMultiple, int pAllowDistort);
  56. ~WPreview();
  57. // Width doesn't include border
  58. // A width or height <= 0 hides the control
  59. // This won't rearrange the dialog, so it should be the last control
  60. // Call load() after this to update image/size/position
  61. void changeSize(int newWidth, int newHeight);
  62. int event(int hasFocus, const SDL_Event* event);
  63. int refuseAll() const;
  64. void load();
  65. void apply();
  66. void display(SDL_Surface* destSurface, Rect& toDisplay, const Rect& clipArea, int xOffset, int yOffset);
  67. };
  68. #endif