1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Dialog handler
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
32 #if defined(__WXMSW__) && !defined(__GNUWIN32__)
35 #include <strstream.h>
43 IMPLEMENT_CLASS(wxResourceEditorDialogHandler
, wxEvtHandler
)
44 IMPLEMENT_CLASS(wxResourceEditorControlHandler
, wxEvtHandler
)
46 BEGIN_EVENT_TABLE(wxResourceEditorDialogHandler
, wxEvtHandler
)
47 EVT_PAINT(wxResourceEditorDialogHandler::OnPaint
)
48 EVT_MOUSE_EVENTS(wxResourceEditorDialogHandler::OnMouseEvent
)
51 BEGIN_EVENT_TABLE(wxResourceEditorControlHandler
, wxEvtHandler
)
52 EVT_MOUSE_EVENTS(wxResourceEditorControlHandler::OnMouseEvent
)
56 * Dialog box event handler
59 wxResourceEditorDialogHandler::wxResourceEditorDialogHandler(wxPanel
*dialog
, wxItemResource
*resource
,
60 wxEvtHandler
*oldHandler
, wxResourceManager
*manager
)
62 handlerDialog
= dialog
;
63 handlerResource
= resource
;
64 handlerOldHandler
= oldHandler
;
65 resourceManager
= manager
;
67 dragMode
= wxDRAG_MODE_NONE
;
68 dragType
= wxDRAG_TYPE_NONE
;
75 checkTolerance
= TRUE
;
76 m_mouseCaptured
= FALSE
;
80 wxResourceEditorDialogHandler::~wxResourceEditorDialogHandler(void)
84 void wxResourceEditorDialogHandler::OnItemSelect(wxControl
*item
, bool select
)
87 resourceManager
->AddSelection(item
);
89 resourceManager
->RemoveSelection(item
);
92 void wxResourceEditorDialogHandler::OnPaint(wxPaintEvent
& WXUNUSED(event
))
94 wxPaintDC
dc(handlerDialog
);
96 PaintSelectionHandles(dc
);
99 // Add event handlers for all children
100 void wxResourceEditorDialogHandler::AddChildHandlers(void)
102 wxNode
*node
= handlerDialog
->GetChildren()->First();
105 wxControl
*child
= (wxControl
*)node
->Data();
106 wxEvtHandler
*childHandler
= child
->GetEventHandler();
107 if ( child
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
== child
)
108 child
->PushEventHandler(new wxResourceEditorControlHandler(child
, childHandler
));
113 void wxResourceEditorDialogHandler::OnLeftClick(int x
, int y
, int keys
)
115 if (keys
& wxKEY_CTRL
)
117 wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog
);
121 // Deselect all items if click on panel
122 if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() == RESED_POINTER
)
124 int needsRefresh
= 0;
125 wxNode
*node
= handlerDialog
->GetChildren()->First();
128 wxControl
*item
= (wxControl
*)node
->Data();
129 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
130 if (item
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
->IsSelected())
133 OnItemSelect(item
, FALSE
);
134 childHandler
->SelectItem(FALSE
);
138 if (needsRefresh
> 0)
140 wxClientDC
dc(handlerDialog
);
142 handlerDialog
->Refresh();
147 wxResourceManager
* manager
= resourceManager
;
149 switch (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection())
152 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxButton", x
, y
);
154 case RESED_BMPBUTTON
:
155 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxBitmapButton", x
, y
, TRUE
);
157 case RESED_STATICTEXT
:
158 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxStaticText", x
, y
);
160 case RESED_STATICBMP
:
161 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxStaticBitmap", x
, y
, TRUE
);
163 case RESED_TEXTCTRL_SINGLE
:
164 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxTextCtrl (single-line)", x
, y
);
166 case RESED_TEXTCTRL_MULTIPLE
:
167 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxTextCtrl (multi-line)", x
, y
);
170 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxChoice", x
, y
);
173 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxComboBox", x
, y
);
176 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxCheckBox", x
, y
);
179 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxRadioBox", x
, y
);
181 case RESED_RADIOBUTTON
:
182 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxRadioButton", x
, y
);
185 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxListBox", x
, y
);
188 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxSlider", x
, y
);
191 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxGauge", x
, y
);
193 case RESED_STATICBOX
:
194 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxStaticBox", x
, y
);
196 case RESED_SCROLLBAR
:
197 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxScrollBar", x
, y
);
203 // Now switch pointer on.
204 if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() != RESED_POINTER
)
206 wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->SetItemState(RESED_POINTER
, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
210 void wxResourceEditorDialogHandler::OnRightClick(int x
, int y
, int WXUNUSED(keys
))
212 wxMenu
*menu
= resourceManager
->GetPopupMenu();
213 menu
->SetClientData((char *)handlerDialog
);
214 handlerDialog
->PopupMenu(menu
, x
, y
);
217 void wxResourceEditorDialogHandler::OnItemLeftClick(wxControl
*item
, int x
, int y
, int keys
)
219 if (keys
& wxKEY_CTRL
)
221 wxResourceManager::GetCurrentResourceManager()->EditWindow(item
);
226 // If this is a wxStaticBox and the pointer isn't an arrow, chances
227 // are that we really meant to place an item on the panel.
229 if ((item->GetClassInfo() == CLASSINFO(wxStaticBox)) && resourceManager->GetEditorPalette()->currentlySelected != PALETTE_ARROW)
231 OnLeftClick(x, y, keys);
236 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
238 if (childHandler
->IsSelected())
240 childHandler
->SelectItem(FALSE
);
241 OnItemSelect(item
, FALSE
);
243 wxClientDC
dc(handlerDialog
);
245 handlerDialog
->Refresh();
249 childHandler
->SelectItem(TRUE
);
250 OnItemSelect(item
, TRUE
);
252 // Deselect other items if shift is not pressed
253 int needsRefresh
= 0;
254 if (!(keys
& wxKEY_SHIFT
))
256 wxNode
*node
= item
->GetParent()->GetChildren()->First();
259 wxControl
*child
= (wxControl
*)node
->Data();
260 wxResourceEditorControlHandler
*childHandler2
= (wxResourceEditorControlHandler
*)child
->GetEventHandler();
261 if (child
->IsKindOf(CLASSINFO(wxControl
)) && childHandler2
->IsSelected() && child
!= item
)
263 childHandler2
->SelectItem(FALSE
);
264 OnItemSelect(child
, FALSE
);
271 wxClientDC
dc(handlerDialog
);
272 childHandler
->DrawSelectionHandles(dc
);
274 if (needsRefresh
> 0)
277 handlerDialog
->Refresh();
282 void wxResourceEditorDialogHandler::OnItemRightClick(wxControl
*item
, int x
, int y
, int WXUNUSED(keys
))
285 if (keys & wxKEY_CTRL)
287 wxDebugMsg("Item %s, selected = %d\n", item->GetName(), item->IsSelected());
292 wxMenu
*menu
= resourceManager
->GetPopupMenu();
293 menu
->SetClientData((char *)item
);
294 handlerDialog
->PopupMenu(menu
, x
, y
);
297 // An event outside any items: may be a drag event.
298 void wxResourceEditorDialogHandler::OnMouseEvent(wxMouseEvent
& event
)
300 if (GetEvtHandlerEnabled())
302 // If we're dragging an item or selection handle,
303 // continue dragging.
304 if (dragMode
!= wxDRAG_MODE_NONE
)
306 ProcessItemEvent(dragItem
, event
, dragType
);
311 event
.Position(&x
, &y
);
313 // Find which selection handle we're on, if any
314 wxNode
*node
= handlerDialog
->GetChildren()->First();
317 wxWindow
*win
= (wxWindow
*)node
->Data();
318 if (win
->IsKindOf(CLASSINFO(wxControl
)))
320 wxControl
*item
= (wxControl
*)win
;
321 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
322 int selHandle
= childHandler
->SelectionHandleHitTest(x
, y
);
325 ProcessItemEvent(item
, event
, selHandle
);
332 // We're not on an item or selection handle.
333 // so... check for a left or right click event
334 // to send to the application.
336 if (event
.ShiftDown()) keys
= keys
| wxKEY_SHIFT
;
337 if (event
.ControlDown()) keys
= keys
| wxKEY_CTRL
;
343 handlerDialog
->ReleaseMouse();
344 m_mouseCaptured
= FALSE
;
347 OnLeftClick(x
, y
, keys
);
349 else if (event
.RightUp())
353 handlerDialog
->ReleaseMouse();
354 m_mouseCaptured
= FALSE
;
357 OnRightClick(x
, y
, keys
);
364 void wxResourceEditorDialogHandler::OnItemEvent(wxControl
*item
, wxMouseEvent
& event
)
366 if (!GetEvtHandlerEnabled())
369 // Not a selection handle event: just a normal item event.
370 // Transform to panel coordinates.
372 item
->GetPosition(&x
, &y
);
374 event
.m_x
= event
.m_x
+ x
;
375 event
.m_y
= event
.m_y
+ y
;
376 ProcessItemEvent(item
, event
, dragType
);
379 void wxResourceEditorDialogHandler::ProcessItemEvent(wxControl
*item
, wxMouseEvent
& event
, int selectionHandle
)
381 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
384 event
.Position(&x
, &y
);
386 if (event
.ShiftDown()) keys
= keys
| wxKEY_SHIFT
;
387 if (event
.ControlDown()) keys
= keys
| wxKEY_CTRL
;
388 bool dragging
= event
.Dragging();
391 int dx
= (int)abs((x
- firstDragX
));
392 int dy
= (int)abs((y
- firstDragY
));
393 if (checkTolerance
&& (dx
<= dragTolerance
) && (dy
<= dragTolerance
))
398 // If we've ignored the tolerance once, then ALWAYS ignore
399 // tolerance in this drag, even if we come back within
400 // the tolerance range.
402 checkTolerance
= FALSE
;
405 if (event
.LeftDClick())
409 handlerDialog
->ReleaseMouse();
410 m_mouseCaptured
= FALSE
;
413 wxResourceManager::GetCurrentResourceManager()->EditWindow(item
);
415 else if (dragging
&& dragItem
&& dragMode
== wxDRAG_MODE_START_LEFT
)
417 dragMode
= wxDRAG_MODE_CONTINUE_LEFT
;
418 wxClientDC
dc(handlerDialog
);
419 childHandler
->OnDragBegin(x
, y
, keys
, dc
, selectionHandle
);
420 oldDragX
= x
; oldDragY
= y
;
421 if (!m_mouseCaptured
)
423 handlerDialog
->CaptureMouse();
424 m_mouseCaptured
= TRUE
;
427 else if (dragging
&& dragItem
&& dragMode
== wxDRAG_MODE_CONTINUE_LEFT
)
429 wxClientDC
dc(handlerDialog
);
430 childHandler
->OnDragContinue(FALSE
, oldDragX
, oldDragY
, keys
, dc
, selectionHandle
);
431 childHandler
->OnDragContinue(TRUE
, x
, y
, keys
, dc
, selectionHandle
);
432 oldDragX
= x
; oldDragY
= y
;
434 else if (event
.LeftUp() && dragItem
&& dragMode
== wxDRAG_MODE_CONTINUE_LEFT
)
436 wxClientDC
dc(handlerDialog
);
437 dragMode
= wxDRAG_MODE_NONE
;
438 checkTolerance
= TRUE
;
440 childHandler
->OnDragContinue(FALSE
, oldDragX
, oldDragY
, keys
, dc
, selectionHandle
);
441 childHandler
->OnDragEnd(x
, y
, keys
, dc
, selectionHandle
);
444 dragType
= wxDRAG_TYPE_NONE
;
448 handlerDialog
->ReleaseMouse();
449 m_mouseCaptured
= FALSE
;
452 else if (dragging
&& dragItem
&& dragMode
== wxDRAG_MODE_START_RIGHT
)
454 wxClientDC
dc(handlerDialog
);
455 dragMode
= wxDRAG_MODE_CONTINUE_RIGHT
;
456 childHandler
->OnDragBegin(x
, y
, keys
, dc
, selectionHandle
);
457 oldDragX
= x
; oldDragY
= y
;
459 if (!m_mouseCaptured
)
461 handlerDialog
->CaptureMouse();
462 m_mouseCaptured
= TRUE
;
465 else if (dragging
&& dragItem
&& dragMode
== wxDRAG_MODE_CONTINUE_RIGHT
)
467 oldDragX
= x
; oldDragY
= y
;
469 else if (event
.RightUp() && dragItem
&& dragMode
== wxDRAG_MODE_CONTINUE_RIGHT
)
471 dragMode
= wxDRAG_MODE_NONE
;
472 checkTolerance
= TRUE
;
474 dragType
= wxDRAG_TYPE_NONE
;
478 handlerDialog
->ReleaseMouse();
479 m_mouseCaptured
= FALSE
;
482 else if (event
.IsButton())
484 checkTolerance
= TRUE
;
486 if (event
.LeftDown())
489 dragMode
= wxDRAG_MODE_START_LEFT
;
492 dragType
= selectionHandle
;
494 if (!m_mouseCaptured
)
496 handlerDialog
->CaptureMouse();
497 m_mouseCaptured
= TRUE
;
500 else if (event
.RightDown())
503 dragMode
= wxDRAG_MODE_START_RIGHT
;
506 dragType
= selectionHandle
;
508 if (!m_mouseCaptured
)
510 handlerDialog
->CaptureMouse();
511 m_mouseCaptured
= TRUE
;
514 else if (event
.LeftUp())
517 childHandler
->OnLeftClick(x
, y
, keys
);
519 OnLeftClick(x
, y
, keys
);
521 dragItem
= NULL
; dragMode
= wxDRAG_MODE_NONE
; dragType
= wxDRAG_TYPE_NONE
;
525 handlerDialog
->ReleaseMouse();
526 m_mouseCaptured
= FALSE
;
529 else if (event
.RightUp())
532 childHandler
->OnRightClick(x
, y
, keys
);
534 OnRightClick(x
, y
, keys
);
536 dragItem
= NULL
; dragMode
= wxDRAG_MODE_NONE
; dragType
= wxDRAG_TYPE_NONE
;
540 handlerDialog
->ReleaseMouse();
541 m_mouseCaptured
= FALSE
;
547 // Calls DrawSelectionHandles for all items if
549 void wxResourceEditorDialogHandler::PaintSelectionHandles(wxDC
& dc
)
551 if (!GetEvtHandlerEnabled())
556 wxNode
*node
= handlerDialog
->GetChildren()->First();
559 wxWindow
*win
= (wxWindow
*)node
->Data();
560 if (win
->IsKindOf(CLASSINFO(wxControl
)))
562 wxControl
*item
= (wxControl
*)win
;
563 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
565 // Don't draw handles for an item that's being moved: it'll
567 if (childHandler
->IsSelected() && (item
!= dragItem
))
568 childHandler
->DrawSelectionHandles(dc
);
576 * Event handler for controls
579 int wxResourceEditorControlHandler::dragOffsetX
= 0;
580 int wxResourceEditorControlHandler::dragOffsetY
= 0;
582 wxResourceEditorControlHandler::wxResourceEditorControlHandler(wxControl
*control
,
583 wxEvtHandler
*oldHandler
)
585 handlerControl
= control
;
586 handlerOldHandler
= oldHandler
;
596 wxResourceEditorControlHandler::~wxResourceEditorControlHandler(void)
601 * Manipulation and drawing of items in Edit Mode
604 void wxResourceEditorControlHandler::SelectItem(bool select
)
609 // Returns TRUE or FALSE
610 bool wxResourceEditorControlHandler::HitTest(int x
, int y
)
612 int xpos
, ypos
, width
, height
;
613 handlerControl
->GetPosition(&xpos
, &ypos
);
614 handlerControl
->GetSize(&width
, &height
);
616 return ((x
>= xpos
) && (x
<= (xpos
+ width
)) && (y
>= ypos
) && (y
<= (ypos
+ height
)));
619 // Calculate position of the 8 handles
620 void wxResourceEditorControlHandler::CalcSelectionHandles(int *hx
, int *hy
)
622 int xpos
, ypos
, width
, height
;
623 handlerControl
->GetPosition(&xpos
, &ypos
);
624 handlerControl
->GetSize(&width
, &height
);
625 int middleX
= (xpos
+ (width
/2));
626 int middleY
= (ypos
+ (height
/2));
628 // Start from top middle, clockwise.
637 hx
[0] = (int)(middleX
- (handleSize
/2));
638 hy
[0] = ypos
- handleSize
- handleMargin
;
640 hx
[1] = xpos
+ width
+ handleMargin
;
641 hy
[1] = ypos
- handleSize
- handleMargin
;
643 hx
[2] = xpos
+ width
+ handleMargin
;
644 hy
[2] = (int)(middleY
- (handleSize
/2));
646 hx
[3] = xpos
+ width
+ handleMargin
;
647 hy
[3] = ypos
+ height
+ handleMargin
;
649 hx
[4] = (int)(middleX
- (handleSize
/2));
650 hy
[4] = ypos
+ height
+ handleMargin
;
652 hx
[5] = xpos
- handleSize
- handleMargin
;
653 hy
[5] = ypos
+ height
+ handleMargin
;
655 hx
[6] = xpos
- handleSize
- handleMargin
;
656 hy
[6] = (int)(middleY
- (handleSize
/2));
658 hx
[7] = xpos
- handleSize
- handleMargin
;
659 hy
[7] = ypos
- handleSize
- handleMargin
;
662 // Returns 0 (no hit), 1 - 8 for which selection handle
663 // (clockwise from top middle)
664 int wxResourceEditorControlHandler::SelectionHandleHitTest(int x
, int y
)
669 CalcSelectionHandles(hx
, hy
);
672 for (i
= 0; i
< 8; i
++)
674 if ((x
>= hx
[i
]) && (x
<= (hx
[i
] + handleSize
)) && (y
>= hy
[i
]) && (y
<= (hy
[i
] + handleSize
)))
680 void wxResourceEditorControlHandler::DrawSelectionHandles(wxDC
& dc
, bool WXUNUSED(erase
))
682 dc
.SetOptimization(FALSE
);
684 dc
.SetLogicalFunction(wxCOPY
);
685 dc
.SetPen(wxBLACK_PEN
);
686 dc
.SetBrush(wxBLACK_BRUSH
);
688 dc
.SetOptimization(TRUE
);
693 CalcSelectionHandles(hx
, hy
);
696 for (i
= 0; i
< 8; i
++)
698 dc
.DrawRectangle(hx
[i
], hy
[i
], handleSize
, handleSize
);
702 void wxResourceEditorControlHandler::DrawBoundingBox(wxDC
& dc
, int x
, int y
, int w
, int h
)
704 dc
.DrawRectangle(x
, y
, w
, h
);
707 // If selectionHandle is zero, not dragging the selection handle.
708 void wxResourceEditorControlHandler::OnDragBegin(int x
, int y
, int WXUNUSED(keys
), wxDC
& dc
, int selectionHandle
)
710 int xpos
, ypos
, width
, height
;
711 handlerControl
->GetPosition(&xpos
, &ypos
);
712 handlerControl
->GetSize(&width
, &height
);
716 // dc.DestroyClippingRegion();
718 wxPanel
*panel
= (wxPanel
*)handlerControl
->GetParent();
719 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
721 // Erase selection handles
722 // DrawSelectionHandles(dc, TRUE);
724 dc
.SetOptimization(FALSE
);
726 dc
.SetLogicalFunction(wxXOR
);
728 wxPen
pen(wxColour(0, 0, 0), 1, wxDOT
);
730 dc
.SetBrush(wxTRANSPARENT_BRUSH
);
732 dc
.SetOptimization(TRUE
);
734 if (selectionHandle
> 0)
738 DrawBoundingBox(dc
, xpos
, ypos
, width
, height
);
744 dragOffsetX
= (x
- xpos
);
745 dragOffsetY
= (y
- ypos
);
747 DrawBoundingBox(dc
, xpos
, ypos
, width
, height
);
749 // Also draw bounding boxes for other selected items
750 wxNode
*node
= panel
->GetChildren()->First();
753 wxWindow
*win
= (wxWindow
*)node
->Data();
754 if (win
->IsKindOf(CLASSINFO(wxControl
)))
756 wxControl
*item
= (wxControl
*)win
;
757 wxResourceEditorControlHandler
*handler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
758 if ((item
!= handlerControl
) && handler
->IsSelected())
761 item
->GetPosition(&x1
, &y1
);
762 item
->GetSize(&w1
, &h1
);
763 handler
->DrawBoundingBox(dc
, x1
, y1
, w1
, h1
);
772 void wxResourceEditorControlHandler::OnDragContinue(bool paintIt
, int x
, int y
, int WXUNUSED(keys
), wxDC
& dc
, int selectionHandle
)
774 wxPanel
*panel
= (wxPanel
*)handlerControl
->GetParent();
775 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
777 int xpos
, ypos
, width
, height
;
778 handlerControl
->GetPosition(&xpos
, &ypos
);
779 handlerControl
->GetSize(&width
, &height
);
781 if (selectionHandle
> 0)
791 int x1
, y1
, width1
, height1
;
793 switch (selectionHandle
)
799 height1
= (ypos
+ height
) - y
;
805 height1
= (y
- ypos
);
816 width1
= (xpos
+ width
) - x
;
823 height1
= (ypos
+ height
) - y
;
829 height1
= (y
- ypos
);
834 width1
= (xpos
+ width
) - x
;
840 width1
= (xpos
+ width
) - x
;
841 height1
= (ypos
+ height
) - y
;
846 dc
.SetLogicalFunction(wxXOR
);
847 wxPen
pen(wxColour(0, 0, 0), 1, wxDOT
);
849 dc
.SetBrush(wxTRANSPARENT_BRUSH
);
851 DrawBoundingBox(dc
, x1
, y1
, width1
, height1
);
858 dc
.SetLogicalFunction(wxXOR
);
859 wxPen
pen(wxColour(0, 0, 0), 1, wxDOT
);
861 dc
.SetBrush(wxTRANSPARENT_BRUSH
);
863 DrawBoundingBox(dc
, (int)(x
- dragOffsetX
), (int)(y
- dragOffsetY
), width
, height
);
865 // Also draw bounding boxes for other selected items
866 wxNode
*node
= panel
->GetChildren()->First();
869 wxWindow
*win
= (wxWindow
*)node
->Data();
870 if (win
->IsKindOf(CLASSINFO(wxControl
)))
872 wxControl
*item
= (wxControl
*)win
;
873 wxResourceEditorControlHandler
*handler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
874 if ((item
!= handlerControl
) && handler
->IsSelected())
877 item
->GetPosition(&x1
, &y1
);
878 item
->GetSize(&w1
, &h1
);
879 int x2
= (int)(x1
+ (x
- dragOffsetX
) - xpos
);
880 int y2
= (int)(y1
+ (y
- dragOffsetY
) - ypos
);
881 handler
->DrawBoundingBox(dc
, x2
, y2
, w1
, h1
);
890 void wxResourceEditorControlHandler::OnDragEnd(int x
, int y
, int WXUNUSED(keys
), wxDC
& dc
, int selectionHandle
)
892 wxPanel
*panel
= (wxPanel
*)handlerControl
->GetParent();
893 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
897 int xpos
, ypos
, width
, height
;
898 handlerControl
->GetPosition(&xpos
, &ypos
);
899 handlerControl
->GetSize(&width
, &height
);
901 if (selectionHandle
> 0)
903 int x1
, y1
, width1
, height1
;
905 switch (selectionHandle
)
911 height1
= (ypos
+ height
) - y
;
917 height1
= (y
- ypos
);
928 width1
= (xpos
+ width
) - x
;
935 height1
= (ypos
+ height
) - y
;
941 height1
= (y
- ypos
);
946 width1
= (xpos
+ width
) - x
;
952 width1
= (xpos
+ width
) - x
;
953 height1
= (ypos
+ height
) - y
;
956 handlerControl
->SetSize(x1
, y1
, width1
, height1
);
960 handlerControl
->Move((int)(x
- dragOffsetX
), (int)(y
- dragOffsetY
));
961 OldOnMove((int)(x
- dragOffsetX
), (int)(y
- dragOffsetY
));
963 // Also move other selected items
964 wxNode
*node
= panel
->GetChildren()->First();
967 wxWindow
*win
= (wxWindow
*)node
->Data();
968 if (win
->IsKindOf(CLASSINFO(wxControl
)))
970 wxControl
*item
= (wxControl
*)win
;
971 wxResourceEditorControlHandler
*handler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
972 if ((item
!= handlerControl
) && handler
->IsSelected())
975 item
->GetPosition(&x1
, &y1
);
976 int x2
= (int)(x1
+ (x
- dragOffsetX
) - xpos
);
977 int y2
= (int)(y1
+ (y
- dragOffsetY
) - ypos
);
979 ((wxResourceEditorControlHandler
*)item
->GetEventHandler())->OldOnMove(x2
, y2
);
980 ((wxResourceEditorControlHandler
*)item
->GetEventHandler())->DrawSelectionHandles(dc
);
986 dc
.SetOptimization(FALSE
);
988 dc
.SetLogicalFunction(wxCOPY
);
989 dc
.SetPen(wxBLACK_PEN
);
990 dc
.SetBrush(wxBLACK_BRUSH
);
992 dc
.SetOptimization(TRUE
);
994 // Force it to repaint the selection handles (if any)
995 // since the panel thinks we're still within a drag and
996 // won't paint the handles.
998 DrawSelectionHandles(dc
);
1005 // These functions call OnItemEvent, OnItemMove and OnItemSize
1007 void wxResourceEditorControlHandler::OnMouseEvent(wxMouseEvent
& event
)
1010 if ((event.m_eventType == wxEVENT_TYPE_LEFT_DCLICK) ||
1011 (event.m_eventType == wxEVENT_TYPE_RIGHT_DCLICK))
1014 wxWindow
*panel
= handlerControl
->GetParent();
1015 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
1017 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
1018 if ( !panelHandler
->GetEvtHandlerEnabled() )
1024 panelHandler
->OnItemEvent(handlerControl
, event
);
1027 void wxResourceEditorControlHandler::OldOnMove(int x
, int y
)
1029 wxWindow
*panel
= handlerControl
->GetParent();
1030 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
1033 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
1034 panelHandler
->OnItemMove(handlerControl
, x
, y
);
1037 void wxResourceEditorControlHandler::OldOnSize(int w
, int h
)
1039 wxWindow
*panel
= handlerControl
->GetParent();
1040 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
1043 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
1044 panelHandler
->OnItemSize(handlerControl
, w
, h
);
1047 void wxResourceEditorControlHandler::OnSelect(bool select
)
1049 wxWindow
*panel
= handlerControl
->GetParent();
1050 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
1053 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
1054 panelHandler
->OnItemSelect(handlerControl
, select
);
1057 void wxResourceEditorControlHandler::OnLeftClick(int x
, int y
, int keys
)
1059 wxWindow
*panel
= handlerControl
->GetParent();
1060 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
1063 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
1064 panelHandler
->OnItemLeftClick(handlerControl
, x
, y
, keys
);
1067 void wxResourceEditorControlHandler::OnRightClick(int x
, int y
, int keys
)
1069 wxWindow
*panel
= handlerControl
->GetParent();
1070 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
1073 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
1074 panelHandler
->OnItemRightClick(handlerControl
, x
, y
, keys
);