1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /* GCSx
- ** WPREVIEW.H
- **
- ** Widget that previews an image (tile, map, etc.)
- */
- /*****************************************************************************
- ** Copyright (C) 2003-2006 Janson
- **
- ** 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, USA.
- *****************************************************************************/
- #ifndef __GCSx_WPREVIEW_H_
- #define __GCSx_WPREVIEW_H_
- // Shows a scaled (if needed) preview of an image
- // Call load() when the image updates
- class WPreview : public Widget {
- private:
- enum {
- PREVIEW_BORDER_SIZE = 1,
- };
- SDL_Surface* const* source;
- SDL_Surface* scaled; // Scaled version, OR copy of src
- int scaledIsSource;
-
- int displayW;
- int displayH;
- int showMultiple;
- int allowDistort;
- int imageX;
- int imageY;
- int imageFullX; // If fullsize in X (safer than floating comparison to 1.0)
- int imageFullY;
- float imageScaleX;
- float imageScaleY;
-
- // Location of copy on white background; 0 if none
- int imageWhiteX;
- int imageWhiteY;
-
- // Location of tiled copy; 0 if none
- int imageTiledX;
- int imageTiledY; // (can be negative)
- int imageTiledQty;
- public:
- // Width doesn't include border
- // A width or height <= 0 hides the control
- WPreview(int pId, SDL_Surface* const* src, int myWidth, int myHeight, int pShowMultiple, int pAllowDistort);
- ~WPreview();
-
- // Width doesn't include border
- // A width or height <= 0 hides the control
- // This won't rearrange the dialog, so it should be the last control
- // Call load() after this to update image/size/position
- void changeSize(int newWidth, int newHeight);
- int event(int hasFocus, const SDL_Event* event);
- int refuseAll() const;
- void load();
- void apply();
- void display(SDL_Surface* destSurface, Rect& toDisplay, const Rect& clipArea, int xOffset, int yOffset);
- };
- #endif
|