tdebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

konq_frame.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. /* This file is part of the KDE project
  2. Copyright (C) 1998, 1999 Michael Reiher <michael.reiher@gmx.de>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. */
  15. #ifndef __konq_frame_h__
  16. #define __konq_frame_h__
  17. #include "konq_factory.h"
  18. #include <tqguardedptr.h>
  19. #include <tqcolor.h>
  20. #include <tqwidget.h>
  21. #include <tqsplitter.h>
  22. #include <tqcheckbox.h>
  23. #include <tqlabel.h>
  24. #include <kpixmap.h>
  25. #include <kpixmapeffect.h>
  26. #include <kstatusbar.h>
  27. class TQPixmap;
  28. class TQVBoxLayout;
  29. class TQHBoxLayout;
  30. class TQTimer;
  31. class TQPushButton;
  32. class TQToolButton;
  33. class KonqView;
  34. class KonqViewManager;
  35. class KonqFrameBase;
  36. class KonqFrame;
  37. class KonqFrameContainerBase;
  38. class KonqFrameContainer;
  39. class KonqFrameTabs;
  40. class TDEConfig;
  41. class KSeparator;
  42. class KProgress;
  43. class TDEAction;
  44. class KSqueezedTextLabel;
  45. namespace KParts
  46. {
  47. class ReadOnlyPart;
  48. }
  49. /**
  50. * A CheckBox with a special paintEvent(). It looks like the
  51. * unchecked radiobutton in b2k style if unchecked and contains a little
  52. * anchor if checked.
  53. */
  54. class KonqCheckBox : public TQCheckBox
  55. {
  56. Q_OBJECT // for classname
  57. public:
  58. KonqCheckBox(TQWidget *parent=0, const char *name=0)
  59. :TQCheckBox( parent, name ) {}
  60. protected:
  61. void drawButton( TQPainter * );
  62. };
  63. /**
  64. * The KonqFrameStatusBar is the statusbar under each konqueror view.
  65. * It indicates in particular whether a view is active or not.
  66. */
  67. class KonqFrameStatusBar : public KStatusBar
  68. {
  69. Q_OBJECT
  70. public:
  71. KonqFrameStatusBar( KonqFrame *_parent = 0L, const char *_name = 0L );
  72. virtual ~KonqFrameStatusBar();
  73. /**
  74. * Checks/unchecks the linked-view checkbox
  75. */
  76. void setLinkedView( bool b );
  77. /**
  78. * Shows/hides the active-view indicator
  79. */
  80. void showActiveViewIndicator( bool b );
  81. /**
  82. * Shows/hides the linked-view indicator
  83. */
  84. void showLinkedViewIndicator( bool b );
  85. /**
  86. * Updates the active-view indicator and the statusbar color.
  87. */
  88. void updateActiveStatus();
  89. public slots:
  90. void slotConnectToNewView(KonqView *, KParts::ReadOnlyPart *oldOne,KParts::ReadOnlyPart *newOne);
  91. void slotLoadingProgress( int percent );
  92. void slotSpeedProgress( int bytesPerSecond );
  93. void slotDisplayStatusText(const TQString& text);
  94. void slotClear();
  95. void message ( const TQString & message );
  96. signals:
  97. /**
  98. * This signal is emitted when the user clicked the bar.
  99. */
  100. void clicked();
  101. /**
  102. * The "linked view" checkbox was clicked
  103. */
  104. void linkedViewClicked( bool mode );
  105. protected:
  106. virtual bool eventFilter(TQObject*,TQEvent *);
  107. virtual void resizeEvent( TQResizeEvent* );
  108. virtual void mousePressEvent( TQMouseEvent* );
  109. /**
  110. * Brings up the context menu for this frame
  111. */
  112. virtual void splitFrameMenu();
  113. /**
  114. * Takes care of the statusbars size
  115. **/
  116. virtual void fontChange(const TQFont &oldFont);
  117. private:
  118. KonqFrame* m_pParentKonqFrame;
  119. TQCheckBox *m_pLinkedViewCheckBox;
  120. KProgress *m_progressBar;
  121. KSqueezedTextLabel *m_pStatusLabel;
  122. TQLabel* m_led;
  123. TQString m_savedMessage;
  124. };
  125. typedef TQPtrList<KonqView> ChildViewList;
  126. class KonqFrameBase
  127. {
  128. public:
  129. virtual ~KonqFrameBase() {}
  130. virtual void saveConfig( TDEConfig* config, const TQString &prefix, bool saveURLs, KonqFrameBase* docContainer, int id = 0, int depth = 0) = 0;
  131. virtual void copyHistory( KonqFrameBase *other ) = 0;
  132. virtual void printFrameInfo( const TQString& spaces );
  133. virtual void reparentFrame( TQWidget* parent,
  134. const TQPoint & p, bool showIt=FALSE ) = 0;
  135. virtual KonqFrameContainerBase* parentContainer() { return m_pParentContainer; }
  136. virtual void setParentContainer(KonqFrameContainerBase* parent) { m_pParentContainer = parent; }
  137. virtual void setTitle( const TQString &title , TQWidget* sender) = 0;
  138. virtual void setTabIcon( const KURL &url, TQWidget* sender ) = 0;
  139. virtual TQWidget* widget() = 0;
  140. virtual void listViews( ChildViewList *viewList ) = 0;
  141. virtual TQCString frameType() = 0;
  142. virtual void activateChild() = 0;
  143. virtual KonqView* activeChildView() = 0;
  144. protected:
  145. KonqFrameBase() {}
  146. KonqFrameContainerBase* m_pParentContainer;
  147. };
  148. /**
  149. * The KonqFrame is the actual container for the views. It takes care of the
  150. * widget handling i.e. it attaches/detaches the view widget and activates
  151. * them on click at the statusbar.
  152. *
  153. * KonqFrame makes the difference between built-in views and remote ones.
  154. * We create a layout in it (with the KonqFrameStatusBar as top item in the layout)
  155. * For builtin views we have the view as direct child widget of the layout
  156. * For remote views we have an OPFrame, having the view attached, as child
  157. * widget of the layout
  158. */
  159. class KonqFrame : public TQWidget, public KonqFrameBase
  160. {
  161. Q_OBJECT
  162. public:
  163. KonqFrame( TQWidget* parent, KonqFrameContainerBase *parentContainer = 0L,
  164. const char *name = 0L );
  165. virtual ~KonqFrame();
  166. /**
  167. * Attach a view to the KonqFrame.
  168. * @param viewFactory the view to attach (instead of the current one, if any)
  169. */
  170. KParts::ReadOnlyPart *attach( const KonqViewFactory &viewFactory );
  171. /**
  172. * Filters the CTRL+Tab event from the views and emits ctrlTabPressed to
  173. make KonqMainWindow switch to the next view
  174. */
  175. virtual bool eventFilter(TQObject*obj,TQEvent *ev);
  176. /**
  177. * Inserts the part's widget and the statusbar into the layout
  178. */
  179. void attachInternal();
  180. /**
  181. * Inserts a widget at the top of the part's widget, in the layout
  182. * (used for the find functionality)
  183. */
  184. void insertTopWidget( TQWidget * widget );
  185. /**
  186. * Returns the part that is currently connected to the Frame.
  187. */
  188. KParts::ReadOnlyPart *part() { return m_pPart; }
  189. /**
  190. * Returns the view that is currently connected to the Frame.
  191. */
  192. KonqView* childView()const { return m_pView; }
  193. bool isActivePart();
  194. void setView( KonqView* child );
  195. virtual void listViews( ChildViewList *viewList );
  196. virtual void saveConfig( TDEConfig* config, const TQString &prefix, bool saveURLs, KonqFrameBase* docContainer, int id = 0, int depth = 0 );
  197. virtual void copyHistory( KonqFrameBase *other );
  198. virtual void printFrameInfo( const TQString& spaces );
  199. virtual void setTitle( const TQString &title, TQWidget* sender );
  200. virtual void setTabIcon( const KURL &url, TQWidget* sender );
  201. virtual void reparentFrame(TQWidget * parent,
  202. const TQPoint & p, bool showIt=FALSE );
  203. //virtual KonqFrameContainerBase* parentContainer();
  204. virtual TQWidget* widget() { return this; }
  205. virtual TQCString frameType() { return TQCString("View"); }
  206. TQVBoxLayout *layout()const { return m_pLayout; }
  207. KonqFrameStatusBar *statusbar() const { return m_pStatusBar; }
  208. virtual void activateChild();
  209. KonqView* activeChildView() { return m_pView; }
  210. TQString title() const { return m_title; }
  211. public slots:
  212. /**
  213. * Is called when the frame statusbar has been clicked
  214. */
  215. void slotStatusBarClicked();
  216. void slotLinkedViewClicked( bool mode );
  217. /**
  218. * Is called when 'Remove View' is called from the popup menu
  219. */
  220. void slotRemoveView();
  221. protected:
  222. virtual void paintEvent( TQPaintEvent* );
  223. TQVBoxLayout *m_pLayout;
  224. TQGuardedPtr<KonqView> m_pView;
  225. TQGuardedPtr<KParts::ReadOnlyPart> m_pPart;
  226. KonqViewManager* m_pViewManager;
  227. KSeparator *m_separator;
  228. KonqFrameStatusBar* m_pStatusBar;
  229. TQString m_title;
  230. };
  231. class KonqFrameContainerBase : public KonqFrameBase
  232. {
  233. public:
  234. virtual ~KonqFrameContainerBase() {}
  235. /**
  236. * Call this after inserting a new frame into the splitter.
  237. */
  238. virtual void insertChildFrame( KonqFrameBase * frame, int index = -1 ) = 0;
  239. /**
  240. * Call this before deleting one of our children.
  241. */
  242. virtual void removeChildFrame( KonqFrameBase * frame ) = 0;
  243. //inherited
  244. virtual void printFrameInfo( const TQString& spaces );
  245. virtual TQCString frameType() { return TQCString("ContainerBase"); }
  246. virtual void reparentFrame(TQWidget * parent,
  247. const TQPoint & p, bool showIt=FALSE ) = 0;
  248. virtual KonqFrameBase* activeChild() { return m_pActiveChild; }
  249. virtual void setActiveChild( KonqFrameBase* activeChild ) { m_pActiveChild = activeChild;
  250. m_pParentContainer->setActiveChild( this ); }
  251. virtual void activateChild() { if (m_pActiveChild) m_pActiveChild->activateChild(); }
  252. virtual KonqView* activeChildView() { if (m_pActiveChild) return m_pActiveChild->activeChildView();
  253. else return 0L; }
  254. protected:
  255. KonqFrameContainerBase() {}
  256. KonqFrameBase* m_pActiveChild;
  257. };
  258. /**
  259. * With KonqFrameContainers and @refKonqFrames we can create a flexible
  260. * storage structure for the views. The top most element is a
  261. * KonqFrameContainer. It's a direct child of the MainView. We can then
  262. * build up a binary tree of containers. KonqFrameContainers are the nodes.
  263. * That means that they always have two childs. Which are either again
  264. * KonqFrameContainers or, as leaves, KonqFrames.
  265. */
  266. class KonqFrameContainer : public TQSplitter, public KonqFrameContainerBase
  267. {
  268. Q_OBJECT
  269. friend class KonqFrame; //for emitting ctrlTabPressed() only, aleXXX
  270. public:
  271. KonqFrameContainer( Orientation o,
  272. TQWidget* parent,
  273. KonqFrameContainerBase* parentContainer,
  274. const char * name = 0);
  275. virtual ~KonqFrameContainer();
  276. virtual void listViews( ChildViewList *viewList );
  277. virtual void saveConfig( TDEConfig* config, const TQString &prefix, bool saveURLs, KonqFrameBase* docContainer, int id = 0, int depth = 0 );
  278. virtual void copyHistory( KonqFrameBase *other );
  279. KonqFrameBase* firstChild() { return m_pFirstChild; }
  280. KonqFrameBase* secondChild() { return m_pSecondChild; }
  281. KonqFrameBase* otherChild( KonqFrameBase* child );
  282. virtual void printFrameInfo( const TQString& spaces );
  283. void swapChildren();
  284. virtual void setTitle( const TQString &title, TQWidget* sender );
  285. virtual void setTabIcon( const KURL &url, TQWidget* sender );
  286. virtual TQWidget* widget() { return this; }
  287. virtual TQCString frameType() { return TQCString("Container"); }
  288. /**
  289. * Call this after inserting a new frame into the splitter.
  290. */
  291. void insertChildFrame( KonqFrameBase * frame, int index = -1 );
  292. /**
  293. * Call this before deleting one of our children.
  294. */
  295. void removeChildFrame( KonqFrameBase * frame );
  296. //inherited
  297. virtual void reparentFrame(TQWidget * parent,
  298. const TQPoint & p, bool showIt=FALSE );
  299. //make this one public
  300. int idAfter( TQWidget* w ){ return TQSplitter::idAfter( w ); }
  301. void setAboutToBeDeleted() { m_bAboutToBeDeleted = true; }
  302. //inherited
  303. virtual void childEvent( TQChildEvent * );
  304. signals:
  305. void ctrlTabPressed();
  306. void setRubberbandCalled();
  307. protected:
  308. virtual void setRubberband( int );
  309. KonqFrameBase* m_pFirstChild;
  310. KonqFrameBase* m_pSecondChild;
  311. bool m_bAboutToBeDeleted;
  312. };
  313. #endif