00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __containerarea_h__
00025 #define __containerarea_h__
00026
00027 #include <tqpixmap.h>
00028 #include <tqptrlist.h>
00029 #include <tqtimer.h>
00030
00031 #include <appletinfo.h>
00032
00033 #include "global.h"
00034 #include "panner.h"
00035 #include "container_base.h"
00036
00037 class KConfig;
00038 class DragIndicator;
00039 class PanelContainer;
00040 class KRootPixmap;
00041
00042 class AppletContainer;
00043 class ContainerAreaLayout;
00044 class AddAppletDialog;
00045
00046 class ContainerArea : public Panner
00047 {
00048 Q_OBJECT
00049
00050 public:
00051 ContainerArea( KConfig* config, TQWidget* parent, TQPopupMenu* opMenu, const char* name = 0 );
00052 ~ContainerArea();
00053
00054 void initialize(bool useDefaultConfig);
00055 int position() const;
00056 KPanelApplet::Direction popupDirection() const;
00057 bool isImmutable() const;
00058
00059 const TQWidget* addButton(const AppletInfo& info);
00060 const TQWidget* addKMenuButton();
00061 const TQWidget* addDesktopButton();
00062 const TQWidget* addWindowListButton();
00063 const TQWidget* addBookmarksButton();
00064 const TQWidget* addServiceButton(const TQString& desktopFile);
00065 const TQWidget* addURLButton(const TQString &url);
00066 const TQWidget* addBrowserButton();
00067 const TQWidget* addBrowserButton(const TQString &startDir,
00068 const TQString& icon = TQString("kdisknav"));
00069 const TQWidget* addServiceMenuButton(const TQString& relPath);
00070 const TQWidget* addNonKDEAppButton();
00071 const TQWidget* addNonKDEAppButton(const TQString &name,
00072 const TQString &description,
00073 const TQString &filePath,
00074 const TQString &icon,
00075 const TQString &cmdLine, bool inTerm);
00076 const TQWidget* addExtensionButton(const TQString& desktopFile);
00077 AppletContainer* addApplet(const AppletInfo& info,
00078 bool isImmutable = false,
00079 int insertionIndex = -1);
00080
00081 void configure();
00082
00083 bool inMoveOperation() const { return (_moveAC != 0); }
00084 int widthForHeight(int height) const;
00085 int heightForWidth(int width) const;
00086
00087 const TQPixmap* completeBackgroundPixmap() const;
00088
00089 BaseContainer::List containers(const TQString& type) const;
00090 int containerCount(const TQString& type) const;
00091 TQStringList listContainers() const;
00092 bool canAddContainers() const;
00093
00094 signals:
00095 void maintainFocus(bool);
00096
00097 public slots:
00098 void resizeContents(int w, int h);
00099 bool removeContainer(BaseContainer* a);
00100 bool removeContainer(int index);
00101 void removeContainers(BaseContainer::List containers);
00102 void takeContainer(BaseContainer* a);
00103 void setPosition(KPanelExtension::Position p);
00104 void setAlignment(KPanelExtension::Alignment a);
00105 void slotSaveContainerConfig();
00106 void repaint();
00107 void showAddAppletDialog();
00108 void addAppletDialogDone();
00109
00110 protected:
00111 TQString createUniqueId(const TQString& appletType) const;
00112 void completeContainerAddition(BaseContainer* container,
00113 int insertionIndex = -1);
00114
00115 bool eventFilter(TQObject*, TQEvent*);
00116 void mouseMoveEvent(TQMouseEvent*);
00117 void mouseReleaseEvent(TQMouseEvent *);
00118 void dragEnterEvent(TQDragEnterEvent*);
00119 void dragMoveEvent(TQDragMoveEvent*);
00120 void dragLeaveEvent(TQDragLeaveEvent*);
00121 void dropEvent(TQDropEvent*);
00122 void resizeEvent(TQResizeEvent*);
00123 void viewportResizeEvent(TQResizeEvent*);
00124
00125 void defaultContainerConfig();
00126 void loadContainers(const TQStringList& containers);
00127 void saveContainerConfig(bool layoutOnly = false);
00128
00129 TQRect availableSpaceFollowing(BaseContainer*);
00130 void moveDragIndicator(int pos);
00131
00132 void scrollTo(BaseContainer*);
00133
00134 void addContainer(BaseContainer* a,
00135 bool arrange = false,
00136 int insertionIndex = -1);
00137 void removeAllContainers();
00138
00139 protected slots:
00140 void autoScroll();
00141 void updateBackground(const TQPixmap&);
00142 void setBackground();
00143 void immutabilityChanged(bool);
00144 void updateContainersBackground();
00145 void startContainerMove(BaseContainer*);
00146 void resizeContents();
00147 void destroyCachedGeometry();
00148
00149 private:
00150 BaseContainer::List m_containers;
00151 BaseContainer* _moveAC;
00152 KPanelExtension::Position _pos;
00153 KConfig* _config;
00154 DragIndicator* _dragIndicator;
00155 BaseContainer* _dragMoveAC;
00156 QPoint _dragMoveOffset;
00157 TQPopupMenu* m_opMenu;
00158 KRootPixmap* _rootPixmap;
00159 bool _transparent;
00160 bool _useBgTheme;
00161 bool _bgSet;
00162 TQPixmap _completeBg;
00163 TQTimer _autoScrollTimer;
00164 bool m_canAddContainers;
00165 bool m_immutable;
00166 bool m_updateBackgroundsCalled;
00167
00168 TQWidget* m_contents;
00169 ContainerAreaLayout* m_layout;
00170 AddAppletDialog* m_addAppletDialog;
00171 TQMap< TQWidget*, TQRect > m_cachedGeometry;
00172 };
00173
00174
00175 class DragIndicator : public QWidget
00176 {
00177 Q_OBJECT
00178
00179 public:
00180 DragIndicator(TQWidget* parent = 0, const char* name = 0);
00181 ~DragIndicator() {}
00182
00183 TQSize preferredSize() const { return _preferredSize; }
00184 void setPreferredSize(const TQSize& size) { _preferredSize = size; }
00185
00186 protected:
00187 void paintEvent(TQPaintEvent*);
00188 void mousePressEvent(TQMouseEvent*);
00189
00190 private:
00191 TQSize _preferredSize;
00192 };
00193
00194 #endif
00195