#include <math.h>
#include <string.h>
+#if wxUSE_IOSTREAMH
#if defined(__WXMSW__) && !defined(__GNUWIN32__)
#include <strstrea.h>
#else
#include <strstream.h>
#endif
+#else
+#include <strstream>
+#endif
#include "reseditr.h"
#include "winprop.h"
BEGIN_EVENT_TABLE(wxResourceEditorDialogHandler, wxEvtHandler)
EVT_PAINT(wxResourceEditorDialogHandler::OnPaint)
EVT_MOUSE_EVENTS(wxResourceEditorDialogHandler::OnMouseEvent)
+ EVT_SIZE(wxResourceEditorDialogHandler::OnSize)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxResourceEditorControlHandler, wxEvtHandler)
handlerDialog->PopupMenu(menu, x, y);
}
+// Under Windows 95, you can resize a panel interactively depending on
+// window styles.
+void wxResourceEditorDialogHandler::OnSize(wxSizeEvent& event)
+{
+ // Update the associated resource
+ int w, h;
+ handlerDialog->GetClientSize(& w, & h);
+
+ wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerDialog);
+ if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxSize sz = handlerDialog->ConvertPixelsToDialog(wxSize(w, h));
+ w = sz.x; h = sz.y;
+ }
+ resource->SetSize(resource->GetX(), resource->GetY(), w, h);
+}
+
// An event outside any items: may be a drag event.
void wxResourceEditorDialogHandler::OnMouseEvent(wxMouseEvent& event)
{
OnRightClick(x, y, keys);
}
+ else if (event.LeftDClick())
+ {
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
+ wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog);
+ }
}
else
event.Skip();
handlerControl->GetPosition(&xpos, &ypos);
handlerControl->GetSize(&width, &height);
+ wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl);
+ wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(handlerControl->GetParent());
+
if (selectionHandle > 0)
{
int x1, y1, width1, height1;
break;
}
handlerControl->SetSize(x1, y1, width1, height1);
+
+ // Also update the associated resource
+ // We need to convert to dialog units if this is not a dialog or panel, but
+ // the parent resource specifies dialog units.
+ if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(x1, y1));
+ x1 = pt.x; y1 = pt.y;
+ wxSize sz = handlerControl->GetParent()->ConvertPixelsToDialog(wxSize(width1, height1));
+ width1 = sz.x; height1 = sz.y;
+ }
+ resource->SetSize(x1, y1, width1, height1);
}
else
{
- handlerControl->Move((int)(x - dragOffsetX), (int)(y - dragOffsetY));
- OldOnMove((int)(x - dragOffsetX), (int)(y - dragOffsetY));
+ int newX = (int)(x - dragOffsetX);
+ int newY = (int)(y - dragOffsetY);
+ handlerControl->Move(newX, newY);
+ OldOnMove(newX, newY);
+
+ // Also update the associated resource
+ if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxPoint pt = handlerControl->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY));
+ newX = pt.x; newY = pt.y;
+ }
+ resource->SetSize(newX, newY, resource->GetWidth(), resource->GetHeight());
// Also move other selected items
wxNode *node = panel->GetChildren()->First();
item->Move(x2, y2);
((wxResourceEditorControlHandler *)item->GetEventHandler())->OldOnMove(x2, y2);
((wxResourceEditorControlHandler *)item->GetEventHandler())->DrawSelectionHandles(dc);
+
+ // Also update the associated resource
+ resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item);
+ if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxPoint pt = item->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY));
+ x2 = pt.x; y2 = pt.y;
+ }
+ resource->SetSize(x2, y2, resource->GetWidth(), resource->GetHeight());
+
}
}
node = node->Next();