bitmap.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/x11/bitmap.h
  3. // Purpose: wxBitmap class
  4. // Author: Julian Smart, Robert Roebling
  5. // Modified by:
  6. // Created: 17/09/98
  7. // Copyright: (c) Julian Smart, Robert Roebling
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_BITMAP_H_
  11. #define _WX_BITMAP_H_
  12. #include "wx/defs.h"
  13. #include "wx/object.h"
  14. #include "wx/string.h"
  15. #include "wx/palette.h"
  16. #include "wx/gdiobj.h"
  17. //-----------------------------------------------------------------------------
  18. // classes
  19. //-----------------------------------------------------------------------------
  20. class WXDLLIMPEXP_FWD_CORE wxMask;
  21. class WXDLLIMPEXP_FWD_CORE wxBitmap;
  22. class WXDLLIMPEXP_FWD_CORE wxImage;
  23. //-----------------------------------------------------------------------------
  24. // wxMask
  25. //-----------------------------------------------------------------------------
  26. class WXDLLIMPEXP_CORE wxMask: public wxObject
  27. {
  28. public:
  29. wxMask();
  30. wxMask(const wxMask& mask);
  31. wxMask( const wxBitmap& bitmap, const wxColour& colour );
  32. wxMask( const wxBitmap& bitmap, int paletteIndex );
  33. wxMask( const wxBitmap& bitmap );
  34. virtual ~wxMask();
  35. bool Create( const wxBitmap& bitmap, const wxColour& colour );
  36. bool Create( const wxBitmap& bitmap, int paletteIndex );
  37. bool Create( const wxBitmap& bitmap );
  38. // implementation
  39. WXPixmap GetBitmap() const { return m_bitmap; }
  40. void SetBitmap( WXPixmap bitmap ) { m_bitmap = bitmap; }
  41. WXDisplay *GetDisplay() const { return m_display; }
  42. void SetDisplay( WXDisplay *display ) { m_display = display; }
  43. private:
  44. WXPixmap m_bitmap;
  45. WXDisplay *m_display;
  46. wxSize m_size;
  47. private:
  48. DECLARE_DYNAMIC_CLASS(wxMask)
  49. };
  50. //-----------------------------------------------------------------------------
  51. // wxBitmap
  52. //-----------------------------------------------------------------------------
  53. class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
  54. {
  55. public:
  56. wxBitmap() {}
  57. wxBitmap( int width, int height, int depth = -1 ) { Create( width, height, depth ); }
  58. wxBitmap( const wxSize& sz, int depth = -1 ) { Create( sz, depth ); }
  59. wxBitmap( const char bits[], int width, int height, int depth = 1 );
  60. wxBitmap( const char* const* bits );
  61. #ifdef wxNEEDS_CHARPP
  62. // needed for old GCC
  63. wxBitmap(char** data)
  64. {
  65. *this = wxBitmap(const_cast<const char* const*>(data));
  66. }
  67. #endif
  68. wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
  69. virtual ~wxBitmap();
  70. static void InitStandardHandlers();
  71. bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
  72. bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
  73. { return Create(sz.GetWidth(), sz.GetHeight(), depth); }
  74. bool Create(int width, int height, const wxDC& WXUNUSED(dc))
  75. { return Create(width,height); }
  76. bool Create(const void* data, wxBitmapType type,
  77. int width, int height, int depth = -1);
  78. // create the wxBitmap using a _copy_ of the pixmap
  79. bool Create(WXPixmap pixmap);
  80. int GetHeight() const;
  81. int GetWidth() const;
  82. int GetDepth() const;
  83. #if wxUSE_IMAGE
  84. wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
  85. wxImage ConvertToImage() const;
  86. bool CreateFromImage(const wxImage& image, int depth = -1);
  87. #endif // wxUSE_IMAGE
  88. // copies the contents and mask of the given (colour) icon to the bitmap
  89. virtual bool CopyFromIcon(const wxIcon& icon);
  90. wxMask *GetMask() const;
  91. void SetMask( wxMask *mask );
  92. wxBitmap GetSubBitmap( const wxRect& rect ) const;
  93. bool SaveFile( const wxString &name, wxBitmapType type, const wxPalette *palette = NULL ) const;
  94. bool LoadFile( const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
  95. wxPalette *GetPalette() const;
  96. wxPalette *GetColourMap() const
  97. { return GetPalette(); }
  98. virtual void SetPalette(const wxPalette& palette);
  99. // implementation
  100. // --------------
  101. void SetHeight( int height );
  102. void SetWidth( int width );
  103. void SetDepth( int depth );
  104. void SetPixmap( WXPixmap pixmap );
  105. void SetBitmap( WXPixmap bitmap );
  106. WXPixmap GetPixmap() const;
  107. WXPixmap GetBitmap() const;
  108. WXPixmap GetDrawable() const;
  109. WXDisplay *GetDisplay() const;
  110. protected:
  111. virtual wxGDIRefData *CreateGDIRefData() const;
  112. virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
  113. private:
  114. DECLARE_DYNAMIC_CLASS(wxBitmap)
  115. };
  116. #endif // _WX_BITMAP_H_