1. wxWindow::Centre() hopefully fixed
2. attempts to construct bitmaps from icons properly 3. wxTreeCtrl background is always white git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1003,9 +1003,11 @@ enum wxDirection
|
||||
|
||||
// wxCENTRE = 0x0400 (defined above)
|
||||
|
||||
// centering into frame rather than screen
|
||||
#define wxCENTER_FRAME 0x0004
|
||||
|
||||
// centering into frame rather than screen (obsolete)
|
||||
#define wxCENTER_FRAME 0x0000
|
||||
// centre on screen rather than parent
|
||||
#define wxCENTRE_ON_SCREEN 0x0004
|
||||
#define wxCENTER_ON_SCREEN wxCENTRE_ON_SCREEN
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Possible SetSize flags
|
||||
|
@@ -36,7 +36,7 @@ class WXDLLEXPORT wxMask: public wxObject
|
||||
DECLARE_DYNAMIC_CLASS(wxMask)
|
||||
|
||||
public:
|
||||
wxMask(void);
|
||||
wxMask();
|
||||
|
||||
// Construct a mask from a bitmap and a colour indicating
|
||||
// the transparent area
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
// Construct a mask from a mono bitmap (copies the bitmap).
|
||||
wxMask(const wxBitmap& bitmap);
|
||||
|
||||
~wxMask(void);
|
||||
~wxMask();
|
||||
|
||||
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
||||
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
||||
@@ -68,8 +68,8 @@ class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
|
||||
friend class WXDLLEXPORT wxIcon;
|
||||
friend class WXDLLEXPORT wxCursor;
|
||||
public:
|
||||
wxBitmapRefData(void);
|
||||
~wxBitmapRefData(void);
|
||||
wxBitmapRefData();
|
||||
~wxBitmapRefData();
|
||||
|
||||
public:
|
||||
int m_width;
|
||||
@@ -121,11 +121,10 @@ class WXDLLEXPORT wxBitmap: public wxGDIObject
|
||||
friend class WXDLLEXPORT wxBitmapHandler;
|
||||
|
||||
public:
|
||||
wxBitmap(void); // Platform-specific
|
||||
wxBitmap(); // Platform-specific
|
||||
|
||||
// Copy constructors
|
||||
inline wxBitmap(const wxBitmap& bitmap)
|
||||
{ Ref(bitmap); if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this); }
|
||||
wxBitmap(const wxBitmap& bitmap);
|
||||
|
||||
// Initialize with raw data
|
||||
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
||||
@@ -141,7 +140,7 @@ public:
|
||||
|
||||
// If depth is omitted, will create a bitmap compatible with the display
|
||||
wxBitmap(int width, int height, int depth = -1);
|
||||
~wxBitmap(void);
|
||||
~wxBitmap();
|
||||
|
||||
virtual bool Create(int width, int height, int depth = -1);
|
||||
virtual bool Create(void *data, long type, int width, int height, int depth = 1);
|
||||
@@ -182,8 +181,8 @@ public:
|
||||
static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType);
|
||||
static wxBitmapHandler *FindHandler(long bitmapType);
|
||||
|
||||
static void InitStandardHandlers(void);
|
||||
static void CleanUpHandlers(void);
|
||||
static void InitStandardHandlers();
|
||||
static void CleanUpHandlers();
|
||||
protected:
|
||||
static wxList sm_handlers;
|
||||
|
||||
|
@@ -303,15 +303,22 @@ void wxWindowBase::Centre(int direction)
|
||||
int widthParent, heightParent;
|
||||
|
||||
wxWindow *parent = GetParent();
|
||||
if ( (direction & wxCENTER_FRAME) && parent )
|
||||
if ( !parent )
|
||||
{
|
||||
parent->GetClientSize(&widthParent, &heightParent);
|
||||
// no other choice
|
||||
direction |= wxCENTRE_ON_SCREEN;
|
||||
}
|
||||
else
|
||||
|
||||
if ( direction & wxCENTRE_ON_SCREEN )
|
||||
{
|
||||
// centre with respect to the whole screen
|
||||
wxDisplaySize(&widthParent, &heightParent);
|
||||
}
|
||||
else
|
||||
{
|
||||
// centre inside the parents rectangle
|
||||
parent->GetClientSize(&widthParent, &heightParent);
|
||||
}
|
||||
|
||||
int width, height;
|
||||
GetSize(&width, &height);
|
||||
@@ -327,8 +334,11 @@ void wxWindowBase::Centre(int direction)
|
||||
|
||||
// controls are always centered on their parent because it doesn't make
|
||||
// sense to centre them on the screen
|
||||
if ( (direction & wxCENTER_FRAME) || wxDynamicCast(this, wxControl) )
|
||||
if ( !(direction & wxCENTRE_ON_SCREEN) || wxDynamicCast(this, wxControl) )
|
||||
{
|
||||
// theo nly chance to get this is to have a wxControl without parent
|
||||
wxCHECK_RET( parent, _T("a control must have a parent") );
|
||||
|
||||
// adjust to the parents client area origin
|
||||
wxPoint posParent = parent->ClientToScreen(wxPoint(0, 0));
|
||||
|
||||
|
@@ -9,6 +9,14 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "bitmap.h"
|
||||
#endif
|
||||
@@ -22,7 +30,7 @@
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <stdio.h>
|
||||
#include "wx/setup.h"
|
||||
|
||||
#include "wx/list.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
@@ -35,16 +43,26 @@
|
||||
#include "wx/msw/private.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
#include "assert.h"
|
||||
|
||||
#include "wx/msw/dib.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
|
||||
#endif
|
||||
|
||||
wxBitmapRefData::wxBitmapRefData(void)
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmapRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxBitmapRefData::wxBitmapRefData()
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_width = 0;
|
||||
@@ -57,7 +75,7 @@ wxBitmapRefData::wxBitmapRefData(void)
|
||||
m_bitmapMask = NULL;
|
||||
}
|
||||
|
||||
wxBitmapRefData::~wxBitmapRefData(void)
|
||||
wxBitmapRefData::~wxBitmapRefData()
|
||||
{
|
||||
if (m_selectedInto)
|
||||
{
|
||||
@@ -77,15 +95,44 @@ wxBitmapRefData::~wxBitmapRefData(void)
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmap
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxList wxBitmap::sm_handlers;
|
||||
|
||||
wxBitmap::wxBitmap(void)
|
||||
wxBitmap::wxBitmap()
|
||||
{
|
||||
if ( wxTheBitmapList )
|
||||
wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::~wxBitmap(void)
|
||||
wxBitmap::wxBitmap(const wxBitmap& bitmap)
|
||||
{
|
||||
wxIcon *icon = wxDynamicCast(&bitmap, wxIcon);
|
||||
if ( icon )
|
||||
{
|
||||
HDC hdc = ::CreateCompatibleDC(NULL); // screen DC
|
||||
HBITMAP hbitmap = ::CreateCompatibleBitmap(hdc,
|
||||
icon->GetWidth(),
|
||||
icon->GetHeight());
|
||||
::SelectObject(hdc, hbitmap);
|
||||
::DrawIcon(hdc, 0, 0, (HICON)icon->GetHICON());
|
||||
|
||||
::DeleteDC(hdc);
|
||||
|
||||
SetHBITMAP((WXHBITMAP)hbitmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ref(bitmap);
|
||||
}
|
||||
|
||||
if ( wxTheBitmapList )
|
||||
wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::~wxBitmap()
|
||||
{
|
||||
if (wxTheBitmapList)
|
||||
wxTheBitmapList->DeleteObject(this);
|
||||
@@ -435,7 +482,7 @@ wxBitmap wxBitmap::GetBitmapForDC(wxDC& dc) const
|
||||
* wxMask
|
||||
*/
|
||||
|
||||
wxMask::wxMask(void)
|
||||
wxMask::wxMask()
|
||||
{
|
||||
m_maskBitmap = 0;
|
||||
}
|
||||
@@ -463,7 +510,7 @@ wxMask::wxMask(const wxBitmap& bitmap)
|
||||
Create(bitmap);
|
||||
}
|
||||
|
||||
wxMask::~wxMask(void)
|
||||
wxMask::~wxMask()
|
||||
{
|
||||
if ( m_maskBitmap )
|
||||
::DeleteObject((HBITMAP) m_maskBitmap);
|
||||
@@ -601,7 +648,7 @@ class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler)
|
||||
public:
|
||||
inline wxBMPResourceHandler(void)
|
||||
inline wxBMPResourceHandler()
|
||||
{
|
||||
m_name = "Windows bitmap resource";
|
||||
m_extension = "";
|
||||
@@ -644,7 +691,7 @@ class WXDLLEXPORT wxBMPFileHandler: public wxBitmapHandler
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxBMPFileHandler)
|
||||
public:
|
||||
inline wxBMPFileHandler(void)
|
||||
inline wxBMPFileHandler()
|
||||
{
|
||||
m_name = "Windows bitmap file";
|
||||
m_extension = "bmp";
|
||||
@@ -697,7 +744,7 @@ bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int WXUN
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxBitmap::CleanUpHandlers(void)
|
||||
void wxBitmap::CleanUpHandlers()
|
||||
{
|
||||
wxNode *node = sm_handlers.First();
|
||||
while ( node )
|
||||
@@ -710,7 +757,7 @@ void wxBitmap::CleanUpHandlers(void)
|
||||
}
|
||||
}
|
||||
|
||||
void wxBitmap::InitStandardHandlers(void)
|
||||
void wxBitmap::InitStandardHandlers()
|
||||
{
|
||||
AddHandler(new wxBMPResourceHandler);
|
||||
AddHandler(new wxBMPFileHandler);
|
||||
|
@@ -591,6 +591,9 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask )
|
||||
HDC cdc = GetHdc();
|
||||
HDC memdc = ::CreateCompatibleDC( cdc );
|
||||
HBITMAP hbitmap = (HBITMAP) bmp.GetHBITMAP( );
|
||||
|
||||
wxASSERT_MSG( hbitmap, _T("bitmap is ok but HBITMAP is NULL?") );
|
||||
|
||||
::SelectObject( memdc, hbitmap );
|
||||
::BitBlt( cdc, x, y, bmp.GetWidth(), bmp.GetHeight(), memdc, 0, 0, SRCCOPY);
|
||||
::DeleteDC( memdc );
|
||||
|
@@ -206,6 +206,10 @@ bool wxTreeCtrl::Create(wxWindow *parent,
|
||||
if ( !MSWCreateControl(WC_TREEVIEW, wstyle) )
|
||||
return FALSE;
|
||||
|
||||
// the treectrl with any other background looks ugly because the items
|
||||
// background is white anyhow
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
|
||||
// VZ: this is some experimental code which may be used to get the
|
||||
// TVS_CHECKBOXES style functionality for comctl32.dll < 4.71.
|
||||
// AFAIK, the standard DLL does about the same thing anyhow.
|
||||
|
Reference in New Issue
Block a user