textinfo.h

Go to the documentation of this file.
00001 // $Id: textinfo.h 1718 2006-08-25 11:06:06Z martin $
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 // Header for the Text tool implementation
00099 
00100 #ifndef INC_TEXTINFO
00101 #define INC_TEXTINFO
00102 
00103 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 #include "fontbase.h"
00105 #include "usercord.h"
00106 
00107 class TextTool;
00108 class FontDropDown;
00109 
00110 
00111 enum FontAttribute{JustifyA,BoldA,ItalicA,UnderLineA,AspectRatioA,FontSizeA,FontNameA,BaseLineShiftA,HorizontalKernA,
00112                    TrackingA,ScriptA,LineSpaceA,LineSpacePercentA,
00113                    LeftMarginA, RightMarginA, FirstIndentA, RulerA,
00114                    AutoKernText}; // AutoKernText is not an attribute
00115 enum JustifyMode {JustifyLeft,JustifyRight,JustifyCentre,JustifyFull};
00116 enum ScriptModes {NormalScript,SuperScript,SubScript};
00117         
00118 
00119 /********************************************************************************************
00120 
00121 >   class TextInfoBarData :
00122 
00123     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00124     Created:    22/5/94
00125     Purpose:    To encapsulate all the data required to interface with the text infobar.
00126 
00127 ********************************************************************************************/
00128 
00129 class TextInfoBarData : public CCObject 
00130 {
00131     CC_DECLARE_DYNCREATE( TextInfoBarData)
00132 
00133 
00134 public:
00135     TextInfoBarData();
00136     static String_64    FontName;
00137     static FontClass    FontType;
00138     static JustifyMode  Justify;
00139     static BOOL         Bold;
00140     static BOOL         Italic;
00141     static BOOL         UnderLine;
00142     static ScriptModes  CurrentScriptMode;
00143     static FIXED16      AspectRatio;
00144     static MILLIPOINT   FontSize; 
00145     static MILLIPOINT   BaseLineShift;
00146     static MILLIPOINT   LineSpace;
00147     static double       LineSpacePercent;
00148     static BOOL         IsLineSpaceAPercent;
00149     static INT32        HorizontalKern;
00150     static INT32        Tracking;
00151     static UINT32       PointToLog(double Points){ return (UINT32) (Points*1000);}
00152     static double       LogToPoint(UINT32 Log){ return (double)Log/1000;}
00153     static BOOL         AutoKerning;
00154 };
00155 
00156 /********************************************************************************************
00157 
00158 >   enum TabStopDragType
00159 
00160     Author:     Martin Wuerthner <xara@mw-software.com>
00161     Created:    13/07/06
00162     Purpose:    Different types of drag operations on the ruler bar
00163 
00164 ********************************************************************************************/
00165 
00166 enum TabStopDragType { DragNew, DragTabStop, DragLeftMargin, DragRightMargin, DragFirstIndent };
00167 
00168 /********************************************************************************************
00169 
00170 >   class TextRulerBarData:
00171 
00172     Author:     Martin Wuerthner <xara@mw-software.com>
00173     Created:    07/07/06
00174     Purpose:    Keep the current ruler bar display state
00175 
00176 ********************************************************************************************/
00177 
00178 class TextRulerBarData : public CCObject
00179 {
00180     CC_DECLARE_DYNCREATE(TextRulerBarData)
00181 
00182 public:
00183     TextRulerBarData(): CurrentTabType(LeftTab), IsLeftMarginValid(FALSE), IsFirstIndentValid(FALSE),
00184         IsRightMarginValid(FALSE), IsRulerValid(FALSE), IsRulerOriginClaimed(FALSE), pNewRuler(NULL),
00185         TabStopDragRunning(FALSE)
00186         { pShownRuler = new TxtRuler; }
00187     ~TextRulerBarData() { if (pShownRuler) delete pShownRuler; }
00188 
00189     TxtTabType CurrentTabType;          // currently chosen tab type (click creates tab of this kind)
00190 
00191     BOOL IsLeftMarginValid:1;
00192     BOOL IsFirstIndentValid:1;
00193     BOOL IsRightMarginValid:1;
00194     BOOL IsRulerValid:1;
00195     BOOL IsRulerOriginClaimed:1;
00196 
00197     MILLIPOINT LeftMargin;
00198     MILLIPOINT FirstIndent;
00199     MILLIPOINT RightMargin;
00200     TxtRuler* pShownRuler;              // the currently shown ruler - this is a copy that is
00201                                         // owned by this object!
00202 
00203     AttrTxtRuler *pNewRuler;            // the new ruler attribute to be applied - this is just
00204                                         // transient so need not be destroyed in the destructor
00205 
00206     INT32 CurrentRulerOrigin;           // origin of our ruler section (in user space)
00207     INT32 CurrentRulerSectionWidth;     // width of our ruler section (-1 for infinite)
00208     BOOL TabStopDragRunning;
00209     TabStopDragType CurrentDragType;
00210 };
00211 
00212 /********************************************************************************************
00213 
00214 >   class FontDataItem : public ListItem
00215 
00216     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00217     Created:    22/5/94
00218     Purpose:    A class used for caching Font data.
00219 
00220 ********************************************************************************************/
00221 /*
00222 class FontDataItem : public ListItem
00223 {
00224     CC_DECLARE_DYNCREATE( FontDataItem )
00225 friend class TextInfoBarOp;
00226 public:
00227     FontDataItem();
00228     FontDataItem(String_64 * Name,UINT32 Size,INT32 Ascent,INT32 Descent);
00229     
00230     void SetHandle(WORD Hdle){Handle = Hdle;}
00231     void SetValid(BOOL State){Valid = State;}
00232     void SetName(String_64 * Name){FontName = *Name;}
00233     
00234     void SetAscent(INT32 A ){Ascent = A;}
00235     void SetDescent(INT32 D){Descent = D;}
00236     void SetSize(UINT32 S){SizeEM = S;}
00237     
00238     void SetLogFont(ENUMLOGFONT * pLogFont){ELogFont = *pLogFont;}
00239     
00240     ENUMLOGFONT * GetELogFont();
00241 
00242     String_64 FontName;
00243     UINT32 SizeEM;
00244     INT32 Ascent;
00245     INT32 Descent;
00246     WORD Handle;
00247     BOOL Valid;
00248     ENUMLOGFONT ELogFont;
00249 };
00250 */
00251 
00252 /********************************************************************************************
00253 
00254 >   class TextInfoBarOp : public InformationBarOp
00255 
00256     Author:     Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
00257     Created:    3/10/94
00258     Purpose:    Class for handling the tool's information bar.
00259 
00260 ********************************************************************************************/
00261 
00262 class TextInfoBarOp : public InformationBarOp
00263 {
00264     CC_DECLARE_DYNCREATE( TextInfoBarOp )
00265     // friend class FontDataItem;  
00266 public:
00267 
00268     TextInfoBarOp();
00269     ~TextInfoBarOp();
00270 
00271     static BOOL Init();             // Added by Simon 20/09/95. To Init CommonAttribSet
00272     static void DeInit(); 
00273 
00274 
00275     MsgResult   Message(Msg* Msg);  // All messages to the info bar come through here
00276 
00277     TextTool* pTextTool;
00278 
00279     void InitControls();
00280     static BOOL Update(BOOL DoUpdate = FALSE);
00281     static BOOL UpdateRulerBar(SelRange* pSelection, BOOL DoUpdate = FALSE);
00282 
00283     //static void GetTMetrics(TEXTMETRIC * Metrics, LOGFONT* pLogFont = NULL);
00284     static void OnFieldChange(FontAttribute ThisChange);
00285     static void AddFontToCombo(String_64 * FontName);
00286     BOOL    StringToDouble(StringBase* pstrIn, double * pnOut,BOOL * IsMultiple);
00287     BOOL UpdateFieldsAfterTyping();
00288     
00289     // update internal data structure
00290     static void DoKernBumps(UINT32 ButtonID);
00291     static void DoTrackingBumps(UINT32 ButtonID);
00292     static void DoLineSpacingBumps(UINT32 ButtonID);
00293     
00294     static void DoFontChange();
00295 
00296     static BOOL SetCurrentPointSize(MILLIPOINT PointSize);
00297     static BOOL SetCurrentAspectRatio(FIXED16 Ratio);
00298     static BOOL SetCurrentTracking(INT32 Tracking);
00299     static BOOL SetCurrentHorizontalKern(INT32 Kern);
00300     static BOOL SetCurrentBaseLineShift(INT32 Kern);
00301     static BOOL SetCurrentLineSpace(INT32 LineSpace);
00302     static BOOL SetCurrentLineSpacePercent(double Percent);
00303     //static BOOL SetCurrentFontName(String_64 * Name,BOOL Cache);
00304     static BOOL SetCurrentFontName(String_64 * Name, FontClass Type, BOOL Cache);
00305     static void SetCurrentFontBold(BOOL IsBold);
00306     static void SetCurrentFontItalic(BOOL IsItalic);
00307     static void SetCurrentAutoKerning(BOOL IsAutoKerning);
00308     static void SetCurrentFontUnderLine(BOOL IsUnderLine);
00309     static void SetCurrentJustify(UINT32 ButtonID);
00310     static void SetCurrentScript(ScriptModes Script);
00311     static void EnableGadgets(BOOL Enable);
00312 
00313     static inline BOOL IsRulerOriginClaimed() { return RulerData.IsRulerOriginClaimed; }
00314     static inline INT32 GetRulerOrigin() { return RulerData.CurrentRulerOrigin; }
00315     static void ReleaseRuler();
00316     static void HighlightRulerSection(RulerBase* pRuler, UserRect& UpdateRect);
00317     static void RenderRulerBlobs(RulerBase* pRuler, UserRect& UpdateRect);
00318     static BOOL OnRulerClick(UserCoord PointerPos, ClickType Click, ClickModifiers Mods,
00319                              Spread* pSpread, RulerBase* pRuler);
00320     static BOOL GetRulerStatusLineText(String_256* pText, UserCoord PointerPos,
00321                                        Spread* pSpread, RulerBase* pRuler);
00322 
00323     static void ForceRulerRedraw();
00324     static void TabStopDragStarting(TabStopDragType);
00325     static void TabStopDragFinished();
00326     static void DoAddTabStop(MILLIPOINT Position);
00327     static void DoAddTabStop(TxtTabStop NewTabStop);
00328     static void DoApplyShownRuler();
00329     static void DoChangeLeftMargin(MILLIPOINT Ordinate);
00330     static void DoChangeRightMargin(MILLIPOINT Ordinate, BOOL bReset);
00331     static void DoChangeFirstIndent(MILLIPOINT Ordinate);
00332 
00333 public:
00334 // the current infobar object - allow static member access
00335     static InformationBarOp * pTextInfoBar;
00336 
00337     static FontDropDown *NameDropDown;      // Font name drop-down list support for the font list and
00338     
00339     // Font Data Caching ---------------------------------------
00340     // a list of fontdata items - these may or may not relate to an installed font 
00341     // the valid flag wil set if there is relevant installed font
00342 
00343     // The Cache
00344     // static List FontCache;
00345     // Next Handle to allocate
00346     // static WORD NextHandle;
00347 
00348     // static FontDataItem DefaultFont;
00349 
00350     // used by call back functions
00351     // static BOOL  FontIsInstalled;
00352     static BOOL DisplayFontIsInstalled;
00353     
00354     // static BOOL InitFontCache();
00355     
00356     // set up a default font - used to substitute for an unavailable cached font  
00357     // static BOOL SetDefaultFont();
00358     
00359     // clean up
00360     // static BOOL DeleteFontCache();
00361     
00362     // cache a font
00363     // static BOOL CacheFont(String_64 * FontName);
00364 
00365     // try to find a named font
00366     // static INT32 DoesFontExist(String_64 *FontName, BOOL SearchCache, BOOL SearchInstalled);
00367 
00368     // check to see if a font is installed
00369     // static BOOL IsFontInstalled(String_64 * FontName);
00370     
00371     // check to see if the display font is installed
00372     static BOOL IsDisplayFontInstalled();
00373     
00374     // search for a cached font
00375     // static WORD GetFontHandle(String_64 * FontName);
00376 
00377     // get a cached logfont structure
00378     // static ENUMLOGFONT * GetCachedLogFont(WORD Handle); 
00379 
00380     // get cached font data for a given handle - will return 
00381     // data even if font is unavailable
00382     // static FontDataItem * GetFontData(WORD Handle);
00383     
00384     // get cached font data for a given handle - will return
00385     // the default font if not available
00386     // static FontDataItem * GetRenderableFontData( WORD Handle);
00387     
00388     static INT32 BuildFontList();   
00389     // called on WM_FONTCHANGE messages
00390     //static BOOL ValidateCache();
00391     // ^^^ this enumerates the fonts - the call back calls :---
00392     // static BOOL ValidateCacheItem(String_64 * FontName);
00393 
00394     // temporary storage for call back functions
00395     // static void SetTempLogFont(ENUMLOGFONT  * ThisFont){TempLogFont = *ThisFont;}
00396     // static void SetFontFound(BOOL State){FontIsInstalled = State;}
00397     // static void SetDisplayFontFound(BOOL State){DisplayFontIsInstalled = State;}
00398 
00399     //static void EncodeFontName(String_64& FontName, String_64& Encoded, INT32 Styles);
00400     //static INT32 DecodeFontName(String_64& IStringRef, String_64& OStringRef);
00401 
00402 
00403     // Super/SubScript constants
00404     static double SuperScriptSize;
00405     static double SuperScriptOffset;
00406     static double SubScriptSize;
00407     static double SubScriptOffset;
00408 
00409     static void RegainCaretOnOpEnd();
00410 
00411 private:
00412     static TextInfoBarData InfoData;
00413     static TextRulerBarData RulerData;
00414 
00415     static BOOL FindBitmapSize(ResourceID ID, UINT32* pWidth, UINT32* pHeight);
00416 
00417     // static ENUMLOGFONT   TempLogFont;
00418     static void UpdateButtonStates();
00419     static void UpdateJustifyButtons(BOOL Clear = FALSE);
00420     static void UpdateScriptButtons();
00421     static void UpdateGadgets();
00422     static void RedrawUnitGadgets();
00423     static void SetLineSpaceGadget();
00424     static void DoInputError(UINT32 GadgetID);
00425 
00426     static INT32 GetLogicalStoryWidth(TextStory* pStory);
00427 
00428     // static BOOL AddFontToCache(String_64 * FontName,WORD Handle);
00429     // static INT32 AddTrueTypeFontsToList();
00430     // static INT32 AddTypeOneFontsToList();
00431     
00432     // static void DumpFontCache();
00433     static Document * pDoc;
00434     static UnitType CurrentFontUnits ;
00435     static BOOL RegainCaretAfterOp;
00436 
00437     // Added by simon. This set contains all attribute types that we need to find common attributes for
00438     // We only need to build this set once during the lifetime of the app.
00439     static CommonAttrSet CommonAttrsToFindSet; 
00440 
00441     // cached bitmap sizes
00442     static UINT32 CurrentTabButtonWidth;
00443     static UINT32 TabBitmapWidth;
00444     static UINT32 TabBitmapHeight;
00445     static UINT32 LeftMarginBitmapWidth;
00446     static UINT32 LeftMarginBitmapHeight;
00447     static UINT32 RightMarginBitmapWidth;
00448 };
00449     
00450 
00451 
00452 /********************************************************************************************
00453 
00454 >   class TextInfoBarOpCreate : public BarCreate
00455 
00456     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00457     Created:    3/10/94
00458     Purpose:    Class for creating TextInfoBarOps.
00459                 Derived classes of BarCreate are used by DialogBarOp::ReadBarsFromFile()
00460 
00461 ********************************************************************************************/
00462 
00463 class TextInfoBarOpCreate : public BarCreate
00464 {
00465 public:
00466     DialogBarOp* Create() { return (new TextInfoBarOp); }
00467 };
00468 
00469 
00470 /********************************************************************************************
00471 
00472 >   class TextInfoBarEnumFont : public OILEnumFonts
00473 
00474     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00475     Created:    3/10/94
00476     Purpose:    Class for creating TextInfoBarOps.
00477                 Derived classes of BarCreate are used by DialogBarOp::ReadBarsFromFile()
00478 
00479 ********************************************************************************************/
00480 
00481 class TextInfoBarEnumFont : public OILEnumFonts
00482 {
00483     CC_DECLARE_DYNCREATE( TextInfoBarEnumFont )
00484     
00485     public:
00486         TextInfoBarEnumFont() { count=0; }
00487         INT32 GetCount() { return count; };
00488         virtual BOOL NewFont(FontClass Class, ENUMLOGFONT FAR* lpelf);
00489     
00490     private:
00491         INT32 count;
00492 
00493 };
00494 
00495 /********************************************************************************************
00496 
00497 >   class TabStopDragOpParam: public OpParam
00498 
00499     Author:     Martin Wuerthner <xara@mw-software.com>
00500     Created:    12/07/06
00501     Purpose:    Parameters for TabStopDragOp operation class
00502 
00503 ********************************************************************************************/
00504 
00505 class TabStopDragOpParam: public OpParam
00506 {
00507 public:
00508     TabStopDragOpParam(TabStopDragType Type, TxtTabStop DraggedTabStop, UserCoord Pos):
00509         DragType(Type), DraggedTabStop(DraggedTabStop), StartPos(Pos) {}
00510     TabStopDragType DragType;
00511     TxtTabStop      DraggedTabStop;   // only for Type == DragNew or DragTabStop
00512     UserCoord       StartPos;
00513 };
00514 
00515 #define OPTOKEN_TABSTOPDRAG _T("TabStopDrag")
00516 
00517 /********************************************************************************************
00518 
00519 >   class TabStopDragOp: public Operation
00520 
00521     Author:     Martin Wuerthner <xara@mw-software.com>
00522     Created:    12/07/06
00523     Purpose:    Operation to handle tab stop dragging
00524 
00525 ********************************************************************************************/
00526 
00527 class TabStopDragOp: public Operation
00528 {
00529     CC_DECLARE_DYNCREATE(TabStopDragOp)
00530 public:
00531     TabStopDragOp();
00532     ~TabStopDragOp();
00533 
00534     static BOOL Init();
00535     static OpState GetState(String_256* Description, OpDescriptor*);
00536 
00537     // The main entry point
00538     void DoWithParam(OpDescriptor *pOpDesc, OpParam* pParam);
00539     void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag);
00540     ResourceID GetStatusLineID();
00541     void UpdateStatusLineAndPos(UserCoord* ToolPos, Spread* pSpread);
00542     virtual void DragFinished(  DocCoord PointerPos, 
00543                                 ClickModifiers ClickMods, Spread*, 
00544                                 BOOL Success, BOOL bSolidDrag);
00545 
00546 private:
00547     void DoDrag(Spread* pThisSpread);
00548     static BOOL IsMouseOverRuler();
00549     static DocCoord SnapAndConvert(UserCoord* DragPos, Spread* pSpread, DocView* pDocView);
00550 
00551     Spread*    pSpread;
00552     MILLIPOINT Ordinate;
00553     INT32      CursorStackID;
00554     Cursor*    m_pTabCursor;
00555     Cursor*    m_pDelCursor;
00556     BOOL       m_TabCursorShown;
00557     ResourceID m_CurrentStatusTextID;
00558     TabStopDragOpParam* m_pParam;
00559 };
00560 
00561 #endif      // INC_TEXTINFO

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