2 Copyright 2007 Google Inc.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
17 #ifndef GGADGET_PLASMA_VIEW_HOST_H__
18 #define GGADGET_PLASMA_VIEW_HOST_H__
22 #include <QtGui/QGraphicsWidget>
24 #include <ggadget/view_interface.h>
25 #include <ggadget/graphics_interface.h>
26 #include <ggadget/view_host_interface.h>
27 #include <ggadget/qt/qt_graphics.h>
28 #include <ggadget/qt/qt_view_widget.h>
29 #include "plasma_host.h"
33 using namespace ggadget::qt
;
35 inline bool isHorizontal(Plasma::Location loc
) {
36 return loc
== Plasma::TopEdge
|| loc
== Plasma::BottomEdge
;
39 inline bool isVertical(Plasma::Location loc
) {
40 return loc
== Plasma::LeftEdge
|| loc
== Plasma::RightEdge
;
44 class PlasmaViewHost
: public ViewHostInterface
{
46 PlasmaViewHost(GadgetInfo
*info
, ViewHostInterface::Type type
, bool popout
= false);
47 virtual ~PlasmaViewHost();
49 virtual Type
GetType() const;
50 virtual void Destroy();
51 virtual void SetView(ViewInterface
*view
);
52 virtual ViewInterface
*GetView() const;
53 virtual GraphicsInterface
*NewGraphics() const {
54 return new QtGraphics(1.0);
56 virtual void *GetNativeWidget() const;
57 virtual void ViewCoordToNativeWidgetCoord(
58 double x
, double y
, double *widget_x
, double *widget_y
) const;
59 virtual void NativeWidgetCoordToViewCoord(
60 double x
, double y
, double *view_x
, double *view_y
) const;
61 virtual void QueueDraw();
62 virtual void QueueResize();
63 virtual void EnableInputShapeMask(bool enable
);
64 virtual void SetResizable(ViewInterface::ResizableMode mode
);
65 virtual void SetCaption(const std::string
&caption
);
66 virtual void SetShowCaptionAlways(bool always
);
67 virtual void SetCursor(ggadget::ViewInterface::CursorType cursor
);
68 virtual void ShowTooltip(const std::string
&tooltip
);
69 virtual void ShowTooltipAtPosition(const std::string
&tooltip
,
71 virtual bool ShowView(bool modal
, int flags
,
72 Slot1
<bool, int> *feedback_handler
);
73 virtual void CloseView();
74 virtual bool ShowContextMenu(int button
);
75 virtual void BeginResizeDrag(int, ViewInterface::HitTest
) {}
76 virtual void BeginMoveDrag(int) {}
78 virtual void Alert(const ViewInterface
*view
, const char *message
);
79 virtual ggadget::ViewHostInterface::ConfirmResponse
Confirm(const ViewInterface
*view
, const char *message
, bool);
80 virtual std::string
Prompt(const ViewInterface
*view
,
82 const char *default_value
);
83 virtual int GetDebugMode() const;
85 GadgetInfo
*getInfo();
90 DISALLOW_EVIL_CONSTRUCTORS(PlasmaViewHost
);
93 } // namespace ggadget
95 #endif // GGADGET_PLASMA_VIEW_HOST_H__