Plasma
plasma_view_host.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef GGADGET_PLASMA_VIEW_HOST_H__
00018 #define GGADGET_PLASMA_VIEW_HOST_H__
00019
00020 #include <set>
00021
00022 #include <QtGui/QGraphicsWidget>
00023
00024 #include <ggadget/view_interface.h>
00025 #include <ggadget/graphics_interface.h>
00026 #include <ggadget/view_host_interface.h>
00027 #include <ggadget/qt/qt_graphics.h>
00028 #include <ggadget/qt/qt_view_widget.h>
00029 #include "plasma_host.h"
00030
00031 namespace ggadget {
00032
00033 using namespace ggadget::qt;
00034
00035 inline bool isHorizontal(Plasma::Location loc) {
00036 return loc == Plasma::TopEdge || loc == Plasma::BottomEdge;
00037 }
00038
00039 inline bool isVertical(Plasma::Location loc) {
00040 return loc == Plasma::LeftEdge || loc == Plasma::RightEdge;
00041 }
00042
00043
00044 class PlasmaViewHost : public ViewHostInterface {
00045 public:
00046 PlasmaViewHost(GadgetInfo *info, ViewHostInterface::Type type, bool popout = false);
00047 virtual ~PlasmaViewHost();
00048
00049 virtual Type GetType() const;
00050 virtual void Destroy();
00051 virtual void SetView(ViewInterface *view);
00052 virtual ViewInterface *GetView() const;
00053 virtual GraphicsInterface *NewGraphics() const {
00054 return new QtGraphics(1.0);
00055 }
00056 virtual void *GetNativeWidget() const;
00057 virtual void ViewCoordToNativeWidgetCoord(
00058 double x, double y, double *widget_x, double *widget_y) const;
00059 virtual void NativeWidgetCoordToViewCoord(
00060 double x, double y, double *view_x, double *view_y) const;
00061 virtual void QueueDraw();
00062 virtual void QueueResize();
00063 virtual void EnableInputShapeMask(bool enable);
00064 virtual void SetResizable(ViewInterface::ResizableMode mode);
00065 virtual void SetCaption(const std::string &caption);
00066 virtual void SetShowCaptionAlways(bool always);
00067 virtual void SetCursor(ggadget::ViewInterface::CursorType cursor);
00068 virtual void ShowTooltip(const std::string &tooltip);
00069 virtual void ShowTooltipAtPosition(const std::string &tooltip,
00070 double x, double y);
00071 virtual bool ShowView(bool modal, int flags,
00072 Slot1<bool, int> *feedback_handler);
00073 virtual void CloseView();
00074 virtual bool ShowContextMenu(int button);
00075 virtual void BeginResizeDrag(int, ViewInterface::HitTest) {}
00076 virtual void BeginMoveDrag(int) {}
00077
00078 virtual void Alert(const ViewInterface *view, const char *message);
00079 virtual ggadget::ViewHostInterface::ConfirmResponse Confirm(const ViewInterface *view, const char *message, bool);
00080 virtual std::string Prompt(const ViewInterface *view,
00081 const char *message,
00082 const char *default_value);
00083 virtual int GetDebugMode() const;
00084
00085 GadgetInfo *getInfo();
00086
00087 private:
00088 class Private;
00089 Private *d;
00090 DISALLOW_EVIL_CONSTRUCTORS(PlasmaViewHost);
00091 };
00092
00093 }
00094
00095 #endif // GGADGET_PLASMA_VIEW_HOST_H__