Added wxAUI_MGR_LIVE_RESIZE flag for live sash sizing, the default on wxMac/CG

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@57885 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2009-01-07 14:51:49 +00:00
parent 6c03c30fe9
commit 04355fb016
6 changed files with 286 additions and 228 deletions

View File

@@ -121,6 +121,8 @@ All (GUI):
- Fixed wxHTML's line breaks handling in <pre> blocks broken in 2.8.8 (#10120). - Fixed wxHTML's line breaks handling in <pre> blocks broken in 2.8.8 (#10120).
- wxHTML: don't include extra whitespace in table cells. - wxHTML: don't include extra whitespace in table cells.
- Implemented wxWindow::DragAcceptFiles() on all platforms. - Implemented wxWindow::DragAcceptFiles() on all platforms.
- Added wxAUI_MGR_LIVE_RESIZE flag to wxAuiManager and made it the default on
wxMac with CoreGraphics where sash drawing isn't implemented.
All (Unix): All (Unix):

View File

@@ -109,6 +109,7 @@ enum wxAuiManagerOption
wxAUI_MGR_RECTANGLE_HINT = 1 << 5, wxAUI_MGR_RECTANGLE_HINT = 1 << 5,
wxAUI_MGR_HINT_FADE = 1 << 6, wxAUI_MGR_HINT_FADE = 1 << 6,
wxAUI_MGR_NO_VENETIAN_BLINDS_FADE = 1 << 7, wxAUI_MGR_NO_VENETIAN_BLINDS_FADE = 1 << 7,
wxAUI_MGR_LIVE_RESIZE = 1 << 8,
wxAUI_MGR_DEFAULT = wxAUI_MGR_ALLOW_FLOATING | wxAUI_MGR_DEFAULT = wxAUI_MGR_ALLOW_FLOATING |
wxAUI_MGR_TRANSPARENT_HINT | wxAUI_MGR_TRANSPARENT_HINT |

View File

@@ -47,6 +47,7 @@ enum wxAuiManagerOption
wxAUI_MGR_RECTANGLE_HINT = 1 << 5, wxAUI_MGR_RECTANGLE_HINT = 1 << 5,
wxAUI_MGR_HINT_FADE = 1 << 6, wxAUI_MGR_HINT_FADE = 1 << 6,
wxAUI_MGR_NO_VENETIAN_BLINDS_FADE = 1 << 7, wxAUI_MGR_NO_VENETIAN_BLINDS_FADE = 1 << 7,
wxAUI_MGR_LIVE_RESIZE = 1 << 8,
wxAUI_MGR_DEFAULT = wxAUI_MGR_ALLOW_FLOATING | wxAUI_MGR_DEFAULT = wxAUI_MGR_ALLOW_FLOATING |
wxAUI_MGR_TRANSPARENT_HINT | wxAUI_MGR_TRANSPARENT_HINT |
@@ -559,6 +560,10 @@ protected:
wxArrayInt& positions, wxArrayInt& positions,
wxArrayInt& sizes); wxArrayInt& sizes);
#if wxABI_VERSION >= 20810
/// Ends a resize action, or for live update, resizes the sash
bool DoEndResizeAction(wxMouseEvent& event);
#endif
public: public:

View File

