00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _MENUAPPLET_H_
00026 #define _MENUAPPLET_H_
00027
00028 #include <assert.h>
00029
00030 #include <tqvaluelist.h>
00031 #include <tqevent.h>
00032 #include <qxembed.h>
00033
00034 #include <kpanelapplet.h>
00035 #include <kmanagerselection.h>
00036
00037 #include <dcopobject.h>
00038 #include <dcopclient.h>
00039
00040 #include <karrowbutton.h>
00041
00042 class KWinModule;
00043
00044 namespace KickerMenuApplet
00045 {
00046
00047 class MenuEmbed;
00048
00067 class Applet : public KPanelApplet, public DCOPObject
00068 {
00069 Q_OBJECT
00070 K_DCOP
00071
00072 k_dcop:
00073
00078 ASYNC configure();
00079
00080 public:
00081 Applet( const TQString& configFile, TQWidget *parent );
00082 virtual ~Applet();
00083 virtual int widthForHeight( int height ) const;
00084 virtual int heightForWidth( int width ) const;
00085
00089 void menuLost( MenuEmbed* embed );
00090 void updateMenuGeometry( MenuEmbed* embed );
00091 void setBackground();
00092
00093 protected:
00094
00095 virtual void paletteChange(const TQPalette& );
00096 virtual void positionChange( Position p );
00097 virtual void moveEvent(TQMoveEvent *);
00098
00099 private slots:
00100
00106 void windowAdded( WId w );
00107
00113 void activeWindowChanged( WId w );
00114
00120 void lostSelection();
00121
00125 void readSettings();
00126 void claimSelection();
00127
00128 private:
00129
00134 bool isDisabled() const;
00135
00136 WId tryTransientFor( WId w );
00137
00141 void activateMenu( MenuEmbed* embed );
00142
00146 static Atom makeSelectionAtom();
00147 void updateTopEdgeOffset();
00148 KWinModule* module;
00149
00153 TQValueList< MenuEmbed* > menus;
00154
00159 MenuEmbed* active_menu;
00160
00161 KSelectionOwner* selection;
00162
00166 KSelectionWatcher* selection_watcher;
00167
00172 bool desktop_menu;
00173 DCOPClient dcopclient;
00174
00178 int topEdgeOffset;
00179 };
00180
00186 class MenuEmbed
00187 : public QXEmbed
00188 {
00189 Q_OBJECT
00190
00191 public:
00192
00199 MenuEmbed( WId mainwindow, bool desktop,
00200 TQWidget* parent = NULL, const char* name = NULL );
00201
00202 void setBackground();
00203
00207 WId mainWindow() const;
00208
00211 bool isDesktopMenu() const;
00212 virtual void setMinimumSize( int w, int h );
00213 void setMinimumSize( const TQSize& s ) { setMinimumSize( s.width(), s.height()); }
00214
00215 protected:
00216
00221 virtual void windowChanged( WId w );
00222
00223 virtual bool x11Event( XEvent* ev );
00224
00225 private:
00226
00227 void sendSyntheticConfigureNotifyEvent();
00228 WId main_window;
00229
00233 bool desktop;
00234 };
00235
00236 inline
00237 bool Applet::isDisabled() const
00238 {
00239 assert( ( selection == NULL && selection_watcher != NULL )
00240 || ( selection != NULL && selection_watcher == NULL ));
00241 return selection == NULL;
00242 }
00243
00244 inline
00245 WId MenuEmbed::mainWindow() const
00246 {
00247 return main_window;
00248 }
00249
00250 inline
00251 bool MenuEmbed::isDesktopMenu() const
00252 {
00253 return desktop;
00254 }
00255
00256 }
00257
00258 #endif