kpresenter

KPrSideBar.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.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 as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef SIDEBAR_H
21#define SIDEBAR_H
22
23#include <tqrect.h>
24#include <tqstringlist.h>
25#include <tqtabwidget.h>
26#include <tqvalidator.h>
27
28#include <kiconview.h>
29#include <tdelistview.h>
30
31class TQListViewItem;
32class KPrDocument;
33class KPrView;
34class TQDropEvent;
35class TQPopupMenu;
36class KPrOutline;
37class OutlineSlideItem;
38class KPrThumbBar;
39class ThumbToolTip;
40class KPrPage;
41
42
43class KPrRenamePageValidator : public TQValidator
44{
45 public:
46 KPrRenamePageValidator( const TQStringList & list=TQStringList() )
47 : TQValidator( 0, 0 ), mStringList( list ) {}
48 virtual State validate( TQString & input, int & pos ) const;
49
50 protected:
51 TQStringList mStringList;
52};
53
54class KPrSideBarBase
55{
56public:
57 KPrSideBarBase(KPrDocument *_doc, KPrView *_view);
58 void setViewMasterPage( bool _b );
59protected:
60 KPrDocument *m_doc;
61 KPrView *m_view;
62 bool m_viewMasterPage;
63};
64
65class KPrThumbBar : public TDEIconView, public KPrSideBarBase
66{
67 TQ_OBJECT
68
69
70public:
71 KPrThumbBar(TQWidget *parent, KPrDocument *d, KPrView *v);
72 ~KPrThumbBar();
73 void setCurrentPage( int pg );
74 void updateItem( int pagenr, bool sticky = false );
75 void addItem( int pos );
76 void moveItem( int oldPos, int newPos );
77 void removeItem( int pos );
78 void refreshItems ( bool offset = false );
79 TQRect tip(const TQPoint &pos, TQString &title);
80
81 bool uptodate;
82
83signals:
84 void showPage( int i );
85
86public slots:
87 void rebuildItems();
88
89private slots:
90 void itemClicked(TQIconViewItem *i);
91 void slotContentsMoving(int x, int y);
92 void slotRefreshItems();
93
94private:
95 TQPixmap getSlideThumb(int slideNr) const;
96
97 ThumbToolTip *m_thumbTip;
98 int m_offsetX;
99 int m_offsetY;
100};
101
102class KPrOutline: public TDEListView, public KPrSideBarBase
103{
104 TQ_OBJECT
105
106
107public:
108 KPrOutline( TQWidget *parent, KPrDocument *d, KPrView *v );
109 ~KPrOutline();
110 void setCurrentPage( int pg );
111 TQSize sizeHint() const { return TQSize( 145, TDEListView::sizeHint().height() ); }
112 void updateItem( int pagenr, bool sticky = false);
113 void addItem( int pos );
114 void moveItem( int oldPos, int newPos );
115 void removeItem( int pos );
116
117protected:
118 void contentsDropEvent( TQDropEvent *e );
119 void moveItem( TQListViewItem *i, TQListViewItem *firstAfter, TQListViewItem *newAfter );
120 OutlineSlideItem* slideItem( int pageNumber );
121 bool acceptDrag( TQDropEvent* e ) const;
122
123 virtual TQDragObject* dragObject();
124
125signals: // all page numbers 0-based
126 void showPage( int i );
127 void movePage( int from, int to );
128 void selectPage( int i, bool );
129
130public slots:
131 void rebuildItems();
132 void renamePageTitle();
133
134private slots:
135 void itemClicked( TQListViewItem *i );
136 void slotDropped( TQDropEvent *e, TQListViewItem *parent, TQListViewItem *target );
137 void rightButtonPressed( TQListViewItem *i, const TQPoint &pnt, int c );
138 void slotContextMenu( TDEListView*, TQListViewItem *item, const TQPoint &p );
139
140private:
141 TQListViewItem *m_movedItem, *m_movedAfter;
142};
143
144class KPrSideBar: public TQTabWidget
145{
146 TQ_OBJECT
147
148
149public:
150 KPrSideBar(TQWidget *parent, KPrDocument *d, KPrView *v);
151 void setCurrentPage( int pg ) {
152 m_outline->setCurrentPage(pg);
153 m_thb->setCurrentPage(pg);
154 };
155 void setOn( int , bool ) { };
156 //TQSize sizeHint() const { return TQSize( 120, TQTabWidget::sizeHint().height() ); };
157 void updateItem( KPrPage *page );
158 void addItem( int pos );
159 void moveItem( int oldPos, int newPos );
160 void removeItem( int pos );
161
162 KPrOutline *outline() const { return m_outline; };
163 KPrThumbBar *thumbBar() const { return m_thb; };
164
165 void setViewMasterPage( bool _masterPage );
166signals: // all page numbers 0-based
167 void showPage( int i );
168 void movePage( int from, int to );
169 void selectPage( int i, bool );
170
171public slots:
172 //void rebuildItems() { m_outline->rebuildItems(); m_thb->rebuildItems();};
173 void renamePageTitle() { m_outline->renamePageTitle(); };
174 void currentChanged(TQWidget *tab);
175
176private:
177 KPrOutline *m_outline;
178 KPrThumbBar *m_thb;
179
180 KPrDocument *m_doc;
181 KPrView *m_view;
182};
183
184#endif