~vcs-imports/xdrawchem/1.9.9

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// text.h -- subclass of Drawable for text/labels

#ifndef TEXT_H
#define TEXT_H

#include <qobject.h>
#include <qrect.h>
#include <qfont.h>
#include "render2d.h"
#include "drawable.h"
#include "dpoint.h"

#define TEXT_AUTO 0
#define TEXT_LALIGN 1
#define TEXT_CALIGN 2
#define TEXT_RALIGN 3

class Molecule;

class Text : public Drawable {
  Q_OBJECT
    public:
  Text(Render2D *, QObject *parent = 0, const char *name = 0);
  void Render();  // draw this object
  int Type();  // return type of object
  bool Find(DPoint *); // does this Text contain this DPoint?
  DPoint * FindNearestPoint(DPoint *, double &);
  Drawable * FindNearestObject(DPoint *, double &);
  Drawable * DeepCopy();
  void setPoint(DPoint *);
  int Justify() { return justify; }
  void setJustify(int a) { justify = a; }
  bool WithinBounds(DPoint *);
  bool WithinRect(QRect, bool);
  void InsertCharacter(QKeyEvent *);
  void InsertString(QString);
  void DeleteKeyPressed();
  QPoint GetTopLeftPoint(void);  // get real top left point, based on justify
  QPoint NearestCenter(QPoint, int, int &);
  void setText(QString nt1, QString nt2) { 
    if (start != 0) {
      start->element = nt1; // element info (plain text)
      start->elementmask = nt2;  // actual display text in underlying point!
      displayText = nt2;
    }
  }
  void setText(QString nt) {
    setText(nt, nt);
  }
  QString getText() { 
    if (start != 0)
      return start->element; 
    else
      return "";
  } // not just Text()!
  QString getRichText() {
    if (start != 0)
      return displayText; 
    else
      return "";
  }
  void setTextMask(QString nm) { 
    // this function is (probably) obsolete.  Use setText() instead.
    //if (start != 0) start->elementmask = nm; 
  }
  QString getTextMask() {
    if (start != 0)
      return start->elementmask; 
    else
      return "";
  }
  void setFont(QFont f) { 
    font = f; 
    bfont = f;
    bfont.setWeight(QFont::Bold);
    ifont = f;
    ifont.setItalic(true);
    ufont = f;
    ufont.setUnderline(true);
  }
  QFont subscriptFont(QFont);
  void setMolecule(Molecule *m1) { molecule = m1; }
  Molecule *getMolecule() { return molecule; }
  void setDataType(int d1) { DataType = d1; }
  int getDataType() { return DataType; }
  QFont getFont() { return font; }
  void MoveCursor(DPoint *);
  void Select(DPoint *, DPoint *);
  QRect BoundingBox();
  void DoSuperscript();
  void DoSubscript();
  void DoBold();
  void DoItalic();
  void DoUnderline();
  void DeselectAllText() { selectMin = -1; selectMax = -1; }
  // set text parsed from XML file
  void SetTextFromXML(QString) { }
  QString ToXML(QString);
  QString ToCDXML(QString);
  void FromXML(QString);
  void SetFontFromXML(QString);
  void SetTextstringFromXML(QString);
  void SetRichstringFromXML(QString);
  void SetTextmaskFromXML(QString);
  void SetBorderColorFromXML(QString);
  void SetFillColorFromXML(QString);
  void SetShapeGeometryFromXML(QString);
  void CheckAlignment(int);
  void ForceAlignment(int);
  void UpdateDisplayText();
  // set shape/border/fill
  void setShape(int s1) {
    shape = s1;
  }
  int getShape() { return shape; }
  void setBorder(bool b1) { drawBorder = b1; }
  bool getBorder() { return drawBorder; }
  void setBorderColor(QColor c1) { borderColor = c1; }
  QColor getBorderColor() { return borderColor; }
  void setFill(bool b1) { drawFill = b1; }
  bool getFill() { return drawFill; }
  void setFillColor(QColor c1) { fillColor = c1; }
  QColor getFillColor() { return fillColor; }
  void setShapeWidth(int i1) {
    shapewidth = i1;
  }
  void setShapeHeight(int i1) {
    shapeheight = i1;
  }
  int getShapeWidth() {
    if (shapewidth < 0) return oshapewidth;
    return shapewidth;
  }
  int getShapeHeight() {
    if (shapeheight < 0) return oshapeheight;
    return shapeheight;
  }

 private:
  // Renderer
  Render2D *r;
  // Text this object holds
  //QString text;  *** NOW DEFINED IN dpoint.h
  // Text modifier -- super/subscript flags
  //QString textmask;  *** NOW DEFINED IN dpoint.h
  // Text and flags which are actually displayed
  QString displayText, displayTextMask;
  // for text which labels a point -- which side is less hindered?
  int whichside;  // 1 = left, 2 = right
  // Text font(s) - regular, bold, italic, underline
  QFont font, bfont, ifont, ufont;
  // justify -- how/where to draw this text
  int justify, tjustify;
  // dimensions of text box
  QRect BBox;
  // cursor position (character # within text)
  int cursor;
  // selection range
  int selectMin, selectMax;
  // is the Shift key down?
  bool shiftdown;
  // Molecule this text gets data from
  Molecule *molecule;
  int DataType;
  // shape/border/fill variables
  int shape;  // 0 = no shape
  bool drawBorder, drawFill;
  QColor borderColor, fillColor;
  int shapewidth, shapeheight;
  int oshapewidth, oshapeheight;
};

#endif