// 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
DECLARE_DYNAMIC_CLASS(wxMask)
public:
- wxMask(void);
+ wxMask();
// Construct a mask from a bitmap and a colour indicating
// the transparent area
// 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);
friend class WXDLLEXPORT wxIcon;
friend class WXDLLEXPORT wxCursor;
public:
- wxBitmapRefData(void);
- ~wxBitmapRefData(void);
+ wxBitmapRefData();
+ ~wxBitmapRefData();
public:
int m_width;
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);
// 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);
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;
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);
// 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));
// 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;
m_bitmapMask = NULL;
}
-wxBitmapRefData::~wxBitmapRefData(void)
+wxBitmapRefData::~wxBitmapRefData()
{
if (m_selectedInto)
{
}
+// ----------------------------------------------------------------------------
+// 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);
* wxMask
*/
-wxMask::wxMask(void)
+wxMask::wxMask()
{
m_maskBitmap = 0;
}
Create(bitmap);
}
-wxMask::~wxMask(void)
+wxMask::~wxMask()
{
if ( m_maskBitmap )
::DeleteObject((HBITMAP) m_maskBitmap);
{
DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler)
public:
- inline wxBMPResourceHandler(void)
+ inline wxBMPResourceHandler()
{
m_name = "Windows bitmap resource";
m_extension = "";
{
DECLARE_DYNAMIC_CLASS(wxBMPFileHandler)
public:
- inline wxBMPFileHandler(void)
+ inline wxBMPFileHandler()
{
m_name = "Windows bitmap file";
m_extension = "bmp";
#endif
}
-void wxBitmap::CleanUpHandlers(void)
+void wxBitmap::CleanUpHandlers()
{
wxNode *node = sm_handlers.First();
while ( node )
}
}
-void wxBitmap::InitStandardHandlers(void)
+void wxBitmap::InitStandardHandlers()
{
AddHandler(new wxBMPResourceHandler);
AddHandler(new wxBMPFileHandler);
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 );
// 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.