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:
@@ -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,42 +9,60 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "bitmap.h"
|
||||
#pragma implementation "bitmap.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <stdio.h>
|
||||
#include "wx/setup.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/palette.h"
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/icon.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wx/list.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/palette.h"
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/icon.h"
|
||||
#endif
|
||||
|
||||
#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)
|
||||
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 );
|
||||
|
@@ -199,13 +199,17 @@ bool wxTreeCtrl::Create(wxWindow *parent,
|
||||
// we emulate the multiple selection tree controls by using checkboxes: set
|
||||
// up the image list we need for this if we do have multiple selections
|
||||
if ( m_windowStyle & wxTR_MULTIPLE )
|
||||
wstyle |= TVS_CHECKBOXES;
|
||||
wstyle |= TVS_CHECKBOXES;
|
||||
#endif
|
||||
|
||||
// Create the tree control.
|
||||
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