├── Fedit.exe ├── Fedit.sln ├── Fedit.suo ├── Fiew ├── Cacher.cpp ├── Cacher.h ├── ChildCore.cpp ├── ChildCore.h ├── Core.cpp ├── Core.h ├── DH_Clr.cpp ├── DH_Fil.cpp ├── Dialogs.cpp ├── Dialogs.h ├── Drawer.cpp ├── Drawer.h ├── Exp_Archive.cpp ├── Exp_File.cpp ├── Exp_Folder.cpp ├── Explorer.cpp ├── Explorer.h ├── Fedit.aps ├── Fedit.cpp ├── Fedit.h ├── Fedit.ico ├── Fedit.rc ├── FeditConfigs.h ├── FeditEssentials.h ├── FeditLocale.h ├── Fiew.aps ├── Fiew.vcproj ├── Fiew.vcproj.NEKO.a0.user ├── Frame.cpp ├── Frame.h ├── FrameText.cpp ├── Ftyper.cpp ├── Ftyper.h ├── FwCHAR.cpp ├── FwCHAR.h ├── History.h ├── HistoryControler.cpp ├── HistoryElements.cpp ├── Icos │ ├── color_reset.png │ ├── color_swap.png │ ├── crop.png │ ├── dock_text_bold.png │ ├── dock_text_italic.png │ ├── dock_text_uline.png │ ├── draw_pen.png │ ├── eraser_normal.png │ ├── fill_bucket.png │ ├── hand.png │ ├── ico_delete.png │ ├── ico_down.png │ ├── ico_newfile.png │ ├── ico_up.png │ ├── lasso_mouse.png │ ├── lasso_poly.png │ ├── magicwand.png │ ├── move.png │ ├── sample_color.png │ ├── select_circ.png │ ├── select_hori.png │ ├── select_rect.png │ ├── select_vert.png │ ├── shape_elli.png │ ├── shape_line.png │ ├── shape_rect.png │ ├── shape_roundrect.png │ ├── text.png │ ├── vector_draw.png │ ├── vector_select.png │ └── zoom.png ├── Interface.cpp ├── Interface.h ├── Layer.cpp ├── Layer.h ├── Layer_Gridlay.cpp ├── Layer_Listlay.cpp ├── Layer_Overlay.cpp ├── Layer_Snaplay.cpp ├── Layer_Thumblay.cpp ├── List.h ├── ProjectOverview.txt ├── Tool.cpp ├── Tool.h ├── ToolBucket.cpp ├── ToolCopy.cpp ├── ToolCrop.cpp ├── ToolDrawing.cpp ├── ToolDrawingLinear.cpp ├── ToolDrawingStrict.cpp ├── ToolFilter.cpp ├── ToolHand.cpp ├── ToolLine.cpp ├── ToolMove.cpp ├── ToolPencil.cpp ├── ToolSampleColor.cpp ├── ToolSelectPoly.cpp ├── ToolSelectRect.cpp ├── ToolSelectWand.cpp ├── ToolSelecting.cpp ├── ToolText.cpp ├── ToolZoom.cpp ├── Toolw.cpp ├── ToolwBox.cpp ├── ToolwBoxContent.cpp ├── ToolwBoxHistory.cpp ├── ToolwBoxInfo.cpp ├── ToolwBoxLayers.cpp ├── ToolwBoxScroll.cpp ├── ToolwCC.cpp ├── ToolwDock.cpp ├── Toolws.cpp ├── Toolws.h ├── Workspace.cpp ├── Workspace.h ├── XUn.cpp ├── XUn.h ├── XUnrar.cpp ├── XUnrar.h ├── XUnzip.cpp ├── XUnzip.h ├── mid.ico ├── ovl_about.png ├── ovl_manual.png ├── resource.h ├── small.ico ├── stdafx.cpp ├── stdafx.h └── unrar.dll ├── LICENSE └── release └── Fedit.exe /Fedit.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fedit.exe -------------------------------------------------------------------------------- /Fedit.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Fiew", "Fiew\Fiew.vcproj", "{399ABEA6-8FE9-4F2E-B760-F49852591C8B}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {399ABEA6-8FE9-4F2E-B760-F49852591C8B}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {399ABEA6-8FE9-4F2E-B760-F49852591C8B}.Debug|Win32.Build.0 = Debug|Win32 14 | {399ABEA6-8FE9-4F2E-B760-F49852591C8B}.Release|Win32.ActiveCfg = Release|Win32 15 | {399ABEA6-8FE9-4F2E-B760-F49852591C8B}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Fedit.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fedit.suo -------------------------------------------------------------------------------- /Fiew/Cacher.h: -------------------------------------------------------------------------------- 1 | class FwCHAR; 2 | 3 | class Catalog; 4 | class File; 5 | 6 | using namespace Gdiplus; 7 | 8 | class Cell 9 | { 10 | private: 11 | File *file; // File object associated with that image 12 | Bitmap *thumb; // Image thumbnail 13 | IStream *stream; // Image raw data as IStream 14 | 15 | public: 16 | Cell(File *file, byte *data); 17 | Cell(File *file); 18 | ~Cell(); 19 | 20 | File *getFile(); 21 | Image *getImage(); 22 | Bitmap *getImageThumb(); 23 | Bitmap *getImageThumb(int width, int height); 24 | IStream *getStream(); 25 | 26 | bool isLoaded(); 27 | 28 | Cell *loadThumb(int load); 29 | 30 | private: 31 | bool loadStream(byte *data, DWORD len); 32 | }; 33 | 34 | class Cacher 35 | { 36 | private: 37 | List *cache; // cache data - Cell list 38 | Catalog *source; // cache source destination of Catalog type 39 | Core *core; // owner 40 | 41 | int full; 42 | 43 | protected: 44 | HANDLE mut_cache, mut_bool; 45 | 46 | HANDLE mut_initloop, mut_initterminator; 47 | HANDLE mut_nextloop, mut_nextstep, mut_nextterminator; 48 | HANDLE mut_prevloop, mut_prevstep, mut_prevterminator; 49 | 50 | HANDLE thrd_init, thrd_next, thrd_prev; 51 | 52 | HANDLE sem_nexts, sem_prevs, sem_nextlock, sem_prevlock; 53 | 54 | public: 55 | Cacher(Core *core); 56 | ~Cacher(); 57 | 58 | void init(); 59 | 60 | Catalog *getSource(); 61 | List *getCache(); 62 | 63 | void setFull(bool val, bool thumbs = true); 64 | int isFull(); 65 | bool isRunning(); 66 | 67 | bool next(); 68 | bool prev(); 69 | Cell *getThat(); 70 | Image *getThatImage(); 71 | Image *getThatThumb(int width, int height); 72 | 73 | void unlockNext(); 74 | void unlockPrev(); 75 | 76 | void lockCache(); 77 | void unlockCache(); 78 | 79 | void gotoCell(Cell *cell); 80 | 81 | static DWORD WINAPI initAlloc(LPVOID param); 82 | static DWORD WINAPI nextAlloc(LPVOID param); 83 | static DWORD WINAPI prevAlloc(LPVOID param); 84 | }; -------------------------------------------------------------------------------- /Fiew/ChildCore.h: -------------------------------------------------------------------------------- 1 | using namespace Gdiplus; 2 | 3 | class FwCHAR; 4 | class Core; 5 | 6 | class Drawer; 7 | class Cacher; 8 | class Explorer; 9 | class Interface; 10 | 11 | class Workspace; 12 | class Tool; 13 | 14 | class ChildCore 15 | { 16 | protected: 17 | Core *core; // owner 18 | HWND windowHandle; // child window handle 19 | 20 | FwCHAR *filepath, // path of edited file (if any) 21 | *title; // filename of edited file 22 | 23 | bool initialized, // initialize flag 24 | constructed, // done constructor flag 25 | repaint, // force repaint flag 26 | isTracked; // mouse leave tracking flag 27 | int maxrollHor, // max horizontal scroll value 28 | maxrollVer; // min -- // -- 29 | 30 | Drawer *drawer; // Drawer object for painting the view 31 | Workspace *workspace; // Workspace object for image editing control 32 | Tool *toolCurrent; // Currently selected Tool 33 | 34 | public: 35 | ChildCore(Core *parent, 36 | FwCHAR *filepath, 37 | int type); 38 | ChildCore(Core *parent, 39 | Bitmap *temp, 40 | FwCHAR *title = NULL); 41 | ChildCore(Core *parent, 42 | FwCHAR *title, 43 | float width, float height, int sunit, 44 | float res, int runit, 45 | int dmode, int dunit, 46 | int bkgnd); 47 | ~ChildCore(); 48 | void reset(); 49 | 50 | bool initialize(); 51 | bool isInitialized(); 52 | bool isConstructed(); 53 | void invalidate(bool repaint = true); 54 | 55 | bool save(WCHAR *filepath,int type); 56 | 57 | void setText(); 58 | 59 | void addSkew(int x, int y); 60 | void setSkew(int x, int y); 61 | void pinSkew(int x, int y); 62 | 63 | void addZoom(double zoom); 64 | void setZoom(double zoom); 65 | 66 | void setTool(Tool *tool); 67 | void sendToolDblClk(UINT message, WPARAM wParam, LPARAM lParam, int itemId); 68 | 69 | void setScrollBar(SCROLLINFO hor, SCROLLINFO ver); 70 | 71 | HWND getWindowHandle(); 72 | 73 | Explorer *getExplorer(); 74 | Interface *getGui(); 75 | Cacher *getCacher(); 76 | Drawer *getDrawer(); 77 | 78 | Workspace *getWorkspace(); 79 | 80 | FwCHAR *getFilepath(); 81 | 82 | static LRESULT CALLBACK processMessages(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 83 | 84 | private: 85 | void destroy(); 86 | 87 | }; -------------------------------------------------------------------------------- /Fiew/Core.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "commctrl.h" 4 | 5 | #include "FwCHAR.h" 6 | #include "List.h" 7 | #include "XUn.h" 8 | 9 | #include "ChildCore.h" 10 | #include "Workspace.h" 11 | #include "History.h" 12 | #include "Frame.h" 13 | #include "Tool.h" 14 | 15 | #include "Dialogs.h" 16 | #include "Toolws.h" 17 | 18 | #include "Interface.h" 19 | #include "Explorer.h" 20 | #include "Cacher.h" 21 | #include "Layer.h" 22 | #include "Drawer.h" 23 | 24 | LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 25 | LRESULT CALLBACK MdiProc(HWND, UINT, WPARAM, LPARAM); 26 | 27 | class Core 28 | { 29 | protected: 30 | HWND windowHandle; // application handle 31 | HWND mdiclientHandle; // mdi client handle 32 | HINSTANCE instance; // application instance 33 | 34 | WNDPROC MDIWndProc; // original mdi window procedure 35 | List *children; // list of opened child windows 36 | 37 | Dialogs *dialogs; // dialogs controler 38 | Toolws *toolws; // tool windows controler 39 | 40 | Interface *gui; // gui controler 41 | Explorer *explorer; // unused 42 | Cacher *cacher; // unused 43 | Drawer *drawer; // unused 44 | 45 | FwCHAR *commandLine; // command line data 46 | HFONT hFontShell; // default interface font 47 | 48 | bool initialized; // init flag 49 | 50 | static HMODULE rarDll; // unrar.dll handle 51 | static int chicounter; // child windows counter 52 | 53 | public: 54 | Core(WCHAR *cmdLine, HINSTANCE instance); 55 | ~Core(); 56 | 57 | static LRESULT CALLBACK processDialogs(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 58 | static LRESULT CALLBACK processFakeDialogs(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 59 | 60 | LRESULT processMessages(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 61 | LRESULT processMdiMessages(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 62 | 63 | HWND getWindowHandle(); 64 | HWND getMdiclientHandle(); 65 | HWND getActiveChildHandle(); 66 | ChildCore *getActiveChild(); 67 | HINSTANCE getInstance(); 68 | 69 | List *getChildren(); 70 | 71 | Dialogs *getDialogs(); 72 | Toolws* getToolws(); 73 | 74 | Interface *getGui(); 75 | Explorer *getExplorer(); 76 | void setExplorer(Explorer *explorer); 77 | 78 | Cacher *getCacher(); 79 | Drawer *getDrawer(); 80 | 81 | RECT getMdiClientSize(); 82 | RECT getClientSize(); 83 | 84 | void mdiArrange(); 85 | void mdiCascade(); 86 | void mdiTileVer(); 87 | void mdiTileHor(); 88 | 89 | bool neww(ChildCore *child); 90 | bool openFolder(FwCHAR *path); 91 | bool open(FwCHAR *path, bool save = true); 92 | bool open(WCHAR *path, bool save = true); 93 | void extract(); 94 | void setwall(); 95 | void close(); 96 | 97 | void redrawAll(RECT *rect); 98 | 99 | int messageBox_Info(WCHAR *string); 100 | int messageBox_Error(WCHAR *string); 101 | int messageBox_Prompt(WCHAR *string); 102 | 103 | HFONT CreateHFONT(WCHAR *fontFamily, UINT size, INT style = FontStyleRegular, Unit unit = UnitPoint); 104 | 105 | HWND CreateWindowExSubstituteFont( 106 | DWORD dwExStyle, 107 | LPCTSTR lpClassName, 108 | LPCTSTR lpWindowName, 109 | DWORD dwStyle, 110 | int x, 111 | int y, 112 | int nWidth, 113 | int nHeight, 114 | HWND hWndParent, 115 | HMENU hMenu, 116 | HINSTANCE hInstance, 117 | LPVOID lpParam 118 | ); 119 | 120 | static HMODULE getRarDll(); 121 | static void getLastError(); 122 | static int getEncoder(WCHAR* format, CLSID* pClsid); 123 | static int tickChicounter(); 124 | static int getChicounter(); 125 | static int getPixelFormat(); 126 | 127 | static FwCHAR *getDlgItemString(HWND hDlg, int itemId); 128 | static float getDlgItemNumber(HWND hDlg, int itemId, bool sign); 129 | 130 | static Image *getImageResource(WORD id, LPCWSTR type); 131 | 132 | static bool isInBmp(Bitmap *bmp, int x, int y); 133 | static Color invClr(Color color, int grey = NULL); 134 | 135 | static UINT RGBtoUINT(int r, int g, int b, int a = 255); 136 | static UINT RGBtoUINT(Color rgb); 137 | static Color UINTtoRGB(UINT uint); 138 | static RGBCOLOR UINTtoRGBCOLOR(UINT uint); 139 | static UINT RGBCOLORtoUINT(RGBCOLOR rgba); 140 | static CMYKCOLOR RGBtoCMYK(Color rgb); 141 | static Color CMYKtoRGB(CMYKCOLOR cmyk); 142 | static HSVCOLOR RGBtoHSV(Color rgb); 143 | static Color HSVtoRGB(HSVCOLOR hsv); 144 | static LabCOLOR RGBtoLab(Color rgb); 145 | static Color LabtoRGB(LabCOLOR lab); 146 | 147 | static POINT makePoint(LPARAM lParam); 148 | static void clearBitmap(Bitmap *bmp, Rect rect); 149 | 150 | static Bitmap *getClipboardBitmap(); 151 | static void setClipboardBitmap(Bitmap *bmp); 152 | static bool isClipboardBitmap(); 153 | 154 | static bool convertToDIB(HBITMAP &hBitmap, HPALETTE &hPalette); 155 | 156 | static Core *self; 157 | static Bitmap *clipboardBitmap; 158 | 159 | private: 160 | void initialize(HWND windowHandle); 161 | void initializeMdi(); 162 | void initializeFonts(); 163 | void initializeToolws(); 164 | 165 | bool extractResource(WORD id, WCHAR *filename); 166 | 167 | void loadDlls(); 168 | void freeDlls(); 169 | 170 | void destroy(); 171 | }; -------------------------------------------------------------------------------- /Fiew/Dialogs.h: -------------------------------------------------------------------------------- 1 | class Core; 2 | class Gridlay; 3 | class ToolFilter; 4 | 5 | struct CMYKCOLOR { UINT C,M,Y,K; }; 6 | struct HSVCOLOR { UINT H,S,V; }; 7 | struct LabCOLOR { UINT L,a,b; }; 8 | 9 | class Dialogs 10 | { 11 | public: 12 | static Core *core; 13 | 14 | Dialogs(Core *core); 15 | ~Dialogs(); 16 | 17 | int showDialog(LPCTSTR resource, DLGPROC dlgproc, LPARAM lParam = NULL); 18 | 19 | static LRESULT CALLBACK processDlg_New(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 20 | static LRESULT CALLBACK processDlg_Clr(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 21 | static LRESULT CALLBACK processDlg_Res(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 22 | static LRESULT CALLBACK processDlg_Fil(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 23 | 24 | static void limitSliderInt(HWND hInput, HWND hWnd, int min, int max, int val); 25 | static void limitInputInt(HWND hWnd, int min, int max); 26 | static void limitInputText(HWND hWnd, int min, int max); 27 | static LRESULT CALLBACK procSliderInt(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 28 | static LRESULT CALLBACK procInputInt(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 29 | static LRESULT CALLBACK procInputText(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 30 | 31 | static void editStaticText(HWND hWnd, int x, int y); 32 | static LRESULT CALLBACK procStaticEditText(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 33 | static LRESULT CALLBACK procStaticEditEdit(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 34 | 35 | static HWND ownerdrawButton(HWND hOwner, WCHAR *icon, int x, int y, int w, int h, int id, BOOL autocheck); 36 | static HWND ownerdrawButton(HWND hWnd, HWND hOwner, BOOL autocheck); 37 | static void paintButton(LPDRAWITEMSTRUCT button); 38 | static LRESULT CALLBACK processButton(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 39 | 40 | static HWND colorPicker(HWND hOwner, Color color, int x, int y, int id, int w = NULL, int h = NULL); 41 | static LRESULT CALLBACK processPicker(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 42 | }; 43 | 44 | class DialogHelper_Clr 45 | { 46 | protected: 47 | static const int intFieldWidth = 256; 48 | static const int intSlidWidth = 20; 49 | static const int intCmpWidth = 70; 50 | 51 | static DialogHelper_Clr *that; 52 | 53 | HWND windowHandle, hField, hSlid, hCmp; 54 | WNDPROC procField, procSlid; 55 | 56 | Bitmap *bmpField, *bmpSlid, *bmpCmp; 57 | Color clrCurrent, clrNew; 58 | CMYKCOLOR clrCmyk; 59 | HSVCOLOR clrHSV; 60 | LabCOLOR clrLab; 61 | 62 | public: 63 | DialogHelper_Clr(HWND hWnd, Color current); 64 | ~DialogHelper_Clr(); 65 | 66 | Color getNewColor(); 67 | Color getOldColor(); 68 | 69 | void valueChange(int ctrlId); 70 | void radioChange(); 71 | 72 | static LRESULT CALLBACK procNewField(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 73 | static LRESULT CALLBACK procNewSlid(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 74 | 75 | private: 76 | void renderField(); 77 | void renderSlid(); 78 | void renderCmp(); 79 | void render(); 80 | 81 | void setField(); 82 | void setSlid(); 83 | void setCmp(); 84 | void setCtrls(int except = NULL); 85 | 86 | void setBitmap(Bitmap *bmp, int itemId); 87 | 88 | int getCheckedRadio(); 89 | }; 90 | 91 | class DialogHelper_Fil 92 | { 93 | protected: 94 | static DialogHelper_Fil *that; 95 | 96 | HWND windowHandle, hThumb; 97 | ToolFilter::Info *fi, fiThumb; 98 | Rect clip; 99 | 100 | Gridlay *grid; 101 | 102 | int **customMatrixIds; 103 | bool isMoving, isTracking; 104 | POINTS lastMouse; 105 | 106 | WNDPROC procThumb; 107 | 108 | public: 109 | DialogHelper_Fil(HWND hWnd, ToolFilter::Info *fi); 110 | ~DialogHelper_Fil(); 111 | 112 | void valueChange(int ctrlId); 113 | void checkChange(int ctrlId); 114 | 115 | void setTextMatrix(); 116 | void clearTextMatrix(); 117 | ToolFilter::Matrix getTextMatrix(); 118 | 119 | static LRESULT CALLBACK procNewThumb(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 120 | 121 | private: 122 | void renderThumb(); 123 | void setThumb(Bitmap *bmp); 124 | }; -------------------------------------------------------------------------------- /Fiew/Drawer.h: -------------------------------------------------------------------------------- 1 | class ChildCore; 2 | 3 | using namespace Gdiplus; 4 | 5 | class Drawer 6 | { 7 | private: 8 | ChildCore *core; // owner 9 | 10 | List *layers; // Layers list 11 | Layer *scene, *overlay; // handles to specific Layers 12 | Snaplay *snaplay; 13 | Gridlay *gridlay; 14 | Thumblay *thumblay; 15 | Listlay *listlay; 16 | 17 | int zoom, // zoom value, DRZOOMINIT compatible 18 | modeInvalidate; // invalidation mode 19 | Bitmap *bmpScene, // last rendered scene bitmap 20 | *bmpInvalidate; // invalidate bitmap buffer 21 | Rect rectScene, // scene rectangle 22 | rectInvalidate; // invalidation rectangle 23 | bool fulldraw, // perform full redraw flag 24 | zoomdraw, // use zoom flag 25 | visAbout, // Overlays flags 26 | visManual, 27 | visThumbs, 28 | visList, 29 | isPreload; // transparency grid preloaded flag 30 | 31 | Pen *penSelection, // pen used for drawing selections 32 | *penDraw; // pen used for drawing draw paths 33 | GraphicsPath *drawpath; // draw path buffer 34 | 35 | public: 36 | Drawer(ChildCore *core); 37 | ~Drawer(); 38 | 39 | void paint(HDC hdc); 40 | void reset(Image *image); 41 | 42 | Layer *getTopmost(); 43 | Layer *getScene(); 44 | Overlay *getOverlay(); 45 | Thumblay *getThumblay(); 46 | Listlay *getListlay(); 47 | RECT getClientSize(); 48 | 49 | Rect getRectScene(); 50 | Bitmap *getBmpScene(); 51 | 52 | Point getCenter(); 53 | 54 | double getZoom(); 55 | 56 | void updateOverlay(); 57 | 58 | void hideOverlay(bool invalid = true); 59 | void showAbout(); 60 | void showManual(); 61 | void showThumbs(); 62 | void showList(); 63 | 64 | bool isAbout(); 65 | bool isManual(); 66 | bool isThumbs(); 67 | bool isList(); 68 | 69 | void setMenuheight(int val = 0); 70 | void invalidate(bool full = true); 71 | void invalidate(Rect *rect, Bitmap *bmp, int mode = INVDEF, bool full = false); 72 | 73 | void zoomer(double val); 74 | void zoomSet(double val); 75 | void zoomReset(); 76 | 77 | void scroll(int x, int y); 78 | void scrollSet(int x, int y); 79 | void scrollPinpoint(int x, int y); 80 | 81 | void setDrawpath(GraphicsPath *path, bool zoom = true, bool invalidate = true); 82 | void setDrawpenSize(int size); 83 | void setDrawpenStyle(DashStyle style = DashStyleSolid); 84 | 85 | void preloadBackground(Layer *lay); 86 | 87 | bool renderBackground(Graphics *scenegfx, double zoom = 1.0, bool supress = false); 88 | bool renderBackground(Graphics *scenegfx, Rect rect); 89 | 90 | static void setInterpolation(Graphics *g, double zoom = ZOOMINIT); 91 | static void setHQInterpolation(Graphics *g, double zoom = ZOOMINIT); 92 | 93 | private: 94 | 95 | void renderGraphicsPath(Bitmap *scene, GraphicsPath *path, Pen *pen, int hatch = NULL, bool zoom = true, bool zoomround = true); 96 | void renderSelection(Bitmap *scene); 97 | void renderDraw(Bitmap *scene); 98 | }; -------------------------------------------------------------------------------- /Fiew/Exp_File.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Exp_File.cpp 3 | Inherited from Fiew 2.0 4 | Represents the filesystem file as an object. 5 | It is the smallest entity in Fedit Explorer. 6 | */ 7 | 8 | #include "stdafx.h" 9 | #include "Core.h" 10 | 11 | File::File(FwCHAR *path, int type, DWORD size, bool archived) 12 | { 13 | this->filepath = path; 14 | 15 | this->filename = new FwCHAR(); 16 | this->filename->getFilenameFrom(this->filepath); 17 | 18 | this->size = size; 19 | this->archived = archived; 20 | 21 | if( type == UNDEFINED ) 22 | this->type = Explorer::getType(this->filepath); 23 | else 24 | this->type = type; 25 | 26 | this->mime = Explorer::getMime(this->type); 27 | } 28 | 29 | File::~File() 30 | { 31 | delete this->filepath; 32 | delete this->filename; 33 | } 34 | 35 | void File::initSort(int sort) 36 | { 37 | return; 38 | } 39 | 40 | FwCHAR *File::getFilePath() 41 | { 42 | return this->filepath; 43 | } 44 | 45 | FwCHAR *File::getFileName() 46 | { 47 | return this->filename; 48 | } 49 | 50 | int File::getType() 51 | { 52 | return this->type; 53 | } 54 | 55 | int File::getMime() 56 | { 57 | return this->mime; 58 | } 59 | 60 | DWORD File::getSize() 61 | { 62 | return this->size; 63 | } 64 | 65 | bool File::isArchived() 66 | { 67 | return this->archived; 68 | } -------------------------------------------------------------------------------- /Fiew/Exp_Folder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Exp_Folder.cpp 3 | Inherited from Fiew 2.0 4 | Class inherits from File. Represents the filesystem folder 5 | as an object. Enables standard file browsing operations. 6 | */ 7 | 8 | #include "stdafx.h" 9 | #include "Core.h" 10 | 11 | Catalog::Catalog(FwCHAR *path, int type, DWORD size) : File(path,type,size) 12 | { 13 | this->sortSide = HEADSORT; 14 | this->count = NULL; 15 | this->idx = NULL; 16 | 17 | this->mut_list = NULL; 18 | this->mut_loop = NULL; 19 | this->mut_step = NULL; 20 | this->mut_terminator = NULL; 21 | 22 | this->thrd_sorting = NULL; 23 | 24 | this->files = new List(); 25 | this->init(); 26 | } 27 | 28 | Catalog::Catalog(FwCHAR *path, FwCHAR *filepath, int type) : File(path,type) 29 | { 30 | this->sortSide = HEADSORT; 31 | this->count = NULL; 32 | this->idx = NULL; 33 | 34 | this->mut_list = NULL; 35 | this->mut_loop = NULL; 36 | this->mut_step = NULL; 37 | this->mut_terminator = NULL; 38 | 39 | this->thrd_sorting = NULL; 40 | 41 | this->files = new List(); 42 | this->init(filepath); 43 | } 44 | 45 | Catalog::~Catalog() 46 | { 47 | if( WaitForSingleObject(this->mut_loop,0) == WAIT_TIMEOUT ){ 48 | ReleaseMutex(this->mut_terminator); 49 | WaitForSingleObject(this->mut_loop,INFINITE); 50 | } 51 | if( this->mut_terminator != NULL ) 52 | CloseHandle(this->mut_terminator); 53 | if( this->mut_step != NULL ) 54 | CloseHandle(this->mut_step); 55 | if( this->mut_loop != NULL ) 56 | CloseHandle(this->mut_loop); 57 | if( this->mut_list != NULL ) 58 | CloseHandle(this->mut_list); 59 | 60 | if( this->thrd_sorting != NULL ) 61 | CloseHandle(this->thrd_sorting); 62 | 63 | delete this->files; 64 | } 65 | 66 | void Catalog::init(FwCHAR *thatpath) 67 | { 68 | if( this->getMime() == MIME_ARCHIVE ) 69 | return; 70 | 71 | WIN32_FIND_DATA FFdata; 72 | HANDLE hFind = INVALID_HANDLE_VALUE; 73 | 74 | FwCHAR *folder = new FwCHAR( this->getFilePath()->toWCHAR() ); 75 | folder->mergeWith(DIRMERGE); 76 | 77 | hFind = FindFirstFile(folder->toWCHAR(),&FFdata); 78 | 79 | if( hFind != INVALID_HANDLE_VALUE ){ 80 | File *that = NULL; 81 | FwCHAR *file = new FwCHAR(this->getFilePath()->toWCHAR() ); 82 | file->mergeWith(FFdata.cFileName); 83 | 84 | int type = Explorer::getType(file); 85 | int mime = Explorer::getMime(type); 86 | DWORD size = (FFdata.nFileSizeHigh * (MAXDWORD + 1)) + FFdata.nFileSizeLow; 87 | 88 | if( mime == MIME_IMAGE ) 89 | this->files->add( that = new File(file,type,size) ); 90 | else if( mime == MIME_ARCHIVE ) 91 | this->files->add( that = new Archive(file,type,size) ); 92 | else 93 | delete file; 94 | 95 | if( thatpath != NULL && that != NULL ){ 96 | if( that->getFilePath()->equals(thatpath) ) 97 | this->files->setThat(that); 98 | that = NULL; 99 | } 100 | while( FindNextFile(hFind,&FFdata) ){ 101 | file = new FwCHAR(this->getFilePath()->toWCHAR() ); 102 | file->mergeWith(FFdata.cFileName); 103 | 104 | type = Explorer::getType(file); 105 | mime = Explorer::getMime(type); 106 | size = (FFdata.nFileSizeHigh * (MAXDWORD + 1)) + FFdata.nFileSizeLow; 107 | 108 | if( mime == MIME_IMAGE ) 109 | this->files->add( that = new File(file,type,size) ); 110 | else if( mime == MIME_ARCHIVE ) 111 | this->files->add( that = new Archive(file,type,size) ); 112 | else 113 | delete file; 114 | 115 | if( thatpath != NULL && that != NULL ){ 116 | if( that->getFilePath()->equals(thatpath) ) 117 | this->files->setThat(that); 118 | that = NULL; 119 | } 120 | } 121 | FindClose(hFind); 122 | this->idx = this->files->countLeftoThat(); 123 | } 124 | delete folder; 125 | } 126 | 127 | int Catalog::getCount() 128 | { 129 | int count = 0; 130 | 131 | File *that = this->getFiles()->getThat(); 132 | if( that != NULL ) 133 | if( that->getMime() == MIME_ARCHIVE ) 134 | count = ((Archive *)that)->getCount(); 135 | if( count <= 0 ) 136 | count = this->getFiles()->getCount(); 137 | 138 | return count; 139 | } 140 | 141 | List *Catalog::getFiles() 142 | { 143 | return this->files; 144 | } 145 | 146 | int Catalog::getIdx() 147 | { 148 | int idx = this->idx; 149 | 150 | File *that = this->getFiles()->getThat(); 151 | if( that != NULL ) 152 | if( that->getMime() == MIME_ARCHIVE ) 153 | idx = ((Archive *)that)->getIdx(); 154 | 155 | return idx; 156 | } 157 | 158 | void Catalog::list(Core *core) 159 | { 160 | this->getFiles()->gotoHead(); 161 | do { 162 | core->messageBox_Info(this->getFiles()->getThat()->getFilePath()->toWCHAR()); 163 | } while( this->getFiles()->next() ); 164 | } 165 | 166 | DWORD WINAPI Catalog::trigSort(LPVOID param) 167 | { 168 | 169 | Catalog *that = (Catalog *)param; 170 | File *right = NULL; 171 | File *left = NULL; 172 | int count = 1; 173 | 174 | WaitForSingleObject(that->mut_loop,INFINITE); 175 | do { 176 | if( WaitForSingleObject(that->mut_terminator,0) != WAIT_TIMEOUT ){ 177 | ReleaseMutex(that->mut_terminator); 178 | ReleaseMutex(that->mut_loop); 179 | return 0; 180 | } 181 | WaitForSingleObject(that->mut_step,INFINITE); 182 | 183 | left = that->getFiles()->getLeftoThat(count); 184 | right = that->getFiles()->getRightoThat(count); 185 | 186 | if( left != NULL ) 187 | left->initSort(); 188 | if( right != NULL ) 189 | right->initSort(); 190 | count++; 191 | 192 | ReleaseMutex(that->mut_step); 193 | 194 | } while( left != NULL || right != NULL ); 195 | ReleaseMutex(that->mut_loop); 196 | 197 | return 0; 198 | } 199 | 200 | void Catalog::initSort(int sort) 201 | { 202 | 203 | this->mut_list = CreateMutex(NULL,false,NULL); 204 | this->mut_loop = CreateMutex(NULL,false,NULL); 205 | this->mut_step = CreateMutex(NULL,false,NULL); 206 | this->mut_terminator = CreateMutex(NULL,true,NULL); 207 | 208 | this->sortSide = sort; 209 | 210 | this->getFiles()->getThat()->initSort(sort); 211 | 212 | this->thrd_sorting = CreateThread(NULL,NULL, 213 | (LPTHREAD_START_ROUTINE)&Catalog::trigSort, 214 | this,NULL,NULL); 215 | 216 | } 217 | 218 | bool Catalog::next(int id) 219 | { 220 | if( this->getFiles()->getCount() <= 0 ) 221 | return false; 222 | 223 | this->sortSide = HEADSORT; 224 | 225 | File *that = this->getFiles()->getThat(); 226 | if( id == LEFT ) 227 | that = this->getFiles()->getLeft(); 228 | else if( id == RIGHT ) 229 | that = this->getFiles()->getRight(); 230 | bool result = false; 231 | 232 | if( that == NULL ) 233 | return result; 234 | 235 | if( that->getMime() == MIME_ARCHIVE ){ 236 | Archive *arch = (Archive *)that; 237 | result = arch->next(id); 238 | } 239 | if( result == false ) 240 | result = this->getFiles()->next(id); 241 | else 242 | return result; 243 | 244 | if( result == true && id == NULL ) 245 | this->idx++; 246 | 247 | return result; 248 | } 249 | 250 | bool Catalog::prev(int id) 251 | { 252 | if( this->getFiles()->getCount() <= 0 ) 253 | return false; 254 | 255 | this->sortSide = TAILSORT; 256 | 257 | File *that = this->getFiles()->getThat(); 258 | if( id == LEFT ) 259 | that = this->getFiles()->getLeft(); 260 | else if( id == RIGHT ) 261 | that = this->getFiles()->getRight(); 262 | bool result = false; 263 | 264 | if( that == NULL ) 265 | return result; 266 | 267 | if( that->getMime() == MIME_ARCHIVE ){ 268 | Archive *arch = (Archive *)that; 269 | result = arch->prev(id); 270 | } 271 | if( result == false ) 272 | result = this->getFiles()->prev(id); 273 | else 274 | return result; 275 | 276 | if( result == true && id == NULL ) 277 | this->idx--; 278 | 279 | return result; 280 | } 281 | 282 | Cell *Catalog::load(int id) 283 | { 284 | if( this->getFiles()->getCount() <= 0 ) 285 | return NULL; 286 | 287 | File *that = this->getFiles()->getThat(); 288 | if( id == LEFT ) 289 | that = this->getFiles()->getLeft(); 290 | else if( id == RIGHT ) 291 | that = this->getFiles()->getRight(); 292 | 293 | if( that == NULL ) 294 | return NULL; 295 | 296 | if( that->getMime() == MIME_ARCHIVE ){ 297 | Archive *arch = (Archive *)that; 298 | arch->initSort(this->sortSide); 299 | 300 | if( arch->getCount() <= 0 ){ 301 | delete this->getFiles()->remove(that); 302 | return this->load(id); 303 | } 304 | return arch->load(id); 305 | } 306 | Cell *cell = new Cell(that); 307 | 308 | if( cell->isLoaded() ) 309 | return cell; 310 | 311 | return NULL; 312 | } 313 | 314 | bool Catalog::isThatHead() 315 | { 316 | bool result = this->getFiles()->isThatHead(); 317 | 318 | if( result == true ){ 319 | File *that = this->getFiles()->getThat(); 320 | if( that != NULL ) 321 | if( that->getMime() == MIME_ARCHIVE ){ 322 | Archive *arch = (Archive *)that; 323 | result = arch->isThatHead(); 324 | } 325 | } 326 | return result; 327 | } 328 | bool Catalog::isThatTail() 329 | { 330 | bool result = this->getFiles()->isThatTail(); 331 | 332 | if( result == true ){ 333 | File *that = this->getFiles()->getThat(); 334 | if( that != NULL ) 335 | if( that->getMime() == MIME_ARCHIVE ){ 336 | Archive *arch = (Archive *)that; 337 | result = arch->isThatTail(); 338 | } 339 | } 340 | return result; 341 | } -------------------------------------------------------------------------------- /Fiew/Explorer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Explorer.cpp 3 | Fedit file browser that enables browsing of folders and archive files. 4 | Browsing is based on file headers and file extensions. Browsing is 5 | different depending of opened file: 6 | 1. normal file - browses through all files in that file folder, including archives 7 | 2. folder - browses through all files in that folder, including archives 8 | 3. archive - browses through all files in that archive, 9 | excluding files in the folder that archive exists, 10 | and excluding any archive files inside that archive 11 | */ 12 | 13 | #include "stdafx.h" 14 | #include "Core.h" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #define BUFLEN 10 22 | 23 | // files header information 24 | char szTiffHeaderForMotorola[] = "MM*"; 25 | char szTiffHeaderForIntel[] = "II*"; 26 | char szPNGHeader[] = "\x89PNG\r\n\x1a\n"; 27 | char szGIF87aHeader[] = "GIF87a"; 28 | char szGIF89aHeader[] = "GIF89a"; 29 | char szJPEGCommonHeader[] = "\xFF\xD8\xFF"; 30 | char szJPEGCommonEOI[] = "\xFF\xD9"; // for future use 31 | char szBMPHeader[] = "\x42\x4D"; 32 | 33 | char szZIPHeader[] = "\x50\x4b\x03\x04"; 34 | char szRARHeader[] = "Rar"; 35 | 36 | Explorer::Explorer(Core *core) 37 | { 38 | this->core = core; 39 | this->root = NULL; 40 | } 41 | 42 | Explorer::~Explorer() 43 | { 44 | if( this->root != NULL ) 45 | delete this->root; 46 | } 47 | 48 | bool Explorer::browse(FwCHAR *path) 49 | { 50 | int type = Explorer::getType(path); 51 | int mime = Explorer::getMime(type); 52 | Catalog *tmp = NULL; 53 | 54 | if( mime == MIME_ARCHIVE ){ 55 | tmp = new Archive(path,type); 56 | tmp->initSort(); 57 | } 58 | else if( mime == MIME_DIR ){ 59 | if( path->toWCHAR()[path->toLength()] != '\\' ) 60 | path->mergeWith(L"\\"); 61 | tmp = new Catalog(path); 62 | } 63 | else if( mime == MIME_IMAGE ){ 64 | FwCHAR *folder = new FwCHAR(); 65 | folder->getFolderFrom(path); 66 | 67 | tmp = new Catalog(folder,path); 68 | } 69 | 70 | if( tmp != NULL ){ 71 | if( tmp->getCount() <= 0 ){ 72 | FwCHAR *notice = new FwCHAR(MESSAGE_EMPTY); 73 | notice->mergeWith(GUI_SEP); 74 | notice->mergeWith(tmp->getFilePath()->toWCHAR()); 75 | 76 | this->core->messageBox_Info( notice->toWCHAR() ); 77 | 78 | delete notice; 79 | delete tmp; 80 | } 81 | else { 82 | this->reset(); 83 | this->root = tmp; 84 | return true; 85 | } 86 | } 87 | return false; 88 | } 89 | 90 | Catalog *Explorer::getRoot() 91 | { 92 | return this->root; 93 | } 94 | 95 | FwCHAR *Explorer::getArchivePath() 96 | { 97 | FwCHAR *path = NULL; 98 | Archive *archive = this->getArchive(); 99 | if( archive != NULL ) 100 | path = archive->getFilePath(); 101 | return path; 102 | } 103 | 104 | void Explorer::reset() 105 | { 106 | if( this->root != NULL ) 107 | delete this->root; 108 | this->root = NULL; 109 | } 110 | 111 | bool Explorer::extract() 112 | { 113 | bool result = false; 114 | 115 | Archive *archive = this->getArchive(); 116 | if( archive != NULL ) 117 | result = archive->extract(); 118 | return result; 119 | } 120 | 121 | int Explorer::getMime(FwCHAR *path) 122 | { 123 | return Explorer::getMime( Explorer::getType(path) ); 124 | } 125 | 126 | int Explorer::getMime(int type) 127 | { 128 | if( type == TYPE_NONE ) 129 | return MIME_NONE; 130 | else if( type == TYPE_ZIP || type == TYPE_RAR ) 131 | return MIME_ARCHIVE; 132 | else if( type == TYPE_DIR ) 133 | return MIME_DIR; 134 | else 135 | return MIME_IMAGE; 136 | 137 | return MIME_NONE; 138 | } 139 | 140 | int Explorer::getType(FwCHAR *path) 141 | { 142 | DWORD fileAtt = GetFileAttributes(path->toWCHAR()); 143 | if( fileAtt == INVALID_FILE_ATTRIBUTES ) 144 | return TYPE_NONE; 145 | 146 | if( fileAtt & FILE_ATTRIBUTE_DIRECTORY ) 147 | return TYPE_DIR; 148 | 149 | int file; 150 | char pData[BUFLEN]; 151 | 152 | file = _wopen(path->toWCHAR(),_O_BINARY); 153 | if( file == FERROR ) 154 | return TYPE_NONE; 155 | 156 | _read(file,pData,BUFLEN); 157 | _close(file); 158 | 159 | if (!memcmp(pData, szTiffHeaderForIntel,3)) 160 | return TYPE_TIFFINTEL; 161 | else if (!memcmp(pData, szTiffHeaderForMotorola,3)) 162 | return TYPE_TIFFMOTOROLA; 163 | else if (!memcmp(pData, szPNGHeader,8)) 164 | return TYPE_PNG; 165 | else if (!memcmp(pData, szGIF87aHeader,6)) 166 | return TYPE_GIF87a; 167 | else if (!memcmp(pData, szGIF89aHeader,6)) 168 | return TYPE_GIF89a; 169 | else if (!memcmp(pData, szZIPHeader,4)) 170 | return TYPE_ZIP; 171 | else if (!memcmp(pData, szRARHeader,3)) 172 | return TYPE_RAR; 173 | else if (!memcmp(pData, szBMPHeader,2)) 174 | { 175 | // 7 to ten byte must be zero 176 | // 3 to 6 is size of image 177 | char szNull[] = "\x0\x0\x0\x0"; 178 | if (!memcmp(pData+6, szNull,4)) 179 | return TYPE_BITMAP; 180 | } 181 | else if (!memcmp(pData, szJPEGCommonHeader,3)) 182 | { 183 | switch (((long)*(pData+3)) & 0xFF) 184 | { 185 | case 0xE0: 186 | return TYPE_JPEGJFIF; 187 | break; 188 | case 0xE1: 189 | return TYPE_JPEGEXIF; 190 | break; 191 | case 0xE2: 192 | return TYPE_JPEGAPP2; 193 | break; 194 | case 0xE3: 195 | return TYPE_JPEGAPP3; 196 | break; 197 | case 0xE4: 198 | return TYPE_JPEGAPP4; 199 | break; 200 | case 0xE5: 201 | return TYPE_JPEGAPP5; 202 | break; 203 | case 0xE6: 204 | return TYPE_JPEGAPP6; 205 | break; 206 | case 0xE7: 207 | return TYPE_JPEGAPP7; 208 | break; 209 | case 0xE8: 210 | return TYPE_JPEGAPP8; 211 | break; 212 | case 0xE9: 213 | return TYPE_JPEGAPP9; 214 | break; 215 | case 0xEA: 216 | return TYPE_JPEGAPPA; 217 | break; 218 | case 0xEB: 219 | return TYPE_JPEGAPPB; 220 | break; 221 | case 0xEC: 222 | return TYPE_JPEGAPPC; 223 | break; 224 | case 0xED: 225 | return TYPE_JPEGAPPD; 226 | break; 227 | case 0xEE: 228 | return TYPE_JPEGAPPE; 229 | break; 230 | case 0xEF: 231 | return TYPE_JPEGAPPF; 232 | break; 233 | default: 234 | break; 235 | } 236 | } 237 | return TYPE_NONE; 238 | } 239 | 240 | int Explorer::getType(WCHAR *name) 241 | { 242 | WCHAR *ext = new WCHAR[10]; 243 | int i = 0; 244 | int type = TYPE_NONE; 245 | 246 | while( name[i] != '\0' ) i++; 247 | while( name[i] != '.' && i > 0 ) i--; 248 | 249 | int j=0; 250 | while( name[i] != '\0' && j < 9 ) 251 | ext[j++] = name[i++]; 252 | ext[j] = '\0'; 253 | 254 | if( !_wcsicmp(ext,L".jpeg") || !_wcsicmp(ext,L".jpg") ) 255 | type = TYPE_JPG; 256 | else if( !_wcsicmp(ext,L".gif") ) 257 | type = TYPE_GIF; 258 | else if( !_wcsicmp(ext,L".tif") || !_wcsicmp(ext,L".tiff") ) 259 | type = TYPE_TIFF; 260 | else if( !_wcsicmp(ext,L".png") ) 261 | type = TYPE_PNG; 262 | else if( !_wcsicmp(ext,L".bmp") ) 263 | type = TYPE_BITMAP; 264 | else if( !_wcsicmp(ext,L".fed") ) 265 | type = TYPE_FED; 266 | else if( !_wcsicmp(ext,L".ico") ) 267 | type = TYPE_ICO; 268 | 269 | else if( !_wcsicmp(ext,L".rar") || !_wcsicmp(ext,L".cbr") ) 270 | type = TYPE_RAR; 271 | else if( !_wcsicmp(ext,L".zip") || !_wcsicmp(ext,L".cbz") ) 272 | type = TYPE_ZIP; 273 | 274 | delete [] ext; 275 | return type; 276 | } 277 | 278 | bool Explorer::isArchived() 279 | { 280 | bool result = false; 281 | if( this->getArchive() != NULL ) 282 | result = true; 283 | return result; 284 | } 285 | 286 | Archive *Explorer::getArchive() 287 | { 288 | Archive *archive = NULL; 289 | if( this->root != NULL ){ 290 | if( this->root->getMime() == MIME_ARCHIVE ) 291 | archive = (Archive *)this->root; 292 | else if( this->root->getFiles() != NULL ) 293 | if( this->root->getFiles()->getCount() > 0 ) 294 | if( this->root->getFiles()->getThat()->getMime() == MIME_ARCHIVE ) 295 | archive = (Archive *)this->root->getFiles()->getThat(); 296 | } 297 | return archive; 298 | } -------------------------------------------------------------------------------- /Fiew/Explorer.h: -------------------------------------------------------------------------------- 1 | #define UNDEFINED -1 2 | 3 | class FwCHAR; 4 | class Core; 5 | class Cell; 6 | 7 | class File 8 | { 9 | protected: 10 | FwCHAR *filepath; // file path 11 | FwCHAR *filename; // file name 12 | int type; // file type 13 | int mime; // file MIME type 14 | DWORD size; // file raw data size 15 | bool archived; // is archived flag 16 | 17 | public: 18 | File(FwCHAR *path, int type = UNDEFINED, DWORD size = NULL, bool archived = false); 19 | virtual ~File(); 20 | 21 | virtual void initSort(int sort = HEADSORT); 22 | 23 | FwCHAR *getFilePath(); 24 | FwCHAR *getFileName(); 25 | 26 | int getType(); 27 | int getMime(); 28 | DWORD getSize(); 29 | 30 | bool isArchived(); 31 | }; 32 | 33 | class Catalog : public File 34 | { 35 | protected: 36 | List *files; // list of files in that folder 37 | 38 | int sortSide; // sorting side, either left-to-right or backwards 39 | int count; // number of sorted files 40 | int idx; // current index 41 | 42 | HANDLE mut_list, mut_loop, mut_step, mut_terminator; 43 | HANDLE thrd_sorting; 44 | 45 | public: 46 | Catalog(FwCHAR *path, int type = UNDEFINED, DWORD size = NULL); 47 | Catalog(FwCHAR *path, FwCHAR *filepath, int type = UNDEFINED); 48 | virtual ~Catalog(); 49 | 50 | virtual void init(FwCHAR *thatpath = NULL); 51 | virtual void initSort(int sort = HEADSORT); 52 | 53 | virtual bool next(int id = NULL); 54 | virtual bool prev(int id = NULL); 55 | 56 | virtual Cell *load(int id = NULL); 57 | 58 | virtual bool isThatHead(); 59 | virtual bool isThatTail(); 60 | 61 | virtual int getCount(); 62 | List *getFiles(); 63 | int getIdx(); 64 | 65 | virtual void list(Core *core); 66 | 67 | static DWORD WINAPI trigSort(LPVOID param); 68 | }; 69 | 70 | class Archive : public Catalog 71 | { 72 | private: 73 | XUn *pack; 74 | List *unsortedFiles; 75 | 76 | HANDLE sem_sorted; 77 | bool sorted, terminate; 78 | 79 | public: 80 | Archive(FwCHAR *path, int type = UNDEFINED, DWORD size = NULL); 81 | ~Archive(); 82 | 83 | void init(FwCHAR *thatpath = NULL); 84 | void initSort(int sort = HEADSORT); 85 | 86 | List *getUnsortedFiles(); 87 | int getCount(); 88 | 89 | void setSorted(); 90 | bool isSorted(); 91 | 92 | bool extract(); 93 | bool extract(File *file); 94 | void list(Core *core); 95 | 96 | bool next(int id = NULL); 97 | bool prev(int id = NULL); 98 | 99 | Cell *load(int id = NULL); 100 | 101 | bool isThatHead(); 102 | bool isThatTail(); 103 | 104 | static DWORD WINAPI sort(LPVOID param); 105 | static DWORD WINAPI sortStep(LPVOID param); 106 | }; 107 | 108 | /* *** */ 109 | 110 | class Explorer 111 | { 112 | private: 113 | Core *core; 114 | 115 | Catalog *root; 116 | 117 | public: 118 | Explorer(Core *core); 119 | ~Explorer(); 120 | 121 | bool browse(FwCHAR *path); 122 | 123 | FwCHAR *getArchivePath(); 124 | Catalog *getRoot(); 125 | 126 | static int getMime(FwCHAR *path); 127 | static int getMime(int type); 128 | 129 | static int getType(FwCHAR *path); 130 | static int getType(WCHAR *name); 131 | 132 | void reset(); 133 | bool extract(); 134 | 135 | bool isArchived(); 136 | 137 | private: 138 | Archive *getArchive(); 139 | }; -------------------------------------------------------------------------------- /Fiew/Fedit.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Fedit.aps -------------------------------------------------------------------------------- /Fiew/Fedit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Fedit.cpp 3 | The standard template code of a window application 4 | */ 5 | 6 | #include "stdafx.h" 7 | #include "Core.h" 8 | 9 | using namespace Gdiplus; 10 | #pragma comment(lib,"gdiplus.lib") 11 | #pragma comment(lib,"comctl32.lib"); 12 | 13 | HINSTANCE hInst; 14 | ATOM MyRegisterClass(HINSTANCE hInstance); 15 | BOOL InitInstance(HINSTANCE, int); 16 | 17 | /* 18 | Application Core Object 19 | */ 20 | Core *Miracle; 21 | 22 | int APIENTRY _tWinMain(HINSTANCE hInstance, 23 | HINSTANCE hPrevInstance, 24 | LPTSTR lpCmdLine, 25 | int nCmdShow) 26 | { 27 | UNREFERENCED_PARAMETER(hPrevInstance); 28 | 29 | MSG msg; 30 | HACCEL hAccelTable; 31 | GdiplusStartupInput gdiplusStartupInput; 32 | ULONG_PTR gdiplusToken; 33 | 34 | Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); 35 | MyRegisterClass(hInstance); 36 | 37 | /* 38 | Application Core creation 39 | */ 40 | Miracle = new Core((WCHAR *)lpCmdLine,hInstance); 41 | 42 | if (!InitInstance (hInstance, nCmdShow)) 43 | { 44 | return FALSE; 45 | } 46 | 47 | hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATORS)); 48 | 49 | while(GetMessage(&msg, NULL, 0, 0)) 50 | { 51 | if (!TranslateMDISysAccel(Miracle->getMdiclientHandle(), &msg) && 52 | !TranslateAccelerator(Miracle->getWindowHandle(), hAccelTable, &msg) ) 53 | { 54 | TranslateMessage(&msg); 55 | DispatchMessage(&msg); 56 | } 57 | } 58 | delete Miracle; 59 | 60 | Gdiplus::GdiplusShutdown(gdiplusToken); 61 | return (int) msg.wParam; 62 | } 63 | 64 | ATOM MyRegisterClass(HINSTANCE hInstance) 65 | { 66 | WNDCLASSEX wcex; 67 | 68 | wcex.cbSize = sizeof(WNDCLASSEX); 69 | 70 | wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; 71 | wcex.lpfnWndProc = (WNDPROC) WndProc; 72 | wcex.cbClsExtra = 0; 73 | wcex.cbWndExtra = 0; 74 | wcex.hInstance = hInstance; 75 | wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FIEW)); 76 | wcex.hCursor = LoadCursor(NULL, IDC_ARROW); 77 | wcex.hbrBackground = NULL; 78 | wcex.lpszMenuName = NULL; 79 | wcex.lpszClassName = IDCL_FEDIT; 80 | wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); 81 | 82 | if( RegisterClassEx(&wcex) == NULL ) 83 | return NULL; 84 | 85 | // Register the Toolbar - Control Center 86 | wcex.style = CS_DBLCLKS; 87 | wcex.lpfnWndProc = (WNDPROC) ToolwCC::processMessages; 88 | wcex.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1; 89 | wcex.lpszClassName = IDCL_TOOLW_CC; 90 | 91 | if( RegisterClassEx(&wcex) == NULL ) 92 | return NULL; 93 | 94 | // Register the Toolbar - Control Center Popup 95 | wcex.style = CS_DBLCLKS; 96 | wcex.lpfnWndProc = (WNDPROC) ToolwCC::processPopups; 97 | wcex.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1; 98 | wcex.lpszClassName = IDCL_TOOLW_CCP; 99 | 100 | if( RegisterClassEx(&wcex) == NULL ) 101 | return NULL; 102 | 103 | // Register the Toolbar - Dock 104 | wcex.style = CS_DBLCLKS; 105 | wcex.lpfnWndProc = (WNDPROC) ToolwDock::processMessages; 106 | wcex.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1; 107 | wcex.lpszClassName = IDCL_TOOLW_DOCK; 108 | 109 | if( RegisterClassEx(&wcex) == NULL ) 110 | return NULL; 111 | 112 | // Register the Toolbar - Tool in Dock 113 | wcex.style = CS_DBLCLKS; 114 | wcex.lpfnWndProc = (WNDPROC) ToolwDock::processTools; 115 | wcex.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1; 116 | wcex.lpszClassName = IDCL_TOOLW_DKTL; 117 | 118 | if( RegisterClassEx(&wcex) == NULL ) 119 | return NULL; 120 | 121 | // Register the Toolbar - Box 122 | wcex.style = CS_DBLCLKS; 123 | wcex.lpfnWndProc = (WNDPROC) ToolwBox::processMessages; 124 | wcex.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1; 125 | wcex.lpszClassName = IDCL_TOOLW_BOX; 126 | 127 | if( RegisterClassEx(&wcex) == NULL ) 128 | return NULL; 129 | 130 | // Register the Toolbar - Box Contents 131 | wcex.style = CS_DBLCLKS; 132 | wcex.lpfnWndProc = (WNDPROC) ToolwBox::processContents; 133 | wcex.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1; 134 | wcex.lpszClassName = IDCL_TOOLW_BXCNT; 135 | 136 | if( RegisterClassEx(&wcex) == NULL ) 137 | return NULL; 138 | 139 | // Register the Toolbar - Scroll Frame 140 | wcex.style = CS_DBLCLKS; 141 | wcex.lpfnWndProc = (WNDPROC) ToolwBoxScroll::processMessages; 142 | wcex.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1; 143 | wcex.lpszClassName = IDCL_TOOLW_BXSCRL; 144 | 145 | if( RegisterClassEx(&wcex) == NULL ) 146 | return NULL; 147 | 148 | // Register the Toolbar - Scroll Content 149 | wcex.style = CS_DBLCLKS; 150 | wcex.lpfnWndProc = (WNDPROC) ToolwBoxScroll::processContents; 151 | wcex.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1; 152 | wcex.lpszClassName = IDCL_TOOLW_BXPANCNT; 153 | 154 | if( RegisterClassEx(&wcex) == NULL ) 155 | return NULL; 156 | 157 | // Register the Toolbar - Scroll Content 158 | wcex.style = CS_DBLCLKS; 159 | wcex.lpfnWndProc = (WNDPROC) ToolwBoxScroll::processContents; 160 | wcex.hbrBackground = (HBRUSH)(COLOR_BTNSHADOW + 1); 161 | wcex.lpszClassName = IDCL_TOOLW_BXSCRLCNT; 162 | 163 | if( RegisterClassEx(&wcex) == NULL ) 164 | return NULL; 165 | 166 | // Register the Tooltip 167 | wcex.style = CS_DBLCLKS; 168 | wcex.lpfnWndProc = (WNDPROC) Toolw::tooltipLabelProc; 169 | wcex.hbrBackground = (HBRUSH)(COLOR_BTNSHADOW + 1); 170 | wcex.lpszClassName = IDCL_FAKETOOLTIP; 171 | 172 | if( RegisterClassEx(&wcex) == NULL ) 173 | return NULL; 174 | 175 | // Register the MDI child window class. 176 | 177 | wcex.style = CS_DBLCLKS; 178 | wcex.lpfnWndProc = (WNDPROC) ChildCore::processMessages; 179 | wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FIEW)); 180 | wcex.hCursor = NULL; 181 | wcex.hbrBackground = NULL; 182 | wcex.lpszMenuName = NULL; 183 | wcex.cbWndExtra = MDI_EXTRADATA; 184 | wcex.lpszClassName = IDCL_MDICHILD; 185 | 186 | return RegisterClassEx(&wcex); 187 | } 188 | 189 | BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) 190 | { 191 | HWND hWnd; 192 | 193 | hInst = hInstance; 194 | 195 | hWnd = CreateWindowEx(WS_EX_ACCEPTFILES, 196 | IDCL_FEDIT, APP_TITLE, 197 | WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_MAXIMIZE, 198 | CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 199 | NULL, NULL, hInstance, NULL); 200 | 201 | if (!hWnd) 202 | { 203 | return FALSE; 204 | } 205 | ShowWindow(hWnd, nCmdShow | SW_SHOWMAXIMIZED); 206 | UpdateWindow(hWnd); 207 | 208 | return TRUE; 209 | } 210 | /* 211 | Window procedures redirected to respective procedures of the Core object 212 | */ 213 | LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 214 | { 215 | return Miracle->processMessages(hWnd,message,wParam,lParam); 216 | } 217 | 218 | LRESULT CALLBACK MdiProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 219 | { 220 | return Miracle->processMdiMessages(hWnd,message,wParam,lParam); 221 | } -------------------------------------------------------------------------------- /Fiew/Fedit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | 5 | #include "FeditEssentials.h" 6 | #include "FeditConfigs.h" 7 | #include "FeditLocale.h" 8 | -------------------------------------------------------------------------------- /Fiew/Fedit.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Fedit.ico -------------------------------------------------------------------------------- /Fiew/FeditConfigs.h: -------------------------------------------------------------------------------- 1 | /* 2 | FeditCofigs.h 3 | Contains all configurable variables, that is they can be changed 4 | without interfering the workflow of the application 5 | */ 6 | 7 | /* confs */ 8 | #define DEBUG // unused 9 | //#define DISKCACHING // force Cacher to copy all data to memory instead of reading from disk files 10 | 11 | #define FONT L"Arial" // unused 12 | #define FILE_EXT L".fed" // default Fedit Document extension 13 | #define FONT_STATIC L"MS Shell Dlg" // default interface font 14 | #define FONTSIZE 11 // unused 15 | #define FONTSIZE_STATIC 8 // default interface font size 16 | #define DIRMERGE L"\\*" // dorectory browse all symbol 17 | 18 | #define STGWSPC L"0" // object identifiers of compound file 19 | #define STGINFO L"I" // that is used to create a .fed file 20 | #define STGDATA L"D" // D - layer data 21 | #define STGI 'I' // I - layer info 22 | #define STGD 'D' 23 | 24 | #define TIPTOUT 600 // tooltip timeout in milliseconds 25 | 26 | #define HISTHUMBSIZE 22 // History Window icon size 27 | 28 | #define GAUSSMAX 2 // Gaussian Blur maximal value 29 | #define SHARPENMAX 10 // Sharpen filter maximal value 30 | #define FILTERMAX 30 // Defined filter matrix maximal value 31 | 32 | #define MATRIXMIN -50 // Custom filter matrix limit values 33 | #define MATRIXMAX 50 34 | 35 | #define LASTITEMS 7 // number of recently opened files in menu 36 | 37 | #define ADD 1 38 | #define REMOVE 2 39 | 40 | #define LAYNAMEMARGIN 10 // Layers Window margin 41 | #define LAYTHUMBSIZE 40 // Layers Window thumbnail size 42 | 43 | #define IDJUMP 10 // identifier jump for list windows 44 | // like Layers of History, 45 | // each controls in one row of the list 46 | // are identified in the following way: 47 | // first id is a multiplication of IDJUMP 48 | // next ones are: first id + i, where i > 0 && i < IDJUMP 49 | // thus the row number of any processed control 50 | // can be obtaines by control id % IDJUMP 51 | 52 | #define MAXFONTSIZE 1000 // maximum font size of ToolText 53 | #define MAXOPACITY 100 // maximum layer opacity 54 | 55 | #define MAX_WIDTH 10000 // maximum document width 56 | #define MAX_HEIGHT 10000 // maximum document height 57 | 58 | #define TW_BX_MINW 200 // TW_ define various Tool Windows 59 | #define TW_BX_MINH 150 // properties of display 60 | 61 | #define TW_CC_POPTOUT 500 // time needed to hold the button on Control Center 62 | // in order to a switcher popup to appear 63 | 64 | #define TW_CC_SEP 2 // thickness of Control Center separator 65 | #define TW_CC_BUTW 25 // witdth of Control Center buttons 66 | #define TW_CC_BUTH 21 // height of Control Center buttons 67 | 68 | #define TW_DOCK_TOPMARGIN 5 // margin for contents in the Dock Window 69 | #define TW_DOCK_BOTMARGIN 5 70 | #define TW_DOCK_LEFTMARGIN 5 71 | 72 | #define TW_DOCK_W 800 // Dock Window default width 73 | #define TW_DOCK_H 35 // Dock Window default height 74 | #define TW_DOCK_DKGRAB 10 // Dock Window grabbing distance needed to undock 75 | #define TW_DOCK_UDKGRAB 15 // Dock Window docking distance need to dock 76 | 77 | #define TWPOS_CC 100 // Default Control Center position 78 | #define TWPOS_DOCK 75 // Default Dock Window position when initialised undocked 79 | 80 | #define MINCHISIZE 150 // minimal child size 81 | 82 | #define CHIPADDING 50 // child windows top-left padding on screen 83 | #define CHIPADMULTI 15 // child windows padding modificator for concurrent children 84 | #define CHICTRLIMIT 10 // child windows limit of padding reset 85 | 86 | #define INIT_TOUT 10 // initial timeout 87 | 88 | #define RC_DLL L"DLL" // resource identifier 89 | #define RC_PNG L"PNG" // resource identifier 90 | #define RARDLL L"unrar.dll" // resource on-disk name 91 | 92 | #define CACHE_SIZE 20 // Cacher object size 93 | #define CACHE_LIMIT 10 // Cacher limit - at any moment, stores only LIMIT number 94 | // of objects before and after the current object 95 | 96 | #define MARGIN 20 // default margin 97 | #define FRAME 2 // default frame thickness 98 | 99 | #define SCROLLSTEP 10 // scrolling step 100 | 101 | #define GRDBGBLOCK 10 // transparency grid block size 102 | 103 | #define DRZOOMINIT 100 // initial zoom in integer values 104 | #define DRZOOMLOSTEP 20 // zoom step below initial zoom 105 | #define DRZOOMHISTEP 100 // zoom step above initial zoom 106 | 107 | #define ZOOMHISTEP 1.0 // initial zoom in double values 108 | #define ZOOMLOSTEP 0.2 // zoom step below initial zoom 109 | #define ZOOMINIT 1.0 // zoom step above initial zoom 110 | 111 | #define ZOOMTOOLIMIT 3 // miniaml size of zoom tool slecting rectangle 112 | 113 | #define MINDELAY 50 // minimal thread delay 114 | 115 | #define CURSOR_CLIENT IDC_ARROW 116 | #define CURSOR_SCROLL IDC_SIZEALL 117 | #define CURSOR_WAIT IDC_WAIT 118 | #define CURSOR_ARRWAIT IDC_APPSTARTING 119 | #define CURSOR_HAND IDC_HAND 120 | 121 | #define CURSOR_HIDE 2000 // cursor hide timout 122 | #define MOUSE_BLOCK 200 // mouse buttons block timeout 123 | #define SCROLL_TOUT 50 // scroll timeout 124 | #define OVL_HIDEOUT 100 // unused 125 | 126 | #define SCROLL_DIV 3.0 127 | 128 | #define OVL_SIZE 650 // overlay size 129 | #define OVL_MARGIN 30 // overlay margin 130 | 131 | #define THB_SIZE 165 // thumbnail view selected thumbnail size 132 | #define THB_SMSIZE 110 // thumbnail view thumbnail size 133 | #define THB_SPACE 10 // thumbnail view separation distnace 134 | #define THB_ROW 5 // thumbnail view number of rows 135 | #define THB_COUNT 12 // thumbnail view number of thumbnails 136 | #define THB_TOUT 500 // thumbnail view progress indicator timeout 137 | 138 | #define LST_X 5 // values for list view (unused) 139 | #define LST_Y 30 140 | #define LST_MAXLEN 96 141 | #define LST_MOD 5 142 | 143 | // application defined colors 144 | 145 | #define MAKECLR(dword) (Color(GetRValue(dword),GetGValue(dword),GetBValue(dword))) 146 | #define MAKEALPHA(alpha,dword) (Color(alpha,GetRValue(dword),GetGValue(dword),GetBValue(dword))) 147 | 148 | #define CLR_BLACK Color(255,0,0,0) 149 | #define CLR_WHITE Color(255,255,255,255) 150 | #define CLR_WHITE_ALPHA Color(175,255,255,255) 151 | #define CLR_FRAME_LIGHT MAKECLR(GetSysColor(COLOR_BTNFACE)) 152 | #define CLR_FRAME_DARK MAKECLR(GetSysColor(COLOR_BTNSHADOW)) 153 | #define CLR_LITE MAKEALPHA(200,GetSysColor(COLOR_BTNFACE)) 154 | #define CLR_DIRK MAKEALPHA(200,GetSysColor(COLOR_BTNSHADOW)) 155 | #define CLR_CAPTION_ACTIV MAKECLR(GetSysColor(COLOR_ACTIVECAPTION)) 156 | #define CLR_CAPTION_GRAD MAKECLR(GetSysColor(COLOR_GRADIENTACTIVECAPTION)) 157 | -------------------------------------------------------------------------------- /Fiew/FeditEssentials.h: -------------------------------------------------------------------------------- 1 | /* 2 | FeditEssentials.h 3 | Contains all non-configurable variables strictly important for 4 | the workflow of the application 5 | */ 6 | 7 | /* essentials */ 8 | 9 | #define APP_TITLE L"Fedit" 10 | #define MAX_LOADSTRING 100 11 | #define FERROR -1 12 | #define DEFAULT 666 13 | #define ENGLISH_LOCALE "English_US.1252" 14 | 15 | #define ENCBMP L"image/bmp" 16 | #define ENCJPG L"image/jpeg" 17 | #define ENCGIF L"image/gif" 18 | #define ENCTIF L"image/tiff" 19 | #define ENCPNG L"image/png" 20 | 21 | /* window classes */ 22 | #define IDCL_FEDIT L"FEDIT" 23 | 24 | #define IDCL_EDIT L"EDIT" 25 | #define IDCL_REDIT RICHEDIT_CLASS 26 | #define IDCL_REDITDLL L"RICHED20.DLL" 27 | #define IDCL_BUTTON L"BUTTON" 28 | #define IDCL_STATIC L"STATIC" 29 | #define IDCL_COMBO L"COMBOBOX" 30 | #define IDCL_SLIDER TRACKBAR_CLASS 31 | #define IDCL_TOOLTIP TOOLTIPS_CLASS 32 | 33 | #define IDCL_MDICHILD L"MDICHILD" 34 | #define IDCL_FAKEDLG L"FAKEDIALOG" 35 | #define IDCL_FAKETOOLTIP L"TOOLTIP" 36 | 37 | #define IDCL_TOOLW_CC L"TOOLW_CC" 38 | #define IDCL_TOOLW_CCB L"TOOLW_CCBUTTON" 39 | #define IDCL_TOOLW_CCP L"TOOLW_CCPOPUP" 40 | #define IDCL_TOOLW_DOCK L"TOOLW_DOCK" 41 | #define IDCL_TOOLW_DKTL L"TOOLW_DOCKTOOL" 42 | #define IDCL_TOOLW_BOX L"TOOLW_BOX" 43 | #define IDCL_TOOLW_BXCNT L"TOOLW_BOXCONTENT" 44 | #define IDCL_TOOLW_BXSCRL L"TOOLW_BOXSCROLL" 45 | #define IDCL_TOOLW_BXSCRLCNT L"TOOLW_BOXSCROLLCONTENT" 46 | #define IDCL_TOOLW_BXPANCNT L"TOOLW_BOXPANECONTENT" 47 | 48 | /* message identifiers */ 49 | #define ICC_COLORFORE 1400 50 | #define ICC_COLORBACK 1410 51 | #define ICC_COLORSWT 1420 52 | #define ICC_COLORRES 1430 53 | 54 | /* mdi essentials */ 55 | #define ID_FIRSTCHILD 60000 56 | #define MDI_EXTRADATA 1024 57 | #define MDICLIENT L"MDICLIENT" 58 | 59 | /* window properties identifiers*/ 60 | #define ATOM_ID L"ID" 61 | #define ATOM_OWNER L"OWNER" 62 | #define ATOM_THIS L"THIS" 63 | #define ATOM_PROC L"WNDPROC" 64 | #define ATOM_TTPROC L"TOOLTIPPROC" 65 | 66 | #define ATOM_LIMIT L"LIMIT" 67 | #define ATOM_POPLIST L"POPLIST" 68 | #define ATOM_PARENT L"PARENT" 69 | #define ATOM_CHILD L"CHILD" 70 | #define ATOM_POINT L"POINT" 71 | #define ATOM_BOOL L"BOOL" 72 | #define ATOM_STL_AC L"STYLE_AUTOCHECK" 73 | #define ATOM_COLOR L"COLOR" 74 | #define ATOM_SLIDER L"SLIDER" 75 | #define ATOM_VAL L"VALUE" 76 | #define ATOM_TTL L"TOOLTIP" 77 | 78 | /* custom messages */ 79 | #define EN_UPDATED 4401 80 | 81 | /* identifiers */ 82 | #define FRM_NULL 0 83 | #define FRM_TEXT 1 84 | #define FRM_VECT 2 85 | 86 | #define WSPCSIZE 10 87 | #define WSPC_ 0 88 | #define WSPC_W 1 89 | #define WSPC_H 2 90 | #define WSPC_RES 3 91 | #define WSPC_PXW 4 92 | #define WSPC_PXH 5 93 | #define WSPC_SUNIT 6 94 | #define WSPC_RUNIT 7 95 | #define WSPC_DMODE 8 96 | #define WSPC_DUNIT 9 97 | 98 | #define FRMDSIZE 9 99 | #define FRMD_TYPE 0 100 | #define FRMD_X 1 101 | #define FRMD_Y 2 102 | #define FRMD_OPCT 3 103 | #define FRMD_LOCK 4 104 | #define FRMD_VIS 5 105 | #define FRMD_EMPT 6 106 | #define FRMD_NAMELEN 7 107 | #define FRMD_NAMEPTR 8 108 | 109 | #define FRMTSIZE 10 110 | #define FRMT_TXTLEN 0 111 | #define FRMT_ 112 | 113 | #define INVDEF 0 114 | #define INVSCENE 1 115 | #define INVSCENEXOR 2 116 | #define INVSCENEXORNOSCALE 3 117 | 118 | #define FILTER 2222 119 | 120 | #define COPCOP 1111 121 | #define COPCPM 1112 122 | #define COPCUT 1113 123 | #define COPPAS 1114 124 | #define COPCLR 1115 125 | 126 | #define PENPEN 1 127 | #define PENRUB 2 128 | 129 | #define SELRECT 1 130 | #define SELCIRC 2 131 | #define SELHOR 3 132 | #define SELVER 4 133 | 134 | #define CROP 0 135 | #define CROPTL 1 136 | #define CROPTM 2 137 | #define CROPTR 3 138 | #define CROPML 4 139 | #define CROPMR 5 140 | #define CROPBL 6 141 | #define CROPBM 7 142 | #define CROPBR 8 143 | 144 | #define GRID_BKGND 1 145 | #define GRID_SNAPD 2 146 | 147 | #define INFLATE 1 148 | #define STRICTY 2 149 | 150 | #define HEADSORT -1 151 | #define TAILSORT 1 152 | 153 | #define LEFT 1 154 | #define MID 2 155 | #define RIGHT 3 156 | 157 | #define TOP -1 158 | #define BOT 1 159 | #define UPDATE 777 160 | 161 | #define CLIENT 1 162 | #define NONCLIENT 2 163 | 164 | #define NO 0 165 | #define YES 1 166 | #define AUTO 2 167 | #define NOTHUMBS 3 168 | 169 | #define FITSCREEN 10 170 | #define FITSCREENOV 15 171 | #define FITNUMPAD 20 172 | #define FITWIDTH 30 173 | #define FITHEIGHT 40 174 | #define FITLEFT 50 175 | #define FITRIGHT 60 176 | 177 | #define ROT_0 0 178 | #define ROT_90 1 179 | #define ROT_180 2 180 | #define ROT_270 3 181 | 182 | #define VK_O 0x4F 183 | #define VK_P 0x50 184 | 185 | #define TIMER_MBB 333 186 | #define TIMER_MCH 325 187 | #define TIMER_MMM 111 188 | #define TIMER_OVL 847 189 | #define TIMER_THB 783 190 | #define TIMER_TCC 888 191 | #define TIMER_TIP 999 192 | 193 | #define TIMER_INT 777 194 | 195 | #define TICKER_OFF -1 196 | #define TICKER_STEPS 4 197 | #define TICKER_SIZE 5 198 | #define TICKER_INDENT 6 199 | 200 | /* file recognition */ 201 | 202 | /* mime */ 203 | #define MIME_NONE 0 204 | #define MIME_IMAGE 1 205 | #define MIME_ARCHIVE 2 206 | #define MIME_DIR 3 207 | 208 | /* type */ 209 | #define TYPE_NONE 0 210 | #define TYPE_TIFF 111 211 | #define TYPE_TIFFINTEL 1 212 | #define TYPE_TIFFMOTOROLA 2 213 | #define TYPE_GIF 333 214 | #define TYPE_GIF87a 3 215 | #define TYPE_GIF89a 4 216 | #define TYPE_PNG 5 217 | #define TYPE_JPG 666 218 | #define TYPE_JPEGJFIF 6 219 | #define TYPE_JPEGEXIF 7 220 | #define TYPE_JPEGAPP2 8 221 | #define TYPE_JPEGAPP3 9 222 | #define TYPE_JPEGAPP4 10 223 | #define TYPE_JPEGAPP5 11 224 | #define TYPE_JPEGAPP6 12 225 | #define TYPE_JPEGAPP7 13 226 | #define TYPE_JPEGAPP8 14 227 | #define TYPE_JPEGAPP9 15 228 | #define TYPE_JPEGAPPA 16 229 | #define TYPE_JPEGAPPB 17 230 | #define TYPE_JPEGAPPC 18 231 | #define TYPE_JPEGAPPD 19 232 | #define TYPE_JPEGAPPE 20 233 | #define TYPE_JPEGAPPF 21 234 | #define TYPE_BITMAP 22 235 | 236 | #define TYPE_ZIP 23 237 | #define TYPE_RAR 24 238 | 239 | #define TYPE_DIR 25 240 | 241 | #define TYPE_FED 26 242 | 243 | #define TYPE_ICO 27 -------------------------------------------------------------------------------- /Fiew/FeditLocale.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/FeditLocale.h -------------------------------------------------------------------------------- /Fiew/Fiew.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Fiew.aps -------------------------------------------------------------------------------- /Fiew/Fiew.vcproj.NEKO.a0.user: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 35 | 36 | 39 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Fiew/Frame.h: -------------------------------------------------------------------------------- 1 | using namespace Gdiplus; 2 | 3 | class Frame 4 | { 5 | protected: 6 | Workspace *workspace; // owner 7 | FwCHAR *name; // frame display name 8 | 9 | Bitmap *image, // image data 10 | *thumb; // thumbnail data 11 | Graphics *gfx; // image graphics 12 | 13 | ImageAttributes *iatt; // image attributes 14 | 15 | int x, // Frame x position 16 | y, // Frame y position 17 | opacity; // transparency 18 | 19 | bool isLocked, // lock flag 20 | isVisible, // visibility flag 21 | isEmpty; // empty flag 22 | 23 | public: 24 | Frame(Workspace *wspc, int width, int height); 25 | Frame(Workspace *wspc, Bitmap *source, int x, int y); 26 | Frame(Workspace *wspc, Bitmap *source); 27 | Frame(Workspace *wspc, Image *source); 28 | Frame(Workspace *wspc, FwCHAR *name); 29 | virtual ~Frame(); 30 | 31 | virtual void applyPaint(Bitmap *srcBmp, Rect trgtRect, Rect srcRect, Tool *executor, bool effect = false, int toolId = FERROR, bool historical = false); 32 | virtual void applyClear(GraphicsPath *clrPath, Tool *executor, bool historical = false); 33 | virtual void applyEffect(Bitmap *effect, Rect *trgtRect, Tool *executor, int toolId, bool historical = false); 34 | 35 | virtual void resizeFrame(double wFactor, double hFactor, InterpolationMode mode = InterpolationModeInvalid); 36 | 37 | void addXY(int x, int y, bool force = false); 38 | void setXY(int x, int y, bool force = false); 39 | 40 | virtual int getX(); 41 | virtual int getY(); 42 | virtual int getWidth(); 43 | virtual int getHeight(); 44 | 45 | void setOpacity(int value); 46 | int getOpacity(); 47 | 48 | void setVisibility(bool val); 49 | void setLock(bool val); 50 | 51 | void toggleLock(); 52 | void toggleEmpty(bool val); 53 | void toggleVisibility(); 54 | bool getIsLocked(); 55 | bool getIsVisible(); 56 | bool getIsEmpty(); 57 | 58 | bool isFrameReady(); 59 | 60 | void setName(FwCHAR *name); 61 | FwCHAR *getName(); 62 | 63 | virtual Bitmap *getRender(); 64 | virtual Graphics *getGraphics(); 65 | virtual Bitmap *getThumb(int w, int h); 66 | virtual void resetThumb(); 67 | 68 | ImageAttributes *getIatt(); 69 | 70 | virtual int getType(); 71 | 72 | virtual bool setStream(IStream *stream, CLSID *encoder); 73 | virtual IStream *getStream(int &len, CLSID *encoder); 74 | 75 | Workspace *getWorkspace(); 76 | 77 | virtual Frame *clone(); 78 | 79 | private: 80 | void initialize(FwCHAR *text = NULL); 81 | 82 | }; 83 | 84 | class FrameText : public Frame 85 | { 86 | private: 87 | FwCHAR *text; // layer text 88 | GraphicsPath *textPath; // layer text as Path 89 | 90 | FontFamily *textFontFamily; // text font family 91 | StringFormat *textStringFormat; // text string format 92 | 93 | INT textFontStyle; // text style 94 | REAL textFontSize; // text size 95 | Rect textRect; // text bounding rectangle 96 | Point textOrigin; // text origin point 97 | 98 | Color color; // text color 99 | 100 | Image *icon; // icon used for thumbnail 101 | 102 | int shiftY; // vertical position shift 103 | bool isAA, // antialiasing flag 104 | isEdited; // editing state flag 105 | 106 | public: 107 | struct TextContainer { 108 | INT style; 109 | REAL size; 110 | INT orgx, orgy; 111 | UINT col; 112 | bool isAA; 113 | WCHAR family[LF_FACESIZE]; 114 | int textlen; 115 | WCHAR *text; 116 | }; 117 | 118 | FrameText(Workspace *wspc, 119 | FwCHAR *text, 120 | FontFamily *family, 121 | StringFormat *format, 122 | INT style, 123 | REAL size, 124 | Point org, 125 | Color col, 126 | bool aa, 127 | int x, 128 | int y); 129 | ~FrameText(); 130 | 131 | virtual void applyPaint(Bitmap *srcBmp, Rect trgtRect, Rect srcRect, Tool *executor, bool effect = false, int toolId = FERROR, bool historical = false); 132 | virtual void applyClear(GraphicsPath *clrPath, Tool *executor, bool historical = false); 133 | virtual void applyEffect(Bitmap *effect, Rect *trgtRect, Tool *executor, int toolId, bool historical = false); 134 | 135 | void resizeFrame(double wFactor, double hFactor, InterpolationMode mode = InterpolationModeInvalid); 136 | 137 | void beginEdit(); 138 | void endEdit(FwCHAR *newText); 139 | 140 | void setText(bool update = true); 141 | void setText(FontFamily *family, 142 | StringFormat *format, 143 | INT style, 144 | REAL size, 145 | Color col, 146 | bool isAA, 147 | bool update = true); 148 | void setText(FwCHAR *text, 149 | FontFamily *family, 150 | StringFormat *format, 151 | INT style, 152 | REAL size, 153 | Point org, 154 | Color col, 155 | bool update = true); 156 | 157 | void setAA(bool val); 158 | void setColor(Color color); 159 | 160 | Bitmap *getRender(); 161 | Bitmap *getThumb(int w, int h); 162 | 163 | FwCHAR *getText(); 164 | 165 | FontFamily *getFamily(); 166 | StringFormat *getFormat(); 167 | INT getStyle(); 168 | REAL getSize(); 169 | Rect getRect(); 170 | Color getColor(); 171 | bool getIsAA(); 172 | 173 | int getType(); 174 | int getY(); 175 | 176 | bool setStream(IStream *stream, CLSID *encoder); 177 | IStream *getStream(int &len, CLSID *encoder); 178 | 179 | Frame *clone(); 180 | }; -------------------------------------------------------------------------------- /Fiew/Ftyper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "FwCHAR.h" 3 | #include "Ftyper.h" 4 | 5 | Ftyper::Ftyper() 6 | { 7 | 8 | } 9 | 10 | ~Ftyper::~Ftyper() 11 | { 12 | 13 | } 14 | 15 | static int Ftyper::getMime(FwCHAR *path) 16 | { 17 | 18 | } -------------------------------------------------------------------------------- /Fiew/Ftyper.h: -------------------------------------------------------------------------------- 1 | class Ftyper 2 | { 3 | public: 4 | Ftyper(); 5 | ~Ftyper(); 6 | 7 | static int getMime(FwCHAR *path); 8 | static int getMime(File *file); 9 | 10 | static int getType(FwCHAR *path); 11 | static int getType(File *file); 12 | }; -------------------------------------------------------------------------------- /Fiew/FwCHAR.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FwCHAR.cpp 3 | Partially inherited from Fiew 2.0 4 | Custom Fedit WCHAR object for managing strings 5 | */ 6 | 7 | #include "stdafx.h" 8 | #include "FwCHAR.h" 9 | 10 | #include 11 | using namespace std; 12 | 13 | FwCHAR::FwCHAR() 14 | { 15 | this->string = new WCHAR[1]; 16 | this->string[0] = '\0'; 17 | } 18 | 19 | FwCHAR::FwCHAR(int source) 20 | { 21 | WCHAR *tmp = new WCHAR[MAX_LOADSTRING]; 22 | _itow(source,tmp,10); 23 | 24 | this->string = new WCHAR[wcslen(tmp) + 1]; 25 | 26 | int i = 0; 27 | while( tmp[i] != '\0' ) 28 | this->string[i] = tmp[i++]; 29 | 30 | this->string[i] = '\0'; 31 | delete [] tmp; 32 | } 33 | 34 | FwCHAR::FwCHAR(WCHAR *source) 35 | { 36 | if( source != NULL ){ 37 | this->string = new WCHAR[wcslen(source) + 1]; 38 | 39 | int i = 0; 40 | while( source[i] != '\0' ) 41 | this->string[i] = source[i++]; 42 | 43 | this->string[i] = '\0'; 44 | } 45 | else { 46 | this->string = new WCHAR[1]; 47 | this->string[0] = '\0'; 48 | } 49 | } 50 | 51 | FwCHAR::~FwCHAR() 52 | { 53 | delete [] this->string; 54 | } 55 | 56 | void FwCHAR::mergeWith(WCHAR *source) 57 | { 58 | if( source == NULL ) 59 | return; 60 | 61 | WCHAR *tmp = this->string; 62 | this->string = new WCHAR[wcslen(tmp) + wcslen(source) + 1]; 63 | 64 | wcscpy(this->string,tmp); 65 | wcscpy(&this->string[this->toLength()],source); 66 | 67 | delete [] tmp; 68 | } 69 | 70 | void FwCHAR::mergeWith(FwCHAR *source) 71 | { 72 | if( source == NULL ) 73 | return; 74 | 75 | this->mergeWith(source->toWCHAR()); 76 | } 77 | 78 | void FwCHAR::getFolderFrom(FwCHAR *source) 79 | { 80 | if( source == NULL ) 81 | return; 82 | 83 | int len, offset = 0; 84 | int i = len = source->toLength(); 85 | while( (source->toWCHAR()[i] != '\\' && source->toWCHAR()[i] != '/') && i > 0 ){ 86 | offset++; 87 | i--; 88 | } 89 | 90 | delete [] this->string; 91 | 92 | int copy, diff = len - offset; 93 | if( diff > 0 ) 94 | copy = diff + 1; 95 | else 96 | copy = len + 1; 97 | 98 | this->string = new WCHAR[copy + 1]; 99 | for( i = 0; i < copy; i++ ) 100 | this->string[i] = source->toWCHAR()[i]; 101 | this->string[i] = '\0'; 102 | } 103 | 104 | void FwCHAR::getFilenameFrom(FwCHAR *source) 105 | { 106 | if( source == NULL ) 107 | return; 108 | 109 | int len, offset = 0; 110 | int i = len = source->toLength(); 111 | while( (source->toWCHAR()[i] != '\\' && source->toWCHAR()[i] != '/') && i > 0 ){ 112 | offset++; 113 | i--; 114 | } 115 | 116 | delete [] this->string; 117 | 118 | int diff = len - offset; 119 | if( diff > 0 ){ 120 | this->string = new WCHAR[offset + 1]; 121 | wcscpy(this->string,&source->toWCHAR()[diff + 1]); 122 | } 123 | else { 124 | this->string = new WCHAR[len + 1]; 125 | wcscpy(this->string,source->toWCHAR()); 126 | } 127 | } 128 | 129 | WCHAR *FwCHAR::toWCHAR() 130 | { 131 | return this->string; 132 | } 133 | 134 | char *FwCHAR::tochar() 135 | { 136 | char *target = new char[this->toLength() + 1]; 137 | 138 | int i = 0; 139 | while( this->string[i] != '\0' ) 140 | target[i] = (char)this->string[i++]; 141 | target[i] = '\0'; 142 | 143 | return target; 144 | } 145 | 146 | bool FwCHAR::equals(FwCHAR *source) 147 | { 148 | if( wcscmp(this->string,source->toWCHAR()) == 0 ) 149 | return true; 150 | return false; 151 | } 152 | 153 | void FwCHAR::stripBraces() 154 | { 155 | if( this->string[0] == '"' ){ 156 | int i = 1; 157 | while( this->string[i] != '"' ){ 158 | this->string[i-1] = this->string[i]; 159 | i++; 160 | } 161 | this->string[--i] = '\0'; 162 | } 163 | } 164 | 165 | void FwCHAR::stripExtension() 166 | { 167 | int len = this->toLength(); 168 | int dotloc = len; 169 | 170 | while( this->string[dotloc] != '.' && dotloc >= 0 ){ 171 | if( this->string[dotloc] == '\\' ) return; 172 | dotloc--; 173 | } 174 | if( dotloc >= 0 ) 175 | this->string[dotloc] = '\0'; 176 | } 177 | 178 | int FwCHAR::toLength() 179 | { 180 | return (int)wcslen(this->string); 181 | } 182 | /* 183 | Counts what is the maximal length of lines the string has 184 | */ 185 | int FwCHAR::toMaxLineLength() 186 | { 187 | int len = this->toLength(); 188 | int maxline = 0; 189 | 190 | int counter = 0; 191 | for( int i = 0; i <= len; i++ ){ 192 | if( this->string[i] != '\n' ){ 193 | counter++; 194 | } 195 | else { 196 | maxline = max(maxline,counter); 197 | counter = 0; 198 | } 199 | } 200 | maxline = max(maxline,counter); 201 | 202 | return maxline; 203 | } 204 | /* 205 | Counts the lines of the string basing on the newline \n character 206 | */ 207 | int FwCHAR::toLines() 208 | { 209 | int len = this->toLength(); 210 | int lines = 1; 211 | 212 | for( int i = 0; i <= len; i++ ){ 213 | if( this->string[i] == '\n' ){ 214 | lines++; 215 | } 216 | } 217 | return lines; 218 | } 219 | /* 220 | Compares 2 strings using locale data 221 | */ 222 | int FwCHAR::compare(FwCHAR *string1, FwCHAR *string2) 223 | { 224 | locale loc(ENGLISH_LOCALE); 225 | 226 | FwCHAR *fol1, *fol2, *fil1, *fil2; 227 | int result = 0; 228 | 229 | fol1 = new FwCHAR(); 230 | fol2 = new FwCHAR(); 231 | 232 | fol1->getFolderFrom(string1); 233 | fol2->getFolderFrom(string2); 234 | 235 | if( fol1->toLength() < 3 || fol2->toLength() < 3 ) 236 | result = 0; 237 | else 238 | result = wcscmp(fol1->toWCHAR(),fol2->toWCHAR()); 239 | /*use_facet>(loc).compare(fol1->toWCHAR(), 240 | &fol1->toWCHAR()[wcslen(fol1->toWCHAR())], 241 | fol2->toWCHAR(), 242 | &fol2->toWCHAR()[wcslen(fol2->toWCHAR())]);*/ 243 | if( result == 0 ){ 244 | fil1 = new FwCHAR(); 245 | fil2 = new FwCHAR(); 246 | 247 | fil1->getFilenameFrom(string1); 248 | fil2->getFilenameFrom(string2); 249 | 250 | result = wcscmp(fil1->toWCHAR(),fil2->toWCHAR()); 251 | /*use_facet>(loc).compare(fil1->toWCHAR(), 252 | &fil1->toWCHAR()[wcslen(fil1->toWCHAR())], 253 | fil2->toWCHAR(), 254 | &fil2->toWCHAR()[wcslen(fil2->toWCHAR())]);*/ 255 | delete fil1; 256 | delete fil2; 257 | } 258 | delete fol1; 259 | delete fol2; 260 | 261 | return result; 262 | } -------------------------------------------------------------------------------- /Fiew/FwCHAR.h: -------------------------------------------------------------------------------- 1 | class FwCHAR 2 | { 3 | private: 4 | WCHAR *string; 5 | 6 | public: 7 | FwCHAR(); 8 | FwCHAR(int source); 9 | FwCHAR(WCHAR *source); 10 | ~FwCHAR(); 11 | 12 | void mergeWith(WCHAR *source); 13 | void mergeWith(FwCHAR *source); 14 | 15 | void getFolderFrom(FwCHAR *source); 16 | void getFilenameFrom(FwCHAR *source); 17 | 18 | WCHAR *toWCHAR(); 19 | char *tochar(); 20 | 21 | bool equals(FwCHAR *source); 22 | void stripBraces(); 23 | void stripExtension(); 24 | 25 | int toLength(); 26 | int toMaxLineLength(); 27 | int toLines(); 28 | 29 | static int compare(FwCHAR *string1, FwCHAR *string2); 30 | 31 | private: 32 | }; -------------------------------------------------------------------------------- /Fiew/History.h: -------------------------------------------------------------------------------- 1 | using namespace Gdiplus; 2 | 3 | class Workspace; 4 | class Frame; 5 | class FrameText; 6 | class Tool; 7 | 8 | class HistoryElement 9 | { 10 | protected: 11 | Workspace *wspc; 12 | Frame *frame; 13 | Tool *tool; 14 | 15 | FwCHAR *name; 16 | bool canUndo, canRedo; 17 | 18 | public: 19 | HistoryElement(Workspace *wspc, Frame *frame, Tool *tool); 20 | virtual ~HistoryElement(); 21 | 22 | virtual bool undo(); 23 | virtual bool redo(); 24 | 25 | virtual void undoAct(); 26 | virtual void redoAct(); 27 | 28 | void boolUndo(); 29 | void boolRedo(); 30 | 31 | bool canUndone(); 32 | bool canRedone(); 33 | 34 | virtual FwCHAR *getName(); 35 | virtual WORD getId(); 36 | 37 | Workspace *getWorkspace(); 38 | Frame *getFrame(); 39 | Tool *getTool(); 40 | 41 | }; 42 | 43 | class HistoryBlankElement : public HistoryElement 44 | { 45 | public: 46 | HistoryBlankElement(); 47 | ~HistoryBlankElement(); 48 | 49 | bool undo(); 50 | bool redo(); 51 | 52 | FwCHAR *getName(); 53 | WORD getId(); 54 | }; 55 | 56 | class HEToolMove : public HistoryElement 57 | { 58 | public: 59 | int dx, dy; 60 | 61 | HEToolMove(Workspace *wspc, Frame *frame, Tool *tool); 62 | ~HEToolMove(); 63 | 64 | void set(int dx, int dy); 65 | 66 | void undoAct(); 67 | void redoAct(); 68 | }; 69 | 70 | class HEToolDrawing : public HistoryElement 71 | { 72 | public: 73 | Bitmap *before, *after; 74 | Rect target; 75 | int toolId; 76 | 77 | HEToolDrawing(Workspace *wspc, Frame *frame, Tool *tool); 78 | ~HEToolDrawing(); 79 | 80 | void set(Bitmap *before, Bitmap *after, Rect target); 81 | void setToolId(int id); 82 | 83 | FwCHAR *getName(); 84 | 85 | void undoAct(); 86 | void redoAct(); 87 | 88 | private: 89 | void drawImage(Bitmap *image); 90 | }; 91 | 92 | class HEToolSelecting : public HistoryElement 93 | { 94 | private: 95 | FwCHAR *deseleeName; 96 | 97 | public: 98 | GraphicsPath *seleeBefore, *seleeAfter; 99 | 100 | HEToolSelecting(Workspace *wspc, Frame *frame, Tool *tool); 101 | ~HEToolSelecting(); 102 | 103 | void set(GraphicsPath *pathBefore, GraphicsPath *pathAfter); 104 | void setUpdate(GraphicsPath *pathAfter); 105 | 106 | FwCHAR *getName(); 107 | 108 | void undoAct(); 109 | void redoAct(); 110 | }; 111 | 112 | class HEToolCrop : public HistoryElement 113 | { 114 | public: 115 | RECT canvasChange; 116 | 117 | HEToolCrop(Workspace *wspc, Frame *frame, Tool *tool); 118 | ~HEToolCrop(); 119 | 120 | void set(RECT canvas); 121 | 122 | void undoAct(); 123 | void redoAct(); 124 | }; 125 | 126 | class HEToolResize : public HistoryElement 127 | { 128 | public: 129 | List *layersBefore, *layersAfter; 130 | Rect sizeBefore, sizeAfter; 131 | 132 | HEToolResize(Workspace *wspc, Frame *frame, Tool *tool); 133 | ~HEToolResize(); 134 | 135 | void set(List *layersBefore, List *layersAfter, Rect sizeBefore, Rect sizeAfter); 136 | 137 | FwCHAR *getName(); 138 | 139 | void undoAct(); 140 | void redoAct(); 141 | }; 142 | 143 | class HEToolRaster : public HistoryElement 144 | { 145 | public: 146 | Frame *beforeRaster, *afterRaster; 147 | 148 | HEToolRaster(Workspace *wspc, Frame *frame, Tool *tool); 149 | ~HEToolRaster(); 150 | 151 | void set(Frame *beforeRaster, Frame *afterRaster); 152 | 153 | void undoAct(); 154 | void redoAct(); 155 | }; 156 | 157 | class HEToolManageFrame : public HistoryElement 158 | { 159 | private: 160 | int mode; 161 | FwCHAR *nameAdd, *nameRemove, *nameText; 162 | 163 | public: 164 | Frame *afterLayer; 165 | 166 | HEToolManageFrame(Workspace *wspc, Frame *frame, Tool *tool); 167 | ~HEToolManageFrame(); 168 | 169 | void set(Frame *afterLayer, int mode); 170 | 171 | FwCHAR *getName(); 172 | 173 | void undoAct(); 174 | void redoAct(); 175 | }; 176 | 177 | class HEToolManageFrameOrder : public HistoryElement 178 | { 179 | public: 180 | int move; 181 | 182 | HEToolManageFrameOrder(Workspace *wspc, Frame *frame, Tool *tool); 183 | ~HEToolManageFrameOrder(); 184 | 185 | void set(int movement); 186 | 187 | FwCHAR *getName(); 188 | 189 | void undoAct(); 190 | void redoAct(); 191 | }; 192 | 193 | class HEToolManageText : public HistoryElement 194 | { 195 | private: 196 | FrameText *frameText; 197 | 198 | public: 199 | struct TextState { 200 | FwCHAR *text; 201 | 202 | FontFamily *textFontFamily; 203 | StringFormat *textStringFormat; 204 | 205 | INT textFontStyle; 206 | REAL textFontSize; 207 | 208 | Point org; 209 | Color color; 210 | bool isAA; 211 | } textBefore, textAfter; 212 | 213 | HEToolManageText(Workspace *wspc, Frame *frame, Tool *tool); 214 | ~HEToolManageText(); 215 | 216 | static TextState set( 217 | FwCHAR *text, 218 | FontFamily *textFontFamily, 219 | StringFormat *textStringFormat, 220 | INT textFontStyle, 221 | REAL textFontSize, 222 | Point org, 223 | Color color, 224 | bool isAA 225 | ); 226 | void setBefore(TextState before); 227 | void setAfter(TextState after); 228 | 229 | void setText(TextState state); 230 | static void freeTextState(TextState state); 231 | 232 | void undoAct(); 233 | void redoAct(); 234 | }; 235 | 236 | /* History Controler */ 237 | class HistoryControler 238 | { 239 | private: 240 | Workspace *wspc; 241 | List *historyElems; 242 | 243 | public: 244 | HistoryControler(Workspace *wspc); 245 | ~HistoryControler(); 246 | 247 | void add(HistoryElement *element); 248 | void remove(); 249 | 250 | void gotoElement(HistoryElement *element); 251 | 252 | bool undo(HistoryElement *element); 253 | bool redo(HistoryElement *element); 254 | 255 | bool undo(bool forceUpdate = true); 256 | bool redo(bool forceUpdate = true); 257 | 258 | List *getHistoryElems(); 259 | }; -------------------------------------------------------------------------------- /Fiew/HistoryControler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | HistoryControler.cpp 3 | This object controls the undo and redo processing for a particular Workspace. 4 | It stores, adds and removes HistoryElements. 5 | */ 6 | 7 | #include "stdafx.h" 8 | #include "Core.h" 9 | 10 | HistoryControler::HistoryControler(Workspace *wspc) 11 | { 12 | this->wspc = wspc; 13 | this->historyElems = new List(); 14 | this->historyElems->add(new HistoryBlankElement()); 15 | } 16 | 17 | HistoryControler::~HistoryControler() 18 | { 19 | delete this->historyElems; 20 | } 21 | 22 | void HistoryControler::add(HistoryElement *element) 23 | { 24 | if( this->historyElems->isThatTail() == false ){ 25 | while( this->historyElems->getThat() != this->historyElems->getTail() ){ 26 | delete this->historyElems->removeTail(); 27 | } 28 | } 29 | this->historyElems->add(element); 30 | this->historyElems->gotoTail(); 31 | 32 | Core::self->getToolws()->getToolwBoxHistory()->load(); 33 | } 34 | 35 | void HistoryControler::remove() 36 | { 37 | if( this->historyElems->isThatHead() == false && this->historyElems->isThatTail() == true ){ 38 | this->undo(false); 39 | delete this->historyElems->removeTail(); 40 | } 41 | while( this->historyElems->getThat() != this->historyElems->getTail() ){ 42 | delete this->historyElems->removeTail(); 43 | } 44 | this->wspc->updateToolws(); 45 | this->wspc->update(); 46 | } 47 | 48 | void HistoryControler::gotoElement(HistoryElement *element) 49 | { 50 | int tix = this->historyElems->countLeftoThat(); 51 | int eix = this->historyElems->getIndex(element); 52 | 53 | if( eix <= tix ) 54 | this->undo(element); 55 | else if( eix > tix ) 56 | this->redo(element); 57 | } 58 | 59 | bool HistoryControler::undo(HistoryElement *element) 60 | { 61 | bool result = false; 62 | while( this->historyElems->getThat() != element ) 63 | result = this->undo(false); 64 | 65 | return result; 66 | } 67 | 68 | bool HistoryControler::redo(HistoryElement *element) 69 | { 70 | bool result = false; 71 | while( this->historyElems->getThat() != element ) 72 | result = this->redo(false); 73 | 74 | return result; 75 | } 76 | 77 | bool HistoryControler::undo(bool forceUpdate) 78 | { 79 | bool update = this->historyElems->getThat()->undo(); 80 | bool result = this->historyElems->prev(); 81 | 82 | if( update == true && forceUpdate == true ){ 83 | this->wspc->updateToolws(); 84 | this->wspc->update(); 85 | } 86 | return result; 87 | } 88 | 89 | bool HistoryControler::redo(bool forceUpdate) 90 | { 91 | bool result = this->historyElems->next(); 92 | bool update = this->historyElems->getThat()->redo(); 93 | 94 | if( update == true && forceUpdate == true ){ 95 | this->wspc->updateToolws(); 96 | this->wspc->update(); 97 | } 98 | return result; 99 | } 100 | 101 | List *HistoryControler::getHistoryElems() 102 | { 103 | return this->historyElems; 104 | } -------------------------------------------------------------------------------- /Fiew/Icos/color_reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/color_reset.png -------------------------------------------------------------------------------- /Fiew/Icos/color_swap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/color_swap.png -------------------------------------------------------------------------------- /Fiew/Icos/crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/crop.png -------------------------------------------------------------------------------- /Fiew/Icos/dock_text_bold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/dock_text_bold.png -------------------------------------------------------------------------------- /Fiew/Icos/dock_text_italic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/dock_text_italic.png -------------------------------------------------------------------------------- /Fiew/Icos/dock_text_uline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/dock_text_uline.png -------------------------------------------------------------------------------- /Fiew/Icos/draw_pen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/draw_pen.png -------------------------------------------------------------------------------- /Fiew/Icos/eraser_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/eraser_normal.png -------------------------------------------------------------------------------- /Fiew/Icos/fill_bucket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/fill_bucket.png -------------------------------------------------------------------------------- /Fiew/Icos/hand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/hand.png -------------------------------------------------------------------------------- /Fiew/Icos/ico_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/ico_delete.png -------------------------------------------------------------------------------- /Fiew/Icos/ico_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/ico_down.png -------------------------------------------------------------------------------- /Fiew/Icos/ico_newfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/ico_newfile.png -------------------------------------------------------------------------------- /Fiew/Icos/ico_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/ico_up.png -------------------------------------------------------------------------------- /Fiew/Icos/lasso_mouse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/lasso_mouse.png -------------------------------------------------------------------------------- /Fiew/Icos/lasso_poly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/lasso_poly.png -------------------------------------------------------------------------------- /Fiew/Icos/magicwand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/magicwand.png -------------------------------------------------------------------------------- /Fiew/Icos/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/move.png -------------------------------------------------------------------------------- /Fiew/Icos/sample_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/sample_color.png -------------------------------------------------------------------------------- /Fiew/Icos/select_circ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/select_circ.png -------------------------------------------------------------------------------- /Fiew/Icos/select_hori.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/select_hori.png -------------------------------------------------------------------------------- /Fiew/Icos/select_rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/select_rect.png -------------------------------------------------------------------------------- /Fiew/Icos/select_vert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/select_vert.png -------------------------------------------------------------------------------- /Fiew/Icos/shape_elli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/shape_elli.png -------------------------------------------------------------------------------- /Fiew/Icos/shape_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/shape_line.png -------------------------------------------------------------------------------- /Fiew/Icos/shape_rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/shape_rect.png -------------------------------------------------------------------------------- /Fiew/Icos/shape_roundrect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/shape_roundrect.png -------------------------------------------------------------------------------- /Fiew/Icos/text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/text.png -------------------------------------------------------------------------------- /Fiew/Icos/vector_draw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/vector_draw.png -------------------------------------------------------------------------------- /Fiew/Icos/vector_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/vector_select.png -------------------------------------------------------------------------------- /Fiew/Icos/zoom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/Icos/zoom.png -------------------------------------------------------------------------------- /Fiew/Interface.h: -------------------------------------------------------------------------------- 1 | class FwCHAR; 2 | class Core; 3 | 4 | class Interface 5 | { 6 | private: 7 | Core *core; // owner 8 | 9 | /* fiew */ 10 | LRESULT mState; // mouse state 11 | UINT mButton; // mouse button 12 | int mX, mY, dX, dY; // mouse position and difference 13 | bool mWH, // mouse wheel flag 14 | mMM; // mouse move flag 15 | 16 | FwCHAR *lastFolder; 17 | List *lastItemIds; 18 | List *lastItems; 19 | 20 | bool fullscreen, menuvisible, fullpath; 21 | WCHAR *textmessage; 22 | int menuheight; 23 | 24 | WINDOWINFO windowInfo; 25 | HMENU windowMenu, menuFile, menuView, menuHelp; 26 | LONG windowLong; 27 | HCURSOR cursor; 28 | 29 | public: 30 | bool mBB; 31 | 32 | Interface(Core *core); 33 | ~Interface(); 34 | 35 | void update(); 36 | void updateMenu(); 37 | void updateText(); 38 | 39 | void newFile(); 40 | void openFile(); 41 | void openFolder(); 42 | void openDropFile(WPARAM wParam); 43 | 44 | void addLastItem(WCHAR *item); 45 | void callLastItem(int id); 46 | 47 | bool saveFile(); 48 | bool saveFileAs(); 49 | 50 | static int ofnToExt(int filterId); 51 | static int extToFilter(int ext); 52 | static WCHAR *extToOfn(int ext); 53 | 54 | void close(); 55 | void closeAll(); 56 | 57 | void undo(); 58 | void redo(); 59 | 60 | void cut(); 61 | void copy(); 62 | void copyMerged(); 63 | void paste(); 64 | void clear(); 65 | 66 | void filter(int id); 67 | 68 | void toolToMenu(Tool *tool); 69 | 70 | void resizeImage(); 71 | 72 | bool isFullscreen(); 73 | 74 | void setMessage(WCHAR *message); 75 | 76 | void showCursor(); 77 | HCURSOR setCursor(LPCWSTR name = NULL); 78 | HCURSOR setCursor(HCURSOR cursor); 79 | 80 | void blockMBB(); 81 | void timerMBB(); 82 | void unblockMBB(); 83 | 84 | void movemMM(); 85 | 86 | void processMenu(int id); 87 | void processKeys(UINT message, WPARAM wParam, LPARAM lParam); 88 | void processMouse(UINT message, WPARAM wParam, LPARAM lParam); 89 | LRESULT processMouseState(LPARAM lParam, LRESULT lResult); 90 | 91 | static int CALLBACK BFFCallback(HWND hWnd, UINT message, LPARAM lParam, LPARAM lpData); 92 | 93 | private: 94 | void initialize(); 95 | void initLocale(); 96 | 97 | void showMenu(); 98 | void hideMenu(); 99 | 100 | void capKeyDown(WPARAM wParam); 101 | void capKeyUp(WPARAM wParam); 102 | 103 | void capMouseDown(LPARAM lParam, WPARAM wParam, int button); 104 | void capMouseUp(LPARAM lParam, WPARAM wParam, int button); 105 | void capMouseWheel(LPARAM lParam, WPARAM wParam); 106 | void capMouseMove(LPARAM lParam, WPARAM wParam); 107 | 108 | void setCapture(bool state); 109 | void setFullscreen(int mode); 110 | void setFullpath(); 111 | 112 | static UINT_PTR CALLBACK saveHookProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam); 113 | 114 | }; -------------------------------------------------------------------------------- /Fiew/Layer.h: -------------------------------------------------------------------------------- 1 | using namespace Gdiplus; 2 | 3 | class ChildCore; 4 | 5 | class Cell; 6 | 7 | class Layer { 8 | protected: 9 | ChildCore *core; 10 | 11 | Image *image, *scali; 12 | int type, fitmode, sidemode; 13 | 14 | int x, y, width, height, cwidth, cheight; 15 | int rollHor, rollVer, maxrollHor, maxrollVer, minrollVer, offrollVer; 16 | int offset, menuheight, rot, gifdir; 17 | double zoom; 18 | bool fulldraw, sidedraw, zoomdraw, fullscreen, cancel; 19 | 20 | GUID *dimension; 21 | UINT frameCount, frameThat; 22 | 23 | SolidBrush *Brush_Back; 24 | SolidBrush *Brush_DarkBack; 25 | SolidBrush *Brush_LiteBack; 26 | 27 | Pen *Pen_Border; 28 | Pen *Pen_DarkBorder; 29 | 30 | int FontSize; 31 | 32 | FontFamily *FontFamily_Arial; 33 | Font *Font_Default; 34 | 35 | HANDLE mut_animloop, mut_image, mut_terminator; 36 | HANDLE thrd_anim; 37 | 38 | public: 39 | Layer(ChildCore *core, Image *image); 40 | virtual ~Layer(); 41 | 42 | void loadContent(Image *source,int init = TOP); 43 | 44 | virtual void nextImage(int x = FERROR, int y = FERROR); 45 | virtual void prevImage(int x = FERROR, int y = FERROR); 46 | 47 | virtual Bitmap *render(); 48 | void reset(); 49 | virtual void repos(); 50 | 51 | virtual void scroll(int hor, int ver, bool invalidate = true); 52 | virtual void scrollSet(int x, int y, bool invalidate = true); 53 | virtual void scrollHor(int val); 54 | virtual void scrollVer(int val); 55 | 56 | virtual void zoomer(double val = NULL); 57 | virtual void zoomat(double val = ZOOMINIT, bool invalidate = true); 58 | virtual void zoomend(bool invalidate = true); 59 | 60 | virtual void rotate(int val = NULL); 61 | virtual void rotateReset(bool novalid = false); 62 | 63 | int getX(); 64 | int getY(); 65 | 66 | int getWidth(); 67 | int getHeight(); 68 | File *getFile(); 69 | Image *getImage(); 70 | int getImageWidth(); 71 | int getImageHeight(); 72 | RECT getClientSize(); 73 | 74 | SCROLLINFO getScrollHor(); 75 | SCROLLINFO getScrollVer(); 76 | RECT getScrollInfo(); 77 | POINT getScrollMax(); 78 | 79 | int getMaxrollHor(); 80 | int getMaxrollVer(); 81 | 82 | double getZoom(); 83 | bool getSidedraw(); 84 | int getSidemode(); 85 | int getFitmode(); 86 | 87 | virtual void setFitmode(int mode = DEFAULT); 88 | virtual void unsetFitmode(); 89 | 90 | virtual void setSidemode(int mode = NULL); 91 | 92 | virtual void setSidedraw(); 93 | 94 | void setMenuheight(int val); 95 | void setGifDir(int dir = DEFAULT); 96 | void setCancel(bool set = true); 97 | 98 | bool setWall(); 99 | 100 | bool isCancel(); 101 | bool isContent(); 102 | 103 | void locate(int init = NULL); 104 | void invalidate(bool full = true); 105 | 106 | static void scaleEnlarge(Bitmap *src, Rect srcRect, Bitmap *bmp, double zoom = ZOOMINIT); 107 | static void scaleEnlarge(Bitmap *src, Bitmap *bmp, double zoom = ZOOMINIT); 108 | static void scaleInvert(Bitmap *src, Rect *srcRect, Bitmap *bmp, Rect *bmpRect = NULL, int hatch = NULL, double zoom = ZOOMINIT); 109 | 110 | static DWORD WINAPI anim(LPVOID param); 111 | 112 | protected: 113 | void init(Image *source); 114 | 115 | void afterLoadContent(int init); 116 | 117 | bool nextFrame(bool back = false); 118 | bool prevFrame(bool back = false); 119 | 120 | void rotate(Image *image); 121 | 122 | void zoombegin(); 123 | void rotateSet(); 124 | 125 | void boundRoll(); 126 | void boundZoom(); 127 | 128 | double getZoom(int width, int height); 129 | double getZoom(int width, int height, int cwidth, int cheight); 130 | 131 | void animate(); 132 | Image *scale(Image *source); 133 | 134 | bool isTopmost(); 135 | }; 136 | 137 | class Overlay : public Layer 138 | { 139 | public: 140 | Overlay(ChildCore *core, Image *image); 141 | ~Overlay(); 142 | 143 | virtual void nextImage(int x = FERROR, int y = FERROR); 144 | virtual void prevImage(int x = FERROR, int y = FERROR); 145 | 146 | Bitmap *render(); 147 | 148 | virtual void zoomer(double val = NULL); 149 | virtual void zoomat(double val = ZOOMINIT, bool invalidate = true); 150 | virtual void zoomend(bool invalidate = true); 151 | 152 | virtual void rotate(int val = NULL); 153 | virtual void rotateReset(bool novalid = false); 154 | 155 | virtual void setFitmode(int mode = DEFAULT); 156 | virtual void unsetFitmode(); 157 | virtual void setSidedraw(); 158 | 159 | virtual void setSidemode(int mode = NULL); 160 | 161 | RECT getOverlayRect(); 162 | 163 | protected: 164 | virtual void hide(); 165 | }; 166 | 167 | class Thumblay : public Overlay 168 | { 169 | private: 170 | Explorer *explorer; 171 | Cacher *cacher; 172 | Core *hardcore; 173 | 174 | HWND hOwner; 175 | 176 | Cell *lastCell; 177 | int ticker; 178 | int picker; 179 | 180 | public: 181 | Thumblay(ChildCore *core, Image *image); 182 | Thumblay(HWND hOwner, Core *core, FwCHAR *path); 183 | ~Thumblay(); 184 | 185 | void update(bool init = false); 186 | 187 | void nextImage(int x = FERROR, int y = FERROR); 188 | void prevImage(int x = FERROR, int y = FERROR); 189 | void prevImageDblClk(int x = FERROR, int y = FERROR); 190 | 191 | void scroll(int hor, int ver, bool invalidate = true); 192 | void scrollSet(int x, int y, bool invalidate = true); 193 | void scrollHor(int val); 194 | void scrollVer(int val); 195 | 196 | void zoomer(double val = NULL); 197 | void zoomat(double val = ZOOMINIT, bool invalidate = true); 198 | void zoomend(bool invalidate = true); 199 | 200 | void rotate(int val = NULL); 201 | void rotateReset(bool novalid = false); 202 | 203 | void setFitmode(int mode = DEFAULT); 204 | void unsetFitmode(); 205 | void setSidedraw(); 206 | 207 | void setSidemode(int mode = NULL); 208 | 209 | Cell *getLastCell(); 210 | 211 | void hide(); 212 | void subrender(); 213 | 214 | private: 215 | void setPicker(int newpick); 216 | int getPicker(int x, int y); 217 | 218 | }; 219 | 220 | class Listlay : public Overlay 221 | { 222 | private: 223 | Cell *lastCell; 224 | int ticker; 225 | 226 | public: 227 | Listlay(ChildCore *core, Image *image); 228 | ~Listlay(); 229 | 230 | void update(bool init = false); 231 | 232 | void nextImage(int x = FERROR, int y = FERROR); 233 | void prevImage(int x = FERROR, int y = FERROR); 234 | 235 | void scroll(int hor, int ver, bool invalidate = true); 236 | void scrollSet(int x, int y, bool invalidate = true); 237 | void scrollHor(int val); 238 | void scrollVer(int val); 239 | 240 | void zoomer(double val = NULL); 241 | void zoomat(double val = ZOOMINIT, bool invalidate = true); 242 | void zoomend(bool invalidate = true); 243 | 244 | void rotate(int val = NULL); 245 | void rotateReset(bool novalid = false); 246 | 247 | void setFitmode(int mode = DEFAULT); 248 | void unsetFitmode(); 249 | void setSidedraw(); 250 | 251 | void setSidemode(int mode = NULL); 252 | 253 | Cell *getLastCell(); 254 | 255 | private: 256 | void subrender(); 257 | }; 258 | 259 | class Gridlay : public Layer 260 | { 261 | private: 262 | Bitmap *gridblock; 263 | CachedBitmap *pattern; 264 | 265 | bool rendered; 266 | int oldx, oldy; 267 | 268 | public: 269 | Gridlay(ChildCore *core); 270 | ~Gridlay(); 271 | 272 | Bitmap *render(); 273 | bool isRendered(); 274 | 275 | void preload(RECT client, RECT scrollInfo, int x, int y, int width, int height); 276 | 277 | void scroll(int hor, int ver, bool invalidate = true); 278 | void scrollSet(int x, int y, bool invalidate = true); 279 | void scrollHor(int val); 280 | void scrollVer(int val); 281 | 282 | void zoomer(double val = NULL); 283 | void zoomat(double val = ZOOMINIT, bool invalidate = true); 284 | void zoomend(bool invalidate = true); 285 | }; 286 | 287 | class Snaplay : public Layer 288 | { 289 | private: 290 | Pen *penPattern, *penSolid; 291 | 292 | int oldWidth, oldHeight; 293 | double oldZoom; 294 | 295 | public: 296 | Snaplay(ChildCore *core, Image *image); 297 | ~Snaplay(); 298 | 299 | Bitmap *render(); 300 | 301 | void preload(); 302 | }; -------------------------------------------------------------------------------- /Fiew/Layer_Gridlay.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Layer_Gridlay.cpp 3 | Inherits from Layer. This object is responsible for drawing 4 | the transparency grid in the scene presented on the MDI child window 5 | */ 6 | 7 | #include "stdafx.h" 8 | #include "Core.h" 9 | 10 | Gridlay::Gridlay(ChildCore *core) : Layer(core,NULL) 11 | { 12 | this->image = NULL; 13 | this->gridblock = NULL; 14 | this->pattern = NULL; 15 | this->x = 0; 16 | this->y = 0; 17 | this->oldx = 0; 18 | this->oldy = 0; 19 | this->width = 0; 20 | this->height = 0; 21 | 22 | this->rendered = false; 23 | 24 | SolidBrush *b = new SolidBrush(CLR_FRAME_LIGHT); 25 | 26 | this->image = new Bitmap(2 * GRDBGBLOCK,2 * GRDBGBLOCK,Core::getPixelFormat()); 27 | Graphics *g = Graphics::FromImage(this->image); 28 | 29 | g->SetInterpolationMode(InterpolationModeNearestNeighbor); 30 | g->Clear(CLR_WHITE); 31 | g->FillRectangle(b,GRDBGBLOCK,0,GRDBGBLOCK,GRDBGBLOCK); 32 | g->FillRectangle(b,0,GRDBGBLOCK,GRDBGBLOCK,GRDBGBLOCK); 33 | 34 | delete b; 35 | delete g; 36 | 37 | g = Graphics::FromHWND(this->core->getWindowHandle()); 38 | this->pattern = new CachedBitmap((Bitmap *)this->image,g); 39 | delete g; 40 | } 41 | 42 | Gridlay::~Gridlay() 43 | { 44 | if( this->pattern != NULL ) 45 | delete this->pattern; 46 | if( this->gridblock != NULL ) 47 | delete this->gridblock; 48 | } 49 | 50 | Bitmap *Gridlay::render() 51 | { 52 | return this->gridblock; 53 | } 54 | 55 | bool Gridlay::isRendered() 56 | { 57 | return this->rendered; 58 | } 59 | /* 60 | Preload transparency grid basing on the size of MDI child client area 61 | */ 62 | void Gridlay::preload(RECT client, RECT scrollInfo, int x, int y, int width, int height) 63 | { 64 | this->rendered = true; 65 | 66 | int multi = 2; 67 | double zoom = this->core->getDrawer()->getZoom(); 68 | 69 | if( scrollInfo.left < 0 ){ 70 | this->x = - abs(x % (multi * GRDBGBLOCK)); 71 | if( zoom > ZOOMINIT ) 72 | this->x -= this->x % (int)zoom; 73 | } 74 | else 75 | this->x = x; 76 | if( scrollInfo.top < 0 ){ 77 | this->y = - abs(y % (multi * GRDBGBLOCK)); 78 | if( zoom > ZOOMINIT ) 79 | this->y -= this->y % (int)zoom; 80 | } 81 | else 82 | this->y = y; 83 | 84 | width = min(client.right, width); 85 | height = min(client.bottom, height); 86 | 87 | if( this->width != width || this->height != height || 88 | this->oldx != this->x || this->oldy != this->y ){ 89 | if( this->gridblock != NULL ) 90 | delete this->gridblock; 91 | this->gridblock = NULL; 92 | 93 | this->width = width; 94 | this->height = height; 95 | 96 | this->gridblock = new Bitmap(this->width, 97 | this->height, 98 | Core::getPixelFormat()); 99 | 100 | Graphics *g = Graphics::FromImage(this->gridblock); 101 | g->SetInterpolationMode(InterpolationModeNearestNeighbor); 102 | 103 | for( int i = min(this->y,0); i < this->height + (multi * GRDBGBLOCK); i += multi * GRDBGBLOCK ) 104 | for( int j = min(this->x,0); j < this->width + (multi * GRDBGBLOCK); j += multi * GRDBGBLOCK ) 105 | g->DrawCachedBitmap(this->pattern,j,i); 106 | 107 | delete g; 108 | 109 | this->oldx = this->x; 110 | this->oldy = this->y; 111 | } 112 | this->x = max(this->x,0); 113 | this->y = max(this->y,0); 114 | } 115 | 116 | void Gridlay::scroll(int hor, int ver, bool invalidate){ } 117 | void Gridlay::scrollSet(int x, int y, bool invalidate){ } 118 | void Gridlay::scrollHor(int val){ } 119 | void Gridlay::scrollVer(int val){ } 120 | 121 | void Gridlay::zoomer(double val){ } 122 | void Gridlay::zoomat(double val, bool invalidate){ } 123 | void Gridlay::zoomend(bool invalidate){ } -------------------------------------------------------------------------------- /Fiew/Layer_Listlay.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Inherited from Fiew 2.0 3 | Displays a list of files in the current Cacher object. For future use. 4 | */ 5 | 6 | #include "stdafx.h" 7 | #include "Core.h" 8 | 9 | Listlay::Listlay(ChildCore *core, Image *image) : Overlay(core,image) 10 | { 11 | this->lastCell = NULL; 12 | this->ticker = TICKER_OFF; 13 | 14 | if( this->image != NULL ) 15 | delete this->image; 16 | 17 | if( this->core->getCacher() != NULL ){ 18 | this->lastCell = this->core->getCacher()->getThat(); 19 | this->core->getCacher()->setFull(true,false); 20 | } 21 | 22 | this->image = new Bitmap(OVL_SIZE,OVL_SIZE,Core::getPixelFormat()); 23 | this->update(true); 24 | } 25 | 26 | Listlay::~Listlay() 27 | { 28 | } 29 | 30 | void Listlay::update(bool init) 31 | { 32 | this->subrender(); 33 | this->invalidate(init); 34 | 35 | if( this->core->getCacher() != NULL ){ 36 | if( this->core->getCacher()->isRunning() == true ){ 37 | this->ticker++; 38 | this->ticker = this->ticker % TICKER_STEPS; 39 | SetTimer(this->core->getWindowHandle(),TIMER_THB,THB_TOUT,NULL); 40 | return; 41 | } 42 | } 43 | if( this->ticker > TICKER_OFF ){ 44 | this->ticker = TICKER_OFF; 45 | SetTimer(this->core->getWindowHandle(),TIMER_THB,THB_TOUT,NULL); 46 | } 47 | } 48 | 49 | void Listlay::nextImage(int x, int y) 50 | { 51 | this->setCancel(); 52 | this->hide(); 53 | } 54 | void Listlay::prevImage(int x, int y) 55 | { 56 | this->hide(); 57 | } 58 | 59 | void Listlay::scroll(int hor, int ver, bool invalidate) 60 | { 61 | if( this->core->getCacher() != NULL ){ 62 | bool result = false; 63 | HCURSOR last = NULL; 64 | if( this->core->getGui() != NULL ) 65 | last = this->core->getGui()->setCursor(CURSOR_ARRWAIT); 66 | 67 | int limit, i = 0; 68 | if( ver < 0 ){ 69 | if( (result = this->core->getCacher()->next()) == true ){ 70 | limit = (int)(abs(ver) / LST_MOD); 71 | for( i = 0; i < limit; i++ ) 72 | if( this->core->getCacher()->next() == false ) 73 | break; 74 | } 75 | } 76 | else if( ver > 0 ){ 77 | if( (result = this->core->getCacher()->prev()) == true ){ 78 | limit = (int)(abs(ver) / LST_MOD); 79 | for( i = 0; i < limit; i++ ) 80 | if( this->core->getCacher()->prev() == false ) 81 | break; 82 | } 83 | } 84 | if( result == true ){ 85 | this->subrender(); 86 | if( this->core->getGui() != NULL ) 87 | this->core->getGui()->updateText(); 88 | 89 | this->invalidate(false); 90 | } 91 | if( this->core->getGui() != NULL ) 92 | this->core->getGui()->setCursor(last); 93 | } 94 | } 95 | void Listlay::scrollSet(int x, int y, bool invalidate) 96 | { 97 | return; 98 | } 99 | void Listlay::scrollHor(int val) 100 | { 101 | return; 102 | } 103 | void Listlay::scrollVer(int val) 104 | { 105 | if( this->core->getCacher() != NULL ){ 106 | bool result = false; 107 | HCURSOR last = NULL; 108 | if( this->core->getGui() != NULL ) 109 | last = this->core->getGui()->setCursor(CURSOR_ARRWAIT); 110 | 111 | if( val < 0 ) 112 | result = this->core->getCacher()->next(); 113 | 114 | else if( val > 0 ) 115 | result = this->core->getCacher()->prev(); 116 | 117 | if( result == true ){ 118 | this->subrender(); 119 | if( this->core->getGui() != NULL ) 120 | this->core->getGui()->updateText(); 121 | 122 | this->invalidate(false); 123 | } 124 | if( this->core->getGui() != NULL ) 125 | this->core->getGui()->setCursor(last); 126 | } 127 | } 128 | 129 | void Listlay::zoomer(double val) 130 | { 131 | return; 132 | } 133 | void Listlay::zoomat(double val, bool invalidate) 134 | { 135 | return; 136 | } 137 | void Listlay::zoomend(bool invalidate) 138 | { 139 | return; 140 | } 141 | 142 | void Listlay::rotate(int val) 143 | { 144 | return; 145 | } 146 | void Listlay::rotateReset(bool novalid) 147 | { 148 | return; 149 | } 150 | 151 | void Listlay::setFitmode(int mode) 152 | { 153 | return; 154 | } 155 | void Listlay::unsetFitmode() 156 | { 157 | return; 158 | } 159 | void Listlay::setSidedraw() 160 | { 161 | return; 162 | } 163 | void Listlay::setSidemode(int mode) 164 | { 165 | return; 166 | } 167 | 168 | void Listlay::subrender() 169 | { 170 | Graphics *gfx = Graphics::FromImage(this->image); 171 | gfx->Clear(CLR_WHITE); 172 | 173 | Cacher *cacher = this->core->getCacher(); 174 | if( cacher != NULL ){ 175 | FwCHAR *string = NULL; 176 | FwCHAR *name = NULL; 177 | Cell *cell = NULL; 178 | int i, x, y; 179 | bool top, bot, archived = false; 180 | 181 | top = false; 182 | bot = false; 183 | 184 | x = LST_X; 185 | y = LST_Y; 186 | 187 | for( i = -CACHE_SIZE; i < CACHE_SIZE; i++ ){ 188 | cacher->lockCache(); 189 | 190 | if( cacher->getCache() != NULL ){ 191 | cell = cacher->getCache()->gettoThat(i); 192 | if( cell != NULL ){ 193 | if( cell->getFile() != NULL ){ 194 | name = cell->getFile()->getFileName(); 195 | } 196 | if( name != NULL ){ 197 | if( i == 0 ) 198 | gfx->FillRectangle(this->Brush_LiteBack,0,y+1,OVL_SIZE,FONTSIZE+2); 199 | 200 | string = name; 201 | if( cell->getFile()->isArchived() == true ){ 202 | if( archived == false ) 203 | archived = true; 204 | 205 | string = new FwCHAR(L"~"); 206 | string->mergeWith(name); 207 | 208 | x = 3*LST_X; 209 | } 210 | else if( archived == true ){ 211 | archived = false; 212 | x = LST_X; 213 | } 214 | gfx->DrawString(string->toWCHAR(), 215 | string->toLength(), 216 | this->Font_Default, 217 | PointF((REAL)x,(REAL)y), 218 | this->Brush_DarkBack); 219 | 220 | if( archived == true ) 221 | delete string; 222 | } 223 | if( i == -1 && cacher->getCache()->isThatHead() == false ) 224 | top = true; 225 | if( i == 1 && cacher->getCache()->isThatTail() == false ) 226 | bot = true; 227 | } 228 | } 229 | cacher->unlockCache(); 230 | 231 | y += (FONTSIZE + 2); 232 | } 233 | int size = 3; 234 | int width = 20; 235 | int ax = (int)(OVL_SIZE/2); 236 | int ay = LST_Y; 237 | int asize = OVL_SIZE - 2*LST_Y; 238 | Point arrow[3]; 239 | 240 | if( top == true ){ 241 | arrow[0].X = ax - width; 242 | arrow[0].Y = ay; 243 | arrow[1].X = ax; 244 | arrow[1].Y = ay - width; 245 | arrow[2].X = ax + width; 246 | arrow[2].Y = ay; 247 | gfx->FillPolygon(this->Brush_LiteBack,arrow,size); 248 | } 249 | if( bot == true ){ 250 | arrow[0].X = ax - width; 251 | arrow[0].Y = ay + asize; 252 | arrow[1].X = ax; 253 | arrow[1].Y = ay + asize + width; 254 | arrow[2].X = ax + width; 255 | arrow[2].Y = ay + asize; 256 | gfx->FillPolygon(this->Brush_LiteBack,arrow,size); 257 | } 258 | } 259 | if( this->ticker > TICKER_OFF ){ 260 | int tsize = TICKER_SIZE; 261 | int tx,ty; 262 | if( this->ticker == 0 ){ 263 | tx = OVL_SIZE - 2*TICKER_INDENT; 264 | ty = OVL_SIZE - 2*TICKER_INDENT; 265 | } 266 | if( this->ticker == 1 ){ 267 | tx = OVL_SIZE - TICKER_INDENT; 268 | ty = OVL_SIZE - 2*TICKER_INDENT; 269 | } 270 | if( this->ticker == 2 ){ 271 | tx = OVL_SIZE - TICKER_INDENT; 272 | ty = OVL_SIZE - TICKER_INDENT; 273 | } 274 | if( this->ticker == 3 ){ 275 | tx = OVL_SIZE - 2*TICKER_INDENT; 276 | ty = OVL_SIZE - TICKER_INDENT; 277 | } 278 | gfx->FillRectangle(this->Brush_DarkBack,tx,ty,tsize,tsize); 279 | } 280 | delete gfx; 281 | } 282 | 283 | Cell *Listlay::getLastCell() 284 | { 285 | return this->lastCell; 286 | } -------------------------------------------------------------------------------- /Fiew/Layer_Overlay.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Layer_Overlay.cpp 3 | Inherited from Fiew 2.0 4 | Defines generall overlay object that can be displayed over the current 5 | MDI child scene with an additional alpha blended white area for improved look 6 | */ 7 | 8 | #include "stdafx.h" 9 | #include "Core.h" 10 | 11 | Overlay::Overlay(ChildCore *core, Image *image) : Layer(core,image) 12 | { 13 | this->fitmode = NULL; 14 | } 15 | 16 | Overlay::~Overlay() 17 | { 18 | } 19 | 20 | void Overlay::nextImage(int x, int y) 21 | { 22 | this->hide(); 23 | } 24 | void Overlay::prevImage(int x, int y) 25 | { 26 | this->hide(); 27 | } 28 | 29 | Bitmap *Overlay::render() 30 | { 31 | if( this->core != NULL ){ 32 | this->locate(); 33 | 34 | int frame = FRAME; 35 | Bitmap *scene = NULL; 36 | if( this->fulldraw == true ) 37 | scene = new Bitmap(this->cwidth,this->cheight,Core::getPixelFormat()); 38 | else 39 | scene = new Bitmap(this->width,this->height,Core::getPixelFormat()); 40 | 41 | Graphics *tmpgfx = Graphics::FromImage(scene); 42 | 43 | if( this->fulldraw == true ){ 44 | tmpgfx->Clear(CLR_WHITE_ALPHA); 45 | 46 | if( this->image != NULL ){ 47 | tmpgfx->DrawRectangle(this->Pen_Border, 48 | this->x - frame, 49 | this->y - frame, 50 | this->width + frame + 1, 51 | this->height + frame + 1); 52 | 53 | tmpgfx->DrawImage(this->image,this->x,this->y,this->width,this->height); 54 | } 55 | this->x = 0; 56 | this->y = 0; 57 | this->width = scene->GetWidth(); 58 | this->height = scene->GetHeight(); 59 | } 60 | else { 61 | tmpgfx->DrawImage(this->image,0,0,this->width,this->height); 62 | } 63 | this->fulldraw = true; 64 | delete tmpgfx; 65 | 66 | return scene; 67 | } 68 | else { 69 | return (Bitmap *)this->image; 70 | } 71 | } 72 | 73 | void Overlay::zoomer(double val) 74 | { 75 | return; 76 | } 77 | void Overlay::zoomat(double val, bool invalidate) 78 | { 79 | return; 80 | } 81 | void Overlay::zoomend(bool invalidate) 82 | { 83 | return; 84 | } 85 | 86 | void Overlay::rotate(int val) 87 | { 88 | return; 89 | } 90 | void Overlay::rotateReset(bool novalid) 91 | { 92 | return; 93 | } 94 | 95 | void Overlay::setFitmode(int mode) 96 | { 97 | return; 98 | } 99 | void Overlay::unsetFitmode() 100 | { 101 | return; 102 | } 103 | void Overlay::setSidedraw() 104 | { 105 | return; 106 | } 107 | void Overlay::setSidemode(int mode) 108 | { 109 | return; 110 | } 111 | 112 | void Overlay::hide() 113 | { 114 | SetTimer(this->core->getWindowHandle(),TIMER_OVL,OVL_HIDEOUT,NULL); 115 | } 116 | 117 | RECT Overlay::getOverlayRect() 118 | { 119 | RECT client = this->getClientSize(); 120 | 121 | RECT overlay; 122 | 123 | overlay.left = (int)((client.right - OVL_SIZE)/2); 124 | overlay.top = (int)((client.bottom - OVL_SIZE)/2); 125 | overlay.right = overlay.left + OVL_SIZE; 126 | overlay.bottom = overlay.top + OVL_SIZE; 127 | 128 | return overlay; 129 | } -------------------------------------------------------------------------------- /Fiew/Layer_Snaplay.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Layer_Snaplay.cpp 3 | Object responsible for displaying snapping grid. For future use. 4 | */ 5 | 6 | #include "stdafx.h" 7 | #include "Core.h" 8 | 9 | Snaplay::Snaplay(ChildCore *core, Image *image) : Layer(core,NULL) 10 | { 11 | this->image = NULL; 12 | this->x = 0; 13 | this->y = 0; 14 | this->oldZoom = 1; 15 | this->oldWidth = 0; 16 | this->oldHeight = 0; 17 | this->width = 0; 18 | this->height = 0; 19 | 20 | Bitmap *texture = new Bitmap(2,2); 21 | texture->SetPixel(0,0,CLR_WHITE); 22 | texture->SetPixel(1,0,CLR_BLACK); 23 | texture->SetPixel(0,1,CLR_BLACK); 24 | texture->SetPixel(1,1,CLR_WHITE); 25 | 26 | TextureBrush *tb = new TextureBrush(texture); 27 | this->penPattern = new Pen(tb,1); 28 | this->penSolid = new Pen(CLR_BLACK,1); 29 | 30 | if( image != NULL ) 31 | this->image = new Bitmap(image->GetWidth(),image->GetHeight(),Core::getPixelFormat()); 32 | 33 | delete texture; 34 | delete tb; 35 | } 36 | 37 | Snaplay::~Snaplay() 38 | { 39 | if( this->penPattern != NULL ) 40 | delete this->penPattern; 41 | } 42 | 43 | Bitmap *Snaplay::render() 44 | { 45 | return NULL; 46 | } 47 | 48 | void Snaplay::preload() 49 | { 50 | 51 | } -------------------------------------------------------------------------------- /Fiew/ProjectOverview.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | WIN32 APPLICATION : Fedit Project Overview 3 | ======================================================================== 4 | 5 | Fedit Project Filters: 6 | | 7 | `- Header Files: header files 8 | | 9 | `- Resource Files: icons and images, dialog templates 10 | | 11 | `- Source Files: code that represents the Core of the application 12 | | 13 | `- Child Core: code that represents MDI child windows 14 | | 15 | `- En Core: code that represents accessing compressed archives 16 | | 17 | `- Hard Core: code that represents the very basic data structures 18 | | 19 | `- Mini Core: code that represents file browsing and addition display functionality 20 | | 21 | `- Soft Core: code that represents the whole interface either in graphic display mode 22 | | | or api controls and dialogs 23 | | | 24 | | `- DialogHelpers: code that represents dialog helper objects 25 | | 26 | `- Toolw Core: code that represents Tool Windows functionality 27 | | 28 | `- Tools: code that represents all Control Center Tools 29 | | 30 | `- ToolwBox: code that represents particular Tool Window boxes -------------------------------------------------------------------------------- /Fiew/Tool.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Tool.cpp 3 | One of the major objects in Fedit. Tool class is the base class for all 4 | tools that can be choosed from the Tool Control Center and some that can 5 | be choosed from the application main menu. 6 | 7 | All of the definitions of Tools are defined in Tool.h - to make reading 8 | clearer all important info about different Tools methods are described there! 9 | */ 10 | 11 | #include "stdafx.h" 12 | #include "Core.h" 13 | 14 | Tool::Tool(FwCHAR *name, HCURSOR cursor, UINT id) 15 | { 16 | this->core = Core::self; 17 | this->chicore = NULL; 18 | this->name = name; 19 | 20 | this->cursor = cursor; 21 | this->cursorBackup = cursor; 22 | 23 | this->id = id; 24 | 25 | this->mouse.x = this->mouse.y = 0; 26 | 27 | this->hdocktool = CreateWindowEx( 28 | NULL, 29 | IDCL_TOOLW_DKTL, 30 | name->toWCHAR(), 31 | WS_CHILD, 32 | 0,0,0,0, 33 | this->core->getToolws()->getToolwDock()->getWindowHandle(), 34 | NULL,this->core->getInstance(),NULL 35 | ); 36 | this->submitDock(); 37 | } 38 | 39 | Tool::~Tool() 40 | { 41 | if( this->name != NULL ) 42 | delete this->name; 43 | } 44 | 45 | UINT Tool::getId() 46 | { 47 | return this->id; 48 | } 49 | 50 | FwCHAR *Tool::getName() 51 | { 52 | return this->name; 53 | } 54 | 55 | HCURSOR Tool::getCursor() 56 | { 57 | return this->cursor; 58 | } 59 | void Tool::activate(){ this->activateDock(); } 60 | void Tool::deactivate(){ } 61 | void Tool::notify(int id){ } 62 | void Tool::activateDock() 63 | { 64 | this->core->getToolws()->getToolwDock()->setChild(this->hdocktool); 65 | } 66 | void Tool::submitDock() 67 | { 68 | this->core->getToolws()->getToolwDock()->addChild(this->hdocktool,HWND_TOP,this); 69 | } 70 | void Tool::fillDock(){ } 71 | void Tool::updateDock(){ } 72 | 73 | void Tool::capKeyDown(WPARAM wParam, LPARAM lParam){ } 74 | void Tool::capKeyUp(WPARAM wParam, LPARAM lParam){ } 75 | 76 | void Tool::capMouseDblClk(WPARAM wParam, LPARAM lParam, int button){ } 77 | 78 | void Tool::capMouseClientDlbClk(WPARAM wParam, LPARAM lParam, int button){ } 79 | void Tool::capMouseDown(WPARAM wParam, LPARAM lParam, int button){ } 80 | void Tool::capMouseMove(WPARAM wParam, LPARAM lParam){ } 81 | void Tool::capMouseUp(WPARAM wParam, LPARAM lParam, int button){ } 82 | void Tool::capMouseWheel(WPARAM wParam, LPARAM lParam){ } 83 | 84 | LRESULT Tool::processMessages(Core *core, 85 | ChildCore *chicore, 86 | HWND hWnd, 87 | UINT message, 88 | WPARAM wParam, 89 | LPARAM lParam, 90 | int area) 91 | { 92 | this->core = core; 93 | this->chicore = chicore; 94 | 95 | if( area == CLIENT ){ 96 | switch(message){ 97 | case WM_LBUTTONDBLCLK: 98 | case WM_LBUTTONDOWN: 99 | case WM_LBUTTONUP: 100 | case WM_MBUTTONDBLCLK: 101 | case WM_MBUTTONDOWN: 102 | case WM_MBUTTONUP: 103 | case WM_RBUTTONDBLCLK: 104 | case WM_RBUTTONDOWN: 105 | case WM_RBUTTONUP: 106 | case WM_MOUSEWHEEL: 107 | case WM_MOUSEMOVE: 108 | this->mouse = this->getMousePos(lParam); 109 | this->getKeyStatus(wParam); 110 | 111 | this->updateInterface(wParam,lParam); 112 | break; 113 | } 114 | } 115 | switch(message){ 116 | case WM_KEYDOWN: 117 | this->capKeyDown(wParam,lParam); 118 | break; 119 | case WM_KEYUP: 120 | this->capKeyUp(wParam,lParam); 121 | break; 122 | case WM_LBUTTONDBLCLK: 123 | if( area == CLIENT ) 124 | this->capMouseClientDlbClk(wParam,lParam,LEFT); 125 | else 126 | this->capMouseDblClk(wParam,lParam,LEFT); 127 | break; 128 | case WM_MBUTTONDBLCLK: 129 | if( area == CLIENT ) 130 | this->capMouseClientDlbClk(wParam,lParam,MID); 131 | else 132 | this->capMouseDblClk(wParam,lParam,MID); 133 | break; 134 | case WM_RBUTTONDBLCLK: 135 | if( area == CLIENT ) 136 | this->capMouseClientDlbClk(wParam,lParam,RIGHT); 137 | else 138 | this->capMouseDblClk(wParam,lParam,RIGHT); 139 | break; 140 | case WM_LBUTTONDOWN: 141 | this->capMouseDown(wParam,lParam,LEFT); 142 | break; 143 | case WM_LBUTTONUP: 144 | this->capMouseUp(wParam,lParam,LEFT); 145 | break; 146 | case WM_MBUTTONDOWN: 147 | this->capMouseDown(wParam,lParam,MID); 148 | break; 149 | case WM_MBUTTONUP: 150 | this->capMouseUp(wParam,lParam,MID); 151 | break; 152 | case WM_RBUTTONDOWN: 153 | this->capMouseDown(wParam,lParam,RIGHT); 154 | break; 155 | case WM_RBUTTONUP: 156 | this->capMouseUp(wParam,lParam,RIGHT); 157 | break; 158 | case WM_MOUSEWHEEL: 159 | this->capMouseWheel(wParam,lParam); 160 | break; 161 | case WM_MOUSEMOVE: 162 | this->capMouseMove(wParam,lParam); 163 | break; 164 | } 165 | return 0; 166 | } 167 | 168 | void Tool::updateInterface(WPARAM wParam, LPARAM lParam) 169 | { 170 | this->updateToolws(wParam,lParam); 171 | } 172 | void Tool::updateToolws(WPARAM wParam, LPARAM lParam) 173 | { 174 | POINT pw = Tool::getWorkspaceMousePos(this->chicore,lParam); 175 | this->core->getToolws()->getToolwBoxInfo()->loadPos(Point(pw.x,pw.y)); 176 | 177 | POINT ps = Core::makePoint(lParam); 178 | Color color; 179 | ((ToolSampleColor *)this->core->getToolws()->getToolwCC()->toolSampleColor)->getPixel( 180 | ps,this->chicore->getDrawer()->getBmpScene(),&color); 181 | this->core->getToolws()->getToolwBoxInfo()->loadColor(color); 182 | } 183 | POINT Tool::getMousePos(LPARAM lParam) 184 | { 185 | return Core::makePoint(lParam); 186 | } 187 | void Tool::getKeyStatus(WPARAM wParam) 188 | { 189 | SHORT state; 190 | 191 | state = GetKeyState(VK_SHIFT); 192 | this->isShift = ( state < 0 ); 193 | 194 | state = GetKeyState(VK_CONTROL); 195 | this->isCtrl = ( state < 0 ); 196 | 197 | state = GetKeyState(VK_MENU); 198 | this->isAlt = ( state < 0 ); 199 | } 200 | 201 | void Tool::setMouseCapture() 202 | { 203 | SetCapture(this->chicore->getWindowHandle()); 204 | } 205 | 206 | void Tool::setMouseRelease() 207 | { 208 | ReleaseCapture(); 209 | } 210 | POINT Tool::getWorkspaceMousePos(ChildCore *chicore, LPARAM lParam) 211 | { 212 | POINT mouse = Core::makePoint(lParam); 213 | 214 | Rect scene = chicore->getDrawer()->getRectScene(); 215 | double zoom = chicore->getDrawer()->getZoom(); 216 | 217 | mouse.x = (int)floor(mouse.x / zoom); 218 | mouse.y = (int)floor(mouse.y / zoom); 219 | 220 | scene.X /= zoom; 221 | scene.Y /= zoom; 222 | 223 | mouse.x -= scene.X; 224 | mouse.y -= scene.Y; 225 | 226 | return mouse; 227 | } 228 | HCURSOR Tool::createToolCursor(int hotXspot, int hotYspot, int toolId) 229 | { 230 | HCURSOR cursor = NULL; 231 | HBITMAP hbmp = NULL; 232 | HBITMAP hmsk = NULL; 233 | Bitmap *bmp = (Bitmap *)Core::getImageResource(toolId,RC_PNG); 234 | 235 | /* 236 | Bitmap *msk = bmp->Clone(0,0,bmp->GetWidth(),bmp->GetHeight(),bmp->GetPixelFormat()); 237 | 238 | Color color; 239 | Color pick(255,255,255); 240 | for( UINT i = 0; i < msk->GetWidth(); i++ ){ 241 | for( UINT j = 0; j < msk->GetHeight(); j++ ){ 242 | msk->GetPixel(i,j,&color); 243 | if( color.ToCOLORREF() == pick.ToCOLORREF() ) 244 | msk->SetPixel(i,j,NULL); 245 | } 246 | } 247 | msk->GetHBITMAP(NULL,&hmsk); 248 | */ 249 | 250 | bmp->GetHBITMAP(NULL,&hbmp); 251 | 252 | ICONINFO ii; 253 | ii.fIcon = FALSE; 254 | ii.hbmColor = hbmp; 255 | ii.hbmMask = hbmp; 256 | ii.xHotspot = hotXspot; 257 | ii.yHotspot = hotYspot; 258 | 259 | cursor = (HCURSOR)CreateIconIndirect(&ii); 260 | 261 | delete bmp; 262 | DeleteObject(hbmp); 263 | 264 | /* 265 | delete msk; 266 | DeleteObject(hmsk); 267 | */ 268 | 269 | if( cursor == NULL ) 270 | cursor = LoadCursor(NULL,IDC_ARROW); 271 | 272 | return cursor; 273 | } 274 | bool Tool::isLayerReady() 275 | { 276 | if( this->chicore->getWorkspace()->getSelectedLayer()->isFrameReady() == false || 277 | this->chicore->getWorkspace()->getSelectedLayer()->getType() == FRM_TEXT ) 278 | return false; 279 | 280 | return true; 281 | } 282 | 283 | bool Tool::loadCursor() 284 | { 285 | bool result = this->isLayerReady(); 286 | 287 | if( result == false ) 288 | this->cursor = LoadCursor(NULL,IDC_NO); 289 | else 290 | this->cursor = this->cursorBackup; 291 | 292 | return result; 293 | } 294 | /* 295 | Fake Tools to store names in the form acceptable by HistoryElements 296 | */ 297 | ToolMerge::ToolMerge() : Tool(new FwCHAR(TOOL_MERGE),NULL,NULL){ } 298 | ToolMerge::~ToolMerge(){ } 299 | 300 | ToolRaster::ToolRaster() : Tool(new FwCHAR(TOOL_RASTER),NULL,ICC_TEX){ } 301 | ToolRaster::~ToolRaster(){ } -------------------------------------------------------------------------------- /Fiew/ToolBucket.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolBucket::ToolBucket() : ToolDrawingStrict(new FwCHAR(TOOL_FILBUC),NULL,ICC_FILBUC) 5 | { 6 | this->isPreselect = false; 7 | this->sourceBmp = NULL; 8 | 9 | this->cursor = Tool::createToolCursor(19,15,ICC_FILBUC); 10 | this->cursorBackup = this->cursor; 11 | } 12 | 13 | ToolBucket::~ToolBucket() 14 | { 15 | if( this->sourceBmp != NULL ) 16 | delete this->sourceBmp; 17 | 18 | DestroyIcon(this->cursorBackup); 19 | } 20 | 21 | void ToolBucket::capMouseDown(WPARAM wParam, LPARAM lParam, int button) 22 | { 23 | switch(button){ 24 | case LEFT: 25 | if( this->isLayerReady() == false ) 26 | return; 27 | 28 | if( this->chicore->getWorkspace()->getSelection() == NULL ){ 29 | this->setMouseCapture(); 30 | 31 | this->sourceBmp = this->chicore->getWorkspace()->getSelectedLayerProjection(true); 32 | 33 | this->callColor(&this->colorPick); 34 | this->callMagic(wParam,lParam); 35 | 36 | this->isDraw = true; 37 | } 38 | else { 39 | this->isPreselect = true; 40 | } 41 | break; 42 | } 43 | } 44 | 45 | void ToolBucket::capMouseMove(WPARAM wParam, LPARAM lParam) 46 | { 47 | this->loadCursor(); 48 | 49 | if( this->isDraw == true ){ 50 | Color temp; 51 | this->callColor(&temp); 52 | 53 | if( temp.GetValue() != this->colorPick.GetValue() ){ 54 | this->colorPick = temp; 55 | this->callMagic(wParam,lParam); 56 | } 57 | } 58 | } 59 | 60 | void ToolBucket::capMouseUp(WPARAM wParam, LPARAM lParam, int button) 61 | { 62 | switch(button){ 63 | case LEFT: 64 | this->setMouseRelease(); 65 | 66 | this->isDraw = false; 67 | 68 | if( this->chicore->getWorkspace()->getSelection() != NULL ){ 69 | if( this->chicore->getWorkspace()->getSelection()->IsVisible( 70 | this->mouse.x,this->mouse.y) ){ 71 | 72 | if( this->sourceBmp != NULL ) 73 | delete this->sourceBmp; 74 | this->sourceBmp = NULL; 75 | 76 | this->beginPaint(); 77 | 78 | this->drawgfx->FillPath( 79 | this->brushColor, 80 | this->chicore->getWorkspace()->getSelection() 81 | ); 82 | 83 | Rect bounds; 84 | this->chicore->getWorkspace()->getSelection()->GetBounds(&bounds); 85 | SetRect( 86 | &this->srcrect, 87 | bounds.X, 88 | bounds.Y, 89 | bounds.X + bounds.Width, 90 | bounds.Y + bounds.Height 91 | ); 92 | this->endPaint(); 93 | } 94 | } 95 | 96 | if( this->isPreselect == false ) 97 | this->chicore->getWorkspace()->setSelection(NULL); 98 | this->isPreselect = false; 99 | 100 | break; 101 | } 102 | } 103 | 104 | void ToolBucket::callColor(Color *color) 105 | { 106 | this->chicore->getWorkspace()->getSelectedLayer()->getRender()->GetPixel( 107 | this->mouse.x, 108 | this->mouse.y, 109 | color); 110 | } 111 | 112 | void ToolBucket::callMagic(WPARAM wParam, LPARAM lParam) 113 | { 114 | this->chicore->getWorkspace()->setSelection( ToolSelectWand::doMagic( 115 | this->sourceBmp, 116 | NULL, 117 | this->mouse.x, 118 | this->mouse.y, 119 | 0, 120 | 0, 121 | this->size ) 122 | ); 123 | this->chicore->getDrawer()->invalidate(); 124 | } -------------------------------------------------------------------------------- /Fiew/ToolCopy.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolCopy::ToolCopy(int mode) : Tool(new FwCHAR(),NULL,mode) 5 | { 6 | this->mode = mode; 7 | this->noclipboard = false; 8 | 9 | delete this->name; 10 | switch(this->mode){ 11 | case COPCOP: 12 | this->name = new FwCHAR(TOOL_COPY); 13 | break; 14 | case COPCPM: 15 | this->name = new FwCHAR(TOOL_COPM); 16 | break; 17 | case COPCUT: 18 | this->name = new FwCHAR(TOOL_CUT); 19 | break; 20 | case COPPAS: 21 | this->name = new FwCHAR(TOOL_PASTE); 22 | break; 23 | case COPCLR: 24 | this->name = new FwCHAR(TOOL_CLEAR); 25 | break; 26 | } 27 | } 28 | 29 | ToolCopy::~ToolCopy() 30 | { 31 | 32 | } 33 | 34 | void ToolCopy::activate() 35 | { 36 | ChildCore *child = this->core->getActiveChild(); 37 | if( child != NULL ){ 38 | Bitmap *clipboardBmp = NULL; 39 | 40 | switch(this->mode){ 41 | case COPCOP: 42 | case COPCPM: 43 | case COPCUT: 44 | case COPCLR: 45 | if( child->getWorkspace()->getSelection() != NULL ){ 46 | clipboardBmp = 47 | child->getWorkspace()->getSelectedProjection(NULL,this->mode); 48 | 49 | if( clipboardBmp != NULL && this->noclipboard == false ){ 50 | Core::setClipboardBitmap(clipboardBmp); 51 | delete clipboardBmp; 52 | } 53 | } 54 | else { 55 | this->core->messageBox_Error(TOOL_COPY_MESSAGE); 56 | } 57 | break; 58 | case COPPAS: 59 | if( this->noclipboard == false ) 60 | clipboardBmp = Core::getClipboardBitmap(); 61 | if( clipboardBmp != NULL ){ 62 | child->getWorkspace()->setSelectedProjection(clipboardBmp,this->mode); 63 | } 64 | break; 65 | } 66 | } 67 | this->noclipboard = false; 68 | } 69 | 70 | void ToolCopy::setNoclipboard() 71 | { 72 | this->noclipboard = true; 73 | } -------------------------------------------------------------------------------- /Fiew/ToolDrawingLinear.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolDrawingLinear::ToolDrawingLinear(FwCHAR *name, HCURSOR cursor, UINT id) : ToolDrawing(name,cursor,id) 5 | { 6 | this->drawpath = NULL; 7 | 8 | this->mouseLinear.x = this->mouseLinear.y = 0; 9 | this->startLinear.x = this->startLinear.y = 0; 10 | } 11 | 12 | ToolDrawingLinear::~ToolDrawingLinear() 13 | { 14 | if( this->drawpath != NULL ) 15 | delete this->drawpath; 16 | } 17 | 18 | void ToolDrawingLinear::capMouseDblClk(WPARAM wParam, LPARAM lParam, int button){ } 19 | 20 | void ToolDrawingLinear::capMouseClientDlbClk(WPARAM wParam, LPARAM lParam, int button){ } 21 | void ToolDrawingLinear::capMouseWheel(WPARAM wParam, LPARAM lParam){ } 22 | void ToolDrawingLinear::capMouseDown(WPARAM wParam, LPARAM lParam, int button){ } 23 | void ToolDrawingLinear::capMouseMove(WPARAM wParam, LPARAM lParam){ } 24 | void ToolDrawingLinear::capMouseUp(WPARAM wParam, LPARAM lParam, int button){ } 25 | 26 | void ToolDrawingLinear::capKeyDown(WPARAM wParam, LPARAM lParam){ } 27 | void ToolDrawingLinear::capKeyUp(WPARAM wParam, LPARAM lParam){ } 28 | 29 | Rect ToolDrawingLinear::getDrawrect(){ return Rect(0,0,0,0); } 30 | 31 | POINT ToolDrawingLinear::getMousePos(LPARAM lParam) 32 | { 33 | POINT mouse = Core::makePoint(lParam); 34 | 35 | Rect scene = this->chicore->getDrawer()->getRectScene(); 36 | double zoom = this->chicore->getDrawer()->getZoom(); 37 | 38 | mouse.x = (int)floor(mouse.x / zoom); 39 | mouse.y = (int)floor(mouse.y / zoom); 40 | 41 | this->mouseLinear.x = mouse.x; 42 | this->mouseLinear.y = mouse.y; 43 | 44 | scene.X /= zoom; 45 | scene.Y /= zoom; 46 | 47 | mouse.x -= max(scene.X,0); 48 | mouse.y -= max(scene.Y,0); 49 | 50 | this->mouseLinear.x -= scene.X; 51 | this->mouseLinear.y -= scene.Y; 52 | 53 | return mouse; 54 | } 55 | 56 | void ToolDrawingLinear::beginPath() 57 | { 58 | if( this->drawpath != NULL ) 59 | delete this->drawpath; 60 | this->drawpath = new GraphicsPath(); 61 | 62 | this->chicore->getDrawer()->setDrawpenSize(this->size); 63 | } 64 | 65 | void ToolDrawingLinear::updatePath() 66 | { 67 | GraphicsPath *temp = new GraphicsPath(); 68 | temp->AddPath(this->drawpath,FALSE); 69 | 70 | this->chicore->getDrawer()->setDrawpath(temp); 71 | } 72 | 73 | void ToolDrawingLinear::endPath() 74 | { 75 | if( this->drawpath != NULL ) 76 | delete this->drawpath; 77 | this->drawpath = NULL; 78 | 79 | this->chicore->getDrawer()->setDrawpath(NULL); 80 | } -------------------------------------------------------------------------------- /Fiew/ToolDrawingStrict.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolDrawingStrict::ToolDrawingStrict(FwCHAR *name, HCURSOR cursor, UINT id) : ToolDrawing(name,cursor,id) 5 | { 6 | 7 | } 8 | 9 | ToolDrawingStrict::~ToolDrawingStrict() 10 | { 11 | 12 | } 13 | 14 | void ToolDrawingStrict::capMouseDblClk(WPARAM wParam, LPARAM lParam, int button){ } 15 | 16 | void ToolDrawingStrict::capMouseClientDlbClk(WPARAM wParam, LPARAM lParam, int button){ } 17 | void ToolDrawingStrict::capMouseWheel(WPARAM wParam, LPARAM lParam){ } 18 | void ToolDrawingStrict::capMouseDown(WPARAM wParam, LPARAM lParam, int button){ } 19 | void ToolDrawingStrict::capMouseMove(WPARAM wParam, LPARAM lParam){ } 20 | void ToolDrawingStrict::capMouseUp(WPARAM wParam, LPARAM lParam, int button){ } 21 | 22 | void ToolDrawingStrict::capKeyDown(WPARAM wParam, LPARAM lParam){ } 23 | void ToolDrawingStrict::capKeyUp(WPARAM wParam, LPARAM lParam){ } 24 | 25 | void ToolDrawingStrict::beginPaint() 26 | { 27 | Color color = this->core->getToolws()->getToolwCC()->getForeColor(); 28 | 29 | this->brushColor = new SolidBrush(color); 30 | this->penColor = new Pen(color,(REAL)this->size); 31 | 32 | int x = 0; 33 | int y = 0; 34 | int width = this->chicore->getWorkspace()->getSelectedLayer()->getWidth(); 35 | int height = this->chicore->getWorkspace()->getSelectedLayer()->getHeight(); 36 | 37 | this->cliprect = Rect(x,y,width,height); 38 | 39 | if( this->id == ICC_FILBUC ){ 40 | int x = this->chicore->getWorkspace()->getSelectedLayer()->getX(); 41 | int y = this->chicore->getWorkspace()->getSelectedLayer()->getY(); 42 | int w = this->chicore->getWorkspace()->getPxWidth(); 43 | int h = this->chicore->getWorkspace()->getPxHeight(); 44 | 45 | this->cliprect = Rect(min(x,0),min(y,0),w + abs(x),h + abs(y)); 46 | } 47 | 48 | this->sceneAbove = this->chicore->getWorkspace()->renderAbove(this->cliprect); 49 | this->sceneBelow = this->chicore->getWorkspace()->renderBelow(this->cliprect); 50 | 51 | this->drawbmp = new Bitmap(this->cliprect.Width,this->cliprect.Height,Core::getPixelFormat()); 52 | this->drawgfx = Graphics::FromImage(this->drawbmp); 53 | SetRect(&this->drawrect,0,0,0,0); 54 | 55 | if( this->isAA == true ) 56 | this->drawgfx->SetSmoothingMode(SmoothingModeAntiAlias); 57 | 58 | this->setMouseCapture(); 59 | } 60 | 61 | /*void ToolDrawingStrict::endPaint() 62 | { 63 | this->setMouseRelease(); 64 | 65 | this->chicore->getWorkspace()->getSelectedLayer()->applyPaint(this->drawbmp,this->cliprect); 66 | this->chicore->getWorkspace()->update(); 67 | 68 | this->destroy(); 69 | }*/ 70 | 71 | POINT ToolDrawingStrict::getMousePos(LPARAM lParam) 72 | { 73 | POINT mouse = Core::makePoint(lParam); 74 | 75 | Rect scene = this->chicore->getDrawer()->getRectScene(); 76 | double zoom = this->chicore->getDrawer()->getZoom(); 77 | 78 | mouse.x = (int)floor(mouse.x / zoom); 79 | mouse.y = (int)floor(mouse.y / zoom); 80 | 81 | scene.X /= zoom; 82 | scene.Y /= zoom; 83 | 84 | mouse.x -= scene.X; 85 | mouse.y -= scene.Y; 86 | 87 | return mouse; 88 | } -------------------------------------------------------------------------------- /Fiew/ToolHand.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolHand::ToolHand() : Tool(new FwCHAR(TOOL_HAND),NULL,ICC_HAN) 5 | { 6 | this->mouseLast.x = this->mouseLast.y = 0; 7 | this->mouseMoving = false; 8 | 9 | this->isAll = false; 10 | 11 | this->cursor = Tool::createToolCursor(12,10,ICC_HAN); 12 | this->cursorBackup = this->cursor; 13 | 14 | this->fillDock(); 15 | } 16 | 17 | ToolHand::~ToolHand() 18 | { 19 | DestroyIcon(this->cursorBackup); 20 | } 21 | 22 | void ToolHand::fillDock() 23 | { 24 | this->core->CreateWindowExSubstituteFont( 25 | NULL, 26 | IDCL_BUTTON, 27 | TOOL_HAND_RESET, 28 | WS_VISIBLE | WS_CHILD, 29 | 0,0,100,20, 30 | this->hdocktool, 31 | (HMENU)11, 32 | this->core->getInstance(), 33 | NULL 34 | ); 35 | 36 | this->dlgAll = this->core->CreateWindowExSubstituteFont( 37 | NULL, 38 | IDCL_BUTTON, 39 | TOOL_HAND_ALL, 40 | WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, 41 | 110,0,150,20, 42 | this->hdocktool, 43 | (HMENU)22, 44 | this->core->getInstance(), 45 | NULL 46 | ); 47 | CheckDlgButton(this->hdocktool,22,BST_UNCHECKED); 48 | } 49 | 50 | void ToolHand::notify(int id) 51 | { 52 | switch(id){ 53 | case 11: 54 | if( this->isAll == true && this->core->getChildren()->getCount() > 0 ){ 55 | this->core->getChildren()->gotoHead(); 56 | do { 57 | this->core->getChildren()->getThat()->setSkew(0,0); 58 | } while( this->core->getChildren()->next() == true ); 59 | } 60 | else { 61 | this->chicore->setSkew(0,0); 62 | } 63 | break; 64 | case 22: 65 | this->isAll = IsDlgButtonChecked(this->hdocktool,22); 66 | break; 67 | } 68 | } 69 | 70 | void ToolHand::capMouseDown(WPARAM wParam, LPARAM lParam, int button) 71 | { 72 | switch(button){ 73 | case LEFT: 74 | this->setMouseCapture(); 75 | 76 | this->mouseLast = this->mouse; 77 | this->mouseMoving = true; 78 | break; 79 | case MID: 80 | break; 81 | case RIGHT: 82 | break; 83 | } 84 | } 85 | 86 | void ToolHand::capMouseMove(WPARAM wParam, LPARAM lParam) 87 | { 88 | if( this->mouseMoving == true ){ 89 | int x = this->mouse.x - this->mouseLast.x; 90 | int y = this->mouse.y - this->mouseLast.y; 91 | 92 | if( this->isAll == true ){ 93 | this->core->getChildren()->gotoHead(); 94 | do { 95 | this->core->getChildren()->getThat()->addSkew(x,y); 96 | } while( this->core->getChildren()->next() == true ); 97 | } 98 | else { 99 | this->chicore->addSkew(x,y); 100 | } 101 | this->mouseLast = this->mouse; 102 | } 103 | } 104 | 105 | void ToolHand::capMouseUp(WPARAM wParam, LPARAM lParam, int button) 106 | { 107 | switch(button){ 108 | case LEFT: 109 | this->setMouseRelease(); 110 | 111 | this->mouseMoving = false; 112 | break; 113 | case MID: 114 | break; 115 | case RIGHT: 116 | break; 117 | } 118 | } -------------------------------------------------------------------------------- /Fiew/ToolLine.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolLine::ToolLine(int mode) : ToolDrawingLinear(new FwCHAR(TOOL_LINE),NULL,mode) 5 | { 6 | this->start.x = this->start.y = 0; 7 | 8 | this->prevRect = Rect(0,0,0,0); 9 | this->drawRect = Rect(0,0,0,0); 10 | 11 | this->rrcRound = 10; 12 | this->mode = mode; 13 | 14 | switch(mode){ 15 | case ICC_SHAREC: 16 | delete this->name; 17 | this->name = new FwCHAR(TOOL_RECT); 18 | break; 19 | case ICC_SHACIR: 20 | delete this->name; 21 | this->name = new FwCHAR(TOOL_ELLI); 22 | break; 23 | case ICC_SHARRC: 24 | delete this->name; 25 | this->name = new FwCHAR(TOOL_RREC); 26 | break; 27 | } 28 | } 29 | 30 | ToolLine::~ToolLine() 31 | { 32 | 33 | } 34 | 35 | void ToolLine::capMouseDown(WPARAM wParam, LPARAM lParam, int button) 36 | { 37 | switch(button){ 38 | case LEFT: 39 | if( this->isLayerReady() == false ) 40 | return; 41 | 42 | this->isDraw = true; 43 | 44 | this->beginPaint(); 45 | this->beginPath(); 46 | 47 | this->setDrawrectDown(STRICTY); 48 | this->setDrawrect(); 49 | 50 | this->start = this->mouse; 51 | this->startLinear = this->mouseLinear; 52 | 53 | this->drawpath->AddLine( 54 | this->startLinear.x, 55 | this->startLinear.y, 56 | this->startLinear.x, 57 | this->startLinear.y); 58 | break; 59 | } 60 | } 61 | void ToolLine::capMouseMove(WPARAM wParam, LPARAM lParam) 62 | { 63 | this->loadCursor(); 64 | 65 | if( this->isDraw == true ){ 66 | this->setDrawrectMove(STRICTY); 67 | this->setDrawrect(); 68 | 69 | Point point1( 70 | this->startLinear.x, 71 | this->startLinear.y 72 | ); 73 | Point point2( 74 | this->mouseLinear.x, 75 | this->mouseLinear.y 76 | ); 77 | Rect rect( 78 | min(point1.X,point2.X), 79 | min(point1.Y,point2.Y), 80 | abs(point1.X - point2.X), 81 | abs(point1.Y - point2.Y) 82 | ); 83 | 84 | this->drawpath->Reset(); 85 | switch(this->mode){ 86 | case ICC_SHALIN: 87 | this->drawpath->AddLine(point1,point2); 88 | break; 89 | case ICC_SHAREC: 90 | this->drawpath->AddRectangle(rect); 91 | break; 92 | case ICC_SHACIR: 93 | this->drawpath->AddEllipse(rect); 94 | break; 95 | case ICC_SHARRC: 96 | this->drawpath->AddEllipse(Rect( 97 | rect.X,rect.Y,this->rrcRound,this->rrcRound)); 98 | this->drawpath->AddEllipse(Rect( 99 | rect.X + rect.Width - this->rrcRound, 100 | rect.Y,this->rrcRound,this->rrcRound)); 101 | this->drawpath->AddEllipse(Rect( 102 | rect.X,rect.Y + rect.Height - this->rrcRound, 103 | this->rrcRound,this->rrcRound)); 104 | this->drawpath->AddEllipse(Rect( 105 | rect.X + rect.Width - this->rrcRound, 106 | rect.Y + rect.Height - this->rrcRound, 107 | this->rrcRound,this->rrcRound)); 108 | this->drawpath->AddRectangle(Rect( 109 | rect.X + this->rrcRound/2,rect.Y, 110 | rect.Width - this->rrcRound,rect.Height)); 111 | this->drawpath->AddRectangle(Rect( 112 | rect.X,rect.Y + this->rrcRound/2, 113 | rect.Width,rect.Height - this->rrcRound)); 114 | //this->drawpath->Flatten(); 115 | this->drawpath->Outline(); 116 | break; 117 | } 118 | 119 | this->updatePath(); 120 | } 121 | } 122 | void ToolLine::capMouseUp(WPARAM wParam, LPARAM lParam, int button) 123 | { 124 | switch(button){ 125 | case LEFT: 126 | if( this->isDraw == true ){ 127 | this->isDraw = false; 128 | 129 | this->drawLine(); 130 | this->endPath(); 131 | 132 | this->setDrawrect(); 133 | this->setDrawrectUp(STRICTY); 134 | 135 | this->endPaint(); 136 | } 137 | break; 138 | } 139 | } 140 | 141 | void ToolLine::setDrawrect() 142 | { 143 | int margin = this->size + 1; 144 | 145 | Rect last = this->prevRect; 146 | RECT temp; 147 | SetRect( 148 | &temp, 149 | max( min(this->drawrect.left,this->drawrect.right) - margin, 0 ), 150 | max( min(this->drawrect.top,this->drawrect.bottom) - margin, 0 ), 151 | min( max(this->drawrect.left,this->drawrect.right) + margin, 152 | this->chicore->getWorkspace()->getPxWidth() ), 153 | min( max(this->drawrect.top,this->drawrect.bottom) + margin, 154 | this->chicore->getWorkspace()->getPxHeight() ) 155 | ); 156 | 157 | this->prevRect = Rect( 158 | temp.left, 159 | temp.top, 160 | temp.right - temp.left, 161 | temp.bottom - temp.top 162 | ); 163 | 164 | Rect::Union(this->drawRect,last,this->prevRect); 165 | } 166 | 167 | Rect ToolLine::getDrawrect() 168 | { 169 | return this->drawRect; 170 | } 171 | 172 | void ToolLine::drawLine() 173 | { 174 | Matrix mx; 175 | mx.Translate( 176 | (REAL)( this->start.x - this->startLinear.x ), 177 | (REAL)( this->start.y - this->startLinear.y ) 178 | ); 179 | this->drawpath->Transform(&mx); 180 | 181 | this->drawgfx->DrawPath(this->penColor,this->drawpath); 182 | } -------------------------------------------------------------------------------- /Fiew/ToolMove.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolMove::ToolMove() : Tool(new FwCHAR(TOOL_MOVE),NULL,ICC_MOV) 5 | { 6 | this->mouseLast.x = this->mouseLast.y = 0; 7 | this->mouseMoving = false; 8 | this->keyMoving = false; 9 | 10 | this->cursor = Tool::createToolCursor(4,3,ICC_MOV); 11 | this->cursorBackup = this->cursor; 12 | } 13 | 14 | ToolMove::~ToolMove() 15 | { 16 | DestroyIcon(this->cursorBackup); 17 | } 18 | 19 | void ToolMove::capMouseDown(WPARAM wParam, LPARAM lParam, int button) 20 | { 21 | switch(button){ 22 | case LEFT: 23 | if( this->chicore->getWorkspace()->getSelectedLayer()->getIsLocked() == true || 24 | this->chicore->getWorkspace()->getSelectedLayer()->getIsVisible() == false ) 25 | return; 26 | 27 | this->setMouseCapture(); 28 | 29 | this->mouseLast = this->mouse; 30 | this->mouseMoving = true; 31 | 32 | if( this->chicore->getWorkspace()->getSelection() != NULL ){ 33 | ToolCopy *cut = (ToolCopy *)this->core->getToolws()->getToolwCC()->toolCut; 34 | ToolCopy *paste = (ToolCopy *)this->core->getToolws()->getToolwCC()->toolPaste; 35 | 36 | cut->activate(); 37 | paste->activate(); 38 | } 39 | 40 | this->frameStart.x = this->chicore->getWorkspace()->getSelectedLayer()->getX(); 41 | this->frameStart.y = this->chicore->getWorkspace()->getSelectedLayer()->getY(); 42 | this->frameEnd = this->frameStart; 43 | 44 | break; 45 | } 46 | } 47 | 48 | void ToolMove::capMouseMove(WPARAM wParam, LPARAM lParam) 49 | { 50 | if( this->chicore->getWorkspace()->getSelectedLayer()->getIsLocked() == true || 51 | this->chicore->getWorkspace()->getSelectedLayer()->getIsVisible() == false ) 52 | this->loadCursor(); 53 | else 54 | this->cursor = this->cursorBackup; 55 | 56 | if( this->mouseMoving == true ){ 57 | double zoom = this->chicore->getDrawer()->getZoom(); 58 | int x = (int)((this->mouse.x - this->mouseLast.x) / zoom); 59 | int y = (int)((this->mouse.y - this->mouseLast.y) / zoom); 60 | 61 | this->chicore->getWorkspace()->getSelectedLayer()->addXY(x,y); 62 | this->mouseLast = this->mouse; 63 | 64 | if( this->chicore->getWorkspace()->getSelection() != NULL ){ 65 | Matrix off; 66 | off.Translate(x,y); 67 | this->chicore->getWorkspace()->getSelection()->Transform(&off); 68 | } 69 | 70 | this->frameEnd.x = this->chicore->getWorkspace()->getSelectedLayer()->getX(); 71 | this->frameEnd.y = this->chicore->getWorkspace()->getSelectedLayer()->getY(); 72 | 73 | this->chicore->getWorkspace()->update(); 74 | } 75 | } 76 | 77 | void ToolMove::capMouseUp(WPARAM wParam, LPARAM lParam, int button) 78 | { 79 | switch(button){ 80 | case LEFT: 81 | this->setMouseRelease(); 82 | 83 | this->mouseMoving = false; 84 | 85 | int dx = this->frameEnd.x - this->frameStart.x; 86 | int dy = this->frameEnd.y - this->frameStart.y; 87 | if( dx != 0 || dy != 0 ){ 88 | HEToolMove *he = new HEToolMove( 89 | this->chicore->getWorkspace(), 90 | this->chicore->getWorkspace()->getSelectedLayer(), 91 | this); 92 | he->set(dx,dy); 93 | 94 | this->chicore->getWorkspace()->getHistory()->add(he); 95 | } 96 | 97 | this->chicore->getWorkspace()->updateToolws(); 98 | this->chicore->getWorkspace()->update(); 99 | break; 100 | } 101 | } 102 | 103 | void ToolMove::capKeyDown(WPARAM wParam, LPARAM lParam) 104 | { 105 | int dx, dy; 106 | 107 | switch(wParam){ 108 | case VK_UP: 109 | case VK_DOWN: 110 | case VK_LEFT: 111 | case VK_RIGHT: 112 | if( this->keyMoving == false ){ 113 | this->keyMoving = true; 114 | 115 | if( this->chicore->getWorkspace()->getSelection() != NULL ){ 116 | ToolCopy *cut = (ToolCopy *)this->core->getToolws()->getToolwCC()->toolCut; 117 | ToolCopy *paste = (ToolCopy *)this->core->getToolws()->getToolwCC()->toolPaste; 118 | 119 | cut->activate(); 120 | paste->activate(); 121 | } 122 | 123 | this->frameStart.x = this->chicore->getWorkspace()->getSelectedLayer()->getX(); 124 | this->frameStart.y = this->chicore->getWorkspace()->getSelectedLayer()->getY(); 125 | this->frameEnd = this->frameStart; 126 | } 127 | else { 128 | dx = dy = 0; 129 | switch(wParam){ 130 | case VK_UP: 131 | dy = -1; 132 | break; 133 | case VK_DOWN: 134 | dy = 1; 135 | break; 136 | case VK_LEFT: 137 | dx = -1; 138 | break; 139 | case VK_RIGHT: 140 | dx = 1; 141 | break; 142 | } 143 | if( this->chicore->getWorkspace()->getSelection() != NULL ){ 144 | Matrix off; 145 | off.Translate(dx,dy); 146 | this->chicore->getWorkspace()->getSelection()->Transform(&off); 147 | } 148 | 149 | this->chicore->getWorkspace()->getSelectedLayer()->addXY(dx,dy); 150 | this->chicore->getWorkspace()->update(); 151 | 152 | this->frameEnd.x += dx; 153 | this->frameEnd.y += dy; 154 | } 155 | break; 156 | } 157 | } 158 | 159 | void ToolMove::capKeyUp(WPARAM wParam, LPARAM lParam) 160 | { 161 | int dx, dy; 162 | 163 | switch(wParam){ 164 | case VK_UP: 165 | case VK_DOWN: 166 | case VK_LEFT: 167 | case VK_RIGHT: 168 | dx = dy = 0; 169 | switch(wParam){ 170 | case VK_UP: 171 | dy = -1; 172 | break; 173 | case VK_DOWN: 174 | dy = 1; 175 | break; 176 | case VK_LEFT: 177 | dx = -1; 178 | break; 179 | case VK_RIGHT: 180 | dx = 1; 181 | break; 182 | } 183 | this->chicore->getWorkspace()->getSelectedLayer()->addXY(dx,dy); 184 | this->chicore->getWorkspace()->update(); 185 | 186 | this->frameEnd.x += dx; 187 | this->frameEnd.y += dy; 188 | 189 | this->keyMoving = false; 190 | 191 | dx = this->frameEnd.x - this->frameStart.x; 192 | dy = this->frameEnd.y - this->frameStart.y; 193 | if( dx != 0 || dy != 0 ){ 194 | HEToolMove *he = new HEToolMove( 195 | this->chicore->getWorkspace(), 196 | this->chicore->getWorkspace()->getSelectedLayer(), 197 | this); 198 | he->set(dx,dy); 199 | 200 | this->chicore->getWorkspace()->getHistory()->add(he); 201 | } 202 | 203 | this->chicore->getWorkspace()->updateToolws(); 204 | this->chicore->getWorkspace()->update(); 205 | break; 206 | } 207 | } -------------------------------------------------------------------------------- /Fiew/ToolPencil.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolPencil::ToolPencil(int mode) : ToolDrawing( 5 | (mode == PENPEN) ? (new FwCHAR(TOOL_PENCIL)) : (new FwCHAR(TOOL_ERASER)), 6 | NULL, 7 | (mode == PENPEN) ? ICC_DRAPEN : ICC_ERSNOR 8 | ) 9 | { 10 | this->curve = NULL; 11 | this->counter = NULL; 12 | 13 | this->mode = mode; 14 | 15 | this->cursor = Tool::createToolCursor(5,17,(mode == PENPEN) ? ICC_DRAPEN : ICC_ERSNOR); 16 | this->cursorBackup = this->cursor; 17 | } 18 | 19 | ToolPencil::~ToolPencil() 20 | { 21 | if( this->curve != NULL ) 22 | delete this->curve; 23 | 24 | DestroyIcon(this->cursorBackup); 25 | } 26 | 27 | void ToolPencil::capMouseDown(WPARAM wParam, LPARAM lParam, int button) 28 | { 29 | switch(button){ 30 | case LEFT: 31 | if( this->isLayerReady() == false ) 32 | return; 33 | 34 | this->isDraw = true; 35 | this->counter = 0; 36 | 37 | this->beginPaint(); 38 | this->penColor->SetLineCap(LineCapRound,LineCapRound,DashCapFlat); 39 | this->penColor->SetLineJoin(LineJoinRound); 40 | 41 | Rect rect( 42 | this->mouse.x - (int)(this->size/2.0), 43 | this->mouse.y - (int)(this->size/2.0), 44 | this->size, 45 | this->size 46 | ); 47 | 48 | switch(this->mode){ 49 | case PENPEN: 50 | if( this->size > 1 ) 51 | this->drawgfx->FillEllipse(this->brushColor,rect); 52 | else 53 | this->drawgfx->FillRectangle(this->brushColor,rect); 54 | break; 55 | case PENRUB: 56 | GraphicsPath *path = new GraphicsPath(); 57 | if( this->size > 1 ) 58 | path->AddEllipse(rect); 59 | else 60 | path->AddRectangle(rect); 61 | this->drawgfx->SetClip(path); 62 | this->drawgfx->DrawImage(this->sceneBetween,0,0); 63 | this->drawgfx->DrawImage(this->sceneAbove,0,0); 64 | this->drawgfx->ResetClip(); 65 | delete path; 66 | break; 67 | } 68 | 69 | this->setDrawrectDown(); 70 | 71 | this->curve = new List(); 72 | this->curve->add( new PointF((REAL)this->mouse.x,(REAL)this->mouse.y) ); 73 | 74 | this->update(this->getDrawrect()); 75 | break; 76 | } 77 | } 78 | 79 | void ToolPencil::capMouseMove(WPARAM wParam, LPARAM lParam) 80 | { 81 | this->loadCursor(); 82 | 83 | if( this->isDraw == true ){ 84 | this->curve->add( new PointF((REAL)this->mouse.x,(REAL)this->mouse.y) ); 85 | 86 | int last = 3; 87 | this->counter = (this->counter + 1) % 5; 88 | 89 | PointF *ptfar = this->curve->toArray(last); 90 | 91 | switch(this->mode){ 92 | case PENPEN: 93 | this->drawgfx->DrawLines( 94 | this->penColor, 95 | ptfar, 96 | last 97 | ); 98 | break; 99 | case PENRUB: 100 | GraphicsPath *path = new GraphicsPath(); 101 | path->AddLines(ptfar,last); 102 | path->Widen(this->penColor); 103 | this->drawgfx->SetClip(path); 104 | this->drawgfx->DrawImage(this->sceneBetween,0,0); 105 | this->drawgfx->DrawImage(this->sceneAbove,0,0); 106 | this->drawgfx->ResetClip(); 107 | delete path; 108 | break; 109 | } 110 | delete [] ptfar; 111 | 112 | this->setDrawrectMove(); 113 | 114 | this->update(this->getDrawrect()); 115 | 116 | if( this->counter == 0 ) 117 | SetRect( 118 | &this->drawrect, 119 | this->mouse.x, 120 | this->mouse.y, 121 | this->mouse.x, 122 | this->mouse.y); 123 | } 124 | } 125 | 126 | void ToolPencil::capMouseUp(WPARAM wParam, LPARAM lParam, int button) 127 | { 128 | switch(button){ 129 | case LEFT: 130 | if( this->isDraw == true ){ 131 | this->isDraw = false; 132 | /*this->curve->add( new PointF(this->mouse.x,this->mouse.y) );*/ 133 | /*this->drawgfx->DrawLines( 134 | this->penColor, 135 | this->curve->toArray(), 136 | this->curve->getCount() 137 | );*/ 138 | this->setDrawrectUp(); 139 | 140 | switch(this->mode){ 141 | case PENPEN: 142 | this->endPaint(); 143 | break; 144 | case PENRUB: 145 | Rect rect( 146 | this->mouse.x - (int)(this->size/2.0), 147 | this->mouse.y - (int)(this->size/2.0), 148 | this->size, 149 | this->size 150 | ); 151 | 152 | this->setMouseRelease(); 153 | 154 | GraphicsPath *path = new GraphicsPath(); 155 | 156 | if( this->curve->getCount() > 1 ){ 157 | PointF *ptfar = this->curve->toArray(); 158 | path->AddLines(ptfar,this->curve->getCount()); 159 | path->Widen(this->penColor); 160 | delete [] ptfar; 161 | } 162 | if( this->size > 1 ) 163 | path->AddEllipse(rect); 164 | else 165 | path->AddRectangle(rect); 166 | 167 | Matrix mx; 168 | mx.Translate((REAL)this->cliprect.X,(REAL)this->cliprect.Y); 169 | path->Transform(&mx); 170 | 171 | this->chicore->getWorkspace()->getSelectedLayer()->applyClear(path,this); 172 | 173 | delete path; 174 | 175 | this->chicore->getWorkspace()->updateToolws(); 176 | this->chicore->getWorkspace()->update(); 177 | this->destroy(); 178 | 179 | break; 180 | } 181 | delete this->curve; 182 | this->curve = NULL; 183 | } 184 | break; 185 | } 186 | } 187 | 188 | Rect ToolPencil::getDrawrect() 189 | { 190 | int margin = this->size + 1; 191 | 192 | RECT rect; 193 | SetRect( 194 | &rect, 195 | max( min(this->drawrect.left,this->drawrect.right) - margin, 0 ), 196 | max( min(this->drawrect.top,this->drawrect.bottom) - margin, 0 ), 197 | min( max(this->drawrect.left,this->drawrect.right) + margin, 198 | this->chicore->getWorkspace()->getPxWidth() ), 199 | min( max(this->drawrect.top,this->drawrect.bottom) + margin, 200 | this->chicore->getWorkspace()->getPxHeight() ) 201 | ); 202 | 203 | return Rect( 204 | rect.left, 205 | rect.top, 206 | rect.right - rect.left, 207 | rect.bottom - rect.top 208 | ); 209 | } -------------------------------------------------------------------------------- /Fiew/ToolSampleColor.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolSampleColor::ToolSampleColor() : Tool(new FwCHAR(TOOL_SMPCOL),NULL,ICC_SMPCOL) 5 | { 6 | this->isMoving = false; 7 | this->button = NULL; 8 | 9 | this->cursor = Tool::createToolCursor(4,17,ICC_SMPCOL); 10 | this->cursorBackup = this->cursor; 11 | } 12 | 13 | ToolSampleColor::~ToolSampleColor() 14 | { 15 | DestroyIcon(this->cursorBackup); 16 | } 17 | 18 | void ToolSampleColor::capMouseDown(WPARAM wParam, LPARAM lParam, int button) 19 | { 20 | if( this->isMoving == false ){ 21 | this->setMouseCapture(); 22 | 23 | this->isMoving = true; 24 | this->button = button; 25 | 26 | this->pickColor(); 27 | } 28 | } 29 | 30 | void ToolSampleColor::capMouseMove(WPARAM wParam, LPARAM lParam) 31 | { 32 | if( this->isMoving == true ){ 33 | this->pickColor(); 34 | } 35 | } 36 | 37 | void ToolSampleColor::capMouseUp(WPARAM wParam, LPARAM lParam, int button) 38 | { 39 | if( this->isMoving == true ){ 40 | this->setMouseRelease(); 41 | 42 | this->isMoving = false; 43 | 44 | this->pickColor(); 45 | } 46 | } 47 | 48 | bool ToolSampleColor::getPixel(POINT pixel, Bitmap *scene, Color *color) 49 | { 50 | if( scene == NULL ) 51 | return false; 52 | 53 | int x = min( max(pixel.x,0), (int)scene->GetWidth() - 1); 54 | int y = min( max(pixel.y,0), (int)scene->GetHeight() - 1); 55 | 56 | scene->GetPixel(x,y,color); 57 | 58 | return true; 59 | } 60 | 61 | void ToolSampleColor::pickColor() 62 | { 63 | Color color; 64 | if( 65 | this->getPixel( 66 | this->mouse, 67 | this->chicore->getDrawer()->getBmpScene(), 68 | &color) == false 69 | ) 70 | return; 71 | 72 | switch(this->button){ 73 | case LEFT: 74 | this->core->getToolws()->getToolwCC()->setForeColor(color); 75 | break; 76 | case RIGHT: 77 | this->core->getToolws()->getToolwCC()->setBackColor(color); 78 | break; 79 | } 80 | } -------------------------------------------------------------------------------- /Fiew/ToolSelectPoly.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolSelectPoly::ToolSelectPoly(int mode) : ToolSelecting(new FwCHAR(TOOL_SELPOLY),NULL,mode) 5 | { 6 | this->poly = NULL; 7 | 8 | this->mode = mode; 9 | switch(this->mode){ 10 | case ICC_LASMOS: 11 | delete this->name; 12 | this->name = new FwCHAR(TOOL_SELMOS); 13 | break; 14 | } 15 | } 16 | 17 | ToolSelectPoly::~ToolSelectPoly() 18 | { 19 | if( this->poly != NULL ) 20 | delete this->poly; 21 | } 22 | 23 | void ToolSelectPoly::capMouseClientDlbClk(WPARAM wParam, LPARAM lParam, int button) 24 | { 25 | switch(button){ 26 | case LEFT: 27 | this->endPoly(); 28 | break; 29 | } 30 | } 31 | 32 | void ToolSelectPoly::capMouseDown(WPARAM wParam, LPARAM lParam, int button) 33 | { 34 | switch(button){ 35 | case LEFT: 36 | if( this->isSelecting == false ){ 37 | this->beginPaint(); 38 | 39 | if( this->poly != NULL ) 40 | delete this->poly; 41 | this->poly = new List(); 42 | 43 | this->isMoving = this->getSelectionMoveState(this->mouse.x,this->mouse.y); 44 | 45 | if( this->isMoving == false ){ 46 | this->isSelecting = true; 47 | this->setOldPath(); 48 | 49 | this->setSelection(NULL); 50 | } 51 | this->poly->add( new Point(this->mouse.x,this->mouse.y) ); 52 | } 53 | if( this->isSelecting == true ){ 54 | if( this->isEnd() == true && poly->getCount() > 2 ){ 55 | this->endPoly(); 56 | return; 57 | } 58 | } 59 | this->poly->add( new Point(this->mouse.x,this->mouse.y) ); 60 | 61 | break; 62 | } 63 | } 64 | 65 | void ToolSelectPoly::capMouseMove(WPARAM wParam, LPARAM lParam) 66 | { 67 | if( this->isMoving == true ){ 68 | this->move( 69 | this->mouse.x - this->poly->getTail()->X, 70 | this->mouse.y - this->poly->getTail()->Y); 71 | 72 | this->poly->getTail()->X = this->mouse.x; 73 | this->poly->getTail()->Y = this->mouse.y; 74 | } 75 | else if( this->isSelecting == true ){ 76 | if( this->mode == ICC_LASMOS ){ 77 | this->poly->add(new Point(this->mouse.x,this->mouse.y)); 78 | } 79 | else { 80 | this->poly->getTail()->X = this->mouse.x; 81 | this->poly->getTail()->Y = this->mouse.y; 82 | } 83 | 84 | this->setSelection(this->poly,false,false); 85 | } 86 | } 87 | 88 | void ToolSelectPoly::capMouseUp(WPARAM wParam, LPARAM lParam, int button) 89 | { 90 | switch(button){ 91 | case LEFT: 92 | if( this->isMoving == true ){ 93 | this->endPaint(); 94 | 95 | this->isMoving = false; 96 | 97 | if( this->mouse.x == this->poly->getHead()->X && 98 | this->mouse.y == this->poly->getHead()->Y ) 99 | this->setSelection(NULL,true); 100 | 101 | this->setUpdate(this->chicore->getWorkspace()->getSelection()); 102 | 103 | delete this->poly; 104 | this->poly = NULL; 105 | } 106 | else if( this->isSelecting == true ){ 107 | if( this->mode == ICC_LASMOS ){ 108 | this->endPoly(); 109 | } 110 | else { 111 | if( this->isEnd() == true && poly->getCount() > 2 ){ 112 | this->endPoly(); 113 | } 114 | } 115 | } 116 | break; 117 | } 118 | } 119 | 120 | void ToolSelectPoly::endPoly() 121 | { 122 | this->endPaint(); 123 | 124 | this->isSelecting = false; 125 | 126 | if( this->poly != NULL ){ 127 | if( this->poly->getCount() > 3 ){ 128 | if( this->mode == ICC_LASMOS ){ 129 | delete this->poly->removeTail(); 130 | this->setSelection(this->poly,true,true,true); 131 | } 132 | else { 133 | GraphicsPath *path = new GraphicsPath(); 134 | path->AddLines(this->poly->toArray(),this->poly->getCount()); 135 | path->Outline(); 136 | this->setSelection(path,true,this->isCtrl); 137 | } 138 | } 139 | } 140 | else { 141 | this->setSelection(NULL,true); 142 | } 143 | 144 | this->resetOldPath(); 145 | 146 | delete this->poly; 147 | this->poly = NULL; 148 | } 149 | 150 | bool ToolSelectPoly::isEnd() 151 | { 152 | int margin = 5; 153 | Point *head = this->poly->getHead(); 154 | 155 | if( this->mouse.x > head->X - margin && 156 | this->mouse.x < head->X + margin && 157 | this->mouse.y > head->Y - margin && 158 | this->mouse.y < head->Y + margin ) 159 | return true; 160 | 161 | return false; 162 | } -------------------------------------------------------------------------------- /Fiew/ToolSelectRect.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolSelectRect::ToolSelectRect(int mode) : ToolSelecting(new FwCHAR(TOOL_SELRECT),NULL,ICC_SELREC) 5 | { 6 | SetRect(&this->selection,0,0,0,0); 7 | this->mode = mode; 8 | 9 | switch(this->mode){ 10 | case SELCIRC: 11 | delete this->name; 12 | this->name = new FwCHAR(TOOL_SELCIRC); 13 | this->id = ICC_SELCIR; 14 | break; 15 | case SELHOR: 16 | delete this->name; 17 | this->name = new FwCHAR(TOOL_SELHOR); 18 | this->id = ICC_SELHOR; 19 | break; 20 | case SELVER: 21 | delete this->name; 22 | this->name = new FwCHAR(TOOL_SELVER); 23 | this->id = ICC_SELVER; 24 | break; 25 | } 26 | } 27 | 28 | ToolSelectRect::~ToolSelectRect() 29 | { 30 | 31 | } 32 | 33 | void ToolSelectRect::capMouseDown(WPARAM wParam, LPARAM lParam, int button) 34 | { 35 | switch(button){ 36 | case LEFT: 37 | this->beginPaint(); 38 | 39 | this->isMoving = this->getSelectionMoveState(this->mouse.x,this->mouse.y); 40 | 41 | this->setOldPath(); 42 | if( this->isMoving == false ){ 43 | this->isSelecting = true; 44 | 45 | 46 | this->setSelection(NULL); 47 | } 48 | 49 | SetRect( 50 | &this->selection, 51 | this->mouse.x, 52 | this->mouse.y, 53 | this->mouse.x, 54 | this->mouse.y 55 | ); 56 | break; 57 | } 58 | } 59 | 60 | void ToolSelectRect::capMouseMove(WPARAM wParam, LPARAM lParam) 61 | { 62 | if( this->isMoving == true ){ 63 | this->move( 64 | this->mouse.x - this->selection.left, 65 | this->mouse.y - this->selection.top); 66 | 67 | this->selection.left = this->mouse.x; 68 | this->selection.top = this->mouse.y; 69 | } 70 | else if( this->isSelecting == true ){ 71 | this->selection.right = this->mouse.x; 72 | this->selection.bottom = this->mouse.y; 73 | 74 | if( this->isShift == true ){ 75 | int dx = this->selection.right - this->selection.left; 76 | int dy = this->selection.bottom - this->selection.top; 77 | 78 | int ds = min(abs(dx),abs(dy)); 79 | 80 | if( dx >= 0 && dy >= 0 ){ 81 | this->selection.right = this->selection.left + ds; 82 | this->selection.bottom = this->selection.top + ds; 83 | } 84 | else if( dx >= 0 && dy < 0 ){ 85 | this->selection.right = this->selection.left + ds; 86 | this->selection.bottom = this->selection.top - ds; 87 | } 88 | else if( dx < 0 && dy >= 0 ){ 89 | this->selection.right = this->selection.left - ds; 90 | this->selection.bottom = this->selection.top + ds; 91 | } 92 | else if( dx < 0 && dy < 0 ){ 93 | this->selection.right = this->selection.left - ds; 94 | this->selection.bottom = this->selection.top - ds; 95 | } 96 | } 97 | 98 | this->setSelection(this->selection,this->mode); 99 | } 100 | } 101 | 102 | void ToolSelectRect::capMouseUp(WPARAM wParam, LPARAM lParam, int button) 103 | { 104 | switch(button){ 105 | case LEFT: 106 | this->endPaint(); 107 | 108 | if( this->isMoving == true ){ 109 | this->isMoving = false; 110 | 111 | if( this->mouse.x == this->selection.right && 112 | this->mouse.y == this->selection.bottom ){ 113 | this->setSelection(NULL,true); 114 | this->resetOldPath(); 115 | } 116 | else { 117 | this->resetOldPath(false); 118 | this->setUpdate(this->chicore->getWorkspace()->getSelection()); 119 | } 120 | } 121 | else if( this->isSelecting == true ){ 122 | this->isSelecting = false; 123 | 124 | if( this->mouse.x == this->selection.left && 125 | this->mouse.y == this->selection.top ) 126 | this->setSelection(NULL,true); 127 | else 128 | this->setSelection(this->selection,this->mode,true); 129 | 130 | this->resetOldPath(); 131 | } 132 | break; 133 | } 134 | } 135 | 136 | void ToolSelectRect::setSelectAll() 137 | { 138 | ChildCore *child = this->core->getActiveChild(); 139 | if( child != NULL ){ 140 | this->chicore = child; 141 | this->setOldPath(); 142 | 143 | RECT rect; 144 | SetRect( 145 | &rect, 146 | 0,0, 147 | child->getWorkspace()->getPxWidth(), 148 | child->getWorkspace()->getPxHeight() 149 | ); 150 | this->setSelection(rect,true); 151 | 152 | this->resetOldPath(); 153 | } 154 | } 155 | void ToolSelectRect::deselect() 156 | { 157 | ChildCore *child = this->core->getActiveChild(); 158 | if( child != NULL ){ 159 | this->chicore = child; 160 | this->setOldPath(); 161 | 162 | this->setSelection(NULL,true); 163 | this->chicore->getDrawer()->setDrawpath(NULL); 164 | 165 | if( this->core->getToolws()->getToolwCC()->getTool() == 166 | this->core->getToolws()->getToolwCC()->toolCrop ){ 167 | ((ToolCrop *)this->core->getToolws()->getToolwCC()->toolCrop)->finalize(false,false); 168 | } 169 | 170 | this->resetOldPath(); 171 | } 172 | } 173 | void ToolSelectRect::setSelectInverse() 174 | { 175 | ChildCore *child = this->core->getActiveChild(); 176 | if( child != NULL ){ 177 | this->chicore = child; 178 | 179 | this->setOldPath(); 180 | if( this->oldPath != NULL ){ 181 | GraphicsPath *path = new GraphicsPath(FillModeWinding); 182 | path->AddRectangle(Rect( 183 | 0,0, 184 | child->getWorkspace()->getPxWidth(), 185 | child->getWorkspace()->getPxHeight()) 186 | ); 187 | this->oldPath->SetFillMode(FillModeWinding); 188 | 189 | path->AddPath(this->oldPath,TRUE); 190 | path->Flatten(); 191 | path->Outline(); 192 | 193 | this->setSelection(path,true); 194 | 195 | this->resetOldPath(); 196 | } 197 | } 198 | } -------------------------------------------------------------------------------- /Fiew/ToolSelecting.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolSelecting::ToolSelecting(FwCHAR *name, HCURSOR cursor, UINT id) : Tool(name, 5 | ((cursor == NULL) ? LoadCursor(NULL,IDC_CROSS) : cursor), 6 | id) 7 | { 8 | this->rectmargin = 2; 9 | 10 | this->isSelecting = false; 11 | this->isMoving = false; 12 | this->isAA = false; 13 | 14 | this->currentPath = NULL; 15 | this->oldPath = NULL; 16 | } 17 | 18 | ToolSelecting::~ToolSelecting() 19 | { 20 | 21 | } 22 | 23 | void ToolSelecting::activate(){ this->activateDock(); } 24 | void ToolSelecting::deactivate(){ } 25 | 26 | void ToolSelecting::beginPaint() 27 | { 28 | SetCapture(this->chicore->getWindowHandle()); 29 | } 30 | 31 | void ToolSelecting::endPaint() 32 | { 33 | ReleaseCapture(); 34 | } 35 | 36 | void ToolSelecting::capMouseDblClk(WPARAM wParam, LPARAM lParam, int button){ } 37 | 38 | void ToolSelecting::capMouseClientDlbClk(WPARAM wParam, LPARAM lParam, int button){ } 39 | void ToolSelecting::capMouseWheel(WPARAM wParam, LPARAM lParam){ } 40 | void ToolSelecting::capMouseDown(WPARAM wParam, LPARAM lParam, int button){ } 41 | void ToolSelecting::capMouseMove(WPARAM wParam, LPARAM lParam){ } 42 | void ToolSelecting::capMouseUp(WPARAM wParam, LPARAM lParam, int button){ } 43 | 44 | void ToolSelecting::capKeyDown(WPARAM wParam, LPARAM lParam) 45 | { 46 | int dx, dy; 47 | 48 | switch(wParam){ 49 | case VK_UP: 50 | case VK_DOWN: 51 | case VK_LEFT: 52 | case VK_RIGHT: 53 | if( this->isMoving == false && this->isSelecting == false ){ 54 | this->isAA = true; 55 | this->currentPath = this->chicore->getWorkspace()->getSelection(); 56 | 57 | if( this->currentPath != NULL ){ 58 | dx = dy = 0; 59 | switch(wParam){ 60 | case VK_UP: 61 | dy = -1; 62 | break; 63 | case VK_DOWN: 64 | dy = 1; 65 | break; 66 | case VK_LEFT: 67 | dx = -1; 68 | break; 69 | case VK_RIGHT: 70 | dx = 1; 71 | break; 72 | } 73 | this->move(dx,dy); 74 | } 75 | } 76 | break; 77 | } 78 | } 79 | void ToolSelecting::capKeyUp(WPARAM wParam, LPARAM lParam) 80 | { 81 | int dx, dy; 82 | 83 | switch(wParam){ 84 | case VK_UP: 85 | case VK_DOWN: 86 | case VK_LEFT: 87 | case VK_RIGHT: 88 | if( this->isMoving == false && this->isSelecting == false && this->isAA == false ){ 89 | this->currentPath = this->chicore->getWorkspace()->getSelection(); 90 | 91 | if( this->currentPath != NULL ){ 92 | dx = dy = 0; 93 | switch(wParam){ 94 | case VK_UP: 95 | dy = -1; 96 | break; 97 | case VK_DOWN: 98 | dy = 1; 99 | break; 100 | case VK_LEFT: 101 | dx = -1; 102 | break; 103 | case VK_RIGHT: 104 | dx = 1; 105 | break; 106 | } 107 | this->move(dx,dy); 108 | } 109 | } 110 | this->isAA = false; 111 | break; 112 | case VK_DELETE: 113 | this->core->getGui()->clear(); 114 | break; 115 | } 116 | } 117 | 118 | POINT ToolSelecting::getMousePos(LPARAM lParam) 119 | { 120 | POINT mouse = Core::makePoint(lParam); 121 | 122 | Rect scene = this->chicore->getDrawer()->getRectScene(); 123 | double zoom = this->chicore->getDrawer()->getZoom(); 124 | 125 | mouse.x = (int)floor(mouse.x / zoom); 126 | mouse.y = (int)floor(mouse.y / zoom); 127 | 128 | scene.X /= zoom; 129 | scene.Y /= zoom; 130 | 131 | mouse.x -= scene.X; 132 | mouse.y -= scene.Y; 133 | 134 | /* 135 | mouse.x = max(mouse.x,0); 136 | mouse.y = max(mouse.y,0); 137 | mouse.x = min(mouse.x,this->chicore->getWorkspace()->getPxWidth() - 1); 138 | mouse.y = min(mouse.y,this->chicore->getWorkspace()->getPxHeight() - 1); 139 | */ 140 | 141 | return mouse; 142 | } 143 | 144 | void ToolSelecting::setOldPath() 145 | { 146 | this->oldPath = NULL; 147 | 148 | if( this->chicore->getWorkspace()->getSelection() != NULL ){ 149 | this->oldPath = this->chicore->getWorkspace()->getSelection()->Clone(); 150 | } 151 | } 152 | void ToolSelecting::resetOldPath(bool final) 153 | { 154 | if( final == true && (this->oldPath != NULL || this->chicore->getWorkspace()->getSelection() != NULL) ){ 155 | HEToolSelecting *he = new HEToolSelecting( 156 | this->chicore->getWorkspace(), 157 | this->chicore->getWorkspace()->getSelectedLayer(), 158 | this 159 | ); 160 | he->set(this->oldPath,this->chicore->getWorkspace()->getSelection()); 161 | 162 | this->chicore->getWorkspace()->getHistory()->add(he); 163 | } 164 | if( this->oldPath != NULL ) 165 | delete this->oldPath; 166 | this->oldPath = NULL; 167 | } 168 | 169 | void ToolSelecting::setUpdate(GraphicsPath *path) 170 | { 171 | ((HEToolSelecting *)this->chicore->getWorkspace()->getHistory()->getHistoryElems()->getTail())->setUpdate(path); 172 | } 173 | 174 | bool ToolSelecting::getSelectionMoveState(int x, int y) 175 | { 176 | this->currentPath = this->chicore->getWorkspace()->getSelection(); 177 | 178 | if( this->currentPath != NULL && this->isCtrl != true ) 179 | return (bool)this->currentPath->IsVisible( Point(x,y) ); 180 | 181 | return false; 182 | } 183 | 184 | void ToolSelecting::setSelection(GraphicsPath *path, bool final, bool shiftJoin) 185 | { 186 | if( this->oldPath != NULL && shiftJoin == true ){ 187 | if( path != NULL ){ 188 | path->AddPath(this->oldPath,TRUE); 189 | } 190 | else { 191 | path = this->oldPath->Clone(); 192 | } 193 | //path->SetFillMode(FillModeWinding); 194 | } 195 | //else if( this->isCtrl == false && path == NULL ) 196 | // this->resetOldPath(false); 197 | 198 | if( final == true && path != NULL ){ 199 | path->Flatten(); 200 | path->Outline(); 201 | } 202 | this->core->getActiveChild()->getWorkspace()->setSelection(path); 203 | this->update(); 204 | } 205 | 206 | void ToolSelecting::setSelection(List *poly, bool close, bool clip, bool final) 207 | { 208 | GraphicsPath *path = new GraphicsPath(); 209 | if( close == true ){ 210 | path->AddPolygon(poly->toArray(),poly->getCount()); 211 | path->Flatten(); 212 | path->Outline(); 213 | } 214 | else { 215 | path->AddLines(poly->toArray(),poly->getCount()); 216 | } 217 | 218 | this->setSelection(path,final,this->isCtrl); 219 | } 220 | 221 | void ToolSelecting::setSelection(RECT rect, int mode, bool final) 222 | { 223 | GraphicsPath *path = new GraphicsPath(); 224 | 225 | if( mode == SELRECT || mode == SELCIRC ){ 226 | SetRect( 227 | &rect, 228 | max( min(rect.left,rect.right), 0 ), 229 | max( min(rect.top,rect.bottom), 0 ), 230 | min( max(rect.left,rect.right), 231 | this->core->getActiveChild()->getWorkspace()->getPxWidth() ), 232 | min( max(rect.top,rect.bottom), 233 | this->core->getActiveChild()->getWorkspace()->getPxHeight() ) 234 | ); 235 | } 236 | else if( mode == SELHOR ){ 237 | SetRect( 238 | &rect, 239 | 0, 240 | min( max(rect.top,0), 241 | this->core->getActiveChild()->getWorkspace()->getPxHeight() - 2 ), 242 | this->chicore->getWorkspace()->getPxWidth(), 243 | min( max(rect.top,0), 244 | this->core->getActiveChild()->getWorkspace()->getPxHeight() - 1 ) + 1 245 | ); 246 | } 247 | else if( mode == SELVER ){ 248 | SetRect( 249 | &rect, 250 | min( max(rect.left,0), 251 | this->core->getActiveChild()->getWorkspace()->getPxWidth() - 2 ), 252 | 0, 253 | min( max(rect.left,0), 254 | this->core->getActiveChild()->getWorkspace()->getPxWidth() - 1 ) + 1, 255 | this->core->getActiveChild()->getWorkspace()->getPxHeight() 256 | ); 257 | } 258 | if( mode == SELRECT || 259 | mode == SELHOR || 260 | mode == SELVER ){ 261 | 262 | path->AddRectangle( 263 | Rect(rect.left, 264 | rect.top, 265 | rect.right - rect.left, 266 | rect.bottom - rect.top) ); 267 | } 268 | else if( mode == SELCIRC ){ 269 | path->AddEllipse( 270 | Rect(rect.left, 271 | rect.top, 272 | rect.right - rect.left, 273 | rect.bottom - rect.top) ); 274 | } 275 | path->Flatten(); 276 | path->Outline(); 277 | 278 | this->setSelection(path,final,this->isCtrl); 279 | } 280 | 281 | void ToolSelecting::move(int x, int y) 282 | { 283 | Matrix mx; 284 | mx.Translate((REAL)x,(REAL)y); 285 | 286 | this->currentPath->Transform(&mx); 287 | this->update(); 288 | } 289 | 290 | void ToolSelecting::update() 291 | { 292 | this->core->getActiveChild()->getDrawer()->invalidate(); 293 | } -------------------------------------------------------------------------------- /Fiew/ToolZoom.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Core.h" 3 | 4 | ToolZoom::ToolZoom() : ToolSelecting(new FwCHAR(TOOL_ZOOM),NULL,ICC_ZOO) 5 | { 6 | this->isSelecting = false; 7 | this->lastPin = Point(0,0); 8 | SetRect(&this->selection,0,0,0,0); 9 | 10 | this->isAll = false; 11 | 12 | this->cursor = Tool::createToolCursor(10,8,ICC_ZOO); 13 | this->cursorBackup = this->cursor; 14 | 15 | this->fillDock(); 16 | } 17 | 18 | ToolZoom::~ToolZoom() 19 | { 20 | DestroyIcon(this->cursorBackup); 21 | } 22 | 23 | void ToolZoom::fillDock() 24 | { 25 | this->core->CreateWindowExSubstituteFont( 26 | NULL, 27 | IDCL_BUTTON, 28 | TOOL_ZOOM_FITTO, 29 | WS_VISIBLE | WS_CHILD, 30 | 0,0,100,20, 31 | this->hdocktool, 32 | (HMENU)33, 33 | this->core->getInstance(), 34 | NULL 35 | ); 36 | 37 | this->core->CreateWindowExSubstituteFont( 38 | NULL, 39 | IDCL_BUTTON, 40 | TOOL_ZOOM_RESET, 41 | WS_VISIBLE | WS_CHILD, 42 | 110,0,100,20, 43 | this->hdocktool, 44 | (HMENU)11, 45 | this->core->getInstance(), 46 | NULL 47 | ); 48 | 49 | this->dlgAll = this->core->CreateWindowExSubstituteFont( 50 | NULL, 51 | IDCL_BUTTON, 52 | TOOL_ZOOM_ALL, 53 | WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, 54 | 220,0,150,20, 55 | this->hdocktool, 56 | (HMENU)22, 57 | this->core->getInstance(), 58 | NULL 59 | ); 60 | CheckDlgButton(this->hdocktool,22,BST_UNCHECKED); 61 | } 62 | 63 | void ToolZoom::notify(int id) 64 | { 65 | RECT client; 66 | double zm; 67 | 68 | switch(id){ 69 | case 11: 70 | if( this->isAll == true && this->core->getChildren()->getCount() > 0 ){ 71 | this->core->getChildren()->gotoHead(); 72 | do { 73 | this->core->getChildren()->getThat()->setZoom(ZOOMINIT); 74 | } while( this->core->getChildren()->next() == true ); 75 | } 76 | else { 77 | this->core->getActiveChild()->setZoom(ZOOMINIT); 78 | } 79 | break; 80 | case 22: 81 | this->isAll = (bool)IsDlgButtonChecked(this->hdocktool,22); 82 | break; 83 | case 33: 84 | if( this->isAll == true && this->core->getChildren()->getCount() > 0 ){ 85 | this->core->getChildren()->gotoHead(); 86 | do { 87 | client = this->core->getChildren()->getThat()->getDrawer()->getClientSize(); 88 | zm = this->calcFit(client.right,client.bottom); 89 | this->core->getChildren()->getThat()->setZoom(zm); 90 | } while( this->core->getChildren()->next() == true ); 91 | } 92 | else { 93 | client = this->core->getActiveChild()->getDrawer()->getClientSize(); 94 | zm = this->calcFit(client.right,client.bottom); 95 | this->core->getActiveChild()->setZoom(zm); 96 | } 97 | break; 98 | } 99 | } 100 | 101 | void ToolZoom::capKeyDown(WPARAM wParam, LPARAM lParam) 102 | { 103 | 104 | } 105 | 106 | void ToolZoom::capKeyUp(WPARAM wParam, LPARAM lParam) 107 | { 108 | 109 | } 110 | 111 | void ToolZoom::capMouseDblClk(WPARAM wParam, LPARAM lParam, int button) 112 | { 113 | switch(button){ 114 | case LEFT: 115 | if( this->isAll == true && this->core->getChildren()->getCount() > 0 ){ 116 | this->core->getChildren()->gotoHead(); 117 | do { 118 | this->core->getChildren()->getThat()->setZoom(ZOOMINIT); 119 | } while( this->core->getChildren()->next() == true ); 120 | } 121 | else { 122 | this->chicore->setZoom(ZOOMINIT); 123 | } 124 | this->chicore->pinSkew(this->lastPin.X,this->lastPin.Y); 125 | break; 126 | } 127 | } 128 | 129 | void ToolZoom::capMouseDown(WPARAM wParam, LPARAM lParam, int button) 130 | { 131 | switch(button){ 132 | case RIGHT: 133 | this->isAlt = true; 134 | case LEFT: 135 | this->setMouseCapture(); 136 | 137 | this->isSelecting = true; 138 | 139 | SetRect( 140 | &this->selection, 141 | this->mouse.x, 142 | this->mouse.y, 143 | this->mouse.x, 144 | this->mouse.y 145 | ); 146 | break; 147 | } 148 | } 149 | 150 | void ToolZoom::capMouseMove(WPARAM wParam, LPARAM lParam) 151 | { 152 | if( this->isSelecting == true ){ 153 | this->selection.right = this->mouse.x; 154 | this->selection.bottom = this->mouse.y; 155 | 156 | this->setDrawpath(); 157 | } 158 | } 159 | 160 | void ToolZoom::capMouseUp(WPARAM wParam, LPARAM lParam, int button) 161 | { 162 | switch(button){ 163 | case RIGHT: 164 | this->isAlt = true; 165 | case LEFT: 166 | this->setMouseRelease(); 167 | 168 | this->isSelecting = false; 169 | this->chicore->getDrawer()->setDrawpath(NULL); 170 | 171 | if( this->selection.left == this->selection.right && 172 | this->selection.top == this->selection.bottom ){ 173 | 174 | if( this->isAlt == false ){ 175 | if( this->isAll == true && this->core->getChildren()->getCount() > 0 ){ 176 | this->core->getChildren()->gotoHead(); 177 | do { 178 | this->core->getChildren()->getThat()->addZoom(ZOOMLOSTEP); 179 | } while( this->core->getChildren()->next() == true ); 180 | } 181 | else { 182 | this->chicore->addZoom(ZOOMLOSTEP); 183 | } 184 | } 185 | else if( this->isAlt == true ){ 186 | if( this->isAll == true && this->core->getChildren()->getCount() > 0 ){ 187 | this->core->getChildren()->gotoHead(); 188 | do { 189 | this->core->getChildren()->getThat()->addZoom(-ZOOMLOSTEP); 190 | } while( this->core->getChildren()->next() == true ); 191 | } 192 | else { 193 | this->chicore->addZoom(-ZOOMLOSTEP); 194 | } 195 | } 196 | 197 | this->chicore->pinSkew(this->selection.left,this->selection.top); 198 | this->lastPin = Point(this->selection.left,this->selection.top); 199 | } 200 | else { 201 | double sw = abs(this->selection.left - this->selection.right); 202 | double sh = abs(this->selection.top - this->selection.bottom); 203 | 204 | if( sw > ZOOMTOOLIMIT && sh > ZOOMTOOLIMIT ){ 205 | double zm = this->calcZoom(sw,sh,this->chicore->getDrawer()->getZoom()); 206 | 207 | if( this->isAll == true && this->core->getChildren()->getCount() > 0 ){ 208 | this->core->getChildren()->gotoHead(); 209 | do { 210 | this->core->getChildren()->getThat()->setZoom(zm); 211 | } while( this->core->getChildren()->next() == true ); 212 | } 213 | else { 214 | this->chicore->setZoom(zm); 215 | } 216 | 217 | RECT pin; 218 | SetRect( 219 | &pin, 220 | min(this->selection.left,this->selection.right), 221 | min(this->selection.top,this->selection.bottom), 222 | max(this->selection.left,this->selection.right), 223 | max(this->selection.top,this->selection.bottom) 224 | ); 225 | 226 | int pinx = pin.left + (pin.right - pin.left)/2; 227 | int piny = pin.top + (pin.bottom - pin.top)/2; 228 | 229 | this->chicore->pinSkew(pinx,piny); 230 | this->lastPin = Point(pinx,piny); 231 | } 232 | } 233 | break; 234 | } 235 | } 236 | 237 | void ToolZoom::setDrawpath() 238 | { 239 | GraphicsPath *path = new GraphicsPath(); 240 | 241 | path->AddRectangle( Rect( 242 | min(this->selection.left,this->selection.right), 243 | min(this->selection.top,this->selection.bottom), 244 | abs(this->selection.left - this->selection.right), 245 | abs(this->selection.top - this->selection.bottom) ) ); 246 | 247 | this->chicore->getDrawer()->setDrawpenSize(1); 248 | this->chicore->getDrawer()->setDrawpath(path); 249 | } 250 | 251 | double ToolZoom::calcZoom(double sw, double sh, double zm) 252 | { 253 | double ww = this->chicore->getWorkspace()->getPxWidth() * zm; 254 | double wh = this->chicore->getWorkspace()->getPxHeight() * zm; 255 | 256 | RECT client = this->chicore->getDrawer()->getClientSize(); 257 | 258 | double zw = floor(sw * zm / ww); 259 | if( sw < ww ){ 260 | zw = client.right / sw; 261 | } 262 | 263 | double zh = floor(sh * zm / wh); 264 | if( sh < wh ){ 265 | zh = client.bottom / sh; 266 | } 267 | 268 | if( this->isAlt == false ) 269 | zm += min(zw,zh); 270 | else 271 | zm -= min(zw,zh); 272 | 273 | return zm; 274 | } 275 | 276 | double ToolZoom::calcFit(double sw, double sh) 277 | { 278 | double ww = this->chicore->getWorkspace()->getPxWidth(); 279 | double wh = this->chicore->getWorkspace()->getPxHeight(); 280 | 281 | double zw = sw / ww; 282 | double zh = sh / wh; 283 | 284 | return min(zw,zh); 285 | } -------------------------------------------------------------------------------- /Fiew/Toolw.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Toolw.cpp 3 | This object represents the interface (in object-oriented programming sense) 4 | of the Tool Windows classes. Contains basic methods and variables. 5 | */ 6 | 7 | #include "stdafx.h" 8 | #include "Core.h" 9 | 10 | Toolw::Toolw(Core *core, Toolws *controler) 11 | { 12 | this->core = core; 13 | this->controler = controler; 14 | 15 | this->hToolw = NULL; 16 | } 17 | 18 | Toolw::~Toolw() 19 | { 20 | this->destroy(); 21 | } 22 | 23 | void Toolw::destroy() 24 | { 25 | 26 | } 27 | 28 | HWND Toolw::initialize() 29 | { 30 | return NULL; 31 | } 32 | 33 | HWND Toolw::getWindowHandle() 34 | { 35 | return this->hToolw; 36 | } 37 | 38 | Core *Toolw::getCore() 39 | { 40 | return this->core; 41 | } 42 | 43 | Toolws *Toolw::getControler() 44 | { 45 | return this->controler; 46 | } 47 | 48 | void Toolw::globalSubclass(HWND hDlg) 49 | { 50 | WNDPROC proc = (WNDPROC)GetWindowLong(hDlg,GWL_WNDPROC); 51 | SetProp(hDlg,ATOM_PROC,(HANDLE)proc); 52 | 53 | SetWindowLong(hDlg,GWL_WNDPROC,(LONG)Toolw::globalProc); 54 | } 55 | 56 | LRESULT CALLBACK Toolw::globalProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 57 | { 58 | WNDPROC proc = (WNDPROC)GetProp(hDlg,ATOM_PROC); 59 | if( proc == NULL ) 60 | return DefWindowProc(hDlg,message,wParam,lParam); 61 | 62 | switch(message){ 63 | case WM_ERASEBKGND: 64 | return 1; 65 | case WM_MOUSEMOVE: 66 | Core::self->getGui()->setCursor(IDC_HAND); 67 | default: 68 | return CallWindowProc(proc,hDlg,message,wParam,lParam); 69 | } 70 | } 71 | 72 | void Toolw::tooltipSubclass(HWND hDlg, FwCHAR *tip) 73 | { 74 | WNDPROC proc = (WNDPROC)GetWindowLong(hDlg,GWL_WNDPROC); 75 | SetProp(hDlg,ATOM_TTPROC,(HANDLE)proc); 76 | SetProp(hDlg,ATOM_TTL,(HANDLE)tip); 77 | 78 | SetWindowLong(hDlg,GWL_WNDPROC,(LONG)Toolw::tooltipProc); 79 | } 80 | 81 | LRESULT CALLBACK Toolw::tooltipProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 82 | { 83 | WNDPROC proc = (WNDPROC)GetProp(hDlg,ATOM_TTPROC); 84 | if( proc == NULL ) 85 | return DefWindowProc(hDlg,message,wParam,lParam); 86 | 87 | FwCHAR *tip = (FwCHAR *)GetProp(hDlg,ATOM_TTL); 88 | HWND hTip = (HWND)GetProp(hDlg,ATOM_CHILD); 89 | BOOL track = (BOOL)GetProp(hDlg,ATOM_BOOL); 90 | 91 | RECT client, screen; 92 | TRACKMOUSEEVENT tme; 93 | tme.cbSize = sizeof(tme); 94 | tme.dwFlags = TME_LEAVE; 95 | tme.dwHoverTime = HOVER_DEFAULT; 96 | tme.hwndTrack = hDlg; 97 | 98 | switch(message){ 99 | case WM_MOUSEMOVE: 100 | KillTimer(hDlg,TIMER_TIP); 101 | if( track == FALSE ){ 102 | TrackMouseEvent(&tme); 103 | SetProp(hDlg,ATOM_BOOL,(HANDLE)TRUE); 104 | } 105 | if( hTip == NULL ) 106 | SetTimer(hDlg,TIMER_TIP,TIPTOUT,NULL); 107 | break; 108 | case WM_MOUSELEAVE: 109 | KillTimer(hDlg,TIMER_TIP); 110 | SetProp(hDlg,ATOM_BOOL,(HANDLE)FALSE); 111 | if( hTip != NULL ){ 112 | SetProp(hDlg,ATOM_CHILD,NULL); 113 | DestroyWindow(hTip); 114 | } 115 | break; 116 | case WM_TIMER: 117 | switch(wParam){ 118 | case TIMER_TIP: 119 | KillTimer(hDlg,TIMER_TIP); 120 | 121 | if( tip != NULL ){ 122 | SetRect(&screen,0,0,GetDeviceCaps(GetDC(NULL),HORZRES),GetDeviceCaps(GetDC(NULL),VERTRES)); 123 | GetWindowRect(hDlg,&client); 124 | 125 | int width = tip->toLength() * (FONTSIZE_STATIC - 1); 126 | int height = 2 * FONTSIZE_STATIC; 127 | 128 | client.left += 5; 129 | client.right = client.left + width; 130 | 131 | client.top = client.bottom + 5; 132 | client.bottom = client.top + height; 133 | 134 | client.left += min(screen.right - client.right,0); 135 | client.top += min(screen.bottom - client.bottom,0); 136 | 137 | hTip = CreateWindowEx( 138 | WS_EX_TOPMOST, 139 | IDCL_FAKETOOLTIP, 140 | NULL, 141 | WS_POPUP | WS_BORDER, 142 | client.left, 143 | client.top, 144 | width, 145 | height, 146 | hDlg, 147 | NULL, 148 | Core::self->getInstance(), 149 | tip 150 | ); 151 | SetProp(hDlg,ATOM_CHILD,hTip); 152 | } 153 | return 1; 154 | } 155 | break; 156 | } 157 | return CallWindowProc(proc,hDlg,message,wParam,lParam); 158 | } 159 | 160 | LRESULT CALLBACK Toolw::tooltipLabelProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 161 | { 162 | RECT client; 163 | FwCHAR *tip = NULL; 164 | CREATESTRUCT *cs; 165 | 166 | switch(message){ 167 | case WM_CREATE: 168 | Core::self->getToolws()->getToolwset()->add(hDlg); 169 | 170 | cs = (LPCREATESTRUCT)lParam; 171 | tip = (FwCHAR *)cs->lpCreateParams; 172 | 173 | GetClientRect(hDlg,&client); 174 | 175 | if( tip != NULL ){ 176 | Core::self->CreateWindowExSubstituteFont( 177 | NULL, 178 | IDCL_STATIC, 179 | tip->toWCHAR(), 180 | WS_CHILD | WS_VISIBLE | SS_CENTER, 181 | client.left, 182 | client.top, 183 | client.right, 184 | client.bottom, 185 | hDlg, 186 | NULL, 187 | Core::self->getInstance(), 188 | NULL 189 | ); 190 | 191 | SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); 192 | ShowWindow(hDlg,SW_SHOW); 193 | } 194 | else { 195 | DestroyWindow(hDlg); 196 | } 197 | break; 198 | case WM_CTLCOLORSTATIC: 199 | SetBkMode((HDC)wParam,TRANSPARENT); 200 | SetDCBrushColor((HDC)wParam,GetSysColor(COLOR_INFOBK)); 201 | SetTextColor((HDC)wParam,GetSysColor(COLOR_INFOTEXT)); 202 | return (LRESULT)GetStockObject(DC_BRUSH); 203 | case WM_NCACTIVATE: 204 | return Core::self->getToolws()->overrideNCActivate(hDlg,wParam,lParam); 205 | case WM_ENABLE: 206 | return Core::self->getToolws()->overrideEnable(hDlg,wParam,lParam); 207 | case WM_DESTROY: 208 | Core::self->getToolws()->getToolwset()->remove(hDlg); 209 | break; 210 | default: 211 | return DefWindowProc(hDlg,message,wParam,lParam); 212 | } 213 | return 0; 214 | } -------------------------------------------------------------------------------- /Fiew/ToolwBox.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ToolwBox.cpp 3 | This object represents a Tool Window that contains content like Layer, History, Info. 4 | It is a container and is prepared for the future option of moving inside contents 5 | between other ToolwBox windows. 6 | */ 7 | 8 | #include "stdafx.h" 9 | #include "Core.h" 10 | 11 | ToolwBox::ToolwBox(Core *core, Toolws *controler, bool noresize) : Toolw(core,controler) 12 | { 13 | this->contents = new List(); 14 | this->noresize = noresize; 15 | 16 | int right = GetDeviceCaps(GetDC(NULL),HORZRES); 17 | DWORD style = WS_POPUPWINDOW | WS_CAPTION | WS_VISIBLE | WS_CLIPCHILDREN; 18 | 19 | if( noresize == false ) 20 | style |= WS_SIZEBOX; 21 | 22 | this->hToolw = CreateWindowEx( 23 | WS_EX_TOOLWINDOW, 24 | IDCL_TOOLW_BOX, 25 | NULL, 26 | style, 27 | right - TW_BX_MINW - 5, 28 | TWPOS_CC + Toolws::boxCounter * (TW_BX_MINH + 5), 29 | TW_BX_MINW, 30 | TW_BX_MINH, 31 | this->core->getWindowHandle(), 32 | NULL, 33 | this->core->getInstance(), 34 | NULL 35 | ); 36 | 37 | SetProp(this->hToolw,ATOM_THIS,this); 38 | 39 | GetClientRect(this->hToolw,&this->sizeContent); 40 | } 41 | 42 | ToolwBox::~ToolwBox() 43 | { 44 | 45 | } 46 | 47 | void ToolwBox::addContent(ToolwBoxContent *content) 48 | { 49 | this->contents->add(content); 50 | 51 | if( this->contents->getCount() == 1 ) 52 | SetWindowText(this->hToolw,content->getName()->toWCHAR()); 53 | else 54 | SetWindowText(this->hToolw,NULL); 55 | } 56 | 57 | void ToolwBox::removeContent(ToolwBoxContent *content) 58 | { 59 | this->contents->add(content); 60 | } 61 | 62 | void ToolwBox::resizeContent() 63 | { 64 | RECT client; 65 | GetClientRect(this->hToolw,&client); 66 | 67 | int dw = client.right - this->sizeContent.right; 68 | int dh = client.bottom - this->sizeContent.bottom; 69 | 70 | this->sizeContent = client; 71 | 72 | this->contents->gotoHead(); 73 | do { 74 | this->contents->getThat()->resizeContent(dw,dh); 75 | } while( this->contents->next() == true ); 76 | } 77 | 78 | LRESULT CALLBACK ToolwBox::processMessages(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 79 | { 80 | ToolwBox *that = (ToolwBox *)GetProp(hDlg,ATOM_THIS); 81 | if( that == NULL ) 82 | return DefWindowProc(hDlg,message,wParam,lParam); 83 | 84 | RECT *rect; 85 | int maxw, maxh; 86 | 87 | switch(message){ 88 | case WM_SIZE: 89 | that->resizeContent(); 90 | break; 91 | case WM_CLOSE: 92 | ShowWindow(hDlg,SW_HIDE); 93 | break; 94 | case WM_SIZING: 95 | rect = (RECT *)lParam; 96 | 97 | maxw = max(TW_BX_MINW,rect->right - rect->left); 98 | maxh = max(TW_BX_MINH,rect->bottom - rect->top); 99 | 100 | switch(wParam){ 101 | case WMSZ_BOTTOM: 102 | rect->bottom = rect->top + maxh; 103 | break; 104 | case WMSZ_BOTTOMLEFT: 105 | rect->bottom = rect->top + maxh; 106 | rect->left = rect->right - maxw; 107 | break; 108 | case WMSZ_BOTTOMRIGHT: 109 | rect->bottom = rect->top + maxh; 110 | rect->right = rect->left + maxw; 111 | break; 112 | case WMSZ_LEFT: 113 | rect->left = rect->right - maxw; 114 | break; 115 | case WMSZ_RIGHT: 116 | rect->right = rect->left + maxw; 117 | break; 118 | case WMSZ_TOP: 119 | rect->top = rect->bottom - maxh; 120 | break; 121 | case WMSZ_TOPLEFT: 122 | rect->top = rect->bottom - maxh; 123 | rect->left = rect->right - maxw; 124 | break; 125 | case WMSZ_TOPRIGHT: 126 | rect->top = rect->bottom - maxh; 127 | rect->right = rect->left + maxw; 128 | break; 129 | } 130 | return 1; 131 | case WM_NCACTIVATE: 132 | return that->controler->overrideNCActivate(hDlg,wParam,lParam); 133 | default: 134 | return DefWindowProc(hDlg,message,wParam,lParam); 135 | } 136 | return 0; 137 | } 138 | 139 | LRESULT CALLBACK ToolwBox::processContents(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 140 | { 141 | ToolwBoxContent *that = (ToolwBoxContent *)GetProp(hDlg,ATOM_THIS); 142 | if( that == NULL ) 143 | return DefWindowProc(hDlg,message,wParam,lParam); 144 | else 145 | return that->processMessages(hDlg,message,wParam,lParam); 146 | 147 | return 0; 148 | } -------------------------------------------------------------------------------- /Fiew/ToolwBoxContent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ToolwBoxContent.cpp 3 | This object represents a container that is placed inside ToolwBox. 4 | This class is never used, rather than that it is inherited by the 5 | contextual content like Layers, History, Info 6 | */ 7 | 8 | #include "stdafx.h" 9 | #include "Core.h" 10 | 11 | ToolwBoxContent::ToolwBoxContent(ToolwBox *box, FwCHAR *name) : Toolw(box->getCore(),box->getControler()) 12 | { 13 | this->box = box; 14 | this->name = name; 15 | 16 | RECT client; 17 | GetClientRect(box->getWindowHandle(),&client); 18 | 19 | this->hToolw = CreateWindowEx( 20 | NULL, 21 | IDCL_TOOLW_BXCNT, 22 | name->toWCHAR(), 23 | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, 24 | 0,0, 25 | client.right,client.bottom, 26 | box->getWindowHandle(), 27 | NULL,box->getCore()->getInstance(),NULL 28 | ); 29 | SetProp(this->hToolw,ATOM_THIS,this); 30 | 31 | this->box->addContent(this); 32 | } 33 | 34 | ToolwBoxContent::~ToolwBoxContent() 35 | { 36 | if( this->name != NULL ) 37 | delete name; 38 | } 39 | 40 | FwCHAR *ToolwBoxContent::getName() 41 | { 42 | return this->name; 43 | } 44 | 45 | ToolwBox *ToolwBoxContent::getBox() 46 | { 47 | return this->box; 48 | } 49 | 50 | void ToolwBoxContent::resizeContent(int dw, int dh) 51 | { 52 | RECT content; 53 | GetWindowRect(this->hToolw,&content); 54 | 55 | SetWindowPos( 56 | this->hToolw, 57 | this->hToolw, 58 | NULL,NULL, 59 | content.right - content.left + dw, 60 | content.bottom - content.top + dh, 61 | SWP_NOZORDER | 62 | SWP_NOOWNERZORDER | 63 | SWP_NOACTIVATE 64 | ); 65 | } 66 | 67 | void ToolwBoxContent::disable() 68 | { 69 | 70 | } 71 | 72 | HWND ToolwBoxContent::createContent(int x, int y, int w, int h) 73 | { 74 | HWND hWnd = CreateWindowEx( 75 | NULL, 76 | IDCL_TOOLW_BXPANCNT, 77 | NULL, 78 | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, 79 | x,y,w,h, 80 | this->hToolw, 81 | NULL, 82 | Core::self->getInstance(), 83 | NULL 84 | ); 85 | SetProp(hWnd,ATOM_OWNER,this); 86 | 87 | return hWnd; 88 | } 89 | 90 | LRESULT ToolwBoxContent::processMessages(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 91 | { 92 | return DefWindowProc(hDlg,message,wParam,lParam); 93 | } -------------------------------------------------------------------------------- /Fiew/ToolwBoxInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ToolwBoxInfo.cpp 3 | This object represents the contents of 'Info' Tool Window. 4 | It is a simple content pane without any scrolls. 5 | */ 6 | 7 | #include "stdafx.h" 8 | #include "Core.h" 9 | 10 | ToolwBoxInfo::ToolwBoxInfo(ToolwBox *box) : ToolwBoxContent(box,new FwCHAR(TOOLWBOX_INFO)) 11 | { 12 | RECT client; 13 | GetClientRect(this->hToolw,&client); 14 | 15 | int xRGB = 80; 16 | int yRGB = 10; 17 | 18 | int xCMYK = 130; 19 | int yCMYK = 7; 20 | 21 | int xXY = 5; 22 | int yXY = client.bottom / 2 + 25; 23 | 24 | int xWH = 100; 25 | int yWH = client.bottom / 2 + 25; 26 | 27 | int width = 20; 28 | int height = 15; 29 | 30 | this->core->CreateWindowExSubstituteFont( 31 | NULL, 32 | IDCL_STATIC, 33 | TOOLWBOX_INFO_COLOR, 34 | WS_VISIBLE | WS_CHILD | SS_CENTER, 35 | 10, 36 | 10, 37 | 50, 38 | 20, 39 | this->hToolw, 40 | NULL, 41 | this->core->getInstance(), 42 | NULL 43 | ); 44 | this->core->CreateWindowExSubstituteFont( 45 | NULL, 46 | IDCL_STATIC, 47 | TOOLWBOX_INFO_POS, 48 | WS_VISIBLE | WS_CHILD | SS_CENTER, 49 | 10, 50 | client.bottom / 2 + 5, 51 | 50, 52 | 20, 53 | this->hToolw, 54 | NULL, 55 | this->core->getInstance(), 56 | NULL 57 | ); 58 | this->core->CreateWindowExSubstituteFont( 59 | NULL, 60 | IDCL_STATIC, 61 | TOOLWBOX_INFO_RECT, 62 | WS_VISIBLE | WS_CHILD | SS_CENTER, 63 | 90, 64 | client.bottom / 2 + 5, 65 | 50, 66 | 20, 67 | this->hToolw, 68 | NULL, 69 | this->core->getInstance(), 70 | NULL 71 | ); 72 | 73 | CreateWindowEx( 74 | WS_EX_STATICEDGE, 75 | IDCL_STATIC, 76 | NULL, 77 | WS_VISIBLE | WS_CHILD | SS_ETCHEDHORZ, 78 | 0, 79 | client.bottom / 2, 80 | client.right, 81 | 2, 82 | this->hToolw, 83 | NULL, 84 | this->core->getInstance(), 85 | NULL 86 | ); 87 | 88 | this->createPair(xRGB,yRGB,width,height,L"R: ",this->dlgColR); 89 | this->createPair(xRGB,yRGB + height + 2,width,height,L"G: ",this->dlgColG); 90 | this->createPair(xRGB,yRGB + 2 * height + 4,width,height,L"B: ",this->dlgColB); 91 | 92 | this->createPair(xCMYK,yCMYK,width,height - 2,L"C: ",this->dlgColC); 93 | this->createPair(xCMYK,yCMYK + height - 2,width,height - 2,L"M: ",this->dlgColM); 94 | this->createPair(xCMYK,yCMYK + 2 * height - 4,width,height - 2,L"Y: ",this->dlgColY); 95 | this->createPair(xCMYK,yCMYK + 3 * height - 6,width,height - 2,L"K: ",this->dlgColK); 96 | 97 | width += 15; 98 | 99 | this->createPair(xXY,yXY,width,height,L"X: ",this->dlgPosX); 100 | this->createPair(xXY,yXY + height + 2,width,height,L"Y: ",this->dlgPosY); 101 | 102 | this->createPair(xWH,yWH,width,height,L"W: ",this->dlgSizW); 103 | this->createPair(xWH,yWH + height + 2,width,height,L"H: ",this->dlgSizH); 104 | } 105 | 106 | ToolwBoxInfo::~ToolwBoxInfo() 107 | { 108 | 109 | } 110 | 111 | void ToolwBoxInfo::createPair(int x, int y, int w, int h, WCHAR *label, HWND &handle) 112 | { 113 | this->core->CreateWindowExSubstituteFont( 114 | NULL, 115 | IDCL_STATIC, 116 | label, 117 | WS_VISIBLE | WS_CHILD | SS_RIGHT, 118 | x,y,w,h, 119 | this->hToolw, 120 | NULL, 121 | this->core->getInstance(), 122 | NULL 123 | ); 124 | handle = this->core->CreateWindowExSubstituteFont( 125 | NULL, 126 | IDCL_STATIC, 127 | NULL, 128 | WS_VISIBLE | WS_CHILD | SS_RIGHT, 129 | x + w,y,w,h, 130 | this->hToolw, 131 | NULL, 132 | this->core->getInstance(), 133 | NULL 134 | ); 135 | } 136 | 137 | void ToolwBoxInfo::loadColor(Color rgb) 138 | { 139 | CMYKCOLOR cmyk = Core::RGBtoCMYK(rgb); 140 | 141 | this->loadLabel(this->dlgColR,rgb.GetR()); 142 | this->loadLabel(this->dlgColG,rgb.GetG()); 143 | this->loadLabel(this->dlgColB,rgb.GetB()); 144 | 145 | this->loadLabel(this->dlgColC,cmyk.C); 146 | this->loadLabel(this->dlgColM,cmyk.M); 147 | this->loadLabel(this->dlgColY,cmyk.Y); 148 | this->loadLabel(this->dlgColK,cmyk.K); 149 | } 150 | 151 | void ToolwBoxInfo::loadPos(Point pos) 152 | { 153 | this->loadLabel(this->dlgPosX,pos.X); 154 | this->loadLabel(this->dlgPosY,pos.Y); 155 | } 156 | 157 | void ToolwBoxInfo::loadSize(Rect size) 158 | { 159 | this->loadLabel(this->dlgSizW , max(size.Width - 1,0) ); 160 | this->loadLabel(this->dlgSizH , max(size.Height - 1,0) ); 161 | } 162 | 163 | void ToolwBoxInfo::loadLabel(HWND handle, UINT value) 164 | { 165 | FwCHAR *buffer = new FwCHAR(value); 166 | SetWindowText(handle,buffer->toWCHAR()); 167 | delete buffer; 168 | 169 | InvalidateRect(handle,NULL,TRUE); 170 | } 171 | 172 | void ToolwBoxInfo::nullLabel(HWND handle) 173 | { 174 | SetWindowText(handle,L""); 175 | InvalidateRect(handle,NULL,TRUE); 176 | } 177 | 178 | void ToolwBoxInfo::resizeContent(int dw, int dh) 179 | { 180 | 181 | } 182 | 183 | void ToolwBoxInfo::disable() 184 | { 185 | this->nullLabel(this->dlgColR); 186 | this->nullLabel(this->dlgColG); 187 | this->nullLabel(this->dlgColB); 188 | 189 | this->nullLabel(this->dlgColC); 190 | this->nullLabel(this->dlgColM); 191 | this->nullLabel(this->dlgColY); 192 | this->nullLabel(this->dlgColK); 193 | 194 | this->nullLabel(this->dlgPosX); 195 | this->nullLabel(this->dlgPosY); 196 | 197 | this->nullLabel(this->dlgSizW); 198 | this->nullLabel(this->dlgSizH); 199 | } 200 | 201 | LRESULT ToolwBoxInfo::processMessages(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 202 | { 203 | switch(message){ 204 | case WM_CREATE: 205 | break; 206 | default: 207 | return DefWindowProc(hDlg,message,wParam,lParam); 208 | } 209 | return 0; 210 | } 211 | -------------------------------------------------------------------------------- /Fiew/Toolws.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Toolws.cpp 3 | This object represents the controler of Tool Windows and is the connection 4 | between the ToolWindows and the Core of the application or MDI children. 5 | This object is not a strict connection, that is some messages can be passed 6 | from Tool Windows to Core or children without the controler, however not the 7 | other way around. 8 | */ 9 | 10 | #include "stdafx.h" 11 | #include "Core.h" 12 | 13 | int Toolws::boxCounter = NULL; 14 | 15 | Toolws::Toolws(Core *core) 16 | { 17 | this->core = core; 18 | this->toolwset = new List(); 19 | 20 | this->nameColRes = new FwCHAR(BUT_COLRES); 21 | this->nameColCho = new FwCHAR(BUT_COLCHOOSE); 22 | this->nameColSwap = new FwCHAR(BUT_COLSWAP); 23 | this->nameDelHis = new FwCHAR(BUT_DELHIS); 24 | this->nameDelLay = new FwCHAR(BUT_DELLAY); 25 | this->nameLayDown = new FwCHAR(BUT_LAYDOWN); 26 | this->nameLayUp = new FwCHAR(BUT_LAYUP); 27 | this->nameNewLay = new FwCHAR(BUT_NEWLAY); 28 | this->nameRedo = new FwCHAR(BUT_REDO); 29 | this->nameUndo = new FwCHAR(BUT_UNDO); 30 | } 31 | 32 | Toolws::~Toolws() 33 | { 34 | delete this->nameColRes; 35 | delete this->nameColCho; 36 | delete this->nameColSwap; 37 | delete this->nameDelHis; 38 | delete this->nameDelLay; 39 | delete this->nameLayDown; 40 | delete this->nameLayUp; 41 | delete this->nameNewLay; 42 | delete this->nameRedo; 43 | delete this->nameUndo; 44 | } 45 | 46 | void Toolws::show_CC() 47 | { 48 | this->toolwDock = new ToolwDock(this->core,this); 49 | this->toolwset->add( this->toolwDock->initialize() ); 50 | 51 | this->toolwCC = new ToolwCC(this->core,this); 52 | this->toolwset->add( this->toolwCC->initialize() ); 53 | 54 | this->toolwBox = new ToolwBox(this->core,this); 55 | this->toolwset->add( this->toolwBox->getWindowHandle() ); 56 | Toolws::boxCounter++; 57 | 58 | this->toolwBoxLayers = new ToolwBoxLayers(this->toolwBox); 59 | 60 | this->toolwBox = new ToolwBox(this->core,this,true); 61 | this->toolwset->add( this->toolwBox->getWindowHandle() ); 62 | Toolws::boxCounter++; 63 | 64 | this->toolwBoxInfo = new ToolwBoxInfo(this->toolwBox); 65 | 66 | this->toolwBox = new ToolwBox(this->core,this); 67 | this->toolwset->add( this->toolwBox->getWindowHandle() ); 68 | Toolws::boxCounter++; 69 | 70 | this->toolwBoxHistory = new ToolwBoxHistory(this->toolwBox); 71 | } 72 | void Toolws::hide(HWND toolw) 73 | { 74 | this->toolwset->remove(toolw); 75 | } 76 | 77 | void Toolws::enableToolwBoxes() 78 | { 79 | this->toolwBoxLayers->load(); 80 | this->toolwBoxHistory->load(); 81 | } 82 | 83 | void Toolws::disableToolwBoxes() 84 | { 85 | this->toolwBoxInfo->disable(); 86 | this->toolwBoxLayers->disable(); 87 | this->toolwBoxHistory->disable(); 88 | } 89 | 90 | void Toolws::toggleBoxInfo() 91 | { 92 | int cmd = SW_SHOW; 93 | if( IsWindowVisible(this->toolwBoxInfo->getBox()->getWindowHandle()) ) 94 | cmd = SW_HIDE; 95 | 96 | ShowWindow(this->toolwBoxInfo->getBox()->getWindowHandle(),cmd); 97 | this->core->getGui()->updateMenu(); 98 | } 99 | void Toolws::toggleBoxLayers() 100 | { 101 | int cmd = SW_SHOW; 102 | if( IsWindowVisible(this->toolwBoxLayers->getBox()->getWindowHandle()) ) 103 | cmd = SW_HIDE; 104 | 105 | ShowWindow(this->toolwBoxLayers->getBox()->getWindowHandle(),cmd); 106 | this->core->getGui()->updateMenu(); 107 | } 108 | void Toolws::toggleBoxHistory() 109 | { 110 | int cmd = SW_SHOW; 111 | if( IsWindowVisible(this->toolwBoxHistory->getBox()->getWindowHandle()) ) 112 | cmd = SW_HIDE; 113 | 114 | ShowWindow(this->toolwBoxHistory->getBox()->getWindowHandle(),cmd); 115 | this->core->getGui()->updateMenu(); 116 | } 117 | 118 | List *Toolws::getToolwset() 119 | { 120 | return this->toolwset; 121 | } 122 | 123 | ToolwCC *Toolws::getToolwCC() 124 | { 125 | return this->toolwCC; 126 | } 127 | 128 | ToolwDock *Toolws::getToolwDock() 129 | { 130 | return this->toolwDock; 131 | } 132 | 133 | ToolwBoxLayers *Toolws::getToolwBoxLayers() 134 | { 135 | return this->toolwBoxLayers; 136 | } 137 | 138 | ToolwBoxInfo *Toolws::getToolwBoxInfo() 139 | { 140 | return this->toolwBoxInfo; 141 | } 142 | 143 | ToolwBoxHistory *Toolws::getToolwBoxHistory() 144 | { 145 | return this->toolwBoxHistory; 146 | } 147 | /* 148 | These two methods ensure that the Tool Windows title bar 149 | remains active even upon logical deactivation, and becomes 150 | inactive in proper moments (like dialog boxes) 151 | */ 152 | LRESULT Toolws::overrideEnable(HWND hWnd, WPARAM wParam, LPARAM lParam) 153 | { 154 | this->toolwset->gotoHead(); 155 | do { 156 | if( this->toolwset->getThat() != hWnd ) 157 | EnableWindow(this->toolwset->getThat(),(BOOL)wParam); 158 | } while( this->toolwset->next() != NULL ); 159 | 160 | return DefWindowProc(hWnd, WM_ENABLE, wParam, lParam); 161 | } 162 | LRESULT Toolws::overrideNCActivate(HWND hWnd, WPARAM wParam, LPARAM lParam) 163 | { 164 | HWND hParam = (HWND)lParam; 165 | BOOL fKeepActive = (BOOL)wParam; 166 | BOOL fSyncOthers = TRUE; 167 | 168 | if( hParam == (HWND)-1 ){ 169 | SendMessage(this->core->getMdiclientHandle(),WM_NCACTIVATE,wParam,lParam); 170 | return DefWindowProc(hWnd,WM_NCACTIVATE,fKeepActive,0); 171 | } 172 | if( hParam == this->core->getWindowHandle() ){ 173 | fKeepActive = TRUE; 174 | fSyncOthers = TRUE; 175 | } 176 | this->toolwset->gotoHead(); 177 | do { 178 | if( this->toolwset->getThat() == hParam ){ 179 | fKeepActive = TRUE; 180 | fSyncOthers = FALSE; 181 | break; 182 | } 183 | } while( this->toolwset->next() != NULL ); 184 | 185 | if( fSyncOthers == TRUE ){ 186 | this->toolwset->gotoHead(); 187 | do { 188 | if( this->toolwset->getThat() != hParam && 189 | this->toolwset->getThat() != hWnd ) 190 | SendMessage(this->toolwset->getThat(),WM_NCACTIVATE,fKeepActive,(LONG)-1); 191 | 192 | } while( this->toolwset->next() != NULL ); 193 | 194 | SendMessage(this->core->getWindowHandle(),WM_NCACTIVATE,fKeepActive,(LONG)-1); 195 | } 196 | SendMessage(this->core->getMdiclientHandle(),WM_NCACTIVATE,fKeepActive,lParam); 197 | return DefWindowProc(hWnd, WM_NCACTIVATE, fKeepActive, lParam); 198 | } 199 | 200 | FwCHAR *Toolws::toolIdToName(int toolId) 201 | { 202 | FwCHAR *result = NULL; 203 | 204 | switch(toolId){ 205 | case ICC_SELREC: 206 | result = this->toolwCC->toolSelectRect->getName(); 207 | break; 208 | case ICC_SELCIR: 209 | result = this->toolwCC->toolSelectCirc->getName(); 210 | break; 211 | case ICC_SELHOR: 212 | result = this->toolwCC->toolSelectHor->getName(); 213 | break; 214 | case ICC_SELVER: 215 | result = this->toolwCC->toolSelectVer->getName(); 216 | break; 217 | case ICC_MOV: 218 | result = this->toolwCC->toolMove->getName(); 219 | break; 220 | case ICC_LASPOL: 221 | result = this->toolwCC->toolSelectPoly->getName(); 222 | break; 223 | case ICC_LASMOS: 224 | result = this->toolwCC->toolSelectFree->getName(); 225 | break; 226 | case ICC_MAG: 227 | result = this->toolwCC->toolSelectWand->getName(); 228 | break; 229 | case ICC_CRO: 230 | result = this->toolwCC->toolCrop->getName(); 231 | break; 232 | case ICC_ERSNOR: 233 | result = this->toolwCC->toolEraser->getName(); 234 | break; 235 | case ICC_DRAPEN: 236 | result = this->toolwCC->toolPencil->getName(); 237 | break; 238 | case ICC_FILBUC: 239 | result = this->toolwCC->toolBucket->getName(); 240 | break; 241 | case ICC_SHALIN: 242 | result = this->toolwCC->toolLine->getName(); 243 | break; 244 | case ICC_SHAREC: 245 | result = this->toolwCC->toolRect->getName(); 246 | break; 247 | case ICC_SHACIR: 248 | result = this->toolwCC->toolElli->getName(); 249 | break; 250 | case ICC_SHARRC: 251 | result = this->toolwCC->toolRRec->getName(); 252 | break; 253 | case ICC_TEX: 254 | result = this->toolwCC->toolText->getName(); 255 | break; 256 | case ICC_HAN: 257 | result = this->toolwCC->toolHand->getName(); 258 | break; 259 | case ICC_ZOO: 260 | result = this->toolwCC->toolZoom->getName(); 261 | break; 262 | case ICC_SMPCOL: 263 | result = this->toolwCC->toolSampleColor->getName(); 264 | break; 265 | case ICC_COLORFORE: 266 | break; 267 | case ICC_COLORBACK: 268 | break; 269 | case ICC_COLRES: 270 | result = this->nameColRes; 271 | break; 272 | case ICC_COLSWA: 273 | result = this->nameColSwap; 274 | break; 275 | default: 276 | break; 277 | } 278 | return result; 279 | } -------------------------------------------------------------------------------- /Fiew/Workspace.h: -------------------------------------------------------------------------------- 1 | using namespace Gdiplus; 2 | 3 | class ChildCore; 4 | class HistoryControler; 5 | class Frame; 6 | 7 | class Workspace 8 | { 9 | private: 10 | ChildCore *chicore; // owner 11 | HistoryControler *history; // history controler 12 | 13 | bool initialized; // init flag 14 | 15 | float width, // document width 16 | height, // document height 17 | res; // document resolution 18 | int pxwidth, // pixel width 19 | pxheight, // pixel height 20 | sunit, // size unit 21 | runit, // resolution unit 22 | dmode, // color depth mode 23 | dunit, // color depth unit 24 | bkgnd; // init background mode 25 | 26 | GraphicsPath *selection; // current selection 27 | 28 | List *layers; // layers list 29 | List *selectedLayers;// selected layers list 30 | 31 | public: 32 | Workspace(ChildCore *core, 33 | float width, float height, int sunit, 34 | float res, int runit, 35 | int dmode, int dunit, 36 | int bkgnd); 37 | Workspace(ChildCore *core, 38 | Bitmap *source); 39 | Workspace(ChildCore *core); 40 | ~Workspace(); 41 | 42 | void initialize(); 43 | bool save(WCHAR *filename); 44 | bool load(WCHAR *filename); 45 | 46 | void update(); 47 | void updateToolws(); 48 | 49 | Bitmap *render(); 50 | Bitmap *renderAbove(Rect clip); 51 | Bitmap *renderBelow(Rect clip, bool withGrid = false); 52 | 53 | void resizeCanvas(RECT canvas, bool historical = false, Tool *executor = NULL); 54 | void resizeImage(int width, int height, InterpolationMode mode = InterpolationModeInvalid, bool historical = false, Tool *executor = NULL); 55 | 56 | void setSelection(GraphicsPath *path); 57 | GraphicsPath *getSelection(); 58 | 59 | HistoryControler *getHistory(); 60 | 61 | bool moveSelectedUp(bool historical = false); 62 | bool moveSelectedDown(bool historical = false); 63 | 64 | void mergeDownSelected(); 65 | void rasterizeSelected(); 66 | 67 | bool isMergeReady(); 68 | bool isRasterizeReady(); 69 | 70 | int getPxWidth(); 71 | int getPxHeight(); 72 | 73 | void addLayerAfter(Frame *newLayer = NULL, Frame *layer = NULL, bool historical = false, Tool *executor = NULL); 74 | void deleteLayer(Frame *layer, bool historical = false); 75 | 76 | void setPxSize(int width, int height); 77 | void setPxSize(Rect size); 78 | void setLayers(List *layers); 79 | List *getLayers(); 80 | List *getSelectedLayers(); 81 | Frame *getSelectedLayer(); 82 | int getSelectedLayerIndex(); 83 | 84 | Bitmap *getSelectedLayerProjection(bool inflate = false); 85 | 86 | Bitmap *getSelectedProjection(Rect *rect, int mode); 87 | void setSelectedProjection(Bitmap *bmp, int mode); 88 | 89 | void setSelectedLayer(Frame *layer); 90 | void addSelectedLayer(Frame *layer); 91 | 92 | ChildCore *getChicore(); 93 | 94 | private: 95 | 96 | }; -------------------------------------------------------------------------------- /Fiew/XUn.h: -------------------------------------------------------------------------------- 1 | #include "XUnrar.h" 2 | #include "XUnzip.h" 3 | 4 | class FwCHAR; 5 | template 6 | class List; 7 | class Core; 8 | 9 | class Archive; 10 | class File; 11 | 12 | class XUn 13 | { 14 | protected: 15 | Core *core; 16 | 17 | FwCHAR *path; 18 | byte *buffer; 19 | char *comment; 20 | 21 | bool extracting; 22 | 23 | int error; 24 | int count; 25 | int buflen, bufpot; 26 | 27 | FwCHAR *password; 28 | HANDLE sem_pass; 29 | 30 | public: 31 | XUn(WCHAR *archivepath); 32 | virtual ~XUn(); 33 | 34 | virtual bool list(List *list); 35 | virtual bool extract(File *file, WCHAR *dest = NULL); 36 | 37 | virtual bool isLoaded(); 38 | 39 | int getLastError(); 40 | void setLastError(int error); 41 | 42 | FwCHAR *getPassword(); 43 | void setPassword(FwCHAR *password); 44 | void sendPassReq(); 45 | 46 | int getBuflen(); 47 | byte *getBuffer(); 48 | void clearBuffer(); 49 | void setBuffer(void *source, int size); 50 | }; 51 | 52 | class XUnrar : public XUn 53 | { 54 | private: 55 | bool loaded; 56 | char *charpath; 57 | 58 | HANDLE handle; 59 | 60 | public: 61 | XUnrar(WCHAR *archivepath); 62 | ~XUnrar(); 63 | 64 | bool list(List *list); 65 | bool extract(File *file, WCHAR *dest = NULL); 66 | 67 | bool isLoaded(); 68 | 69 | static int CALLBACK callbackProc(UINT,LONG,LONG,LONG); 70 | 71 | private: 72 | HANDLE (WINAPI *openArchive)(RAROpenArchiveData *); 73 | HANDLE (WINAPI *openArchiveEx)(RAROpenArchiveDataEx *); 74 | int (WINAPI *closeArchive)(HANDLE); 75 | int (WINAPI *readHeader)(HANDLE,RARHeaderData *); 76 | int (WINAPI *readHeaderEx)(HANDLE,RARHeaderDataEx *); 77 | int (WINAPI *processFile)(HANDLE,int,char *,char *); 78 | int (WINAPI *processFileW)(HANDLE,int,WCHAR *,WCHAR *); 79 | void (WINAPI *setCallback)(HANDLE,UNRARCALLBACK,LONG); 80 | 81 | bool loadFunc(); 82 | bool reopen(int mode); 83 | }; 84 | 85 | class XUnzip : public XUn 86 | { 87 | private: 88 | HZIP handle; 89 | 90 | public: 91 | XUnzip(WCHAR *archivepath); 92 | ~XUnzip(); 93 | 94 | bool list(List *list); 95 | bool extract(File *file, WCHAR *dest = NULL); 96 | 97 | bool isLoaded(); 98 | }; -------------------------------------------------------------------------------- /Fiew/XUnrar.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | #include "XUn.h" 4 | 5 | -------------------------------------------------------------------------------- /Fiew/XUnrar.h: -------------------------------------------------------------------------------- 1 | #define ERAR_END_ARCHIVE 10 2 | #define ERAR_NO_MEMORY 11 3 | #define ERAR_BAD_DATA 12 4 | #define ERAR_BAD_ARCHIVE 13 5 | #define ERAR_UNKNOWN_FORMAT 14 6 | #define ERAR_EOPEN 15 7 | #define ERAR_ECREATE 16 8 | #define ERAR_ECLOSE 17 9 | #define ERAR_EREAD 18 10 | #define ERAR_EWRITE 19 11 | #define ERAR_SMALL_BUF 20 12 | #define ERAR_UNKNOWN 21 13 | #define ERAR_EMPTY 22 14 | #define ERAR_BAD_PASS 23 15 | 16 | #define RAR_OM_LIST 0 17 | #define RAR_OM_EXTRACT 1 18 | 19 | #define RAR_SKIP 0 20 | #define RAR_TEST 1 21 | #define RAR_EXTRACT 2 22 | 23 | #define RAR_VOL_ASK 0 24 | #define RAR_VOL_NOTIFY 1 25 | 26 | #define RAR_DLL_VERSION 4 27 | 28 | enum UNRARCALLBACK_MESSAGES { 29 | UCM_CHANGEVOLUME, 30 | UCM_PROCESSDATA, 31 | UCM_NEEDPASSWORD 32 | }; 33 | 34 | typedef int (CALLBACK *UNRARCALLBACK)(UINT msg,LONG UserData,LONG P1,LONG P2); 35 | 36 | struct RAROpenArchiveData 37 | { 38 | char *ArcName; 39 | UINT OpenMode; 40 | UINT OpenResult; 41 | char *CmtBuf; 42 | UINT CmtBufSize; 43 | UINT CmtSize; 44 | UINT CmtState; 45 | }; 46 | 47 | struct RAROpenArchiveDataEx 48 | { 49 | char *ArcName; 50 | wchar_t *ArcNameW; 51 | unsigned int OpenMode; 52 | unsigned int OpenResult; 53 | char *CmtBuf; 54 | unsigned int CmtBufSize; 55 | unsigned int CmtSize; 56 | unsigned int CmtState; 57 | unsigned int Flags; 58 | unsigned int Reserved[32]; 59 | }; 60 | 61 | struct RARHeaderData 62 | { 63 | char ArcName[260]; 64 | char FileName[260]; 65 | UINT Flags; 66 | UINT PackSize; 67 | UINT UnpSize; 68 | UINT HostOS; 69 | UINT FileCRC; 70 | UINT FileTime; 71 | UINT UnpVer; 72 | UINT Method; 73 | UINT FileAttr; 74 | char *CmtBuf; 75 | UINT CmtBufSize; 76 | UINT CmtSize; 77 | UINT CmtState; 78 | }; 79 | 80 | struct RARHeaderDataEx 81 | { 82 | char ArcName[1024]; 83 | wchar_t ArcNameW[1024]; 84 | char FileName[1024]; 85 | wchar_t FileNameW[1024]; 86 | unsigned int Flags; 87 | unsigned int PackSize; 88 | unsigned int PackSizeHigh; 89 | unsigned int UnpSize; 90 | unsigned int UnpSizeHigh; 91 | unsigned int HostOS; 92 | unsigned int FileCRC; 93 | unsigned int FileTime; 94 | unsigned int UnpVer; 95 | unsigned int Method; 96 | unsigned int FileAttr; 97 | char *CmtBuf; 98 | unsigned int CmtBufSize; 99 | unsigned int CmtSize; 100 | unsigned int CmtState; 101 | unsigned int Reserved[1024]; 102 | }; -------------------------------------------------------------------------------- /Fiew/mid.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/mid.ico -------------------------------------------------------------------------------- /Fiew/ovl_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/ovl_about.png -------------------------------------------------------------------------------- /Fiew/ovl_manual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/ovl_manual.png -------------------------------------------------------------------------------- /Fiew/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/small.ico -------------------------------------------------------------------------------- /Fiew/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // Fiew.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Fiew/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef WINVER // Allow use of features specific to Windows XP or later. 11 | #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 15 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 16 | #endif 17 | 18 | #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. 19 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 20 | #endif 21 | 22 | #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. 23 | #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. 24 | #endif 25 | 26 | //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 27 | // Windows Header Files: 28 | #include 29 | 30 | // C RunTime Header Files 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | // TODO: reference additional headers your program requires here 38 | #include 39 | #include "Fedit.h" -------------------------------------------------------------------------------- /Fiew/unrar.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/Fiew/unrar.dll -------------------------------------------------------------------------------- /release/Fedit.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f055/fedit-image-editor/a214a0482375d1d67be2b63f60e93689520b4c70/release/Fedit.exe --------------------------------------------------------------------------------