added wxRendererNative to be used by the generic controls for rendering platfomr-specific parts
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22151 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -38,9 +38,7 @@
|
||||
#include "wx/settings.h"
|
||||
#include "wx/dcclient.h"
|
||||
|
||||
#ifdef __WXMAC__
|
||||
#include "wx/mac/private.h"
|
||||
#endif
|
||||
#include "wx/renderer.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// array types
|
||||
@@ -58,54 +56,6 @@ static const int NO_IMAGE = -1;
|
||||
|
||||
static const int PIXELS_PER_UNIT = 10;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Aqua arrows
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* XPM */
|
||||
static const char *aqua_arrow_right[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"13 11 4 1",
|
||||
" c None",
|
||||
"b c #C0C0C0",
|
||||
"c c #707070",
|
||||
"d c #A0A0A0",
|
||||
/* pixels */
|
||||
" b ",
|
||||
" ddb ",
|
||||
" cccdb ",
|
||||
" cccccd ",
|
||||
" ccccccdb ",
|
||||
" ccccccccd",
|
||||
" ccccccdb ",
|
||||
" cccccb ",
|
||||
" cccdb ",
|
||||
" ddb ",
|
||||
" b "
|
||||
};
|
||||
|
||||
/* XPM */
|
||||
static const char *aqua_arrow_down[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"13 11 4 1",
|
||||
" c None",
|
||||
"b c #C0C0C0",
|
||||
"c c #707070",
|
||||
"d c #A0A0A0",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ",
|
||||
" bdcccccccdb ",
|
||||
" dcccccccd ",
|
||||
" bcccccccb ",
|
||||
" dcccccd ",
|
||||
" bcccccb ",
|
||||
" bcccd ",
|
||||
" dcd ",
|
||||
" bcb ",
|
||||
" d "
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -796,26 +746,11 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent,
|
||||
int major,minor;
|
||||
wxGetOsVersion( &major, &minor );
|
||||
|
||||
if (style & wxTR_HAS_BUTTONS) style |= wxTR_MAC_BUTTONS;
|
||||
if (style & wxTR_HAS_BUTTONS) style &= ~wxTR_HAS_BUTTONS;
|
||||
style &= ~wxTR_LINES_AT_ROOT;
|
||||
style |= wxTR_NO_LINES;
|
||||
if (major < 10)
|
||||
style |= wxTR_ROW_LINES;
|
||||
if (major >= 10)
|
||||
style |= wxTR_AQUA_BUTTONS;
|
||||
#endif
|
||||
|
||||
if (style & wxTR_AQUA_BUTTONS)
|
||||
{
|
||||
m_arrowRight = new wxBitmap( aqua_arrow_right );
|
||||
m_arrowDown = new wxBitmap( aqua_arrow_down );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_arrowRight = NULL;
|
||||
m_arrowDown = NULL;
|
||||
}
|
||||
#endif // __WXMAC__
|
||||
|
||||
wxScrolledWindow::Create( parent, id, pos, size,
|
||||
style|wxHSCROLL|wxVSCROLL, name );
|
||||
@@ -847,9 +782,6 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl()
|
||||
delete m_hilightBrush;
|
||||
delete m_hilightUnfocusedBrush;
|
||||
|
||||
delete m_arrowRight;
|
||||
delete m_arrowDown;
|
||||
|
||||
DeleteAllItems();
|
||||
|
||||
delete m_renameTimer;
|
||||
@@ -2351,101 +2283,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
|
||||
dc.SetPen(m_dottedPen);
|
||||
dc.SetTextForeground(*wxBLACK);
|
||||
|
||||
if (item->HasPlus() && HasButtons()) // should the item show a button?
|
||||
{
|
||||
if (!HasFlag(wxTR_NO_LINES))
|
||||
{
|
||||
if (x > (signed)m_indent)
|
||||
dc.DrawLine(x - m_indent, y_mid, x - 5, y_mid);
|
||||
else if (HasFlag(wxTR_LINES_AT_ROOT))
|
||||
dc.DrawLine(3, y_mid, x - 5, y_mid);
|
||||
dc.DrawLine(x + 5, y_mid, x + m_spacing, y_mid);
|
||||
}
|
||||
|
||||
if (m_imageListButtons != NULL)
|
||||
{
|
||||
// draw the image button here
|
||||
int image_h = 0, image_w = 0, image = wxTreeItemIcon_Normal;
|
||||
if (item->IsExpanded()) image = wxTreeItemIcon_Expanded;
|
||||
if (item->IsSelected())
|
||||
image += wxTreeItemIcon_Selected - wxTreeItemIcon_Normal;
|
||||
m_imageListButtons->GetSize(image, image_w, image_h);
|
||||
int xx = x - (image_w>>1);
|
||||
int yy = y_mid - (image_h>>1);
|
||||
dc.SetClippingRegion(xx, yy, image_w, image_h);
|
||||
m_imageListButtons->Draw(image, dc, xx, yy,
|
||||
wxIMAGELIST_DRAW_TRANSPARENT);
|
||||
dc.DestroyClippingRegion();
|
||||
}
|
||||
else if (HasFlag(wxTR_TWIST_BUTTONS))
|
||||
{
|
||||
// draw the twisty button here
|
||||
|
||||
if (HasFlag(wxTR_AQUA_BUTTONS))
|
||||
{
|
||||
// This causes update problems, so disabling for now.
|
||||
#if 0 // def __WXMAC__
|
||||
wxMacPortSetter helper(&dc) ;
|
||||
wxMacWindowClipper clipper(this) ;
|
||||
wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
|
||||
|
||||
int loc_x = x - 5 ;
|
||||
int loc_y = y_mid - 6 ;
|
||||
MacWindowToRootWindow( & loc_x , & loc_y ) ;
|
||||
Rect bounds = { loc_y , loc_x , loc_y + 18 , loc_x + 12 } ;
|
||||
ThemeButtonDrawInfo info = { kThemeStateActive , item->IsExpanded() ? kThemeDisclosureDown : kThemeDisclosureRight ,
|
||||
kThemeAdornmentNone };
|
||||
DrawThemeButton( &bounds, kThemeDisclosureButton ,
|
||||
&info , NULL , NULL , NULL , NULL ) ;
|
||||
#else
|
||||
if (item->IsExpanded())
|
||||
dc.DrawBitmap( *m_arrowDown, x-5, y_mid-6, TRUE );
|
||||
else
|
||||
dc.DrawBitmap( *m_arrowRight, x-5, y_mid-6, TRUE );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.SetBrush(*m_hilightBrush);
|
||||
dc.SetPen(*wxBLACK_PEN);
|
||||
wxPoint button[3];
|
||||
|
||||
if (item->IsExpanded())
|
||||
{
|
||||
button[0].x = x-5;
|
||||
button[0].y = y_mid-2;
|
||||
button[1].x = x+5;
|
||||
button[1].y = y_mid-2;
|
||||
button[2].x = x;
|
||||
button[2].y = y_mid+3;
|
||||
}
|
||||
else
|
||||
{
|
||||
button[0].y = y_mid-5;
|
||||
button[0].x = x-2;
|
||||
button[1].y = y_mid+5;
|
||||
button[1].x = x-2;
|
||||
button[2].y = y_mid;
|
||||
button[2].x = x+3;
|
||||
}
|
||||
dc.DrawPolygon(3, button);
|
||||
dc.SetPen(m_dottedPen);
|
||||
}
|
||||
}
|
||||
else // if (HasFlag(wxTR_HAS_BUTTONS))
|
||||
{
|
||||
// draw the plus sign here
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
dc.DrawRectangle(x-5, y_mid-4, 11, 9);
|
||||
dc.SetPen(*wxBLACK_PEN);
|
||||
dc.DrawLine(x-2, y_mid, x+3, y_mid);
|
||||
if (!item->IsExpanded())
|
||||
dc.DrawLine(x, y_mid-2, x, y_mid+3);
|
||||
dc.SetPen(m_dottedPen);
|
||||
}
|
||||
}
|
||||
else if (!HasFlag(wxTR_NO_LINES)) // no button; maybe a line?
|
||||
if ( !HasFlag(wxTR_NO_LINES) )
|
||||
{
|
||||
// draw the horizontal line here
|
||||
int x_start = x;
|
||||
@@ -2455,6 +2293,46 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
|
||||
x_start = 3;
|
||||
dc.DrawLine(x_start, y_mid, x + m_spacing, y_mid);
|
||||
}
|
||||
|
||||
// should the item show a button?
|
||||
if ( item->HasPlus() && HasButtons() )
|
||||
{
|
||||
if ( m_imageListButtons )
|
||||
{
|
||||
// draw the image button here
|
||||
int image_h = 0,
|
||||
image_w = 0;
|
||||
int image = item->IsExpanded() ? wxTreeItemIcon_Expanded
|
||||
: wxTreeItemIcon_Normal;
|
||||
if ( item->IsSelected() )
|
||||
image += wxTreeItemIcon_Selected - wxTreeItemIcon_Normal;
|
||||
|
||||
m_imageListButtons->GetSize(image, image_w, image_h);
|
||||
int xx = x - image_w/2;
|
||||
int yy = y_mid - image_h/2;
|
||||
|
||||
wxDCClipper clip(dc, xx, yy, image_w, image_h);
|
||||
m_imageListButtons->Draw(image, dc, xx, yy,
|
||||
wxIMAGELIST_DRAW_TRANSPARENT);
|
||||
}
|
||||
else // no custom buttons
|
||||
{
|
||||
static const int wImage = 10;
|
||||
static const int hImage = 12;
|
||||
|
||||
wxRendererNative::Get().DrawTreeItemButton
|
||||
(
|
||||
this,
|
||||
dc,
|
||||
wxRect(x - wImage/2,
|
||||
y_mid - hImage/2,
|
||||
wImage, hImage),
|
||||
item->IsExpanded()
|
||||
? wxCONTROL_EXPANDED
|
||||
: 0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item->IsExpanded())
|
||||
|
Reference in New Issue
Block a user