123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- /* GCSx
- ** IMPORTIMG.H
- **
- ** Import image (creating tileset/fontset) dialog
- */
- /*****************************************************************************
- ** 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_IMPORTIMG_H_
- #define __GCSx_IMPORTIMG_H_
- class ImportImgDialog : private Dialog {
- private:
- int initialized;
- int isFont;
- std::string filename;
- int width;
- int height;
- int left;
- int top;
- int horiz;
- int vert;
- int skipBlank;
- int skipDupe;
- int importScene;
- color bkColor;
-
- SDL_Surface* image;
- enum {
- ID_LABEL = 1,
- ID_FILE,
- ID_FILECHOOSE,
- ID_TRANSPARENCY,
- ID_PREVIEW,
- ID_WIDTH,
- ID_HEIGHT,
- ID_LEFT,
- ID_TOP,
- ID_HORIZ,
- ID_VERT,
- ID_SKIPBLANK,
- ID_SKIPDUPE,
- ID_IMPORTSCENE,
- ID_OK,
- ID_CANCEL,
- };
- static class ImportImgDialog* dialogTileSet;
- static class ImportImgDialog* dialogFontSet;
- // (sl NULL to not import a scene)
- int doImport(TileSetEdit* ts, SceneEdit* sc, LayerEdit* sl, WorldEdit* world);
- public:
- ImportImgDialog(int font);
- ~ImportImgDialog();
- static class ImportImgDialog* createFontSet();
- static class ImportImgDialog* createTileSet();
- static void destroy();
- void run(class WorldEdit* world, Window* srcWin = NULL);
- void childModified(Window* modified);
- Dialog::ButtonAction verifyEntry(int buttonId, Dialog::ButtonAction buttonType);
- };
- // Shows a preview of splitting an image into tiles
- // Call load() when the image updates
- class WSplitPreview : public Widget {
- private:
- enum {
- PREVIEW_BORDER_SIZE = 1,
- TILE_SPACING = 1,
- };
- SDL_Surface* const* source;
- SDL_Surface* split; // Version to display (split/etc)
- int displayW;
- int displayH;
-
- int topPad;
- int leftPad;
- int horizSplit;
- int vertSplit;
- int tileWidth;
- int tileHeight;
-
- color bkColor;
- enum {
- WSPLITPREVIEW_DRAG_NONE = 0,
- WSPLITPREVIEW_DRAG_BK,
- } dragMode;
-
- void setBk(int x, int y);
- public:
- // Width doesn't include border
- // A width or height <= 0 hides the control
- // Doesn't update display until you call changeStats
- WSplitPreview(int pId, color* pSetting, SDL_Surface* const* src, int myWidth, int myHeight);
- ~WSplitPreview();
- // Width doesn't include border
- // A width or height <= 0 hides the control
- // Call load() after this to update image/size/position (not auto)
- void changeSize(int newWidth, int newHeight);
- // Automatically updates image
- void changeStats(int width, int height, int top, int left, int horiz, int vert);
- int event(int hasFocus, const SDL_Event* event);
- void load();
- void apply();
- void display(SDL_Surface* destSurface, Rect& toDisplay, const Rect& clipArea, int xOffset, int yOffset);
- };
- #endif
|