]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/dlghndlr.cpp
some typos fixed
[wxWidgets.git] / utils / dialoged / src / dlghndlr.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dlghndlr.cpp
3 // Purpose: Dialog handler
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/wx.h"
25 #endif
26
27 #include <ctype.h>
28 #include <stdlib.h>
29 #include <math.h>
30 #include <string.h>
31
32 #include "reseditr.h"
33 #include "winprop.h"
34 #include "dlghndlr.h"
35 #include "edlist.h"
36
37
38 IMPLEMENT_CLASS(wxResourceEditorDialogHandler, wxEvtHandler)
39 IMPLEMENT_CLASS(wxResourceEditorControlHandler, wxEvtHandler)
40
41 BEGIN_EVENT_TABLE(wxResourceEditorDialogHandler, wxEvtHandler)
42 EVT_PAINT(wxResourceEditorDialogHandler::OnPaint)
43 EVT_MOUSE_EVENTS(wxResourceEditorDialogHandler::OnMouseEvent)
44 EVT_SIZE(wxResourceEditorDialogHandler::OnSize)
45 END_EVENT_TABLE()
46
47 BEGIN_EVENT_TABLE(wxResourceEditorControlHandler, wxEvtHandler)
48 EVT_MOUSE_EVENTS(wxResourceEditorControlHandler::OnMouseEvent)
49 END_EVENT_TABLE()
50
51 /*
52 * Dialog box event handler
53 */
54
55 wxResourceEditorDialogHandler::wxResourceEditorDialogHandler(wxPanel *dialog, wxItemResource *resource,
56 wxEvtHandler *oldHandler, wxResourceManager *manager)
57 {
58 handlerDialog = dialog;
59 handlerResource = resource;
60 handlerOldHandler = oldHandler;
61 resourceManager = manager;
62
63 dragMode = wxDRAG_MODE_NONE;
64 dragType = wxDRAG_TYPE_NONE;
65 dragItem = NULL;
66 firstDragX = 0;
67 firstDragY = 0;
68 oldDragX = 0;
69 oldDragY = 0;
70 dragTolerance = 3;
71 checkTolerance = TRUE;
72 m_mouseCaptured = FALSE;
73 // m_treeItem = 0;
74 }
75
76 wxResourceEditorDialogHandler::~wxResourceEditorDialogHandler(void)
77 {
78 }
79
80 void wxResourceEditorDialogHandler::OnItemSelect(wxControl *item, bool select)
81 {
82 if (select)
83 resourceManager->AddSelection(item);
84 else
85 resourceManager->RemoveSelection(item);
86 }
87
88 void wxResourceEditorDialogHandler::OnPaint(wxPaintEvent& WXUNUSED(event))
89 {
90 wxPaintDC dc(handlerDialog);
91
92 PaintSelectionHandles(dc);
93 }
94
95 // Add event handlers for all children
96 void wxResourceEditorDialogHandler::AddChildHandlers(void)
97 {
98 wxNode *node = handlerDialog->GetChildren().First();
99 while ( node )
100 {
101 wxControl *child = (wxControl *)node->Data();
102 wxEvtHandler *childHandler = child->GetEventHandler();
103 if ( child->IsKindOf(CLASSINFO(wxControl)) && childHandler == child )
104 child->PushEventHandler(new wxResourceEditorControlHandler(child, childHandler));
105 node = node->Next();
106 }
107 }
108
109 void wxResourceEditorDialogHandler::OnLeftClick(int x, int y, int keys)
110 {
111 if (keys & wxKEY_CTRL)
112 {
113 wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog);
114 return;
115 }
116
117 // Deselect all items if click on panel
118 if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() == RESED_POINTER)
119 {
120 int needsRefresh = 0;
121 wxNode *node = handlerDialog->GetChildren().First();
122 while (node)
123 {
124 wxControl *item = (wxControl *)node->Data();
125 wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
126 if (item->IsKindOf(CLASSINFO(wxControl)) && childHandler->IsSelected())
127 {
128 needsRefresh ++;
129 OnItemSelect(item, FALSE);
130 childHandler->SelectItem(FALSE);
131 }
132 node = node->Next();
133 }
134 if (needsRefresh > 0)
135 {
136 wxClientDC dc(handlerDialog);
137 dc.Clear();
138 handlerDialog->Refresh();
139 }
140 return;
141 }
142
143 // Round down to take account of dialog units
144 wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerDialog);
145 if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
146 {
147 wxPoint pt = handlerDialog->ConvertPixelsToDialog(wxPoint(x, y));
148
149 // Convert back so we've rounded down
150 pt = handlerDialog->ConvertDialogToPixels(pt);
151 pt = handlerDialog->ConvertPixelsToDialog(pt);
152 pt = handlerDialog->ConvertDialogToPixels(pt);
153 x = pt.x;
154 y = pt.y;
155 }
156
157 switch (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection())
158 {
159 case RESED_BUTTON:
160 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxButton", x, y);
161 break;
162 case RESED_BMPBUTTON:
163 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxBitmapButton", x, y, TRUE);
164 break;
165 case RESED_STATICTEXT:
166 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticText", x, y);
167 break;
168 case RESED_STATICBMP:
169 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBitmap", x, y, TRUE);
170 break;
171 case RESED_TEXTCTRL_SINGLE:
172 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (single-line)", x, y);
173 break;
174 case RESED_TEXTCTRL_MULTIPLE:
175 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (multi-line)", x, y);
176 break;
177 case RESED_CHOICE:
178 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxChoice", x, y);
179 break;
180 case RESED_COMBOBOX:
181 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxComboBox", x, y);
182 break;
183 case RESED_CHECKBOX:
184 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxCheckBox", x, y);
185 break;
186 case RESED_RADIOBOX:
187 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxRadioBox", x, y);
188 break;
189 case RESED_RADIOBUTTON:
190 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxRadioButton", x, y);
191 break;
192 case RESED_LISTBOX:
193 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxListBox", x, y);
194 break;
195 case RESED_SLIDER:
196 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxSlider", x, y);
197 break;
198 case RESED_GAUGE:
199 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxGauge", x, y);
200 break;
201 case RESED_STATICBOX:
202 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBox", x, y);
203 break;
204 case RESED_SCROLLBAR:
205 resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxScrollBar", x, y);
206 break;
207 default:
208 break;
209 }
210
211 // Now switch pointer on.
212 if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() != RESED_POINTER)
213 {
214 wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->SetItemState(RESED_POINTER, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
215 }
216 }
217
218 void wxResourceEditorDialogHandler::OnRightClick(int x, int y, int WXUNUSED(keys))
219 {
220 wxMenu *menu = resourceManager->GetPopupMenu();
221 menu->SetClientData((char *)handlerDialog);
222
223 wxString str("wxDialog : ");
224 str += handlerDialog->GetName();
225
226 menu->SetLabel(OBJECT_MENU_TITLE,str);
227
228 handlerDialog->PopupMenu(menu, x, y);
229 }
230
231 void wxResourceEditorDialogHandler::OnItemLeftClick(wxControl *item, int WXUNUSED(x), int WXUNUSED(y), int keys)
232 {
233 if (keys & wxKEY_CTRL)
234 {
235 wxResourceManager::GetCurrentResourceManager()->EditWindow(item);
236 return;
237 }
238
239 /*
240 // If this is a wxStaticBox and the pointer isn't an arrow, chances
241 // are that we really meant to place an item on the panel.
242 // Fake this event.
243 if ((item->GetClassInfo() == CLASSINFO(wxStaticBox)) && resourceManager->GetEditorPalette()->currentlySelected != PALETTE_ARROW)
244 {
245 OnLeftClick(x, y, keys);
246 return;
247 }
248 */
249
250 wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
251
252 if (childHandler->IsSelected())
253 {
254 childHandler->SelectItem(FALSE);
255 OnItemSelect(item, FALSE);
256
257 wxClientDC dc(handlerDialog);
258 dc.Clear();
259 handlerDialog->Refresh();
260 }
261 else
262 {
263 childHandler->SelectItem(TRUE);
264 OnItemSelect(item, TRUE);
265
266 // Deselect other items if shift is not pressed
267 int needsRefresh = 0;
268 if (!(keys & wxKEY_SHIFT))
269 {
270 wxNode *node = item->GetParent()->GetChildren().First();
271 while (node)
272 {
273 wxControl *child = (wxControl *)node->Data();
274 wxResourceEditorControlHandler *childHandler2 = (wxResourceEditorControlHandler *)child->GetEventHandler();
275 if (child->IsKindOf(CLASSINFO(wxControl)) && childHandler2->IsSelected() && child != item)
276 {
277 childHandler2->SelectItem(FALSE);
278 OnItemSelect(child, FALSE);
279 needsRefresh ++;
280 }
281 node = node->Next();
282 }
283 }
284
285 wxClientDC dc(handlerDialog);
286 childHandler->DrawSelectionHandles(dc);
287
288 if (needsRefresh > 0)
289 {
290 dc.Clear();
291 handlerDialog->Refresh();
292 }
293 }
294 }
295
296 void wxResourceEditorDialogHandler::OnItemRightClick(wxControl *item, int x, int y, int WXUNUSED(keys))
297 {
298 /*
299 if (keys & wxKEY_CTRL)
300 {
301 wxDebugMsg("Item %s, selected = %d\n", item->GetName(), item->IsSelected());
302 return;
303 }
304 */
305
306 wxMenu *menu = resourceManager->GetPopupMenu();
307 menu->SetClientData((char *)item);
308
309 wxWindow *win = (wxWindow *)item;
310
311 wxWindowPropertyInfo *info = resourceManager->CreatePropertyInfoForWindow(win);
312 if (info)
313 {
314 info->SetResource(resourceManager->FindResourceForWindow(win));
315 wxString str;
316 str = win->GetClassInfo()->GetClassName();
317 str += " : ";
318 if (win->GetName() != "")
319 str += win->GetName();
320
321 menu->SetLabel(OBJECT_MENU_TITLE,str);
322 }
323
324 handlerDialog->PopupMenu(menu, x, y);
325 }
326
327 // Under Windows 95, you can resize a panel interactively depending on
328 // window styles.
329 void wxResourceEditorDialogHandler::OnSize(wxSizeEvent& event)
330 {
331 // Update the associated resource
332 int w, h;
333 handlerDialog->GetClientSize(& w, & h);
334
335 wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerDialog);
336 if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
337 {
338 wxSize sz = handlerDialog->ConvertPixelsToDialog(wxSize(w, h));
339 w = sz.x; h = sz.y;
340 }
341 resource->SetSize(resource->GetX(), resource->GetY(), w, h);
342 }
343
344 // An event outside any items: may be a drag event.
345 void wxResourceEditorDialogHandler::OnMouseEvent(wxMouseEvent& event)
346 {
347 if (GetEvtHandlerEnabled())
348 {
349 // If we're dragging an item or selection handle,
350 // continue dragging.
351 if (dragMode != wxDRAG_MODE_NONE)
352 {
353 if (dragType != wxDRAG_TYPE_BOUNDING_BOX &&
354 dragItem != NULL)
355 {
356 ProcessItemEvent(dragItem, event, dragType);
357 return;
358 }
359 }
360
361 wxCoord x, y;
362 event.GetPosition(&x, &y);
363
364 // Find which selection handle we're on, if any
365 wxNode *node = handlerDialog->GetChildren().First();
366 while (node)
367 {
368 wxWindow *win = (wxWindow *)node->Data();
369 if (win->IsKindOf(CLASSINFO(wxControl)))
370 {
371 wxControl *item = (wxControl *)win;
372 wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
373 int selHandle = childHandler->SelectionHandleHitTest(x, y);
374 if (selHandle > 0)
375 {
376 ProcessItemEvent(item, event, selHandle);
377 return;
378 }
379 }
380 node = node->Next();
381 }
382
383 // We're not on an item or selection handle.
384 // so... check for a left or right click event
385 // to send to the application.
386 int keys = 0;
387 if (event.ShiftDown()) keys = keys | wxKEY_SHIFT;
388 if (event.ControlDown()) keys = keys | wxKEY_CTRL;
389
390 if (node == NULL)
391 {
392 if (event.Dragging() &&
393 (dragType == wxDRAG_TYPE_BOUNDING_BOX))
394
395 {
396 if (dragMode == wxDRAG_MODE_CONTINUE_LEFT)
397 {
398 wxClientDC dc(handlerDialog);
399 OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, NULL);
400 OnDragContinue(TRUE, x, y, keys, dc, NULL);
401 oldDragX = x; oldDragY = y;
402 }
403 /*
404 else if (event.LeftUp() && dragMode == wxDRAG_MODE_CONTINUE_LEFT)
405 {
406
407 wxClientDC dc(handlerDialog);
408 OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, NULL);
409 OnDragContinue(TRUE, x, y, keys, dc, NULL);
410 oldDragX = x; oldDragY = y;
411 }
412 */
413 }
414 }
415
416 if (event.LeftDown())
417 {
418 if (!m_mouseCaptured)
419 {
420 handlerDialog->CaptureMouse();
421 m_mouseCaptured = TRUE;
422 }
423
424 // Starting to draw a bounding box around
425 // some numbe of controls on the dialog
426 if (node == NULL &&
427 wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() == RESED_POINTER)
428 {
429 dragItem = NULL;
430 dragMode = wxDRAG_MODE_START_LEFT;
431 firstDragX = x;
432 firstDragY = y;
433 dragType = wxDRAG_TYPE_BOUNDING_BOX;
434 wxClientDC dc(handlerDialog);
435 OnDragBegin(x, y, keys, dc, NULL);
436 dragMode = wxDRAG_MODE_CONTINUE_LEFT;
437 oldDragX = x; oldDragY = y;
438 }
439
440 event.Skip();
441 }
442 else if (event.LeftUp())
443 {
444 if (m_mouseCaptured)
445 {
446 handlerDialog->ReleaseMouse();
447 m_mouseCaptured = FALSE;
448 }
449
450 if (dragType == wxDRAG_TYPE_BOUNDING_BOX)
451 {
452 // Determine the bounds of the surrounding box
453 int upperLeftX = (x < firstDragX) ? x : firstDragX;
454 int upperLeftY = (y < firstDragY) ? y : firstDragY;
455 int lowerRightX = (x > firstDragX) ? x : firstDragX;
456 int lowerRightY = (y > firstDragY) ? y : firstDragY;
457
458 int xpos,ypos;
459 int width,height;
460
461 bool widgetWithinBounds = FALSE;
462
463 int needsRefresh = 0;
464
465 wxClientDC dc(handlerDialog);
466
467 // Determine what widgets which fall within the bounding box
468 // and select them
469 wxNode *node = handlerDialog->GetChildren().First();
470 while (node)
471 {
472 widgetWithinBounds = FALSE;
473 wxWindow *win = (wxWindow *)node->Data();
474 if (win->IsKindOf(CLASSINFO(wxControl)))
475 {
476 wxControl *item = (wxControl *)win;
477 wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
478
479 // Unselect all widgets that are currently selected
480 if (!(keys & wxKEY_SHIFT) && childHandler->IsSelected())
481 {
482 needsRefresh ++;
483 OnItemSelect(item, FALSE);
484 childHandler->SelectItem(FALSE);
485 }
486
487 // Get X,Y and WIDTH,HEIGHT of the widget to be able
488 // to determine if any portion of it is within the bounded
489 // area
490 childHandler->handlerControl->GetPosition(&xpos, &ypos);
491 childHandler->handlerControl->GetSize(&width, &height);
492
493 // Check if the current widget is inside the rectangle
494 // that was just bounded
495 if (xpos >= upperLeftX && xpos <= lowerRightX)
496 {
497 if (ypos >= upperLeftY && ypos <= lowerRightY)
498 widgetWithinBounds = TRUE;
499 else if (ypos+height >= upperLeftY && ypos+height <= lowerRightY)
500 widgetWithinBounds = TRUE;
501 }
502 else if (xpos+width >= upperLeftX && xpos <= lowerRightX)
503 {
504 if (ypos >= upperLeftY && ypos <= lowerRightY)
505 widgetWithinBounds = TRUE;
506 else if (ypos+height >= upperLeftY && ypos+height <= lowerRightY)
507 widgetWithinBounds = TRUE;
508 }
509
510 if (widgetWithinBounds)
511 {
512 childHandler->SelectItem(TRUE);
513 OnItemSelect(item, TRUE);
514
515 // childHandler->DrawSelectionHandles(dc);
516 }
517
518 }
519 node = node->Next();
520 }
521
522 OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, NULL);
523 OnDragEnd(x, y, keys, dc, NULL);
524
525 if (needsRefresh > 0)
526 {
527 dc.Clear();
528 handlerDialog->Refresh();
529 }
530
531 // Always paint, in case the bounding box overlapped with
532 // the handles of any selected widgets, that way when the
533 // bounding box is cleared, the handles don't get partially
534 // erased where the overlap occured
535 PaintSelectionHandles(dc);
536
537 dragMode = wxDRAG_MODE_NONE;
538 checkTolerance = TRUE;
539 dragItem = NULL;
540 dragType = wxDRAG_TYPE_NONE;
541 }
542 else
543 OnLeftClick(x, y, keys);
544 }
545 else if (event.RightDown())
546 {
547 if (m_mouseCaptured)
548 {
549 handlerDialog->ReleaseMouse();
550 m_mouseCaptured = FALSE;
551 }
552
553 OnRightClick(x, y, keys);
554 }
555 else if (event.LeftDClick())
556 {
557 if (m_mouseCaptured)
558 {
559 handlerDialog->ReleaseMouse();
560 m_mouseCaptured = FALSE;
561 }
562 wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog);
563 }
564 }
565 else
566 event.Skip();
567 }
568
569 void wxResourceEditorDialogHandler::OnItemEvent(wxControl *item, wxMouseEvent& event)
570 {
571 if (!GetEvtHandlerEnabled())
572 return;
573
574 // Not a selection handle event: just a normal item event.
575 // Transform to panel coordinates.
576 wxCoord x, y;
577 item->GetPosition(&x, &y);
578
579 event.m_x = event.m_x + x;
580 event.m_y = event.m_y + y;
581
582 ProcessItemEvent(item, event, dragType);
583 }
584
585 void wxResourceEditorDialogHandler::ProcessItemEvent(wxControl *item, wxMouseEvent& event, int selectionHandle)
586 {
587 wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
588
589 wxCoord x, y;
590 event.GetPosition(&x, &y);
591 int keys = 0;
592 if (event.ShiftDown()) keys = keys | wxKEY_SHIFT;
593 if (event.ControlDown()) keys = keys | wxKEY_CTRL;
594 bool dragging = event.Dragging();
595
596 if (dragging)
597 {
598 int dx = (int)abs((x - firstDragX));
599 int dy = (int)abs((y - firstDragY));
600 if (checkTolerance && (dx <= dragTolerance) && (dy <= dragTolerance))
601 {
602 return;
603 }
604 else
605 // If we've ignored the tolerance once, then ALWAYS ignore
606 // tolerance in this drag, even if we come back within
607 // the tolerance range.
608 {
609 checkTolerance = FALSE;
610 }
611 }
612 if (event.LeftDClick())
613 {
614 if (m_mouseCaptured)
615 {
616 handlerDialog->ReleaseMouse();
617 m_mouseCaptured = FALSE;
618 }
619
620 wxResourceManager::GetCurrentResourceManager()->EditWindow(item);
621 }
622 else if (dragging && dragItem && dragMode == wxDRAG_MODE_START_LEFT)
623 {
624 dragMode = wxDRAG_MODE_CONTINUE_LEFT;
625 wxClientDC dc(handlerDialog);
626 childHandler->OnDragBegin(x, y, keys, dc, selectionHandle);
627 oldDragX = x; oldDragY = y;
628 if (!m_mouseCaptured)
629 {
630 handlerDialog->CaptureMouse();
631 m_mouseCaptured = TRUE;
632 }
633 }
634 else if (dragging && dragItem && dragMode == wxDRAG_MODE_CONTINUE_LEFT)
635 {
636 wxClientDC dc(handlerDialog);
637 childHandler->OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, selectionHandle);
638 childHandler->OnDragContinue(TRUE, x, y, keys, dc, selectionHandle);
639 oldDragX = x; oldDragY = y;
640 }
641 else if (event.LeftUp() && dragItem && dragMode == wxDRAG_MODE_CONTINUE_LEFT)
642 {
643 wxClientDC dc(handlerDialog);
644 dragMode = wxDRAG_MODE_NONE;
645 checkTolerance = TRUE;
646
647 childHandler->OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, selectionHandle);
648 childHandler->OnDragEnd(x, y, keys, dc, selectionHandle);
649
650 dragItem = NULL;
651 dragType = wxDRAG_TYPE_NONE;
652
653 if (m_mouseCaptured)
654 {
655 handlerDialog->ReleaseMouse();
656 m_mouseCaptured = FALSE;
657 }
658 }
659 else if (dragging && dragItem && dragMode == wxDRAG_MODE_START_RIGHT)
660 {
661 wxClientDC dc(handlerDialog);
662 dragMode = wxDRAG_MODE_CONTINUE_RIGHT;
663 childHandler->OnDragBegin(x, y, keys, dc, selectionHandle);
664 oldDragX = x; oldDragY = y;
665
666 if (!m_mouseCaptured)
667 {
668 handlerDialog->CaptureMouse();
669 m_mouseCaptured = TRUE;
670 }
671 }
672 else if (dragging && dragItem && dragMode == wxDRAG_MODE_CONTINUE_RIGHT)
673 {
674 oldDragX = x; oldDragY = y;
675 }
676 // Obsolete; no longer try to right-drag
677 else if (event.RightUp() && dragItem && dragMode == wxDRAG_MODE_CONTINUE_RIGHT)
678 {
679 dragMode = wxDRAG_MODE_NONE;
680 checkTolerance = TRUE;
681 dragItem = NULL;
682 dragType = wxDRAG_TYPE_NONE;
683
684 if (m_mouseCaptured)
685 {
686 handlerDialog->ReleaseMouse();
687 m_mouseCaptured = FALSE;
688 }
689 }
690 else if (event.IsButton())
691 {
692 checkTolerance = TRUE;
693
694 if (event.LeftDown())
695 {
696 dragItem = item;
697 dragMode = wxDRAG_MODE_START_LEFT;
698 firstDragX = x;
699 firstDragY = y;
700 dragType = selectionHandle;
701
702 if (!m_mouseCaptured)
703 {
704 handlerDialog->CaptureMouse();
705 m_mouseCaptured = TRUE;
706 }
707 }
708 else if (event.RightDown())
709 {
710 if (m_mouseCaptured)
711 {
712 handlerDialog->ReleaseMouse();
713 m_mouseCaptured = FALSE;
714 }
715
716 if (item)
717 childHandler->OnRightClick(x, y, keys);
718 else
719 OnRightClick(x, y, keys);
720
721 dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE;
722
723 /*
724 dragItem = item;
725 dragMode = wxDRAG_MODE_START_RIGHT;
726 firstDragX = x;
727 firstDragY = y;
728 dragType = selectionHandle;
729
730 if (!m_mouseCaptured)
731 {
732 handlerDialog->CaptureMouse();
733 m_mouseCaptured = TRUE;
734 }
735 */
736 }
737 else if (event.LeftUp())
738 {
739 if (dragItem)
740 childHandler->OnLeftClick(x, y, keys);
741 else
742 OnLeftClick(x, y, keys);
743
744 dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE;
745
746 if (m_mouseCaptured)
747 {
748 handlerDialog->ReleaseMouse();
749 m_mouseCaptured = FALSE;
750 }
751 }
752 else if (event.RightUp())
753 {
754 /*
755 if (dragItem)
756 childHandler->OnRightClick(x, y, keys);
757 else
758 OnRightClick(x, y, keys);
759
760 dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE;
761
762 if (m_mouseCaptured)
763 {
764 handlerDialog->ReleaseMouse();
765 m_mouseCaptured = FALSE;
766 }
767 */
768 }
769 }
770 }
771
772 // Calls DrawSelectionHandles for all items if
773 // edit mode is on.
774 void wxResourceEditorDialogHandler::PaintSelectionHandles(wxDC& dc)
775 {
776 if (!GetEvtHandlerEnabled())
777 return;
778
779 dc.BeginDrawing();
780
781 wxNode *node = handlerDialog->GetChildren().First();
782 while (node)
783 {
784 wxWindow *win = (wxWindow *)node->Data();
785 if (win->IsKindOf(CLASSINFO(wxControl)))
786 {
787 wxControl *item = (wxControl *)win;
788 wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
789
790 // Don't draw handles for an item that's being moved: it'll
791 // smear.
792 if (childHandler->IsSelected() && (item != dragItem))
793 childHandler->DrawSelectionHandles(dc);
794 }
795 node = node->Next();
796 }
797 dc.EndDrawing();
798 }
799
800
801
802 void wxResourceEditorDialogHandler::DrawBoundingBox(wxDC& dc, int x, int y, int w, int h)
803 {
804 dc.DrawRectangle(x, y, w, h);
805 }
806
807
808 void wxResourceEditorDialogHandler::OnDragBegin(int x, int y, int WXUNUSED(keys), wxDC& dc, int selectionHandle)
809 {
810 /*
811 dc.BeginDrawing();
812
813 dc.SetOptimization(FALSE);
814
815 dc.SetLogicalFunction(wxINVERT);
816
817 wxPen pen(wxColour(0, 0, 0), 1, wxDOT);
818 dc.SetPen(pen);
819 dc.SetBrush(* wxTRANSPARENT_BRUSH);
820
821 dc.SetOptimization(TRUE);
822
823 // Refresh();
824 // DrawBoundingBox(dc, xpos, ypos, width, height);
825
826 dc.EndDrawing();
827 */
828 } //wxResourceEditorDialogHandler::OnDragBegin()
829
830
831 void wxResourceEditorDialogHandler::OnDragContinue(bool WXUNUSED(paintIt), int x, int y, int WXUNUSED(keys), wxDC& dc, int selectionHandle)
832 {
833 int upperLeftX = (x < firstDragX) ? x : firstDragX;
834 int upperLeftY = (y < firstDragY) ? y : firstDragY;
835 int lowerRightX = (x > firstDragX) ? x : firstDragX;
836 int lowerRightY = (y > firstDragY) ? y : firstDragY;
837
838 dc.BeginDrawing();
839 dc.SetLogicalFunction(wxINVERT);
840 wxPen pen(wxColour(0, 0, 0), 1, wxDOT);
841 dc.SetPen(pen);
842 dc.SetBrush(* wxTRANSPARENT_BRUSH);
843
844 DrawBoundingBox(dc, (int)upperLeftX, upperLeftY,
845 lowerRightX-upperLeftX, lowerRightY-upperLeftY);
846
847 dc.EndDrawing();
848
849 } // wxResourceEditorDialogHandler::OnDragContinue()
850
851
852 void wxResourceEditorDialogHandler::OnDragEnd(int x, int y, int WXUNUSED(keys), wxDC& dc, int selectionHandle)
853 {
854 /*
855 dc.BeginDrawing();
856
857 dc.SetOptimization(FALSE);
858
859 dc.SetLogicalFunction(wxCOPY);
860 dc.SetPen(* wxBLACK_PEN);
861 dc.SetBrush(* wxBLACK_BRUSH);
862
863 dc.SetOptimization(TRUE);
864
865 dc.EndDrawing();
866 */
867
868 } // wxResourceEditorDialogHandler::OnDragEnd()
869
870
871
872
873 /*
874 * Event handler for controls
875 */
876
877 int wxResourceEditorControlHandler::dragOffsetX = 0;
878 int wxResourceEditorControlHandler::dragOffsetY = 0;
879
880 wxResourceEditorControlHandler::wxResourceEditorControlHandler(wxControl *control,
881 wxEvtHandler *oldHandler)
882 {
883 handlerControl = control;
884 handlerOldHandler = oldHandler;
885
886 handleSize = 6;
887 handleMargin = 1;
888 isSelected = FALSE;
889 dragOffsetX = 0;
890 dragOffsetY = 0;
891 // m_treeItem = 0;
892 }
893
894 wxResourceEditorControlHandler::~wxResourceEditorControlHandler(void)
895 {
896 }
897
898 /*
899 * Manipulation and drawing of items in Edit Mode
900 */
901
902 void wxResourceEditorControlHandler::SelectItem(bool select)
903 {
904 isSelected = select;
905 }
906
907 // Returns TRUE or FALSE
908 bool wxResourceEditorControlHandler::HitTest(int x, int y)
909 {
910 int xpos, ypos, width, height;
911 handlerControl->GetPosition(&xpos, &ypos);
912 handlerControl->GetSize(&width, &height);
913
914 return ((x >= xpos) && (x <= (xpos + width)) && (y >= ypos) && (y <= (ypos + height)));
915 }
916
917 // Calculate position of the 8 handles
918 void wxResourceEditorControlHandler::CalcSelectionHandles(int *hx, int *hy)
919 {
920 int xpos, ypos, width, height;
921 handlerControl->GetPosition(&xpos, &ypos);
922 handlerControl->GetSize(&width, &height);
923 int middleX = (xpos + (width/2));
924 int middleY = (ypos + (height/2));
925
926 // Start from top middle, clockwise.
927 /*
928 7 0 1
929
930 6 2
931
932 5 4 3
933 */
934
935 hx[0] = (int)(middleX - (handleSize/2));
936 hy[0] = ypos - handleSize - handleMargin;
937
938 hx[1] = xpos + width + handleMargin;
939 hy[1] = ypos - handleSize - handleMargin;
940
941 hx[2] = xpos + width + handleMargin;
942 hy[2] = (int)(middleY - (handleSize/2));
943
944 hx[3] = xpos + width + handleMargin;
945 hy[3] = ypos + height + handleMargin;
946
947 hx[4] = (int)(middleX - (handleSize/2));
948 hy[4] = ypos + height + handleMargin;
949
950 hx[5] = xpos - handleSize - handleMargin;
951 hy[5] = ypos + height + handleMargin;
952
953 hx[6] = xpos - handleSize - handleMargin;
954 hy[6] = (int)(middleY - (handleSize/2));
955
956 hx[7] = xpos - handleSize - handleMargin;
957 hy[7] = ypos - handleSize - handleMargin;
958 }
959
960 // Returns 0 (no hit), 1 - 8 for which selection handle
961 // (clockwise from top middle)
962 int wxResourceEditorControlHandler::SelectionHandleHitTest(int x, int y)
963 {
964 // Handle positions
965 int hx[8];
966 int hy[8];
967 CalcSelectionHandles(hx, hy);
968
969 int i;
970 for (i = 0; i < 8; i++)
971 {
972 if ((x >= hx[i]) && (x <= (hx[i] + handleSize)) && (y >= hy[i]) && (y <= (hy[i] + handleSize)))
973 return (i + 1);
974 }
975 return 0;
976 }
977
978 void wxResourceEditorControlHandler::DrawSelectionHandles(wxDC& dc, bool WXUNUSED(erase))
979 {
980 dc.SetOptimization(FALSE);
981
982 dc.SetLogicalFunction(wxCOPY);
983 dc.SetPen(* wxBLACK_PEN);
984 dc.SetBrush(* wxBLACK_BRUSH);
985
986 dc.SetOptimization(TRUE);
987
988 // Handle positions
989 int hx[8];
990 int hy[8];
991 CalcSelectionHandles(hx, hy);
992
993 int i;
994 for (i = 0; i < 8; i++)
995 {
996 dc.DrawRectangle(hx[i], hy[i], handleSize, handleSize);
997 }
998 }
999
1000 void wxResourceEditorControlHandler::DrawBoundingBox(wxDC& dc, int x, int y, int w, int h)
1001 {
1002 dc.DrawRectangle(x, y, w, h);
1003 }
1004
1005 // If selectionHandle is zero, not dragging the selection handle.
1006 void wxResourceEditorControlHandler::OnDragBegin(int x, int y, int WXUNUSED(keys), wxDC& dc, int selectionHandle)
1007 {
1008 int xpos, ypos, width, height;
1009 handlerControl->GetPosition(&xpos, &ypos);
1010 handlerControl->GetSize(&width, &height);
1011
1012 dc.BeginDrawing();
1013
1014 // dc.DestroyClippingRegion();
1015
1016 wxPanel *panel = (wxPanel *)handlerControl->GetParent();
1017
1018 // Erase selection handles
1019 // DrawSelectionHandles(dc, TRUE);
1020
1021 dc.SetOptimization(FALSE);
1022
1023 dc.SetLogicalFunction(wxINVERT);
1024
1025 wxPen pen(wxColour(0, 0, 0), 1, wxDOT);
1026 dc.SetPen(pen);
1027 dc.SetBrush(* wxTRANSPARENT_BRUSH);
1028
1029 dc.SetOptimization(TRUE);
1030
1031 if (selectionHandle > 0)
1032 {
1033 panel->Refresh();
1034
1035 DrawBoundingBox(dc, xpos, ypos, width, height);
1036 }
1037 else
1038 {
1039 panel->Refresh();
1040
1041 dragOffsetX = (x - xpos);
1042 dragOffsetY = (y - ypos);
1043
1044 DrawBoundingBox(dc, xpos, ypos, width, height);
1045
1046 // Also draw bounding boxes for other selected items
1047 wxNode *node = panel->GetChildren().First();
1048 while (node)
1049 {
1050 wxWindow *win = (wxWindow *)node->Data();
1051 if (win->IsKindOf(CLASSINFO(wxControl)))
1052 {
1053 wxControl *item = (wxControl *)win;
1054 wxResourceEditorControlHandler *handler = (wxResourceEditorControlHandler *)item->GetEventHandler();
1055 if ((item != handlerControl) && handler->IsSelected())
1056 {
1057 int x1, y1, w1, h1;
1058 item->GetPosition(&x1, &y1);
1059 item->GetSize(&w1, &h1);
1060 handler->DrawBoundingBox(dc, x1, y1, w1, h1);
1061 }
1062 }
1063 node = node->Next();
1064 }
1065 }
1066 dc.EndDrawing();
1067 }
1068
1069 void wxResourceEditorControlHandler::OnDragContinue(bool WXUNUSED(paintIt), int x, int y, int WXUNUSED(keys), wxDC& dc, int selectionHandle)
1070 {
1071 wxPanel *panel = (wxPanel *)handlerControl->GetParent();
1072 int xpos, ypos, width, height;
1073 handlerControl->GetPosition(&xpos, &ypos);
1074 handlerControl->GetSize(&width, &height);
1075
1076 if (selectionHandle > 0)
1077 {
1078 /*
1079 8 1 2
1080
1081 7 3
1082
1083 6 5 4
1084 */
1085
1086 int x1, y1, width1, height1;
1087
1088 switch (selectionHandle)
1089 {
1090 case 1:
1091 x1 = xpos;
1092 y1 = y;
1093 width1 = width;
1094 height1 = (ypos + height) - y;
1095 break;
1096 case 5:
1097 x1 = xpos;
1098 y1 = ypos;
1099 width1 = width;
1100 height1 = (y - ypos);
1101 break;
1102 case 3:
1103 x1 = xpos;
1104 y1 = ypos;
1105 width1 = (x - xpos);
1106 height1 = height;
1107 break;
1108 case 7:
1109 x1 = x;
1110 y1 = ypos;
1111 width1 = (xpos + width) - x;
1112 height1 = height;
1113 break;
1114 case 2:
1115 x1 = xpos;
1116 y1 = y;
1117 width1 = (x - xpos);
1118 height1 = (ypos + height) - y;
1119 break;
1120 case 4:
1121 x1 = xpos;
1122 y1 = ypos;
1123 width1 = (x - xpos);
1124 height1 = (y - ypos);
1125 break;
1126 case 6:
1127 x1 = x;
1128 y1 = ypos;
1129 width1 = (xpos + width) - x;
1130 height1 = y - ypos;
1131 break;
1132 case 8:
1133 x1 = x;
1134 y1 = y;
1135 width1 = (xpos + width) - x;
1136 height1 = (ypos + height) - y;
1137 break;
1138 }
1139 dc.BeginDrawing();
1140
1141 dc.SetLogicalFunction(wxINVERT);
1142 wxPen pen(wxColour(0, 0, 0), 1, wxDOT);
1143 dc.SetPen(pen);
1144 dc.SetBrush(* wxTRANSPARENT_BRUSH);
1145
1146 DrawBoundingBox(dc, x1, y1, width1, height1);
1147
1148 dc.EndDrawing();
1149 }
1150 else
1151 {
1152 dc.BeginDrawing();
1153 dc.SetLogicalFunction(wxINVERT);
1154 wxPen pen(wxColour(0, 0, 0), 1, wxDOT);
1155 dc.SetPen(pen);
1156 dc.SetBrush(* wxTRANSPARENT_BRUSH);
1157
1158 DrawBoundingBox(dc, (int)(x - dragOffsetX), (int)(y - dragOffsetY), width, height);
1159
1160 // Also draw bounding boxes for other selected items
1161 wxNode *node = panel->GetChildren().First();
1162 while (node)
1163 {
1164 wxWindow *win = (wxWindow *)node->Data();
1165 if (win->IsKindOf(CLASSINFO(wxControl)))
1166 {
1167 wxControl *item = (wxControl *)win;
1168 wxResourceEditorControlHandler *handler = (wxResourceEditorControlHandler *)item->GetEventHandler();
1169 if ((item != handlerControl) && handler->IsSelected())
1170 {
1171 int x1, y1, w1, h1;
1172 item->GetPosition(&x1, &y1);
1173 item->GetSize(&w1, &h1);
1174 int x2 = (int)(x1 + (x - dragOffsetX) - xpos);
1175 int y2 = (int)(y1 + (y - dragOffsetY) - ypos);
1176 handler->DrawBoundingBox(dc, x2, y2, w1, h1);
1177 }
1178 }
1179 node = node->Next();
1180 }
1181 dc.EndDrawing();
1182 }
1183 }
1184
1185 void wxResourceEditorControlHandler::OnDragEnd(int x, int y, int WXUNUSED(keys), wxDC& dc, int selectionHandle)
1186 {
1187 wxPanel *panel = (wxPanel *)handlerControl->GetParent();
1188
1189 dc.BeginDrawing();
1190
1191 int xpos, ypos, width, height;
1192 handlerControl->GetPosition(&xpos, &ypos);
1193 handlerControl->GetSize(&width, &height);
1194
1195 wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl);
1196 wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl->GetParent());
1197
1198 if (selectionHandle > 0)
1199 {
1200 int x1, y1, width1, height1;
1201
1202 switch (selectionHandle)
1203 {
1204 case 1:
1205 x1 = xpos;
1206 y1 = y;
1207 width1 = width;
1208 height1 = (ypos + height) - y;
1209 break;
1210 case 5:
1211 x1 = xpos;
1212 y1 = ypos;
1213 width1 = width;
1214 height1 = (y - ypos);
1215 break;
1216 case 3:
1217 x1 = xpos;
1218 y1 = ypos;
1219 width1 = (x - xpos);
1220 height1 = height;
1221 break;
1222 case 7:
1223 x1 = x;
1224 y1 = ypos;
1225 width1 = (xpos + width) - x;
1226 height1 = height;
1227 break;
1228 case 2:
1229 x1 = xpos;
1230 y1 = y;
1231 width1 = (x - xpos);
1232 height1 = (ypos + height) - y;
1233 break;
1234 case 4:
1235 x1 = xpos;
1236 y1 = ypos;
1237 width1 = (x - xpos);
1238 height1 = (y - ypos);
1239 break;
1240 case 6:
1241 x1 = x;
1242 y1 = ypos;
1243 width1 = (xpos + width) - x;
1244 height1 = y - ypos;
1245 break;
1246 case 8:
1247 x1 = x;
1248 y1 = y;
1249 width1 = (xpos + width) - x;
1250 height1 = (ypos + height) - y;
1251 break;
1252 }
1253 // Update the associated resource
1254 // We need to convert to dialog units if this is not a dialog or panel, but
1255 // the parent resource specifies dialog units.
1256 int resourceX = x1;
1257 int resourceY = y1;
1258 int resourceWidth = width1;
1259 int resourceHeight = height1;
1260
1261 if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
1262 {
1263 wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(x1, y1));
1264 wxSize sz = handlerControl->GetParent()->ConvertPixelsToDialog(wxSize(width1, height1));
1265
1266 // Convert back so we've rounded down
1267 sz = handlerControl->GetParent()->ConvertDialogToPixels(sz);
1268 sz = handlerControl->GetParent()->ConvertPixelsToDialog(sz);
1269 resourceWidth = sz.x; resourceHeight = sz.y;
1270
1271 sz = handlerControl->GetParent()->ConvertDialogToPixels(sz);
1272 width1 = sz.x;
1273 height1 = sz.y;
1274
1275 pt = handlerControl->GetParent()->ConvertDialogToPixels(pt);
1276 pt = handlerControl->GetParent()->ConvertPixelsToDialog(pt);
1277 resourceX = pt.x; resourceY = pt.y;
1278
1279 pt = handlerControl->GetParent()->ConvertDialogToPixels(pt);
1280 x1 = pt.x;
1281 y1 = pt.y;
1282 }
1283 handlerControl->SetSize(x1, y1, width1, height1);
1284 resource->SetSize(resourceX, resourceY, resourceWidth, resourceHeight);
1285 }
1286 else
1287 {
1288 // Correction 31/12/98. We need to round down the values to take into account
1289 // the fact that several pixels map to the same dialog unit.
1290
1291 int newX = (int)(x - dragOffsetX);
1292 int newY = (int)(y - dragOffsetY);
1293 int resourceX = newX;
1294 int resourceY = newY;
1295
1296 // Update the associated resource
1297 if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
1298 {
1299 wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY));
1300 pt = handlerControl->GetParent()->ConvertDialogToPixels(pt);
1301 pt = handlerControl->GetParent()->ConvertPixelsToDialog(pt);
1302 resourceX = pt.x; resourceY = pt.y;
1303 pt = handlerControl->GetParent()->ConvertDialogToPixels(pt);
1304
1305 // Having converted it several times, we know it'll map to dialog units exactly.
1306 newX = pt.x;
1307 newY = pt.y;
1308 }
1309 handlerControl->Move(newX, newY);
1310 OldOnMove(newX, newY);
1311
1312 resource->SetSize(resourceX, resourceY, resource->GetWidth(), resource->GetHeight());
1313
1314 // Also move other selected items
1315 wxNode *node = panel->GetChildren().First();
1316 while (node)
1317 {
1318 wxWindow *win = (wxWindow *)node->Data();
1319 if (win->IsKindOf(CLASSINFO(wxControl)))
1320 {
1321 wxControl *item = (wxControl *)win;
1322 wxResourceEditorControlHandler *handler = (wxResourceEditorControlHandler *)item->GetEventHandler();
1323 if ((item != handlerControl) && handler->IsSelected())
1324 {
1325 int x1, y1;
1326 item->GetPosition(&x1, &y1);
1327 int x2 = (int)(x1 + (x - dragOffsetX) - xpos);
1328 int y2 = (int)(y1 + (y - dragOffsetY) - ypos);
1329
1330 resourceX = x2;
1331 resourceY = y2;
1332
1333 // Update the associated resource
1334 resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item);
1335 if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
1336 {
1337 wxPoint pt = item->GetParent()->ConvertPixelsToDialog(wxPoint(x2, y2));
1338 pt = item->GetParent()->ConvertDialogToPixels(pt);
1339 pt = item->GetParent()->ConvertPixelsToDialog(pt);
1340
1341 resourceX = pt.x; resourceY = pt.y;
1342 pt = handlerControl->GetParent()->ConvertDialogToPixels(pt);
1343
1344 // Having converted it several times, we know it'll map to dialog units exactly
1345 x2 = pt.x;
1346 y2 = pt.y;
1347 }
1348
1349 item->Move(x2, y2);
1350 ((wxResourceEditorControlHandler *)item->GetEventHandler())->OldOnMove(x2, y2);
1351 ((wxResourceEditorControlHandler *)item->GetEventHandler())->DrawSelectionHandles(dc);
1352
1353 resource->SetSize(resourceX, resourceY, resource->GetWidth(), resource->GetHeight());
1354
1355 }
1356 }
1357 node = node->Next();
1358 }
1359 }
1360 dc.SetOptimization(FALSE);
1361
1362 dc.SetLogicalFunction(wxCOPY);
1363 dc.SetPen(* wxBLACK_PEN);
1364 dc.SetBrush(* wxBLACK_BRUSH);
1365
1366 dc.SetOptimization(TRUE);
1367
1368 // Force it to repaint the selection handles (if any)
1369 // since the panel thinks we're still within a drag and
1370 // won't paint the handles.
1371 if (IsSelected())
1372 DrawSelectionHandles(dc);
1373
1374 dc.EndDrawing();
1375
1376 panel->Refresh();
1377 }
1378
1379 // These functions call OnItemEvent, OnItemMove and OnItemSize
1380 // by default.
1381 void wxResourceEditorControlHandler::OnMouseEvent(wxMouseEvent& event)
1382 {
1383 /*
1384 if ((event.m_eventType == wxEVENT_TYPE_LEFT_DCLICK) ||
1385 (event.m_eventType == wxEVENT_TYPE_RIGHT_DCLICK))
1386 return;
1387 */
1388 wxWindow *panel = handlerControl->GetParent();
1389 if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) )
1390 return;
1391 wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler();
1392 if ( !panelHandler->GetEvtHandlerEnabled() )
1393 {
1394 event.Skip();
1395 return;
1396 }
1397
1398 panelHandler->OnItemEvent(handlerControl, event);
1399 }
1400
1401 void wxResourceEditorControlHandler::OldOnMove(int x, int y)
1402 {
1403 wxWindow *panel = handlerControl->GetParent();
1404 if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) )
1405 return;
1406
1407 wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler();
1408 panelHandler->OnItemMove(handlerControl, x, y);
1409 }
1410
1411 void wxResourceEditorControlHandler::OldOnSize(int w, int h)
1412 {
1413 wxWindow *panel = handlerControl->GetParent();
1414 if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) )
1415 return;
1416
1417 wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler();
1418 panelHandler->OnItemSize(handlerControl, w, h);
1419 }
1420
1421 void wxResourceEditorControlHandler::OnSelect(bool select)
1422 {
1423 wxWindow *panel = handlerControl->GetParent();
1424 if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) )
1425 return;
1426
1427 wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler();
1428 panelHandler->OnItemSelect(handlerControl, select);
1429 }
1430
1431 void wxResourceEditorControlHandler::OnLeftClick(int x, int y, int keys)
1432 {
1433 wxWindow *panel = handlerControl->GetParent();
1434 if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) )
1435 return;
1436
1437 wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler();
1438 panelHandler->OnItemLeftClick(handlerControl, x, y, keys);
1439 }
1440
1441 void wxResourceEditorControlHandler::OnRightClick(int x, int y, int keys)
1442 {
1443 wxWindow *panel = handlerControl->GetParent();
1444 if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) )
1445 return;
1446
1447 wxResourceEditorDialogHandler *panelHandler = (wxResourceEditorDialogHandler *)panel->GetEventHandler();
1448 panelHandler->OnItemRightClick(handlerControl, x, y, keys);
1449 }
1450
1451