+ if (!m_mouseCaptured)
+ {
+ handlerDialog->CaptureMouse();
+ m_mouseCaptured = TRUE;
+ }
+
+ // Starting to draw a bounding box around
+ // some numbe of controls on the dialog
+ if (node == NULL &&
+ wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() == RESED_POINTER)
+ {
+ dragItem = NULL;
+ dragMode = wxDRAG_MODE_START_LEFT;
+ firstDragX = x;
+ firstDragY = y;
+ dragType = wxDRAG_TYPE_BOUNDING_BOX;
+ wxClientDC dc(handlerDialog);
+ OnDragBegin(x, y, keys, dc, 0);
+ dragMode = wxDRAG_MODE_CONTINUE_LEFT;
+ oldDragX = x; oldDragY = y;
+ }
+
+ event.Skip();
+ }
+ else if (event.LeftUp())
+ {
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
+
+ if (dragType == wxDRAG_TYPE_BOUNDING_BOX)
+ {
+ // Determine the bounds of the surrounding box
+ int upperLeftX = (x < firstDragX) ? x : firstDragX;
+ int upperLeftY = (y < firstDragY) ? y : firstDragY;
+ int lowerRightX = (x > firstDragX) ? x : firstDragX;
+ int lowerRightY = (y > firstDragY) ? y : firstDragY;
+
+ int xpos,ypos;
+ int width,height;
+
+ bool widgetWithinBounds = FALSE;
+
+ int needsRefresh = 0;
+
+ wxClientDC dc(handlerDialog);
+
+ // Determine what widgets which fall within the bounding box
+ // and select them
+ wxNode *node = handlerDialog->GetChildren().First();
+ while (node)
+ {
+ widgetWithinBounds = FALSE;
+ wxWindow *win = (wxWindow *)node->Data();
+ if (win->IsKindOf(CLASSINFO(wxControl)))
+ {
+ wxControl *item = (wxControl *)win;
+ wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
+
+ // Unselect all widgets that are currently selected
+ if (!(keys & wxKEY_SHIFT) && childHandler->IsSelected())
+ {
+ needsRefresh ++;
+ OnItemSelect(item, FALSE);
+ childHandler->SelectItem(FALSE);
+ }
+
+ // Get X,Y and WIDTH,HEIGHT of the widget to be able
+ // to determine if any portion of it is within the bounded
+ // area
+ childHandler->handlerControl->GetPosition(&xpos, &ypos);
+ childHandler->handlerControl->GetSize(&width, &height);
+
+ // Check if the current widget is inside the rectangle
+ // that was just bounded
+ if (xpos >= upperLeftX && xpos <= lowerRightX)
+ {
+ if (ypos >= upperLeftY && ypos <= lowerRightY)
+ widgetWithinBounds = TRUE;
+ else if (ypos+height >= upperLeftY && ypos+height <= lowerRightY)
+ widgetWithinBounds = TRUE;
+ }
+ else if (xpos+width >= upperLeftX && xpos <= lowerRightX)
+ {
+ if (ypos >= upperLeftY && ypos <= lowerRightY)
+ widgetWithinBounds = TRUE;
+ else if (ypos+height >= upperLeftY && ypos+height <= lowerRightY)
+ widgetWithinBounds = TRUE;
+ }
+
+ if (widgetWithinBounds)
+ {
+ childHandler->SelectItem(TRUE);
+ OnItemSelect(item, TRUE);
+
+// childHandler->DrawSelectionHandles(dc);
+ }
+
+ }
+ node = node->Next();
+ }
+
+ OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, NULL);
+ OnDragEnd(x, y, keys, dc, NULL);
+
+ if (needsRefresh > 0)
+ {
+ dc.Clear();
+ handlerDialog->Refresh();
+ }
+
+ // Always paint, in case the bounding box overlapped with
+ // the handles of any selected widgets, that way when the
+ // bounding box is cleared, the handles don't get partially
+ // erased where the overlap occured
+ PaintSelectionHandles(dc);
+
+ dragMode = wxDRAG_MODE_NONE;
+ checkTolerance = TRUE;
+ dragItem = NULL;
+ dragType = wxDRAG_TYPE_NONE;
+ }
+ else
+ OnLeftClick(x, y, keys);
+ }
+ else if (event.RightDown())
+ {
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
+
+ OnRightClick(x, y, keys);
+ }
+ else if (event.LeftDClick())
+ {
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
+ wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog);