slice.h

Go to the documentation of this file.
00001 // $Id: slice.h 751 2006-03-31 15:43:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // The operation for the "Image Slice" menu item
00099 
00100 #ifndef INC_IMAGESLICE
00101 #define INC_IMAGESLICE
00102 
00103 #include "impexpop.h"
00104 //#include <afxtempl.h> // required for CList MFC stuff
00105 
00106 class Layer;
00107 
00108 class RolloverState : public CObject
00109 {
00110 public:
00111 
00112     Layer * pLayer;
00113     BOOL Exists;
00114     BOOL WasVisibleToStartWith;
00115     String_16   Name;
00116 };
00117 
00118 
00119 // defines for show layer, etc..
00120 #define DEFAULT     0
00121 #define MOUSE       1
00122 #define CLICKED     2
00123 #define SELECTED    3
00124 #define ALL_LAYERS  4
00125 #define BACKBAR     4
00126 #define ORIGINAL_LAYERS 5
00127 
00128 /********************************************************************************************
00129 
00130 >   class CSlice : public CObject
00131 
00132     Author:     Simon_Knight (Xara Group Ltd) <camelotdev@xara.com>
00133     Created:    20/7/99
00134     Purpose:    Simple class, stores the data required for each slice
00135     SeeAlso:    OpSlice
00136 
00137 ********************************************************************************************/
00138 class CSlice : public CObject
00139 {
00140 public:
00141     CSlice();
00142     CSlice(INT32 Ax, INT32 Ay, INT32 Cx, INT32 Cy, String_256 ThisName = "", String_16 FileExt = "gif", BOOL Named = FALSE);
00143     
00144 
00145     void SwapSpreadAndSliceCoords();
00146 
00147     // defines the boundary of the slice in spread co-ords
00148     // or in slice co-ords which are the same as spreads co-ords
00149     // only the y axis has been reversed.
00150     // Top and left are always less than bottom and right
00151     INT32 top;  
00152     INT32 bottom;   
00153     INT32 left; 
00154     INT32 right;
00155 
00156     // Used to define the HTML table to reform the slices
00157     INT32 row;  // the row that this slice is in
00158     INT32 colm; // the column that this slice is in
00159     INT32 rowspan;// no. of rows this slice covers
00160     INT32 colmspan;// no. of columns this slice covers
00161     INT32 rowheight; // the minimuim height of an item in this row
00162     INT32 colmwidth; // the minimuim width of an item in this (or previous?) colm
00163 
00164     BOOL deleteme; // this slice has been marked for deletion
00165 
00166     String_256 name;// name of slice
00167     String_16 FileTypeExtStr; // file type used when exporting
00168 
00169     BOOL IsNamedSlice; // is it a user added slice or a computer generated section?
00170     INT32 ButtonNumber;
00171     BOOL IsEmpty;       // if empty the graphic doesn't really need to be exported
00172     BOOL HasURL;    // Set to false all the time unless ScanURL finds a URL tag on this slice
00173     TCHAR *pFrameText; // ptr to the frame text of the HTML frame that the URL links to only valid if HasURL
00174 
00175     BYTE ExistsOnLayerState[4];
00176 
00177 };
00178 
00179 
00180 #define OPTOKEN_IMAGESLICE _T("ImageSlice")
00181 
00182 class BitmapExportOptions;
00183 
00184 /********************************************************************************************
00185 
00186 >   class OpSlice : public OpMenuImport
00187 
00188     Author:     Simon_Knight (Xara Group Ltd) <camelotdev@xara.com>
00189     Created:    20/7/99
00190     Purpose:    The "Image Slice" menu item
00191     SeeAlso:    
00192 
00193 ********************************************************************************************/
00194 class OpSlice : public OpMenuImport
00195 {
00196     CC_DECLARE_DYNCREATE(OpSlice)
00197 
00198 public:
00199     void Do(OpDescriptor*);
00200 
00201     static BOOL Init();
00202     static OpState GetState(String_256*, OpDescriptor*);
00203     static DocRect ScanLargeSliceBounds(const String_256 & Name);
00204 
00205 protected:
00206     BOOL AddSlice (INT32 Ax, INT32 Ay, INT32 Cx, INT32 Cy, CList <CSlice *, CSlice *> * pMosaicList, String_256 SliceName);
00207     BOOL InRect(CSlice * pRect, INT32 x, INT32 y);
00208     BOOL Slice (CSlice * pRect, INT32 Ax, INT32 Ay, INT32 Bx, INT32 By, CList <CSlice *, CSlice *> * pMosaicList);
00209     BOOL CutsRect(CSlice * pRect, INT32 Ax, INT32 Ay, INT32 Bx, INT32 By);
00210     BOOL SortSlices (CList <CSlice *, CSlice *> * pMosaicList, const DocRect & Bounds);
00211     BOOL ExportImageSliceHTML(CList <CSlice *, CSlice *> * pMosaicList, const String_256 & HTMLFile, INT32 FileNumber = 1);
00212     BOOL ExportSliceGraphic(CSlice * pSlice, BitmapExportOptions * pExportOptions, const String_256 & GraphicFileName);
00213     BOOL SaveFileDlg();
00214     INT32 TidyMosaicList(CList <CSlice *, CSlice *> * pMosaicList);
00215     void UpdateSliceFileExts(CList <CSlice *, CSlice *> * pMosaicList);
00216     void NudgeSliceIfClose(INT32 &Ax, INT32 &Ay, INT32 &Cx, INT32 &Cy, CList <CSlice *, CSlice *> * pMosaicList);
00217     void RemoveIlligalFileAndJavaChars(String_256 & Str);
00218     String_256 TurnUnderScoreIntoSpace(const String_256 & StartStr);
00219     void PixelAlignedInflate(DocRect * r);
00220     void MarkEmptySlices(CList <CSlice *, CSlice *> * pMosaicList, DocRect &SelRect, BitmapExportOptions * pExportOptions);
00221     void ScanTextStorySliceBounds(const String_256 & Name, DocRect & Bounds);
00222     CSlice * GetButtonNumber (CList <CSlice *, CSlice *> * pMosaicList, INT32 buttonno);
00223 
00224     PathName m_PathName;
00225     String_256 m_HTMLext;
00226     INT32 m_lRed, m_lGreen, m_lBlue;
00227     String_256 m_ErrorStr;
00228 
00229     BOOL m_UsedShimGraphic;
00230 
00231     BOOL m_UsesDesignNotes;
00232 
00233     // for rollover stuff
00234     BOOL ScanForRolloverStates(CList <CSlice *, CSlice *> * pMosaicList);
00235     BOOL ExportRollOverSlice(CSlice * pSlice, BitmapExportOptions * pExportOptions);
00236     void ShowRolloverLayer(INT32 ShowLayer);
00237 
00238     String_256 * m_pLinkName;
00239     BOOL URLScan(String_256 * pLinkName, CList <CSlice *, CSlice *> * pMosaicList);
00240 
00241 
00242     // store data on each rollover state
00243     RolloverState m_RolloverState[4];
00244     BOOL m_FoundRolloverStates;
00245     INT32 m_NumberOfButtons;
00246 
00247     // for the HTML injection code
00248     static BYTE * LoadFileIntoMemory(String_256 FileName, DWORD & Size);
00249     static BYTE * FindNextOccuranceOf(BYTE * pSearch, BYTE * pFrom);
00250     static BYTE * FindPreviousChar(char Search, BYTE * pFrom, BYTE * pLimit);
00251     static void WriteText(ofstream & f, BYTE * pData, INT32 NoOfBytes);
00252 
00253     void FailledToExportHTML (const String_256 & file);
00254 
00255     BOOL m_ExportedHTMLOK;
00256     BOOL m_InjectHTML; // did the user ask to inject or overwrite?
00257 
00258 };
00259 
00260 
00261 #include "filedlgs.h"
00262 
00263 class SliceSaveFileDlg : public SaveFileDialog
00264 {
00265 public:
00266     SliceSaveFileDlg(LPCTSTR FilterString, String_256& DefPath, String_256& DefName, String_256& DocumentName) :
00267         SaveFileDialog(FilterString, DefPath, DefName, DocumentName) {m_Inject = FALSE; }
00268 
00269     // this is a version of OnFileNameOK that helps work around the win 95 bug
00270     // but asks
00271     virtual BOOL IsValidFilename();
00272 
00273     BOOL m_Inject;
00274 };
00275 
00276 
00277 #endif // !INC_IMAGESLICE
00278 

Generated on Sat Nov 10 03:47:02 2007 for Camelot by  doxygen 1.4.4