#include "wx/renderer.h"
#include "wx/graphics.h"
#include "wx/dcgraph.h"
+#include "wx/splitter.h"
#include "wx/osx/private.h"
#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
#endif // wxHAS_DRAW_TITLE_BAR_BITMAP
-// check if we're currently in a paint event
-inline bool wxInPaintEvent(wxWindow* win, wxDC& dc)
+// check if we're having a CGContext we can draw into
+inline bool wxHasCGContext(wxWindow* WXUNUSED(win), wxDC& dc)
{
- if ( win->MacGetCGContextRef() != NULL )
- return true;
-
wxGCDCImpl* gcdc = wxDynamicCast( dc.GetImpl() , wxGCDCImpl);
if ( gcdc )
if ( gcdc->GetGraphicsContext()->GetNativeContext() )
return true;
}
- /*
- return win->MacGetCGContextRef() != NULL ||
- // wxMemoryDC's also have a valid CGContext.
- dc.IsKindOf( CLASSINFO(wxMemoryDC) );
- */
return false;
}
int flags = 0);
#endif // wxHAS_DRAW_TITLE_BAR_BITMAP
+ virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
+
private:
void DrawMacThemeButton(wxWindow *win,
wxDC& dc,
dc.SetBrush( *wxTRANSPARENT_BRUSH );
HIRect headerRect = CGRectMake( x, y, w, h );
- if ( !wxInPaintEvent(win, dc) )
+ if ( !wxHasCGContext(win, dc) )
{
win->Refresh( &rect );
}
dc.SetBrush( *wxTRANSPARENT_BRUSH );
HIRect headerRect = CGRectMake( x, y, w, h );
- if ( !wxInPaintEvent(win, dc) )
+ if ( !wxHasCGContext(win, dc) )
{
win->Refresh( &rect );
}
}
}
+wxSplitterRenderParams
+wxRendererMac::GetSplitterParams(const wxWindow *win)
+{
+ // see below
+ SInt32 sashWidth,
+ border;
+#if wxOSX_USE_COCOA
+ if ( win->HasFlag(wxSP_3DSASH) )
+ GetThemeMetric( kThemeMetricPaneSplitterHeight, &sashWidth ); // Cocoa == Carbon == 7
+ else if ( win->HasFlag(wxSP_NOSASH) ) // actually Cocoa doesn't allow 0
+ sashWidth = 0;
+ else // no 3D effect - Cocoa [NSSplitView dividerThickNess] for NSSplitViewDividerStyleThin
+ sashWidth = 1;
+#else // Carbon
+ if ( win->HasFlag(wxSP_3DSASH) )
+ GetThemeMetric( kThemeMetricPaneSplitterHeight, &sashWidth );
+ else if ( win->HasFlag(wxSP_NOSASH) )
+ sashWidth = 0;
+ else // no 3D effect
+ GetThemeMetric( kThemeMetricSmallPaneSplitterHeight, &sashWidth );
+#endif // Cocoa/Carbon
+
+ if ( win->HasFlag(wxSP_3DBORDER) )
+ border = 2;
+ else // no 3D effect
+ border = 0;
+
+ return wxSplitterRenderParams(sashWidth, border, false);
+}
+
+
void wxRendererMac::DrawSplitterSash( wxWindow *win,
wxDC& dc,
const wxSize& size,
{
bool hasMetal = win->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL;
SInt32 height;
- GetThemeMetric( kThemeMetricSmallPaneSplitterHeight, &height );
+
+ height = wxRendererNative::Get().GetSplitterParams(win).widthSash;
+
HIRect splitterRect;
if (orient == wxVERTICAL)
splitterRect = CGRectMake( position, 0, height, size.y );
// under compositing we should only draw when called by the OS, otherwise just issue a redraw command
// strange redraw errors occur if we don't do this
- if ( !wxInPaintEvent(win, dc) )
+ if ( !wxHasCGContext(win, dc) )
{
wxRect rect( (int) splitterRect.origin.x, (int) splitterRect.origin.y, (int) splitterRect.size.width,
(int) splitterRect.size.height );
CGContextFillRect(cgContext,splitterRect);
}
- HIThemeSplitterDrawInfo drawInfo;
- drawInfo.version = 0;
- drawInfo.state = kThemeStateActive;
- drawInfo.adornment = hasMetal ? kHIThemeSplitterAdornmentMetal : kHIThemeSplitterAdornmentNone;
- HIThemeDrawPaneSplitter( &splitterRect, &drawInfo, cgContext, kHIThemeOrientationNormal );
+ if ( win->HasFlag(wxSP_3DSASH) )
+ {
+ HIThemeSplitterDrawInfo drawInfo;
+ drawInfo.version = 0;
+ drawInfo.state = kThemeStateActive;
+ drawInfo.adornment = hasMetal ? kHIThemeSplitterAdornmentMetal : kHIThemeSplitterAdornmentNone;
+ HIThemeDrawPaneSplitter( &splitterRect, &drawInfo, cgContext, kHIThemeOrientationNormal );
+ }
}
}
dc.SetBrush( *wxTRANSPARENT_BRUSH );
HIRect headerRect = CGRectMake( x, y, w, h );
- if ( !wxInPaintEvent(win, dc) )
+ if ( !wxHasCGContext(win, dc) )
{
win->Refresh( &rect );
}
dc.SetBrush( *wxTRANSPARENT_BRUSH );
HIRect hiRect = CGRectMake( x, y, w, h );
- if ( !wxInPaintEvent(win, dc) )
+ if ( !wxHasCGContext(win, dc) )
{
win->Refresh( &rect );
}