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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/10/2010 Added this text. :-)
15 #include "qg_fontbox.h"
19 #include "rs_fontlist.h"
22 * Default Constructor. You must call init manually if you choose
23 * to use this constructor.
25 QG_FontBox::QG_FontBox(QWidget * parent/*= 0*/, const char */*name = 0*/): QComboBox(parent)
32 QG_FontBox::~QG_FontBox()
37 * Initialisation (called from constructor or manually but only
40 void QG_FontBox::init()
44 for(RS_Font * f=RS_FONTLIST->firstFont(); f!=NULL; f=RS_FONTLIST->nextFont())
45 fonts.append(f->getFileName());
48 // insertStringList(fonts);
51 connect(this, SIGNAL(activated(int)), this, SLOT(slotFontChanged(int)));
55 // slotFontChanged(currentItem());
56 slotFontChanged(currentIndex());
59 RS_Font * QG_FontBox::getFont()
65 * Sets the currently selected width item to the given width.
67 void QG_FontBox::setFont(const QString & fName)
69 RS_DEBUG->print("QG_FontBox::setFont %s\n", fName.toLatin1().data());
70 // setCurrentText(fName);
71 setItemText(currentIndex(), fName);
72 // slotFontChanged(currentItem());
73 slotFontChanged(currentIndex());
77 * Called when the font has changed. This method
78 * sets the current font to the value chosen.
80 void QG_FontBox::slotFontChanged(int index)
82 RS_DEBUG->print("QG_FontBox::slotFontChanged %d\n", index);
83 currentFont = RS_FONTLIST->requestFont(currentText());
85 if (currentFont != NULL)
86 RS_DEBUG->print("Current font is (%d): %s\n", index, currentFont->getFileName().toLatin1().data());
88 emit fontChanged(currentFont);