kopalette.cpp
1/*
2 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
3 *
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2, as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18#include <tqwidget.h>
19#include <tqdockwindow.h>
20#include <tqvariant.h>
21#include <tqlabel.h>
22#include <tqtoolbutton.h>
23#include <tqtabwidget.h>
24#include <tqlayout.h>
25#include <tqtooltip.h>
26#include <tqwhatsthis.h>
27#include <tqimage.h>
28#include <tqpixmap.h>
29#include <tqlayout.h>
30
31#include <kdebug.h>
32#include <tdeglobal.h>
33#include <tdelocale.h>
34#include <tdeglobalsettings.h>
35#include <tdeaccelmanager.h>
36#include <tdeconfig.h>
37
38#include <KoView.h>
39
40#include "kopalette.h"
41
42KoPalette::KoPalette(TQWidget * parent, const char * name)
43 : TQDockWindow(parent, name)
44{
45
46#if TDE_VERSION >= TDE_MAKE_VERSION(3,3,90)
47 TDEAcceleratorManager::setNoAccel(this);
48#endif
49 setCloseMode( TQDockWindow::Never);
50 setResizeEnabled(true);
51 setOpaqueMoving(true);
52 setFocusPolicy(TQWidget::NoFocus);
53 setVerticallyStretchable(false);
54 setHorizontallyStretchable(false);
55
56 setNewLine(true);
57 layout() -> setSpacing(0);
58 layout() -> setMargin(0);
59
60 resetFont();
61}
62
63void KoPalette::resetFont()
64{
65
66 TDEConfig * cfg = TDEGlobal::config();
67 Q_ASSERT(cfg);
68 cfg->setGroup("");
69 m_font = TDEGlobalSettings::generalFont();
70 float ps = TQMIN(9, TDEGlobalSettings::generalFont().pointSize() * 0.8);
71 ps = cfg->readNumEntry("palettefontsize", (int)ps);
72 if (ps < 6) ps = 6;
73 m_font.setPointSize((int)ps);
74 setFont(m_font);
75
76}
77
78KoPalette::~KoPalette()
79{
80}
81
82void KoPalette::setMainWidget(TQWidget * widget)
83{
84 setWidget(widget);
85 resize( TQSize(285, 233).expandedTo(minimumSizeHint()) );
86 clearWState( WState_Polished );
87 widget->setFont(m_font);
88 m_page = widget;
89}
90
91#include "kopalette.moc"
const char * name(StdAction id)