20#include "Kolinewidthaction.h"
25#include <tqwhatsthis.h>
30#include <tdepopupmenu.h>
31#include <tdeapplication.h>
33#include <tdetoolbar.h>
34#include <tdetoolbarbutton.h>
35#include <kiconloader.h>
38#include <KoUnitWidgets.h>
41class KoLineWidthAction::KoLineWidthActionPrivate
44 KoLineWidthActionPrivate()
47 m_unit = KoUnit::U_PT;
50 ~KoLineWidthActionPrivate()
54 double m_currentWidth;
59 TQObject* parent,
const char* name) :
KoSelectAction(text, icon, parent, name)
61 d =
new KoLineWidthActionPrivate;
67 const char* slot, TQObject* parent,
const char* name) :
KoSelectAction(text, icon, parent, name)
69 d =
new KoLineWidthActionPrivate;
76KoLineWidthAction::~KoLineWidthAction()
86 TQPainter p(&pix,
popup);
90 for(
int i = 1; i <= 10; i++) {
92 pen.setWidth(tqRound(i * POINT_TO_INCH(
static_cast<double>(KoGlobal::dpiY()))));
94 p.drawLine(0, 10, pix.width(), 10);
97 popup->insertItem(pix,cindex++);
100 popup->insertSeparator(cindex++);
101 popup->insertItem(i18n(
"&Custom..."), cindex++);
108 if((index >= 0) && (index < 10)) {
109 d->m_currentWidth = (double) index + 1.0;
117 d->m_currentWidth = dlg.
width();
130 return d->m_currentWidth;
135 d->m_currentWidth = width;
138 for(
int i = 1; i <= 10; i++) {
159class KoLineWidthChooser::KoLineWidthChooserPrivate
165KoLineWidthChooser::KoLineWidthChooser(TQWidget* parent,
const char* name)
166 :
KDialogBase(parent,
name, true, i18n(
"Custom Line Width"), Ok|Cancel, Ok)
168 d =
new KoLineWidthChooserPrivate;
171 TQWidget* mainWidget =
new TQWidget(
this);
172 setMainWidget(mainWidget);
174 TQLabel* textLbl =
new TQLabel(i18n(
"Line width:"), mainWidget);
175 d->m_lineWidthUSBox =
new KoUnitDoubleSpinBox(mainWidget, 0.0, 1000.0, 0.1, 1.0, KoUnit::U_PT, 2);
176 gl->addWidget(textLbl, 0, 0);
177 gl->addWidget(d->m_lineWidthUSBox, 0, 1);
180KoLineWidthChooser::~KoLineWidthChooser()
187 return d->m_lineWidthUSBox->value();
192 d->m_lineWidthUSBox->setUnit(unit);
197 d->m_lineWidthUSBox->changeValue(
width);
200#include "Kolinewidthaction.moc"
void execute(int index)
Reimplemented from KoSelectAction.
void createMenu()
Draws and adds each item of the menu.
void setCurrentWidth(double width)
Set the current width.
KoLineWidthAction(const TQString &text, const TQString &icon, TQObject *parent=0, const char *name=0)
Constructs a KoLineWidthAction with a text and an icon.
double currentWidth() const
Returns the currently selected line width.
void setUnit(KoUnit::Unit unit)
Set which unit to use in the custom width dialog.
void lineWidthChanged(double)
Emited when a new line width have been selected.
This class provides a dialog for setting a custom line width.
void setUnit(KoUnit::Unit unit)
Set unit to use when showing the width.
void setWidth(double width)
Set line width.
double width() const
Returns the selected line width in points.
An action that provides a menu with items that can be selected.
TDEPopupMenu * popupMenu() const
Returns a pointer to the popup menu.
void popup(const TQPoint &global)
Shows the popup menu.
virtual void setCurrentSelection(int index)
Set which item that should be selected.
Spin box for double precision numbers with unit display.
Unit
Length units supported by KOffice.
static double toPoint(double ptValue)
Prepare ptValue to be displayed in pt.
const char * name(StdAction id)