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(__WINDOWS__) && !defined(__GNUWIN32__)
35 #include <strstream.h>
43 extern void wxResourceEditWindow(wxWindow
*win
);
45 IMPLEMENT_CLASS(wxResourceEditorDialogHandler
, wxEvtHandler
)
46 IMPLEMENT_CLASS(wxResourceEditorControlHandler
, wxEvtHandler
)
48 BEGIN_EVENT_TABLE(wxResourceEditorDialogHandler
, wxEvtHandler
)
49 EVT_PAINT(wxResourceEditorDialogHandler::OnPaint
)
50 EVT_MOUSE_EVENTS(wxResourceEditorDialogHandler::OnMouseEvent
)
53 BEGIN_EVENT_TABLE(wxResourceEditorControlHandler
, wxEvtHandler
)
54 EVT_MOUSE_EVENTS(wxResourceEditorControlHandler::OnMouseEvent
)
58 * Dialog box event handler
61 wxResourceEditorDialogHandler::wxResourceEditorDialogHandler(wxPanel
*dialog
, wxItemResource
*resource
,
62 wxEvtHandler
*oldHandler
, wxResourceManager
*manager
)
64 handlerDialog
= dialog
;
65 handlerResource
= resource
;
66 handlerOldHandler
= oldHandler
;
67 resourceManager
= manager
;
69 dragMode
= wxDRAG_MODE_NONE
;
70 dragType
= wxDRAG_TYPE_NONE
;
77 checkTolerance
= TRUE
;
80 void wxResourceEditorDialogHandler::OnItemSelect(wxControl
*item
, bool select
)
83 resourceManager
->AddSelection(item
);
85 resourceManager
->RemoveSelection(item
);
88 bool wxResourceEditorDialogHandler::OnClose(void)
90 handlerDialog
->PopEventHandler();
92 // Now reset all child event handlers
93 wxNode
*node
= handlerDialog
->GetChildren()->First();
96 wxWindow
*child
= (wxWindow
*)node
->Data();
97 wxEvtHandler
*childHandler
= child
->GetEventHandler();
98 if ( child
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
!= child
)
100 child
->PopEventHandler();
106 // Save the information before deleting the dialog.
107 resourceManager
->InstantiateResourceFromWindow(handlerResource
, handlerDialog
, TRUE
);
109 resourceManager
->DisassociateResource(handlerDialog
, FALSE
);
111 handlerDialog
->Show(FALSE
);
116 void wxResourceEditorDialogHandler::OnPaint(wxPaintEvent
& event
)
118 wxPaintDC
dc(handlerDialog
);
120 PaintSelectionHandles(dc
);
123 // Add event handlers for all children
124 void wxResourceEditorDialogHandler::AddChildHandlers(void)
126 wxNode
*node
= handlerDialog
->GetChildren()->First();
129 wxControl
*child
= (wxControl
*)node
->Data();
130 wxEvtHandler
*childHandler
= child
->GetEventHandler();
131 if ( child
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
== child
)
132 child
->PushEventHandler(new wxResourceEditorControlHandler(child
, childHandler
));
137 void wxResourceEditorDialogHandler::OnLeftClick(int x
, int y
, int keys
)
139 if (keys
& wxKEY_CTRL
)
141 wxResourceEditWindow(handlerDialog
);
145 // Deselect all items if click on panel
146 if (resourceManager
->GetEditorPalette()->currentlySelected
== PALETTE_ARROW
)
148 int needsRefresh
= 0;
149 wxNode
*node
= handlerDialog
->GetChildren()->First();
152 wxControl
*item
= (wxControl
*)node
->Data();
153 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
154 if (item
->IsKindOf(CLASSINFO(wxControl
)) && childHandler
->IsSelected())
157 OnItemSelect(item
, FALSE
);
158 childHandler
->SelectItem(FALSE
);
162 if (needsRefresh
> 0)
164 wxClientDC
dc(handlerDialog
);
166 handlerDialog
->Refresh();
171 switch (resourceManager
->GetEditorPalette()->currentlySelected
)
175 case PALETTE_DIALOG_BOX
:
181 case PALETTE_TEXT_WINDOW
:
184 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxButton", x
, y
);
186 case PALETTE_BITMAP_BUTTON
:
187 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxButton", x
, y
, TRUE
);
189 case PALETTE_MESSAGE
:
190 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxMessage", x
, y
);
192 case PALETTE_BITMAP_MESSAGE
:
193 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxMessage", x
, y
, TRUE
);
196 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxText", x
, y
);
198 case PALETTE_MULTITEXT
:
199 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxMultiText", x
, y
);
202 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxChoice", x
, y
);
204 case PALETTE_CHECKBOX
:
205 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxCheckBox", x
, y
);
207 case PALETTE_RADIOBOX
:
208 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxRadioBox", x
, y
);
210 case PALETTE_LISTBOX
:
211 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxListBox", x
, y
);
214 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxSlider", x
, y
);
217 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxGauge", x
, y
);
219 case PALETTE_GROUPBOX
:
220 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxStaticBox", x
, y
);
222 case PALETTE_SCROLLBAR
:
223 resourceManager
->CreatePanelItem(handlerResource
, handlerDialog
, "wxScrollBar", x
, y
);
229 // Now switch pointer on.
230 if (resourceManager
->GetEditorPalette()->currentlySelected
!= PALETTE_ARROW
)
232 resourceManager
->GetEditorPalette()->ToggleTool(resourceManager
->GetEditorPalette()->currentlySelected
, FALSE
);
233 resourceManager
->GetEditorPalette()->ToggleTool(PALETTE_ARROW
, TRUE
);
234 resourceManager
->GetEditorPalette()->currentlySelected
= PALETTE_ARROW
;
238 void wxResourceEditorDialogHandler::OnRightClick(int x
, int y
, int keys
)
240 wxMenu
*menu
= resourceManager
->GetPopupMenu();
241 menu
->SetClientData((char *)handlerDialog
);
243 handlerDialog
->FakePopupMenu(menu
, x
, y
);
245 handlerDialog
->PopupMenu(menu
, x
, y
);
249 void wxResourceEditorDialogHandler::OnItemLeftClick(wxControl
*item
, int x
, int y
, int keys
)
251 if (keys
& wxKEY_CTRL
)
253 wxResourceEditWindow(item
);
257 // If this is a wxStaticBox and the pointer isn't an arrow, chances
258 // are that we really meant to place an item on the panel.
260 if ((item
->GetClassInfo() == CLASSINFO(wxStaticBox
)) && resourceManager
->GetEditorPalette()->currentlySelected
!= PALETTE_ARROW
)
262 OnLeftClick(x
, y
, keys
);
266 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
268 if (childHandler
->IsSelected())
270 childHandler
->SelectItem(FALSE
);
271 OnItemSelect(item
, FALSE
);
273 wxClientDC
dc(handlerDialog
);
275 handlerDialog
->Refresh();
279 childHandler
->SelectItem(TRUE
);
280 OnItemSelect(item
, TRUE
);
282 // Deselect other items if shift is not pressed
283 int needsRefresh
= 0;
284 if (!(keys
& wxKEY_SHIFT
))
286 wxNode
*node
= item
->GetParent()->GetChildren()->First();
289 wxControl
*child
= (wxControl
*)node
->Data();
290 wxResourceEditorControlHandler
*childHandler2
= (wxResourceEditorControlHandler
*)child
->GetEventHandler();
291 if (child
->IsKindOf(CLASSINFO(wxControl
)) && childHandler2
->IsSelected() && child
!= item
)
293 childHandler2
->SelectItem(FALSE
);
294 OnItemSelect(child
, FALSE
);
301 wxClientDC
dc(handlerDialog
);
302 childHandler
->DrawSelectionHandles(dc
);
304 if (needsRefresh
> 0)
307 handlerDialog
->Refresh();
312 void wxResourceEditorDialogHandler::OnItemRightClick(wxControl
*item
, int x
, int y
, int keys
)
315 if (keys & wxKEY_CTRL)
317 wxDebugMsg("Item %s, selected = %d\n", item->GetName(), item->IsSelected());
322 wxMenu
*menu
= resourceManager
->GetPopupMenu();
323 menu
->SetClientData((char *)item
);
325 handlerDialog
->FakePopupMenu(menu
, x
, y
);
327 handlerDialog
->PopupMenu(menu
, x
, y
);
331 // An event outside any items: may be a drag event.
332 void wxResourceEditorDialogHandler::OnMouseEvent(wxMouseEvent
& event
)
334 if (GetEvtHandlerEnabled())
336 // If we're dragging an item or selection handle,
337 // continue dragging.
338 if (dragMode
!= wxDRAG_MODE_NONE
)
340 ProcessItemEvent(dragItem
, event
, dragType
);
345 event
.Position(&x
, &y
);
347 // Find which selection handle we're on, if any
348 wxNode
*node
= handlerDialog
->GetChildren()->First();
351 wxWindow
*win
= (wxWindow
*)node
->Data();
352 if (win
->IsKindOf(CLASSINFO(wxControl
)))
354 wxControl
*item
= (wxControl
*)win
;
355 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
356 int selHandle
= childHandler
->SelectionHandleHitTest(x
, y
);
359 ProcessItemEvent(item
, event
, selHandle
);
366 // We're not on an item or selection handle.
367 // so... check for a left or right click event
368 // to send to the application.
370 if (event
.ShiftDown()) keys
= keys
| wxKEY_SHIFT
;
371 if (event
.ControlDown()) keys
= keys
| wxKEY_CTRL
;
374 OnLeftClick(x
, y
, keys
);
375 else if (event
.RightUp())
376 OnRightClick(x
, y
, keys
);
382 void wxResourceEditorDialogHandler::OnItemEvent(wxControl
*item
, wxMouseEvent
& event
)
384 if (!GetEvtHandlerEnabled())
387 // Not a selection handle event: just a normal item event.
388 // Transform to panel coordinates.
390 item
->GetPosition(&x
, &y
);
392 event
.m_x
= event
.m_x
+ x
;
393 event
.m_y
= event
.m_y
+ y
;
394 ProcessItemEvent(item
, event
, dragType
);
397 void wxResourceEditorDialogHandler::ProcessItemEvent(wxControl
*item
, wxMouseEvent
& event
, int selectionHandle
)
399 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
402 event
.Position(&x
, &y
);
404 if (event
.ShiftDown()) keys
= keys
| wxKEY_SHIFT
;
405 if (event
.ControlDown()) keys
= keys
| wxKEY_CTRL
;
406 bool dragging
= event
.Dragging();
409 int dx
= (int)abs((x
- firstDragX
));
410 int dy
= (int)abs((y
- firstDragY
));
411 if (checkTolerance
&& (dx
<= dragTolerance
) && (dy
<= dragTolerance
))
416 // If we've ignored the tolerance once, then ALWAYS ignore
417 // tolerance in this drag, even if we come back within
418 // the tolerance range.
420 checkTolerance
= FALSE
;
423 if (dragging
&& dragItem
&& dragMode
== wxDRAG_MODE_START_LEFT
)
425 dragMode
= wxDRAG_MODE_CONTINUE_LEFT
;
426 wxClientDC
dc(handlerDialog
);
427 childHandler
->OnDragBegin(x
, y
, keys
, dc
, selectionHandle
);
428 oldDragX
= x
; oldDragY
= y
;
430 else if (dragging
&& dragItem
&& dragMode
== wxDRAG_MODE_CONTINUE_LEFT
)
432 wxClientDC
dc(handlerDialog
);
433 childHandler
->OnDragContinue(FALSE
, oldDragX
, oldDragY
, keys
, dc
, selectionHandle
);
434 childHandler
->OnDragContinue(TRUE
, x
, y
, keys
, dc
, selectionHandle
);
435 oldDragX
= x
; oldDragY
= y
;
437 else if (event
.LeftUp() && dragItem
&& dragMode
== wxDRAG_MODE_CONTINUE_LEFT
)
439 wxClientDC
dc(handlerDialog
);
440 dragMode
= wxDRAG_MODE_NONE
;
441 checkTolerance
= TRUE
;
442 childHandler
->OnDragContinue(FALSE
, oldDragX
, oldDragY
, keys
, dc
, selectionHandle
);
443 childHandler
->OnDragEnd(x
, y
, keys
, dc
, selectionHandle
);
445 dragType
= wxDRAG_TYPE_NONE
;
447 else if (dragging
&& dragItem
&& dragMode
== wxDRAG_MODE_START_RIGHT
)
449 wxClientDC
dc(handlerDialog
);
450 dragMode
= wxDRAG_MODE_CONTINUE_RIGHT
;
451 childHandler
->OnDragBegin(x
, y
, keys
, dc
, selectionHandle
);
452 oldDragX
= x
; oldDragY
= y
;
454 else if (dragging
&& dragItem
&& dragMode
== wxDRAG_MODE_CONTINUE_RIGHT
)
456 oldDragX
= x
; oldDragY
= y
;
458 else if (event
.RightUp() && dragItem
&& dragMode
== wxDRAG_MODE_CONTINUE_RIGHT
)
460 dragMode
= wxDRAG_MODE_NONE
;
461 checkTolerance
= TRUE
;
463 dragType
= wxDRAG_TYPE_NONE
;
465 else if (event
.IsButton())
467 checkTolerance
= TRUE
;
469 if (event
.LeftDown())
472 dragMode
= wxDRAG_MODE_START_LEFT
;
475 dragType
= selectionHandle
;
477 else if (event
.RightDown())
480 dragMode
= wxDRAG_MODE_START_RIGHT
;
483 dragType
= selectionHandle
;
485 else if (event
.LeftUp())
488 childHandler
->OnLeftClick(x
, y
, keys
);
490 OnLeftClick(x
, y
, keys
);
492 dragItem
= NULL
; dragMode
= wxDRAG_MODE_NONE
; dragType
= wxDRAG_TYPE_NONE
;
494 else if (event
.RightUp())
497 childHandler
->OnRightClick(x
, y
, keys
);
499 OnRightClick(x
, y
, keys
);
501 dragItem
= NULL
; dragMode
= wxDRAG_MODE_NONE
; dragType
= wxDRAG_TYPE_NONE
;
506 // Calls DrawSelectionHandles for all items if
508 void wxResourceEditorDialogHandler::PaintSelectionHandles(wxDC
& dc
)
510 if (!GetEvtHandlerEnabled())
515 wxNode
*node
= handlerDialog
->GetChildren()->First();
518 wxWindow
*win
= (wxWindow
*)node
->Data();
519 if (win
->IsKindOf(CLASSINFO(wxControl
)))
521 wxControl
*item
= (wxControl
*)win
;
522 wxResourceEditorControlHandler
*childHandler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
524 // Don't draw handles for an item that's being moved: it'll
526 if (childHandler
->IsSelected() && (item
!= dragItem
))
527 childHandler
->DrawSelectionHandles(dc
);
535 * Event handler for controls
538 int wxResourceEditorControlHandler::dragOffsetX
= 0;
539 int wxResourceEditorControlHandler::dragOffsetY
= 0;
541 wxResourceEditorControlHandler::wxResourceEditorControlHandler(wxControl
*control
,
542 wxEvtHandler
*oldHandler
)
544 handlerControl
= control
;
545 handlerOldHandler
= oldHandler
;
555 * Manipulation and drawing of items in Edit Mode
558 void wxResourceEditorControlHandler::SelectItem(bool select
)
563 // Returns TRUE or FALSE
564 bool wxResourceEditorControlHandler::HitTest(int x
, int y
)
566 int xpos
, ypos
, width
, height
;
567 handlerControl
->GetPosition(&xpos
, &ypos
);
568 handlerControl
->GetSize(&width
, &height
);
570 return ((x
>= xpos
) && (x
<= (xpos
+ width
)) && (y
>= ypos
) && (y
<= (ypos
+ height
)));
573 // Calculate position of the 8 handles
574 void wxResourceEditorControlHandler::CalcSelectionHandles(int *hx
, int *hy
)
576 int xpos
, ypos
, width
, height
;
577 handlerControl
->GetPosition(&xpos
, &ypos
);
578 handlerControl
->GetSize(&width
, &height
);
579 int middleX
= (xpos
+ (width
/2));
580 int middleY
= (ypos
+ (height
/2));
582 // Start from top middle, clockwise.
591 hx
[0] = (int)(middleX
- (handleSize
/2));
592 hy
[0] = ypos
- handleSize
- handleMargin
;
594 hx
[1] = xpos
+ width
+ handleMargin
;
595 hy
[1] = ypos
- handleSize
- handleMargin
;
597 hx
[2] = xpos
+ width
+ handleMargin
;
598 hy
[2] = (int)(middleY
- (handleSize
/2));
600 hx
[3] = xpos
+ width
+ handleMargin
;
601 hy
[3] = ypos
+ height
+ handleMargin
;
603 hx
[4] = (int)(middleX
- (handleSize
/2));
604 hy
[4] = ypos
+ height
+ handleMargin
;
606 hx
[5] = xpos
- handleSize
- handleMargin
;
607 hy
[5] = ypos
+ height
+ handleMargin
;
609 hx
[6] = xpos
- handleSize
- handleMargin
;
610 hy
[6] = (int)(middleY
- (handleSize
/2));
612 hx
[7] = xpos
- handleSize
- handleMargin
;
613 hy
[7] = ypos
- handleSize
- handleMargin
;
616 // Returns 0 (no hit), 1 - 8 for which selection handle
617 // (clockwise from top middle)
618 int wxResourceEditorControlHandler::SelectionHandleHitTest(int x
, int y
)
623 CalcSelectionHandles(hx
, hy
);
626 for (i
= 0; i
< 8; i
++)
628 if ((x
>= hx
[i
]) && (x
<= (hx
[i
] + handleSize
)) && (y
>= hy
[i
]) && (y
<= (hy
[i
] + handleSize
)))
634 void wxResourceEditorControlHandler::DrawSelectionHandles(wxDC
& dc
, bool WXUNUSED(erase
))
636 dc
.SetOptimization(FALSE
);
638 dc
.SetLogicalFunction(wxCOPY
);
639 dc
.SetPen(wxBLACK_PEN
);
640 dc
.SetBrush(wxBLACK_BRUSH
);
642 dc
.SetOptimization(TRUE
);
647 CalcSelectionHandles(hx
, hy
);
650 for (i
= 0; i
< 8; i
++)
652 dc
.DrawRectangle(hx
[i
], hy
[i
], handleSize
, handleSize
);
656 void wxResourceEditorControlHandler::DrawBoundingBox(wxDC
& dc
, int x
, int y
, int w
, int h
)
658 dc
.DrawRectangle(x
, y
, w
, h
);
661 // If selectionHandle is zero, not dragging the selection handle.
662 void wxResourceEditorControlHandler::OnDragBegin(int x
, int y
, int WXUNUSED(keys
), wxDC
& dc
, int selectionHandle
)
664 int xpos
, ypos
, width
, height
;
665 handlerControl
->GetPosition(&xpos
, &ypos
);
666 handlerControl
->GetSize(&width
, &height
);
670 // dc.DestroyClippingRegion();
672 wxPanel
*panel
= (wxPanel
*)handlerControl
->GetParent();
673 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
675 // Erase selection handles
676 // DrawSelectionHandles(dc, TRUE);
678 dc
.SetOptimization(FALSE
);
680 dc
.SetLogicalFunction(wxXOR
);
682 dc
.SetPen(wxBLACK_DASHED_PEN
);
683 dc
.SetBrush(wxTRANSPARENT_BRUSH
);
685 dc
.SetOptimization(TRUE
);
687 if (selectionHandle
> 0)
691 DrawBoundingBox(dc
, xpos
, ypos
, width
, height
);
697 dragOffsetX
= (x
- xpos
);
698 dragOffsetY
= (y
- ypos
);
700 DrawBoundingBox(dc
, xpos
, ypos
, width
, height
);
702 // Also draw bounding boxes for other selected items
703 wxNode
*node
= panel
->GetChildren()->First();
706 wxWindow
*win
= (wxWindow
*)node
->Data();
707 if (win
->IsKindOf(CLASSINFO(wxControl
)))
709 wxControl
*item
= (wxControl
*)win
;
710 wxResourceEditorControlHandler
*handler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
711 if ((item
!= handlerControl
) && handler
->IsSelected())
714 item
->GetPosition(&x1
, &y1
);
715 item
->GetSize(&w1
, &h1
);
716 handler
->DrawBoundingBox(dc
, x1
, y1
, w1
, h1
);
725 void wxResourceEditorControlHandler::OnDragContinue(bool paintIt
, int x
, int y
, int WXUNUSED(keys
), wxDC
& dc
, int selectionHandle
)
727 wxPanel
*panel
= (wxPanel
*)handlerControl
->GetParent();
728 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
730 int xpos
, ypos
, width
, height
;
731 handlerControl
->GetPosition(&xpos
, &ypos
);
732 handlerControl
->GetSize(&width
, &height
);
734 if (selectionHandle
> 0)
744 int x1
, y1
, width1
, height1
;
746 switch (selectionHandle
)
752 height1
= (ypos
+ height
) - y
;
758 height1
= (y
- ypos
);
769 width1
= (xpos
+ width
) - x
;
776 height1
= (ypos
+ height
) - y
;
782 height1
= (y
- ypos
);
787 width1
= (xpos
+ width
) - x
;
793 width1
= (xpos
+ width
) - x
;
794 height1
= (ypos
+ height
) - y
;
799 dc
.SetLogicalFunction(wxXOR
);
800 dc
.SetPen(wxBLACK_DASHED_PEN
);
801 dc
.SetBrush(wxTRANSPARENT_BRUSH
);
803 DrawBoundingBox(dc
, x1
, y1
, width1
, height1
);
811 dc
.SetLogicalFunction(wxXOR
);
812 dc
.SetPen(wxBLACK_DASHED_PEN
);
813 dc
.SetBrush(wxTRANSPARENT_BRUSH
);
815 DrawBoundingBox(dc
, (int)(x
- dragOffsetX
), (int)(y
- dragOffsetY
), width
, height
);
817 // Also draw bounding boxes for other selected items
818 wxNode
*node
= panel
->GetChildren()->First();
821 wxWindow
*win
= (wxWindow
*)node
->Data();
822 if (win
->IsKindOf(CLASSINFO(wxControl
)))
824 wxControl
*item
= (wxControl
*)win
;
825 wxResourceEditorControlHandler
*handler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
826 if ((item
!= handlerControl
) && handler
->IsSelected())
829 item
->GetPosition(&x1
, &y1
);
830 item
->GetSize(&w1
, &h1
);
831 int x2
= (int)(x1
+ (x
- dragOffsetX
) - xpos
);
832 int y2
= (int)(y1
+ (y
- dragOffsetY
) - ypos
);
833 handler
->DrawBoundingBox(dc
, x2
, y2
, w1
, h1
);
843 void wxResourceEditorControlHandler::OnDragEnd(int x
, int y
, int WXUNUSED(keys
), wxDC
& dc
, int selectionHandle
)
845 wxPanel
*panel
= (wxPanel
*)handlerControl
->GetParent();
846 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
850 int xpos
, ypos
, width
, height
;
851 handlerControl
->GetPosition(&xpos
, &ypos
);
852 handlerControl
->GetSize(&width
, &height
);
854 if (selectionHandle
> 0)
856 int x1
, y1
, width1
, height1
;
858 switch (selectionHandle
)
864 height1
= (ypos
+ height
) - y
;
870 height1
= (y
- ypos
);
881 width1
= (xpos
+ width
) - x
;
888 height1
= (ypos
+ height
) - y
;
894 height1
= (y
- ypos
);
899 width1
= (xpos
+ width
) - x
;
905 width1
= (xpos
+ width
) - x
;
906 height1
= (ypos
+ height
) - y
;
909 handlerControl
->SetSize(x1
, y1
, width1
, height1
);
913 handlerControl
->Move((int)(x
- dragOffsetX
), (int)(y
- dragOffsetY
));
914 OldOnMove((int)(x
- dragOffsetX
), (int)(y
- dragOffsetY
));
916 // Also move other selected items
917 wxNode
*node
= panel
->GetChildren()->First();
920 wxWindow
*win
= (wxWindow
*)node
->Data();
921 if (win
->IsKindOf(CLASSINFO(wxControl
)))
923 wxControl
*item
= (wxControl
*)win
;
924 wxResourceEditorControlHandler
*handler
= (wxResourceEditorControlHandler
*)item
->GetEventHandler();
925 if ((item
!= handlerControl
) && handler
->IsSelected())
928 item
->GetPosition(&x1
, &y1
);
929 int x2
= (int)(x1
+ (x
- dragOffsetX
) - xpos
);
930 int y2
= (int)(y1
+ (y
- dragOffsetY
) - ypos
);
932 ((wxResourceEditorControlHandler
*)item
->GetEventHandler())->OldOnMove(x2
, y2
);
933 ((wxResourceEditorControlHandler
*)item
->GetEventHandler())->DrawSelectionHandles(dc
);
940 dc
.SetOptimization(FALSE
);
942 dc
.SetLogicalFunction(wxCOPY
);
943 dc
.SetPen(wxBLACK_PEN
);
944 dc
.SetBrush(wxBLACK_BRUSH
);
946 dc
.SetOptimization(TRUE
);
948 // Force it to repaint the selection handles (if any)
949 // since the panel thinks we're still within a drag and
950 // won't paint the handles.
952 DrawSelectionHandles(dc
);
959 // These functions call OnItemEvent, OnItemMove and OnItemSize
961 void wxResourceEditorControlHandler::OnMouseEvent(wxMouseEvent
& event
)
963 if ((event
.m_eventType
== wxEVENT_TYPE_LEFT_DCLICK
) ||
964 (event
.m_eventType
== wxEVENT_TYPE_RIGHT_DCLICK
))
966 wxWindow
*panel
= handlerControl
->GetParent();
967 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
969 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
970 if ( !panelHandler
->GetEvtHandlerEnabled() )
976 panelHandler
->OnItemEvent(handlerControl
, event
);
979 void wxResourceEditorControlHandler::OldOnMove(int x
, int y
)
981 wxWindow
*panel
= handlerControl
->GetParent();
982 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
985 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
986 panelHandler
->OnItemMove(handlerControl
, x
, y
);
989 void wxResourceEditorControlHandler::OldOnSize(int w
, int h
)
991 wxWindow
*panel
= handlerControl
->GetParent();
992 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
995 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
996 panelHandler
->OnItemSize(handlerControl
, w
, h
);
999 void wxResourceEditorControlHandler::OnSelect(bool select
)
1001 wxWindow
*panel
= handlerControl
->GetParent();
1002 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
1005 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
1006 panelHandler
->OnItemSelect(handlerControl
, select
);
1009 void wxResourceEditorControlHandler::OnLeftClick(int x
, int y
, int keys
)
1011 wxWindow
*panel
= handlerControl
->GetParent();
1012 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
1015 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
1016 panelHandler
->OnItemLeftClick(handlerControl
, x
, y
, keys
);
1019 void wxResourceEditorControlHandler::OnRightClick(int x
, int y
, int keys
)
1021 wxWindow
*panel
= handlerControl
->GetParent();
1022 if ( !panel
->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler
)) )
1025 wxResourceEditorDialogHandler
*panelHandler
= (wxResourceEditorDialogHandler
*)panel
->GetEventHandler();
1026 panelHandler
->OnItemRightClick(handlerControl
, x
, y
, keys
);