• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ap_Preview_Paragraph.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 1998 AbiSource, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 
00021 #ifndef AP_PREVIEW_PARAGRAPH_H
00022 #define AP_PREVIEW_PARAGRAPH_H
00023 
00024 #include "ut_misc.h"
00025 #include "ut_types.h"
00026 #include "ut_vector.h"
00027 
00028 #include "xap_Preview.h"
00029 #include "ap_Dialog_Paragraph.h"
00030 
00031 // fwd decl.
00032 class AP_Dialog_Lists;
00033 
00034 class GR_Font;
00035 
00036 // a mini-class representing a block of text to be
00037 // drawn in the preview
00038 class ABI_EXPORT AP_Preview_Paragraph_Block
00039 {
00040  public:
00041     AP_Preview_Paragraph_Block(UT_RGBColor & clr,
00042                                GR_Graphics * gc,
00043                                AP_Dialog_Paragraph::tAlignState m_align,
00044                                UT_uint32 fontHeight);
00045     virtual ~AP_Preview_Paragraph_Block();
00046 
00047     // sets the vectors full of words and lengths
00048     void setText(const UT_UCSChar * text);
00049 
00050     void setFormat(const gchar * pageLeftMargin,
00051                    const gchar * pageRightMargin,
00052                    AP_Dialog_Paragraph::tAlignState align,
00053                    const gchar * firstLineIndent,
00054                    AP_Dialog_Paragraph::tIndentState indent,
00055                    const gchar * leftIndent,
00056                    const gchar * rightIndent,
00057                    const gchar * beforeSpacing,
00058                    const gchar * afterSpacing,
00059                    const gchar * lineSpacing,
00060                    AP_Dialog_Paragraph::tSpacingState spacing);
00061 
00062     // absolute pixel positions (relative to respective sides)
00063     // at which we'll start/stop drawing.  The firstLine element
00064     // applies to the first line in a block only.  The others
00065     // apply to the rest of the block.
00066     UT_uint32 m_firstLineLeftStop;
00067     UT_uint32 m_leftStop;
00068     UT_uint32 m_rightStop;
00069 
00070     UT_uint32 m_beforeSpacing;
00071     UT_uint32 m_afterSpacing;
00072     UT_uint32 m_lineSpacing;
00073 
00074     AP_Dialog_Paragraph::tAlignState m_align;
00075     AP_Dialog_Paragraph::tIndentState m_indent;
00076     AP_Dialog_Paragraph::tSpacingState m_spacing;
00077 
00078     UT_uint32 m_fontHeight;
00079     UT_RGBColor m_clr;
00080 
00081     GR_Graphics * m_gc;
00082 
00083     // when a string is set, we break it into words for
00084     // easy layout, and store the word content (UT_UCSChar *)
00085     // and its measured length in pixels (UT_uint32)
00086     UT_GenericVector<UT_UCSChar *> m_words;
00087     UT_NumberVector m_widths;
00088 };
00089 
00090 class ABI_EXPORT AP_Preview_Paragraph : public XAP_Preview
00091 {
00092  public:
00093 
00094     AP_Preview_Paragraph(GR_Graphics * gc, const UT_UCSChar * text,
00095                  AP_Dialog_Paragraph * parent, const char * fontname = NULL);
00096 
00097     AP_Preview_Paragraph(GR_Graphics * gc, const UT_UCSChar * text,
00098                  XAP_Dialog * parent);
00099 
00100     AP_Preview_Paragraph(GR_Graphics * gc,
00101                  const UT_UCSChar * text,
00102                  AP_Dialog_Lists * dlg);
00103 
00104     virtual ~AP_Preview_Paragraph(void);
00105 
00106     void setFormat(const gchar * pageLeftMargin,
00107                    const gchar * pageRightMargin,
00108                    AP_Dialog_Paragraph::tAlignState align,
00109                    const gchar * firstLineIndent,
00110                    AP_Dialog_Paragraph::tIndentState indent,
00111                    const gchar * leftIndent,
00112                    const gchar * rightIndent,
00113                    const gchar * beforeSpacing,
00114                    const gchar * afterSpacing,
00115                    const gchar * lineSpacing,
00116                    AP_Dialog_Paragraph::tSpacingState spacing,
00117                    UT_BidiCharType dir = UT_BIDI_LTR);
00118 
00119     virtual void draw(const UT_Rect *clip=NULL);
00120 
00121  protected:
00122 
00123     // standard colors to draw with
00124     UT_RGBColor * m_clrWhite;
00125     UT_RGBColor * m_clrBlack;
00126     UT_RGBColor * m_clrGray;
00127 
00128     // we flow using this as a current position
00129     UT_uint32 m_x;
00130     UT_uint32 m_y;
00131 
00132     virtual bool _loadDrawFont(const char *name = NULL);
00133     virtual void    _drawPageBackground(void);
00134     virtual void    _drawPageBorder(void);
00135     virtual void    _appendBlock(AP_Preview_Paragraph_Block * block);
00136     virtual UT_uint32 _appendLine(UT_GenericVector<UT_UCSChar *> * words,
00137                                   UT_NumberVector * widths,
00138                                   UT_uint32 startWithWord,
00139                                   UT_uint32 left,
00140                                   UT_uint32 right,
00141                                   AP_Dialog_Paragraph::tAlignState align,
00142                                   UT_uint32 y);
00143 
00144     // mini-classes to hold some general data about these three
00145     // blocks
00146     AP_Preview_Paragraph_Block * m_previousBlock;
00147     AP_Preview_Paragraph_Block * m_activeBlock;
00148     AP_Preview_Paragraph_Block * m_followingBlock;
00149 
00150     GR_Font * m_font;
00151     UT_uint32 m_fontHeight;
00152     UT_BidiCharType m_dir;
00153 };
00154 
00155 #endif /* AP_PREVIEW_PARAGRAPH_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1