#include "wx/aui/framemanager.h"
#include "wx/aui/dockart.h"
#include "wx/aui/floatpane.h"
+#include "wx/aui/tabmdi.h"
#ifndef WX_PRECOMP
#include "wx/panel.h"
#include "wx/mac/private.h"
#endif
+#ifdef __WXMSW__
+ #include "wx/msw/wrapwin.h"
+ #include "wx/msw/private.h"
+#endif
+
IMPLEMENT_DYNAMIC_CLASS(wxAuiManagerEvent, wxEvent)
IMPLEMENT_CLASS(wxAuiManager, wxEvtHandler)
const int auiToolBarLayer = 10;
+#ifndef __WXGTK20__
+
class wxPseudoTransparentFrame : public wxFrame
{
wxRect rect(upd.GetRect());
dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
- upd++;
+ ++upd;
}
}
END_EVENT_TABLE()
+#else
+ // __WXGTK20__
+
+#include "wx/gtk/private.h"
+
+static void
+gtk_pseudo_window_realized_callback( GtkWidget *m_widget, void *WXUNUSED(win) )
+{
+ wxSize disp = wxGetDisplaySize();
+ int amount = 128;
+ wxRegion region;
+ for (int y=0; y<disp.y; y++)
+ {
+ // Reverse the order of the bottom 4 bits
+ int j=((y&8)?1:0)|((y&4)?2:0)|((y&2)?4:0)|((y&1)?8:0);
+ if ((j*16+8)<amount)
+ region.Union(0, y, disp.x, 1);
+ }
+ gdk_window_shape_combine_region(m_widget->window, region.GetRegion(), 0, 0);
+}
+
+
+class wxPseudoTransparentFrame: public wxFrame
+{
+public:
+ wxPseudoTransparentFrame(wxWindow* parent = NULL,
+ wxWindowID id = wxID_ANY,
+ const wxString& title = wxEmptyString,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxDEFAULT_FRAME_STYLE,
+ const wxString &name = wxT("frame"))
+ {
+ if (!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
+ return;
+
+ m_title = title;
+
+ m_widget = gtk_window_new( GTK_WINDOW_POPUP );
+
+ g_signal_connect( m_widget, "realize",
+ G_CALLBACK (gtk_pseudo_window_realized_callback), this );
+
+ GdkColor col;
+ col.red = 128 * 256;
+ col.green = 192 * 256;
+ col.blue = 255 * 256;
+ gtk_widget_modify_bg( m_widget, GTK_STATE_NORMAL, &col );
+ }
+
+ bool SetTransparent(wxByte WXUNUSED(alpha))
+ {
+ return true;
+ }
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxPseudoTransparentFrame)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxPseudoTransparentFrame, wxFrame)
+
+#endif
+ // __WXGTK20__
+
+
+
// -- static utility functions --
static wxBitmap wxPaneCreateStippleBitmap()
wxBitmap stipple = wxPaneCreateStippleBitmap();
wxBrush brush(stipple);
dc.SetBrush(brush);
+#ifdef __WXMSW__
+ PatBlt(GetHdcOf(dc), rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight(), PATINVERT);
+#else
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetLogicalFunction(wxXOR);
dc.DrawRectangle(rect);
+#endif
}
}
}
+/*
+// This function works fine, and may be used in the future
+
// RenumberDockRows() takes a dock and assigns sequential numbers
// to existing rows. Basically it takes out the gaps; so if a
// dock has rows with numbers 0,2,5, they will become 0,1,2
static void RenumberDockRows(wxAuiDockInfoPtrArray& docks)
{
- int i, dock_count, j, pane_count;
+ int i, dock_count;
for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i)
{
wxAuiDockInfo& dock = *docks.Item(i);
dock.dock_row = i;
+
+ int j, pane_count;
for (j = 0, pane_count = dock.panes.GetCount(); j < pane_count; ++j)
dock.panes.Item(j)->dock_row = i;
}
}
+*/
// SetActivePane() sets the active pane, as well as cycles through
wxAuiManager::~wxAuiManager()
{
+ // NOTE: It's possible that the windows have already been destroyed by the
+ // time this dtor is called, so this loop can result in memory access via
+ // invalid pointers, resulting in a crash. So it will be disabled while
+ // waiting for a better solution.
+#if 0
for ( size_t i = 0; i < m_panes.size(); i++ )
{
wxAuiPaneInfo& pinfo = m_panes[i];
if (pinfo.window && !pinfo.window->GetParent())
delete pinfo.window;
}
+#endif
delete m_art;
}
return new wxAuiFloatingFrame(parent, this, pane_info);
}
+bool wxAuiManager::CanDockPanel(const wxAuiPaneInfo & WXUNUSED(p))
+{
+ // if a key modifier is pressed while dragging the frame,
+ // don't dock the window
+ return !(wxGetKeyState(WXK_CONTROL) || wxGetKeyState(WXK_ALT));
+}
+
// GetPane() looks up a wxAuiPaneInfo structure based
// on the supplied window pointer. Upon failure, GetPane()
// returns an empty wxAuiPaneInfo, a condition which can be checked
wxAuiPaneInfo().Name(wxT("mdiclient")).
CenterPane().PaneBorder(false));
}
+ else if (m_frame->IsKindOf(CLASSINFO(wxAuiMDIParentFrame)))
+ {
+ wxAuiMDIParentFrame* mdi_frame = (wxAuiMDIParentFrame*)m_frame;
+ wxAuiMDIClientWindow* client_window = mdi_frame->GetClientWindow();
+ wxASSERT_MSG(client_window, wxT("Client window is NULL!"));
+
+ AddPane(client_window,
+ wxAuiPaneInfo().Name(wxT("mdiclient")).
+ CenterPane().PaneBorder(false));
+ }
+
#endif
UpdateHintWindowConfig();
// I believe this to be the correct action, until
// wxToolBar::GetBestSize() is fixed. Is this assumption
// correct?
- pinfo.best_size.y++;
+ // commented out by JACS 2007-9-08 after having added a pixel in wxMSW's wxToolBar::DoGetBestSize()
+ // pinfo.best_size.y++;
}
if (pinfo.min_size != wxDefaultSize)
return false;
}
-// ClosePane() destroys or hides the pane depending on its
-// flags
+// ClosePane() destroys or hides the pane depending on its flags
void wxAuiManager::ClosePane(wxAuiPaneInfo& pane_info)
{
// if we were maximized, restore
if (!p.IsOk())
{
// the pane window couldn't be found
- // in the existing layout
- return false;
+ // in the existing layout -- skip it
+ continue;
}
p.SafeSet(pane);
-
}
if (update)
dock.fixed = false;
if (!pane.IsToolbar())
dock.toolbar = false;
+ if (pane.HasFlag(wxAuiPaneInfo::optionDockFixed))
+ dock.fixed = true;
if (pane.state & wxAuiPaneInfo::actionPane)
action_pane_marked = true;
}
// find any top docks in this layer
FindDocks(docks, wxAUI_DOCK_TOP, layer, -1, arr);
- RenumberDockRows(arr);
if (!arr.IsEmpty())
{
for (row = 0, row_count = arr.GetCount(); row < row_count; ++row)
// find any left docks in this layer
FindDocks(docks, wxAUI_DOCK_LEFT, layer, -1, arr);
- RenumberDockRows(arr);
if (!arr.IsEmpty())
{
for (row = 0, row_count = arr.GetCount(); row < row_count; ++row)
// find any right docks in this layer
FindDocks(docks, wxAUI_DOCK_RIGHT, layer, -1, arr);
- RenumberDockRows(arr);
if (!arr.IsEmpty())
{
for (row = arr.GetCount()-1; row >= 0; --row)
// find any bottom docks in this layer
FindDocks(docks, wxAUI_DOCK_BOTTOM, layer, -1, arr);
- RenumberDockRows(arr);
if (!arr.IsEmpty())
{
for (row = arr.GetCount()-1; row >= 0; --row)
void wxAuiManager::Update()
{
+ m_hover_button = NULL;
+
wxSizer* sizer;
int i, pane_count = m_panes.GetCount();
p.window->SetSize(1,1);
- // the following block is a workaround for bug #1531361
- // (see wxWidgets sourceforge page). On wxGTK (only), when
- // a frame is shown/hidden, a move event unfortunately
- // also gets fired. Because we may be dragging around
- // a pane, we need to cancel that action here to prevent
- // a spurious crash.
- if (m_action_window == p.frame)
- {
- if (wxWindow::GetCapture() == m_frame)
+ // the following block is a workaround for bug #1531361
+ // (see wxWidgets sourceforge page). On wxGTK (only), when
+ // a frame is shown/hidden, a move event unfortunately
+ // also gets fired. Because we may be dragging around
+ // a pane, we need to cancel that action here to prevent
+ // a spurious crash.
+ if (m_action_window == p.frame)
+ {
+ if (wxWindow::GetCapture() == m_frame)
m_frame->ReleaseMouse();
m_action = actionNone;
- m_action_window = NULL;
- }
+ m_action_window = NULL;
+ }
- // hide the frame
+ // hide the frame
if (p.frame->IsShown())
p.frame->Show(false);
{
// frame already exists, make sure it's position
// and size reflect the information in wxAuiPaneInfo
- if (p.frame->GetPosition() != p.floating_pos)
+ if ((p.frame->GetPosition() != p.floating_pos) || (p.frame->GetSize() != p.floating_size))
{
p.frame->SetSize(p.floating_pos.x, p.floating_pos.y,
p.floating_size.x, p.floating_size.y,
return ProcessDockResult(target, drop);
}
- else
- {
- m_skipping = false;
- }
- if (!m_skipping)
- {
- m_last_rect = part->dock->rect;
- m_last_rect.Inflate( 15, 15 );
- }
+ m_skipping = false;
+
+ m_last_rect = part->dock->rect;
+ m_last_rect.Inflate( 15, 15 );
drop.Dock().
Direction(part->dock->dock_direction).
m_hint_fadeamt = 0;
m_hint_wnd->SetSize(rect);
+ m_hint_wnd->SetTransparent(m_hint_fadeamt);
if (!m_hint_wnd->IsShown())
m_hint_wnd->Show();
if (m_action == actionDragFloatingPane && m_action_window)
m_action_window->SetFocus();
- m_hint_wnd->SetTransparent(m_hint_fadeamt);
m_hint_wnd->Raise();
wxAuiDockUIPartArray uiparts;
wxAuiPaneInfo hint = GetPane(pane_window);
hint.name = wxT("__HINT__");
+ hint.PaneBorder(true);
hint.Show();
if (!hint.IsOk())
// no hint for toolbar floating windows
if (pane.IsToolbar() && m_action == actionDragFloatingPane)
{
- if (m_action == actionDragFloatingPane)
- {
- wxAuiDockInfoArray docks;
- wxAuiPaneInfoArray panes;
- wxAuiDockUIPartArray uiparts;
- wxAuiPaneInfo hint = pane;
+ wxAuiDockInfoArray docks;
+ wxAuiPaneInfoArray panes;
+ wxAuiDockUIPartArray uiparts;
+ wxAuiPaneInfo hint = pane;
- CopyDocksAndPanes(docks, panes, m_docks, m_panes);
+ CopyDocksAndPanes(docks, panes, m_docks, m_panes);
- // find out where the new pane would be
- if (!DoDrop(docks, panes, hint, client_pt))
- return;
- if (hint.IsFloating())
- return;
+ // find out where the new pane would be
+ if (!DoDrop(docks, panes, hint, client_pt))
+ return;
+ if (hint.IsFloating())
+ return;
- pane = hint;
- m_action = actionDragToolbarPane;
- m_action_window = pane.window;
+ pane = hint;
+ m_action = actionDragToolbarPane;
+ m_action_window = pane.window;
- Update();
- }
+ Update();
return;
}
// if a key modifier is pressed while dragging the frame,
// don't dock the window
- if (wxGetKeyState(WXK_CONTROL) || wxGetKeyState(WXK_ALT))
+ if (!CanDockPanel(pane))
{
HideHint();
return;
// if a key modifier is pressed while dragging the frame,
// don't dock the window
- if (!wxGetKeyState(WXK_CONTROL) && !wxGetKeyState(WXK_ALT))
+ if (CanDockPanel(pane))
{
// do the drop calculation
DoDrop(m_docks, m_panes, pane, client_pt, action_offset);
}
else
{
- ClosePane(pane);
+ // close the pane, but check that it
+ // still exists in our pane array first
+ // (the event handler above might have removed it)
+
+ wxAuiPaneInfo& check = GetPane(wnd);
+ if (check.IsOk())
+ {
+ ClosePane(pane);
+ }
}
}
void wxAuiManager::OnFloatingPaneActivated(wxWindow* wnd)
{
- if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE)
+ if ((GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE) && GetPane(wnd).IsOk())
{
- // try to find the pane
- wxASSERT_MSG(GetPane(wnd).IsOk(), wxT("Pane window not found"));
-
SetActivePane(m_panes, wnd);
Repaint();
}
{
// if the frame is about to be deleted, don't bother
if (!m_frame || wxPendingDelete.Member(m_frame))
- return;
-
+ return;
+
wxDC* dc = evt.GetDC();
#ifdef __WXMAC__
{
wxAuiDockUIPart& part = m_uiparts.Item(i);
- // don't draw hidden pane items
- if (part.sizer_item && !part.sizer_item->IsShown())
+ // don't draw hidden pane items or items that aren't windows
+ if (part.sizer_item && ((!part.sizer_item->IsWindow() && !part.sizer_item->IsSpacer() && !part.sizer_item->IsSizer()) || !part.sizer_item->IsShown()))
continue;
switch (part.type)
if (part->type == wxAuiDockUIPart::typeDockSizer ||
part->type == wxAuiDockUIPart::typePaneSizer)
{
- if (part->dock && part->dock->dock_direction == wxAUI_DOCK_CENTER)
- return;
+ // Removing this restriction so that a centre pane can be resized
+ //if (part->dock && part->dock->dock_direction == wxAUI_DOCK_CENTER)
+ // return;
// a dock may not be resized if it has a single
// pane which is not resizable
- if (part->dock && part->dock->dock_direction == wxAUI_DOCK_CENTER)
- return;
-
if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE)
{
// set the caption as active
Repaint();
}
+ if (part->dock && part->dock->dock_direction == wxAUI_DOCK_CENTER)
+ return;
+
m_action = actionClickCaption;
m_action_part = part;
m_action_start = wxPoint(event.m_x, event.m_y);
// active panes are allowed by the owner)
if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE)
{
- if (GetPane(event.GetWindow()).IsOk())
+ wxAuiPaneInfo& pane = GetPane(event.GetWindow());
+ if (pane.IsOk() && (pane.state & wxAuiPaneInfo::optionActive) == 0)
{
SetActivePane(m_panes, event.GetWindow());
m_frame->Refresh();
if (!e.GetVeto())
{
- ClosePane(pane);
+ // close the pane, but check that it
+ // still exists in our pane array first
+ // (the event handler above might have removed it)
+
+ wxAuiPaneInfo& check = GetPane(pane.window);
+ if (check.IsOk())
+ {
+ ClosePane(pane);
+ }
+
Update();
}
}