]> Shamusworld >> Repos - architektonas/blob - src/forms/textoptions.cpp
bbb293a09f2eb9d019b174a57bd7300288a6f0f7
[architektonas] / src / forms / textoptions.cpp
1 // textoptions.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  05/28/2010  Created this file. :-)
15 //
16
17 #include "textoptions.h"
18
19 #include "actiondrawtext.h"
20 #include "actioninterface.h"
21
22 TextOptions::TextOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23         QWidget(parent, flags)
24 {
25         ui.setupUi(this);
26
27         // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
28         // nothing will show up on the screen. :-)
29         if (parent)
30                 parent->addWidget(this);
31 }
32
33 TextOptions::~TextOptions()
34 {
35 }
36
37 void TextOptions::setAction(ActionInterface * a, bool update)
38 {
39         if (a != NULL && a->rtti() == RS2::ActionDrawText)
40         {
41                 action = (ActionDrawText *)a;
42
43                 QString st;
44                 QString sa;
45
46                 if (update)
47                 {
48                         st = action->getText();
49                         sa = QString("%1").arg(RS_Math::rad2deg(action->getAngle()));
50                 }
51                 else
52                 {
53                         st = "";
54                         sa = "0.0";
55                 }
56
57                 ui.teText->setText(st);
58                 ui.leAngle->setText(sa);
59         }
60         else
61         {
62                 RS_DEBUG->print(RS_Debug::D_ERROR, "TextOptions::setAction: wrong action type");
63                 action = NULL;
64         }
65 }
66
67 void TextOptions::updateText()
68 {
69         if (action != NULL)
70                 action->setText(ui.teText->text());
71 }
72
73 void TextOptions::updateAngle()
74 {
75         if (action != NULL)
76                 action->setAngle(RS_Math::deg2rad(RS_Math::eval(ui.leAngle->text())));
77 }