@@ -84,6 +84,7 @@ class MyFrame : public wxFrame
ID_NoGradient, ID_NoGradient,
ID_VerticalGradient, ID_VerticalGradient,
ID_HorizontalGradient, ID_HorizontalGradient,
ID_LiveUpdate,
ID_Settings, ID_Settings,
ID_CustomizeToolbar, ID_CustomizeToolbar,
ID_DropDownToolbarItem, ID_DropDownToolbarItem,
@@ -588,6 +589,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_HintFade, MyFrame::OnManagerFlag) EVT_MENU(ID_HintFade, MyFrame::OnManagerFlag)
EVT_MENU(ID_NoVenetianFade, MyFrame::OnManagerFlag) EVT_MENU(ID_NoVenetianFade, MyFrame::OnManagerFlag)
EVT_MENU(ID_TransparentDrag, MyFrame::OnManagerFlag) EVT_MENU(ID_TransparentDrag, MyFrame::OnManagerFlag)
EVT_MENU(ID_LiveUpdate, MyFrame::OnManagerFlag)
EVT_MENU(ID_AllowActivePane, MyFrame::OnManagerFlag) EVT_MENU(ID_AllowActivePane, MyFrame::OnManagerFlag)
EVT_MENU(ID_NotebookTabFixedWidth, MyFrame::OnNotebookFlag) EVT_MENU(ID_NotebookTabFixedWidth, MyFrame::OnNotebookFlag)
EVT_MENU(ID_NotebookNoCloseButton, MyFrame::OnNotebookFlag) EVT_MENU(ID_NotebookNoCloseButton, MyFrame::OnNotebookFlag)
@@ -634,6 +636,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_UPDATE_UI(ID_HintFade, MyFrame::OnUpdateUI) EVT_UPDATE_UI(ID_HintFade, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_NoVenetianFade, MyFrame::OnUpdateUI) EVT_UPDATE_UI(ID_NoVenetianFade, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_TransparentDrag, MyFrame::OnUpdateUI) EVT_UPDATE_UI(ID_TransparentDrag, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_LiveUpdate, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_NoGradient, MyFrame::OnUpdateUI) EVT_UPDATE_UI(ID_NoGradient, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_VerticalGradient, MyFrame::OnUpdateUI) EVT_UPDATE_UI(ID_VerticalGradient, MyFrame::OnUpdateUI)
EVT_UPDATE_UI(ID_HorizontalGradient, MyFrame::OnUpdateUI) EVT_UPDATE_UI(ID_HorizontalGradient, MyFrame::OnUpdateUI)
@@ -696,6 +699,7 @@ MyFrame::MyFrame(wxWindow* parent,
options_menu->AppendCheckItem(ID_NoVenetianFade, _("Disable Venetian Blinds Hint Fade-in")); options_menu->AppendCheckItem(ID_NoVenetianFade, _("Disable Venetian Blinds Hint Fade-in"));
options_menu->AppendCheckItem(ID_TransparentDrag, _("Transparent Drag")); options_menu->AppendCheckItem(ID_TransparentDrag, _("Transparent Drag"));
options_menu->AppendCheckItem(ID_AllowActivePane, _("Allow Active Pane")); options_menu->AppendCheckItem(ID_AllowActivePane, _("Allow Active Pane"));
options_menu->AppendCheckItem(ID_LiveUpdate, _("Live Resize Update"));
options_menu->AppendSeparator(); options_menu->AppendSeparator();
options_menu->AppendRadioItem(ID_NoGradient, _("No Caption Gradient")); options_menu->AppendRadioItem(ID_NoGradient, _("No Caption Gradient"));
options_menu->AppendRadioItem(ID_VerticalGradient, _("Vertical Caption Gradient")); options_menu->AppendRadioItem(ID_VerticalGradient, _("Vertical Caption Gradient"));
@@ -1075,6 +1079,7 @@ void MyFrame::OnManagerFlag(wxCommandEvent& event)
case ID_TransparentHint: flag = wxAUI_MGR_TRANSPARENT_HINT; break; case ID_TransparentHint: flag = wxAUI_MGR_TRANSPARENT_HINT; break;
case ID_VenetianBlindsHint: flag = wxAUI_MGR_VENETIAN_BLINDS_HINT; break; case ID_VenetianBlindsHint: flag = wxAUI_MGR_VENETIAN_BLINDS_HINT; break;
case ID_RectangleHint: flag = wxAUI_MGR_RECTANGLE_HINT; break; case ID_RectangleHint: flag = wxAUI_MGR_RECTANGLE_HINT; break;
case ID_LiveUpdate: flag = wxAUI_MGR_LIVE_RESIZE; break;
} }
if (flag) if (flag)
@@ -1188,6 +1193,9 @@ void MyFrame::OnUpdateUI(wxUpdateUIEvent& event)
case ID_TransparentHint: case ID_TransparentHint:
event.Check((flags & wxAUI_MGR_TRANSPARENT_HINT) != 0); event.Check((flags & wxAUI_MGR_TRANSPARENT_HINT) != 0);
break; break;
case ID_LiveUpdate:
event.Check((flags & wxAUI_MGR_LIVE_RESIZE) != 0);
break;
case ID_VenetianBlindsHint: case ID_VenetianBlindsHint:
event.Check((flags & wxAUI_MGR_VENETIAN_BLINDS_HINT) != 0); event.Check((flags & wxAUI_MGR_VENETIAN_BLINDS_HINT) != 0);
break; break;

View File

