kotoolboxpalette.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
19
20#include <tqdockwindow.h>
21#include <tqtoolbox.h>
22
23#include <kopalette.h>
24#include <kopalettemanager.h>
25#include <kotoolboxpalette.h>
26
27KoToolBoxPalette::KoToolBoxPalette(TQWidget * parent, const char * name)
28 : KoPalette(parent, name)
29{
30 m_page = new TQToolBox(this);
31 m_page->unsetFont();
32 setMainWidget(m_page);
33 m_style = PALETTE_TOOLBOX;
34}
35
36KoToolBoxPalette::~KoToolBoxPalette()
37{
38}
39
40
41void KoToolBoxPalette::resetFont()
42{
43 KoPalette::resetFont();
44 m_page->unsetFont();
45}
46
47
48void KoToolBoxPalette::plug(TQWidget *w, const TQString & label, int position)
49{
50 w->unsetFont();
51 m_page->insertItem( position, w, label );
52}
53
54
55void KoToolBoxPalette::unplug(const TQWidget *w)
56{
57 m_page->removeItem( const_cast<TQWidget*>(w) );
58}
59
60void KoToolBoxPalette::showPage(TQWidget *w)
61{
62 m_page->setCurrentItem( w );
63}
64
65
66int KoToolBoxPalette::indexOf(TQWidget *w)
67{
68 if (m_hiddenPages.find(w) != m_hiddenPages.end()) {
69 return m_page->indexOf(w);
70 }
71 else {
72 return m_page->indexOf(w);
73 }
74}
75
76
77void KoToolBoxPalette::makeVisible(bool v)
78{
79 if (v && m_page->count() > 0) {
80 show();
81 }
82 else {
83 hide();
84 }
85}
86
87bool KoToolBoxPalette::isHidden(TQWidget * w)
88{
89 return (m_hiddenPages.find(w) != m_hiddenPages.end());
90}
91
92void KoToolBoxPalette::togglePageHidden(TQWidget *w)
93{
94 if (m_hiddenPages.find(w) != m_hiddenPages.end()) {
95 int i = *m_hiddenPages.find(w);
96 m_page->insertItem(i, w, w->caption());
97 show();
98 }
99 else {
100 int i = m_page->indexOf(w);
101 m_page->removeItem(w);
102 m_hiddenPages[w] = i;
103 if (m_page->count() == 0) {
104 hide();
105 }
106 }
107
108}
109
110void KoToolBoxPalette::hidePage( TQWidget * w)
111{
112 if (m_hiddenPages.find(w) != m_hiddenPages.end()) return;
113 int i = m_page->indexOf(w);
114 m_page->removeItem(w);
115 m_hiddenPages[w] = i;
116 if (m_page->count() == 0) {
117 hide();
118 }
119}
120
121#include "kotoolboxpalette.moc"
A floating palette that allows the adding and removing of widgets to its organzing principle.
Definition kopalette.h:39
const char * name(StdAction id)