00001
00012 #ifndef _IFM_DND_H_
00013 #define _IFM_DND_H_
00014
00015 #include "definterface.h"
00016
00017 #include <wx/frame.h>
00018 #include <wx/dcscreen.h>
00019
00020
00021 class wxIFMDefaultDockingPlugin;
00022 class wxIFMInitDragEvent;
00023 class wxIFMDragEvent;
00024 class wxIFMDockTargetButton;
00025 class wxIFMShowDropTargetsEvent;
00026
00027 DECLARE_EVENT_TYPE(wxEVT_IFM_INITDRAG, 0);
00028 DECLARE_EVENT_TYPE(wxEVT_IFM_BEGINDRAG, 0);
00029 DECLARE_EVENT_TYPE(wxEVT_IFM_ENDDRAG, 0);
00030 DECLARE_EVENT_TYPE(wxEVT_IFM_DRAGGING, 0);
00031
00032 DECLARE_EVENT_TYPE(wxEVT_IFM_SHOWDROPTARGETS, 0);
00033
00034 #define IFM_DOCK_TARGET_BUTTON_WIDTH 20
00035 #define IFM_DOCK_TARGET_BUTTON_SIZE wxSize(IFM_DOCK_TARGET_BUTTON_WIDTH, IFM_DOCK_TARGET_BUTTON_WIDTH)
00036
00037 #define IFM_DRAG_DISTANCE 4 // how many pixels the mouse must move before dragging starts (only if SystemMetrics doesn't know)
00038
00039
00040 WX_DEFINE_ARRAY(wxIFMDockTargetButton*, DockButtonArray);
00041
00042 enum dock_button_icons
00043 {
00044 IFM_DOCK_ICON_LEFT,
00045 IFM_DOCK_ICON_RIGHT,
00046 IFM_DOCK_ICON_TOP,
00047 IFM_DOCK_ICON_BOTTOM,
00048 IFM_DOCK_ICON_TAB
00049 };
00050
00051 enum dock_button_ids
00052 {
00053 IFM_DOCK_ID_LEFT,
00054 IFM_DOCK_ID_RIGHT,
00055 IFM_DOCK_ID_BOTTOM,
00056 IFM_DOCK_ID_TOP,
00057 IFM_DOCK_ID_TAB,
00058
00059 IFM_DOCK_ID_FRAME_LEFT,
00060 IFM_DOCK_ID_FRAME_RIGHT,
00061 IFM_DOCK_ID_FRAME_BOTTOM,
00062 IFM_DOCK_ID_FRAME_TOP
00063 };
00064
00068 class wxIFMDefaultDockingPlugin : public wxIFMExtensionPluginBase
00069 {
00070 private:
00071
00072 wxIFMDefaultInterfacePlugin *m_ip;
00073
00074 bool m_realtime, m_dragging, m_captured;
00075 wxPoint m_offset, m_oldPos, m_clickPos;
00076 int m_dragx, m_dragy;
00077
00078 wxRect m_hintRect;
00079
00080 DockButtonArray m_dockButtonArray;
00081 wxIFMDockTargetButton *m_oldBtn;
00082
00083 #if IFM_CANFLOAT
00084 wxIFMFloatingWindowBase *m_window;
00085 #endif
00086
00087 public:
00088
00089 wxIFMDefaultDockingPlugin();
00090
00091 bool Initialize(wxIFMInterfacePluginBase *plugin);
00092
00093 private:
00094
00095 void OnLeftDown(wxIFMMouseEvent &event);
00096 #if IFM_CANFLOAT
00097 void OnLeftDClick(wxIFMMouseEvent &event);
00098 #endif
00099 void OnLeftUp(wxIFMMouseEvent &event);
00100 void OnMouseMove(wxIFMMouseEvent &event);
00101 void OnKeyDown(wxIFMKeyEvent &event);
00102
00103 void OnDragInit(wxIFMInitDragEvent &event);
00104 void OnDragBegin(wxIFMDragEvent &event);
00105 void OnDragEnd(wxIFMDragEvent &event);
00106 void OnDrag(wxIFMDragEvent &event);
00107 void OnDock(wxIFMDockEvent &event);
00108 void OnShowDropTargets(wxIFMShowDropTargetsEvent &event);
00109
00110 void DrawHintRect(wxDC &dc, const wxRect &rect);
00111
00112 void CreateTargetButtons();
00113 void DestroyTargetButtons();
00114
00115 void ShowFrameDropButtons(bool show = true);
00116 void ShowComponentDropButtons(bool show = true);
00117
00122 wxIFMDockTargetButton *GetDockTargetButtonByPos(const wxPoint &pos);
00123
00131 #if IFM_CANFLOAT
00132 wxIFMComponent *GetFloatingComponentByPosExclusion(const wxPoint &pos, wxIFMFloatingWindowBase *exclude);
00133 #endif
00134
00135 DECLARE_EVENT_TABLE()
00136
00137 #if IFM_USE_WX_RTTI
00138 DECLARE_DYNAMIC_CLASS_NO_COPY(wxIFMDefaultDockingPlugin)
00139 #endif
00140 };
00141
00150 class wxIFMInitDragEvent : public wxIFMPluginEvent
00151 {
00152 private:
00153 wxIFMComponent *m_drag;
00154 wxPoint m_pos;
00155
00156 public:
00157 wxIFMInitDragEvent(wxIFMComponent *component, wxIFMComponent *drag, const wxPoint &pos)
00158 : wxIFMPluginEvent(wxEVT_IFM_INITDRAG, component),
00159 m_drag(drag),
00160 m_pos(pos)
00161 { }
00162
00163 wxIFMInitDragEvent(const wxIFMInitDragEvent &event)
00164 : wxIFMPluginEvent(event),
00165 m_drag(event.m_drag),
00166 m_pos(event.m_pos)
00167 { }
00168
00169 virtual wxEvent *Clone() const { return new wxIFMInitDragEvent(*this); }
00170
00174 wxIFMComponent *GetDraggedComponent() const { return m_drag; }
00175
00179 const wxPoint &GetPos() const { return m_pos; }
00180 };
00181
00185 class wxIFMDragEvent : public wxIFMPluginEvent
00186 {
00187 private:
00188
00189 wxPoint m_pos;
00190 bool m_canceled, m_realtime;
00191 bool m_altDown, m_ctrlDown, m_shiftDown;
00192
00193 public:
00194
00195 wxIFMDragEvent(wxEventType type, wxIFMComponent *component,
00196 wxPoint pos, bool alt, bool shift, bool control,
00197 bool realtime = false, bool canceled = false)
00198 : wxIFMPluginEvent(type, component),
00199 m_pos(pos),
00200 m_canceled(canceled),
00201 m_realtime(realtime),
00202 m_altDown(alt),
00203 m_ctrlDown(control),
00204 m_shiftDown(shift)
00205 { }
00206
00207 wxIFMDragEvent(const wxIFMDragEvent &event)
00208 : wxIFMPluginEvent(event),
00209 m_pos(event.m_pos),
00210 m_canceled(event.m_canceled),
00211 m_realtime(event.m_realtime),
00212 m_altDown(event.m_altDown),
00213 m_ctrlDown(event.m_ctrlDown),
00214 m_shiftDown(event.m_shiftDown)
00215 { }
00216
00217 virtual wxEvent *Clone() const { return new wxIFMDragEvent(*this); }
00218
00222 const wxPoint &GetPosition() const { return m_pos; }
00223
00228 bool WasCanceled() const { return m_canceled; }
00229
00234 bool RealtimeUpdates() const { return m_realtime; }
00235
00239 bool ControlDown() const { return m_ctrlDown; }
00240
00244 bool ShiftDown() const { return m_shiftDown; }
00245
00249 bool AltDown() const { return m_altDown; }
00250 };
00251
00257 class wxIFMDockEventEx : public wxIFMDockEvent
00258 {
00259 private:
00260 int m_where;
00261
00262 public:
00263 #if IFM_USE_WX_RTTI
00264
00265 wxIFMDockEventEx() : wxIFMDockEvent(0, 0, 0) { }
00266 #endif
00267
00268 wxIFMDockEventEx(wxIFMComponent *component, wxIFMComponent *destination,
00269 int index, int where)
00270 : wxIFMDockEvent(component, destination, index),
00271 m_where(where)
00272 { }
00273
00274 wxIFMDockEventEx(const wxIFMDockEventEx &event)
00275 : wxIFMDockEvent(event),
00276 m_where(event.m_where)
00277 { }
00278
00279 virtual wxEvent *Clone() const { return new wxIFMDockEventEx(*this); }
00280
00281 int GetWhere() const { return m_where; }
00282 void SetIndex(int i) { m_index = i; }
00283
00284 #if IFM_USE_WX_RTTI
00285 DECLARE_DYNAMIC_CLASS(wxIFMDockEventEx)
00286 #endif
00287 };
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00305 class wxIFMShowDropTargetsEvent : public wxIFMPluginEvent
00306 {
00307 private:
00308 wxPoint m_pos;
00309 wxIFMComponent *m_draggedComponent;
00310
00311 public:
00312 wxIFMShowDropTargetsEvent( wxIFMComponent *component,
00313 const wxPoint &pos, wxIFMComponent *dragged_component)
00314 : wxIFMPluginEvent(wxEVT_IFM_SHOWDROPTARGETS, component),
00315 m_pos(pos),
00316 m_draggedComponent(dragged_component)
00317 { }
00318
00319 wxIFMShowDropTargetsEvent(const wxIFMShowDropTargetsEvent &event)
00320 : wxIFMPluginEvent(event),
00321 m_pos(event.m_pos),
00322 m_draggedComponent(event.m_draggedComponent)
00323 { }
00324
00325 virtual wxEvent *Clone() const { return new wxIFMShowDropTargetsEvent(*this); }
00326
00330 const wxPoint &GetPosition() const { return m_pos; }
00331
00335 wxIFMComponent *GetDraggedComponent() const { return m_draggedComponent; }
00336 };
00337
00341
00342
00343 #if 0 //defined(__WXMAC__) || defined (__WXCOCOA)
00344 class wxIFMDockTargetButton : public wxWindow
00345 #else
00346 class wxIFMDockTargetButton : public wxFrame
00347 #endif
00348 {
00349 private:
00350
00351 bool m_hover;
00352 int m_id, m_icon;
00353
00354 wxIFMComponent *m_component;
00355
00356 public:
00357
00358 wxIFMDockTargetButton(wxWindow *parent, const wxPoint &pos, int id, int icon, wxIFMComponent *component = NULL);
00359
00364 void SetHover(bool hover = true);
00365
00366 int GetId() const { return m_id; }
00367
00368 void SetComponent(wxIFMComponent *component) { m_component = component; }
00369 wxIFMComponent *GetComponent() const { return m_component; }
00370
00371 private:
00372
00373 void OnEraseBackground(wxEraseEvent &event);
00374 void OnPaint(wxPaintEvent &event);
00375
00376 DECLARE_EVENT_TABLE()
00377 };
00378
00379 typedef void (wxEvtHandler::*wxIFMInitDragEventFunction)(wxIFMInitDragEvent&);
00380 typedef void (wxEvtHandler::*wxIFMDragEventFunction)(wxIFMDragEvent&);
00381 typedef void (wxEvtHandler::*wxIFMShowDropTargetsEventFunction)(wxIFMShowDropTargetsEvent&);
00382
00383 #define wxIFMInitDragEventFunctionHandler(func) \
00384 (wxObjectEventFunction)wxStaticCastEvent(wxIFMInitDragEventFunction, &func)
00385 #define wxIFMDragEventFunctionHandler(func) \
00386 (wxObjectEventFunction)wxStaticCastEvent(wxIFMDragEventFunction, &func)
00387 #define wxIFMShowDropTargetsEventFunctionHandler(func) \
00388 (wxObjectEventFunction)wxStaticCastEvent(wxIFMShowDropTargetsEventFunction, &func)
00389
00390 #define EVT_IFM_DRAG_INIT(func) wx__DECLARE_EVT0(wxEVT_IFM_INITDRAG, wxIFMInitDragEventFunctionHandler(func))
00391 #define EVT_IFM_DRAG_BEGIN(func) wx__DECLARE_EVT0(wxEVT_IFM_BEGINDRAG, wxIFMDragEventFunctionHandler(func))
00392 #define EVT_IFM_DRAG_END(func) wx__DECLARE_EVT0(wxEVT_IFM_ENDDRAG, wxIFMDragEventFunctionHandler(func))
00393 #define EVT_IFM_DRAG_DRAGGING(func) wx__DECLARE_EVT0(wxEVT_IFM_DRAGGING, wxIFMDragEventFunctionHandler(func))
00394 #define EVT_IFM_SHOWDROPTARGETS(func) wx__DECLARE_EVT0(wxEVT_IFM_SHOWDROPTARGETS, wxIFMShowDropTargetsEventFunctionHandler(func))
00395
00396 #endif