#include "winprop.h"
#include "editrpal.h"
#include "dlghndlr.h"
-
-extern void wxResourceEditWindow(wxWindow *win);
+#include "edlist.h"
IMPLEMENT_CLASS(wxResourceEditorDialogHandler, wxEvtHandler)
IMPLEMENT_CLASS(wxResourceEditorControlHandler, wxEvtHandler)
oldDragY = 0;
dragTolerance = 3;
checkTolerance = TRUE;
+ m_mouseCaptured = FALSE;
+// m_treeItem = 0;
+}
+
+wxResourceEditorDialogHandler::~wxResourceEditorDialogHandler(void)
+{
}
void wxResourceEditorDialogHandler::OnItemSelect(wxControl *item, bool select)
resourceManager->RemoveSelection(item);
}
-bool wxResourceEditorDialogHandler::OnClose(void)
-{
- handlerDialog->PopEventHandler();
-
- // Now reset all child event handlers
- wxNode *node = handlerDialog->GetChildren()->First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- wxEvtHandler *childHandler = child->GetEventHandler();
- if ( child->IsKindOf(CLASSINFO(wxControl)) && childHandler != child )
- {
- child->PopEventHandler();
- delete childHandler;
- }
- node = node->Next();
- }
-
- // Save the information before deleting the dialog.
- resourceManager->InstantiateResourceFromWindow(handlerResource, handlerDialog, TRUE);
-
- resourceManager->DisassociateResource(handlerDialog, FALSE);
-
- handlerDialog->Show(FALSE);
- delete this;
- return TRUE;
-}
-
void wxResourceEditorDialogHandler::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(handlerDialog);
{
if (keys & wxKEY_CTRL)
{
- wxResourceEditWindow(handlerDialog);
+ wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog);
+ return;
+ }
+
+ // Deselect all items if click on panel
+ if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() == RESED_POINTER)
+ {
+ int needsRefresh = 0;
+ wxNode *node = handlerDialog->GetChildren()->First();
+ while (node)
+ {
+ wxControl *item = (wxControl *)node->Data();
+ wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
+ if (item->IsKindOf(CLASSINFO(wxControl)) && childHandler->IsSelected())
+ {
+ needsRefresh ++;
+ OnItemSelect(item, FALSE);
+ childHandler->SelectItem(FALSE);
+ }
+ node = node->Next();
+ }
+ if (needsRefresh > 0)
+ {
+ wxClientDC dc(handlerDialog);
+ dc.Clear();
+ handlerDialog->Refresh();
+ }
+ return;
+ }
+
+ wxResourceManager* manager = resourceManager;
+
+ switch (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection())
+ {
+ case RESED_BUTTON:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxButton", x, y);
+ break;
+ case RESED_BMPBUTTON:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxBitmapButton", x, y, TRUE);
+ break;
+ case RESED_STATICTEXT:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticText", x, y);
+ break;
+ case RESED_STATICBMP:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBitmap", x, y, TRUE);
+ break;
+ case RESED_TEXTCTRL_SINGLE:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (single-line)", x, y);
+ break;
+ case RESED_TEXTCTRL_MULTIPLE:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (multi-line)", x, y);
+ break;
+ case RESED_CHOICE:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxChoice", x, y);
+ break;
+ case RESED_CHECKBOX:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxCheckBox", x, y);
+ break;
+ case RESED_RADIOBOX:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxRadioBox", x, y);
+ break;
+ case RESED_LISTBOX:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxListBox", x, y);
+ break;
+ case RESED_SLIDER:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxSlider", x, y);
+ break;
+ case RESED_GAUGE:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxGauge", x, y);
+ break;
+ case RESED_STATICBOX:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBox", x, y);
+ break;
+ case RESED_SCROLLBAR:
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxScrollBar", x, y);
+ break;
+ default:
+ break;
+ }
+
+ // Now switch pointer on.
+ if (wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->GetSelection() != RESED_POINTER)
+ {
+ wxResourceManager::GetCurrentResourceManager()->GetEditorControlList()->SetItemState(RESED_POINTER, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+ }
+}
+
+#if 0
+void wxResourceEditorDialogHandler::OnLeftClick(int x, int y, int keys)
+{
+ if (keys & wxKEY_CTRL)
+ {
+ wxResourceManager::GetCurrentResourceManager()->EditWindow(handlerDialog);
return;
}
return;
}
+ wxResourceManager* manager = resourceManager;
+
switch (resourceManager->GetEditorPalette()->currentlySelected)
{
case PALETTE_FRAME:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxButton", x, y, TRUE);
break;
case PALETTE_MESSAGE:
- resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxMessage", x, y);
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticText", x, y);
break;
case PALETTE_BITMAP_MESSAGE:
- resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxMessage", x, y, TRUE);
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxStaticBitmap", x, y, TRUE);
break;
case PALETTE_TEXT:
- resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxText", x, y);
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (single-line)", x, y);
break;
case PALETTE_MULTITEXT:
- resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxMultiText", x, y);
+ resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxTextCtrl (multi-line)", x, y);
break;
case PALETTE_CHOICE:
resourceManager->CreatePanelItem(handlerResource, handlerDialog, "wxChoice", x, y);
}
// Now switch pointer on.
- if (resourceManager->GetEditorPalette()->currentlySelected != PALETTE_ARROW)
+ if (manager->GetEditorPalette()->currentlySelected != PALETTE_ARROW)
{
- resourceManager->GetEditorPalette()->ToggleTool(resourceManager->GetEditorPalette()->currentlySelected, FALSE);
- resourceManager->GetEditorPalette()->ToggleTool(PALETTE_ARROW, TRUE);
- resourceManager->GetEditorPalette()->currentlySelected = PALETTE_ARROW;
+ manager->GetEditorPalette()->ToggleTool(manager->GetEditorPalette()->currentlySelected, FALSE);
+ manager->GetEditorPalette()->ToggleTool(PALETTE_ARROW, TRUE);
+ manager->GetEditorPalette()->currentlySelected = PALETTE_ARROW;
}
}
+#endif
void wxResourceEditorDialogHandler::OnRightClick(int x, int y, int keys)
{
wxMenu *menu = resourceManager->GetPopupMenu();
menu->SetClientData((char *)handlerDialog);
-#ifdef __MOTIF__
- handlerDialog->FakePopupMenu(menu, x, y);
-#else
handlerDialog->PopupMenu(menu, x, y);
-#endif
}
void wxResourceEditorDialogHandler::OnItemLeftClick(wxControl *item, int x, int y, int keys)
{
if (keys & wxKEY_CTRL)
{
- wxResourceEditWindow(item);
+ wxResourceManager::GetCurrentResourceManager()->EditWindow(item);
return;
}
wxMenu *menu = resourceManager->GetPopupMenu();
menu->SetClientData((char *)item);
-#ifdef __MOTIF__
- handlerDialog->FakePopupMenu(menu, x, y);
-#else
handlerDialog->PopupMenu(menu, x, y);
-#endif
}
// An event outside any items: may be a drag event.
if (event.ControlDown()) keys = keys | wxKEY_CTRL;
if (event.LeftUp())
- OnLeftClick(x, y, keys);
+ {
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
+
+ OnLeftClick(x, y, keys);
+ }
else if (event.RightUp())
- OnRightClick(x, y, keys);
+ {
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
+
+ OnRightClick(x, y, keys);
+ }
}
else
event.Skip();
checkTolerance = FALSE;
}
}
- if (dragging && dragItem && dragMode == wxDRAG_MODE_START_LEFT)
+ if (event.LeftDClick())
+ {
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
+
+ wxResourceManager::GetCurrentResourceManager()->EditWindow(item);
+ }
+ else if (dragging && dragItem && dragMode == wxDRAG_MODE_START_LEFT)
{
dragMode = wxDRAG_MODE_CONTINUE_LEFT;
wxClientDC dc(handlerDialog);
childHandler->OnDragBegin(x, y, keys, dc, selectionHandle);
oldDragX = x; oldDragY = y;
+ if (!m_mouseCaptured)
+ {
+ handlerDialog->CaptureMouse();
+ m_mouseCaptured = TRUE;
+ }
}
else if (dragging && dragItem && dragMode == wxDRAG_MODE_CONTINUE_LEFT)
{
wxClientDC dc(handlerDialog);
dragMode = wxDRAG_MODE_NONE;
checkTolerance = TRUE;
+
childHandler->OnDragContinue(FALSE, oldDragX, oldDragY, keys, dc, selectionHandle);
childHandler->OnDragEnd(x, y, keys, dc, selectionHandle);
+
dragItem = NULL;
dragType = wxDRAG_TYPE_NONE;
+
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
}
else if (dragging && dragItem && dragMode == wxDRAG_MODE_START_RIGHT)
{
dragMode = wxDRAG_MODE_CONTINUE_RIGHT;
childHandler->OnDragBegin(x, y, keys, dc, selectionHandle);
oldDragX = x; oldDragY = y;
+
+ if (!m_mouseCaptured)
+ {
+ handlerDialog->CaptureMouse();
+ m_mouseCaptured = TRUE;
+ }
}
else if (dragging && dragItem && dragMode == wxDRAG_MODE_CONTINUE_RIGHT)
{
checkTolerance = TRUE;
dragItem = NULL;
dragType = wxDRAG_TYPE_NONE;
+
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
}
else if (event.IsButton())
{
firstDragX = x;
firstDragY = y;
dragType = selectionHandle;
+
+ if (!m_mouseCaptured)
+ {
+ handlerDialog->CaptureMouse();
+ m_mouseCaptured = TRUE;
+ }
}
else if (event.RightDown())
{
firstDragX = x;
firstDragY = y;
dragType = selectionHandle;
+
+ if (!m_mouseCaptured)
+ {
+ handlerDialog->CaptureMouse();
+ m_mouseCaptured = TRUE;
+ }
}
else if (event.LeftUp())
{
OnLeftClick(x, y, keys);
dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE;
+
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
}
else if (event.RightUp())
{
OnRightClick(x, y, keys);
dragItem = NULL; dragMode = wxDRAG_MODE_NONE; dragType = wxDRAG_TYPE_NONE;
+
+ if (m_mouseCaptured)
+ {
+ handlerDialog->ReleaseMouse();
+ m_mouseCaptured = FALSE;
+ }
}
}
}
isSelected = FALSE;
dragOffsetX = 0;
dragOffsetY = 0;
+// m_treeItem = 0;
+}
+
+wxResourceEditorControlHandler::~wxResourceEditorControlHandler(void)
+{
}
/*
dc.SetLogicalFunction(wxXOR);
- dc.SetPen(wxBLACK_DASHED_PEN);
+ wxPen pen(wxColour(0, 0, 0), 1, wxDOT);
+ dc.SetPen(pen);
dc.SetBrush(wxTRANSPARENT_BRUSH);
dc.SetOptimization(TRUE);
dc.BeginDrawing();
dc.SetLogicalFunction(wxXOR);
- dc.SetPen(wxBLACK_DASHED_PEN);
+ wxPen pen(wxColour(0, 0, 0), 1, wxDOT);
+ dc.SetPen(pen);
dc.SetBrush(wxTRANSPARENT_BRUSH);
DrawBoundingBox(dc, x1, y1, width1, height1);
else
{
dc.BeginDrawing();
-
dc.SetLogicalFunction(wxXOR);
- dc.SetPen(wxBLACK_DASHED_PEN);
+ wxPen pen(wxColour(0, 0, 0), 1, wxDOT);
+ dc.SetPen(pen);
dc.SetBrush(wxTRANSPARENT_BRUSH);
DrawBoundingBox(dc, (int)(x - dragOffsetX), (int)(y - dragOffsetY), width, height);
}
node = node->Next();
}
-
dc.EndDrawing();
}
}
node = node->Next();
}
}
-
dc.SetOptimization(FALSE);
dc.SetLogicalFunction(wxCOPY);
// by default.
void wxResourceEditorControlHandler::OnMouseEvent(wxMouseEvent& event)
{
+/*
if ((event.m_eventType == wxEVENT_TYPE_LEFT_DCLICK) ||
(event.m_eventType == wxEVENT_TYPE_RIGHT_DCLICK))
return;
+*/
wxWindow *panel = handlerControl->GetParent();
if ( !panel->GetEventHandler()->IsKindOf(CLASSINFO(wxResourceEditorDialogHandler)) )
return;