@@ -720,6 +720,17 @@ unsigned int wxAuiManager::GetFlags() const
return m_flags; return m_flags;
} }
// Convenience function
bool wxAuiManager_HasLiveResize(wxAuiManager& manager)
{
// With Core Graphics on Mac, it's not possible to show sash feedback,
// so we'll always use live update instead.
#if defined(__WXMAC__) && wxMAC_USE_CORE_GRAPHICS
return true;
#else
return (manager.GetFlags() & wxAUI_MGR_LIVE_RESIZE) == wxAUI_MGR_LIVE_RESIZE;
#endif
}
// don't use these anymore as they are deprecated // don't use these anymore as they are deprecated
// use Set/GetManagedFrame() instead // use Set/GetManagedFrame() instead
@@ -3911,8 +3922,11 @@ void wxAuiManager::UpdateButtonOnScreen(wxAuiDockUIPart* button_ui_part,
} }
} }
static int gs_CurrentDragItem = -1;
void wxAuiManager::OnLeftDown(wxMouseEvent& event) void wxAuiManager::OnLeftDown(wxMouseEvent& event)
{ {
gs_CurrentDragItem = -1;
wxAuiDockUIPart* part = HitTest(event.GetX(), event.GetY()); wxAuiDockUIPart* part = HitTest(event.GetX(), event.GetY());
if (part) if (part)
{ {
@@ -4006,26 +4020,9 @@ void wxAuiManager::OnLeftDown(wxMouseEvent& event)
#endif #endif
} }
/// Ends a resize action, or for live update, resizes the sash
void wxAuiManager::OnLeftUp(wxMouseEvent& event) bool wxAuiManager::DoEndResizeAction(wxMouseEvent& event)
{ {
if (m_action == actionResize)
{
m_frame->ReleaseMouse();
// get rid of the hint rectangle
// On Mac we use a wxClientDC since when compiling and running on Leopard,
// we can get the dreaded _SetDstBlits32BGRA crash (but not in the AUI sample).
// This only helps in non-CG mode - there is zero resize feeedback in CG mode
// at present.
#if defined(__WXMAC__) && !wxMAC_USE_CORE_GRAPHICS
wxClientDC dc(m_frame);
#else
wxScreenDC dc;
#endif
DrawResizeHint(dc, m_action_hintrect);
// resize the dock or the pane // resize the dock or the pane
if (m_action_part && m_action_part->type==wxAuiDockUIPart::typeDockSizer) if (m_action_part && m_action_part->type==wxAuiDockUIPart::typeDockSizer)
{ {
@@ -4147,7 +4144,7 @@ void wxAuiManager::OnLeftUp(wxMouseEvent& event)
if (dock_pixels == 0 || total_proportion == 0 || borrow_pane == -1) if (dock_pixels == 0 || total_proportion == 0 || borrow_pane == -1)
{ {
m_action = actionNone; m_action = actionNone;
return; return false;
} }
// calculate the new proportion of the pane // calculate the new proportion of the pane
@@ -4205,6 +4202,37 @@ void wxAuiManager::OnLeftUp(wxMouseEvent& event)
Update(); Update();
Repaint(NULL); Repaint(NULL);
} }
return true;
}
void wxAuiManager::OnLeftUp(wxMouseEvent& event)
{
if (m_action == actionResize)
{
m_frame->ReleaseMouse();
// get rid of the hint rectangle
// On non-CG Mac we use a wxClientDC since when compiling and running on Leopard,
// we can get the dreaded _SetDstBlits32BGRA crash (but not in the AUI sample).
// In CG mode we always use live resize since DrawResizeHint doesn't work.
if (!wxAuiManager_HasLiveResize(*this))
{
// get rid of the hint rectangle
#if defined(__WXMAC__) && !wxMAC_USE_CORE_GRAPHICS
wxClientDC dc(m_frame);
#else
wxScreenDC dc;
#endif
DrawResizeHint(dc, m_action_hintrect);
}
if (gs_CurrentDragItem != -1 && wxAuiManager_HasLiveResize(*this))
m_action_part = & (m_uiparts.Item(gs_CurrentDragItem));
DoEndResizeAction(event);
gs_CurrentDragItem = -1;
} }
else if (m_action == actionClickButton) else if (m_action == actionClickButton)
{ {
@@ -4287,6 +4315,13 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
if (m_action == actionResize) if (m_action == actionResize)
{ {
// It's necessary to reset m_action_part since it destroyed
// by the Update within DoEndResizeAction.
if (gs_CurrentDragItem != -1)
m_action_part = & (m_uiparts.Item(gs_CurrentDragItem));
else
gs_CurrentDragItem = m_uiparts.Index(* m_action_part);
if (m_action_part) if (m_action_part)
{ {
wxPoint pos = m_action_part->rect.GetPosition(); wxPoint pos = m_action_part->rect.GetPosition();
@@ -4295,10 +4330,15 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
else else
pos.x = wxMax(0, event.m_x - m_action_offset.x); pos.x = wxMax(0, event.m_x - m_action_offset.x);
// On Mac we use a wxClientDC since when compiling and running on Leopard, if (wxAuiManager_HasLiveResize(*this))
// we can get the dreaded _SetDstBlits32BGRA crash (but not in the AUI sample). {
// This only helps in non-CG mode - there is zero resize feeedback in CG mode
// at present. m_frame->ReleaseMouse();
DoEndResizeAction(event);
m_frame->CaptureMouse();
}
else
{
#if defined(__WXMAC__) && !wxMAC_USE_CORE_GRAPHICS #if defined(__WXMAC__) && !wxMAC_USE_CORE_GRAPHICS
wxRect rect(pos, wxRect rect(pos,
m_action_part->rect.GetSize()); m_action_part->rect.GetSize());
@@ -4315,6 +4355,7 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
m_action_hintrect = rect; m_action_hintrect = rect;
} }
} }
}
else if (m_action == actionClickCaption) else if (m_action == actionClickCaption)
{ {
int drag_x_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_X); int drag_x_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_X);

View File

@@ -26,6 +26,7 @@
# public symbols added in 2.8.10 (please keep in alphabetical order): # public symbols added in 2.8.10 (please keep in alphabetical order):
@WX_VERSION_TAG@.10 { @WX_VERSION_TAG@.10 {
*wxArtProvider*PushBack*; *wxArtProvider*PushBack*;
*wxAui*DoEndResizeAction*;
*wxCArrayString*Release*; *wxCArrayString*Release*;
*wxDCBase*GetFontPointSizeAdjustment*; *wxDCBase*GetFontPointSizeAdjustment*;
*wxWindowBase*DragAcceptFiles*; *wxWindowBase*DragAcceptFiles*;