Scribus
Open source desktop publishing at your fingertips
pageitem_textframe.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8  pageitem.h - description
9  -------------------
10  copyright : Scribus Team
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 
22 #ifndef PAGEITEMTEXTFRAME_H
23 #define PAGEITEMTEXTFRAME_H
24 
25 #include <QMap>
26 #include <QRectF>
27 #include <QString>
28 #include <QKeyEvent>
29 
30 #include "scribusapi.h"
31 #include "pageitem.h"
32 #include "marks.h"
33 #include "notesstyles.h"
34 
35 class PageItem_NoteFrame;
36 class ScPainter;
37 class ScribusDoc;
38 
39 typedef QMap<PageItem_NoteFrame*, QList<TextNote *> > NotesInFrameMap;
40 
41 
42 //cezaryece: I remove static statement and made it public as this function is used also by PageItem_NoteFrame
43 double calculateLineSpacing (const ParagraphStyle &style, PageItem *item);
44 
45 class SCRIBUS_API PageItem_TextFrame : public PageItem
46 {
47  Q_OBJECT
48 
49 public:
50  PageItem_TextFrame(ScribusDoc *pa, double x, double y, double w, double h, double w2, QString fill, QString outline);
51  PageItem_TextFrame(const PageItem & p);
52  ~PageItem_TextFrame() {};
53 
54  virtual PageItem_TextFrame * asTextFrame() { return this; }
55  virtual bool isTextFrame() const { return true; }
56 
57  virtual void clearContents();
58  virtual void truncateContents();
59 
65  virtual void handleModeEditKey(QKeyEvent *k, bool& keyRepeat);
66  void deleteSelectedTextFromFrame();
67  void setNewPos(int oldPos, int len, int dir);
68  void ExpandSel(int dir, int oldPos);
69  void deselectAll();
70 
71  //for speed up updates when changed was only one frame from chain
72  virtual void invalidateLayout(bool wholeChain);
74  virtual void layout();
75  //return true if all previouse frames from chain are valid (including that one)
76  bool isValidChainFromBegin();
77  //simplify conditions checking if frame is in chain
78  //FIX: use it in other places
79  bool isInChain() { return ((prevInChain() != NULL) || (nextInChain() != NULL)); }
80  void setTextAnnotationOpen(bool open);
81 
82  double columnWidth();
83 
84  //enable/disable marks inserting actions depending on editMode
85  void toggleEditModeActions();
86  QRegion availableRegion() { return m_availableRegion; }
87 
88 protected:
89  QRegion calcAvailableRegion();
90  QRegion m_availableRegion;
91  virtual void DrawObj_Item(ScPainter *p, QRectF e);
92  virtual void DrawObj_Post(ScPainter *p);
93  virtual void DrawObj_Decoration(ScPainter *p);
94  //void drawOverflowMarker(ScPainter *p);
95  void drawUnderflowMarker(ScPainter *p);
96  void drawColumnBorders(ScPainter *p);
97 
98  bool unicodeTextEditMode;
99  int unicodeInputCount;
100  QString unicodeInputString;
101 
102  void drawNoteIcon(ScPainter *p);
103  virtual bool createInfoGroup(QFrame *, QGridLayout *);
104  virtual void applicableActions(QStringList& actionList);
105  virtual QString infoDescription();
106  // Move incomplete lines from the previous frame if needed.
107  bool moveLinesFromPreviousFrame ();
108  void adjustParagraphEndings ();
109 
110 private:
111  bool cursorBiasBackward;
112  // If the last paragraph had to be split, this is how many lines of the paragraph are in this frame.
113  // Used for orphan/widow control
114  int incompleteLines;
115  // This holds the line splitting positions
116  QList<int> incompletePositions;
117 
118  void setShadow();
119  QString currentShadow;
120  QMap<QString,StoryText> shadows;
121  bool checkKeyIsShortcut(QKeyEvent *k);
122  QRectF m_origAnnotPos;
123 
124 private slots:
125  void slotInvalidateLayout();
126 
127 public:
128  //for footnotes/endnotes
129  bool hasNoteMark(NotesStyle* NS = NULL);
130  bool hasNoteFrame(NotesStyle* NS, bool inChain = false);
131  //bool hasNoteFrame(PageItem_NoteFrame* nF) { return m_notesFramesMap.contains(nF); }
132  void delAllNoteFrames(bool doUpdate = false);
133  void removeNoteFrame(PageItem_NoteFrame* nF) { m_notesFramesMap.remove(nF); }
134  //layout notes frames /updates endnotes frames content if m_Doc->flag_updateEndNotes is set/
135  void notesFramesLayout();
136  //removing all marsk from text, returns number of removed marks
137  int removeMarksFromText(bool doUndo);
138  //return note frame for given notes style if current text frame has notes marks with this style
139  PageItem_NoteFrame* itemNoteFrame(NotesStyle* nStyle);
140  //list all notes frames for current text frame /with endnotes frames if endnotes marks are in that frame/
141  QList<PageItem_NoteFrame*> notesFramesList() { return m_notesFramesMap.keys(); }
142  //list of notes inserted by current text frame into given noteframe
143  QList<TextNote*> notesList(PageItem_NoteFrame* nF) { return m_notesFramesMap.value(nF); }
144  //insert note frame to list with empty notes list
145  void setNoteFrame(PageItem_NoteFrame* nF);
146  void invalidateNotesFrames();
147 
148 private:
149  NotesInFrameMap m_notesFramesMap;
150  NotesInFrameMap updateNotesFrames(QMap<int, Mark*> noteMarksPosMap); //update notes frames content
151  void updateNotesMarks(NotesInFrameMap notesMap);
152  Mark* selectedMark(bool onlySelection = true);
153  TextNote* selectedNoteMark(int& foundPos, bool onlySelection = true);
154  TextNote* selectedNoteMark(bool onlySelection = true);
155 protected:
156  // set text frame height to last line of text
157  double maxY;
158  void setMaxY(double y);
159 
160 public:
161  void setTextFrameHeight();
162 };
163 
164 #endif
Definition: pageitem_noteframe.h:8
Definition: pageitem_textframe.h:45
virtual void invalidateLayout()
invalidates current layout information
Definition: pageitem.h:381
virtual PageItem_TextFrame * asTextFrame()
Return self if Text item, otherwise null.
Definition: pageitem_textframe.h:54
virtual void layout()
creates valid layout information
Definition: pageitem.h:383
Definition: notesstyles.h:28
Definition: paragraphstyle.h:27
Definition: marks.h:40
the Document Class
Definition: scribusdoc.h:90
Definition: scpainter.h:33
virtual void clearContents()
Clear the contents of a frame. WARNING: Currently they do not check if the user wants this...
Definition: pageitem.h:308
virtual bool isTextFrame() const
Return true if Text item, otherwise false.
Definition: pageitem_textframe.h:55
Definition: pageitem.h:92
Definition: notesstyles.h:91