Removed some old cruft from wxBitmap, moved wxMotif- and

wxControl-specific functionality (GetXXXPixmap) into a separate
class, and fixed the implementation. Adapted wxStaticBitmap,
wxBitmapButton and wxToolBar to the new situation.
  Various fixes to wxToolBar: Realize does not create buttons
multiple times anymore, use the disabled bitmap as the disabled
bitmap, not as the toggled bitmap for toggle buttons (!),
reposition buttons/controls when a tool is removed/deleted.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19836 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-03-27 19:40:32 +00:00
parent fc7ca9b347
commit aae91497f6
13 changed files with 523 additions and 134 deletions

View File

@@ -76,9 +76,9 @@ public:
int m_height;
int m_depth;
bool m_ok;
int m_numColors;
// XXX int m_numColors;
wxPalette m_bitmapPalette;
int m_quality;
// XXX int m_quality;
wxMask * m_bitmapMask; // Optional mask
@@ -86,16 +86,22 @@ public:
public:
WXPixmap m_pixmap;
WXDisplay* m_display;
bool m_freePixmap;
// XXX bool m_freePixmap;
#if 0
unsigned long* m_freeColors;
long m_freeColorsCount;
#endif
#if 0
// These 5 variables are for wxControl
WXPixmap m_insensPixmap ;
WXPixmap m_labelPixmap ;
WXPixmap m_armPixmap ;
#endif
#if 0
WXImage* m_image ;
WXImage* m_insensImage ;
#endif
};
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
@@ -186,11 +192,11 @@ public:
int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); }
int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); }
int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); }
int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); }
// XXX int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); }
void SetWidth(int w);
void SetHeight(int h);
void SetDepth(int d);
void SetQuality(int q);
// XXX void SetQuality(int q);
void SetOk(bool isOk);
wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); }
@@ -210,9 +216,11 @@ public:
public:
WXDisplay* GetDisplay() const { return M_BITMAPDATA->m_display; }
WXPixmap GetPixmap() const { return (WXPixmap) M_BITMAPDATA->m_pixmap; }
#if 0
virtual WXPixmap GetLabelPixmap(WXWidget w) ;
virtual WXPixmap GetArmPixmap(WXWidget w) ;
virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ;
#endif
void SetPixmapNull() { M_BITMAPDATA->m_pixmap = 0; }
protected:

View File

@@ -16,6 +16,8 @@
#pragma interface "bmpbuttn.h"
#endif
#include "wx/motif/bmpmotif.h"
WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
#define wxDEFAULT_BUTTON_MARGIN 4
@@ -67,7 +69,9 @@ protected:
// to reflect button background colour
wxBitmap m_bmpSelectedOriginal;
wxBitmap m_bmpDisabledOriginal;
wxBitmapCache m_bitmapCache;
WXPixmap m_insensPixmap;
};

View File

@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bmpmotif.h
// Purpose: Motif-specific bitmap routines
// Author: Julian Smart, originally in bitmap.h
// Modified by:
// Created: 25/03/2003
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPMOTIF_H_
#define _WX_BMPMOTIF_H_
#ifdef __GNUG__
#pragma interface "bmpmotif.h"
#endif
#include "wx/defs.h"
#include "wx/bitmap.h"
class WXDLLEXPORT wxBitmapCache
{
public:
wxBitmapCache()
{
m_labelPixmap = (WXPixmap)NULL;
m_armPixmap = (WXPixmap)NULL;
m_insensPixmap = (WXPixmap)NULL;
m_image = (WXImage)NULL;
m_display = (WXDisplay*)NULL;
SetColoursChanged();
}
~wxBitmapCache();
void SetColoursChanged();
void SetBitmap( const wxBitmap& bitmap );
WXPixmap GetLabelPixmap( WXWidget w );
WXPixmap GetInsensPixmap( WXWidget w = (WXWidget)NULL );
WXPixmap GetArmPixmap( WXWidget w );
private:
void InvalidateCache();
void CreateImageIfNeeded( WXWidget w );
struct
{
bool label : 1;
bool arm : 1;
bool insens : 1;
} m_recalcPixmaps;
wxBitmap m_bitmap;
WXDisplay* m_display;
WXPixmap m_labelPixmap, m_armPixmap, m_insensPixmap;
WXImage m_image;
};
#endif // _WX_BMPMOTIF_H_

View File

@@ -16,7 +16,7 @@
#pragma interface "statbmp.h"
#endif
#include "wx/control.h"
#include "wx/motif/bmpmotif.h"
#include "wx/icon.h"
WXDLLEXPORT_DATA(extern const char*) wxStaticBitmapNameStr;
@@ -82,6 +82,7 @@ protected:
protected:
wxBitmap m_messageBitmap;
wxBitmap m_messageBitmapOriginal;
wxBitmapCache m_bitmapCache;
};
#endif