BitmapView.h 849 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
  3. * Distributed under the terms of the MIT License.
  4. */
  5. #ifndef _BITMAP_VIEW_H
  6. #define _BITMAP_VIEW_H
  7. #include <View.h>
  8. class BBitmap;
  9. class BitmapView : public BView {
  10. public:
  11. BitmapView(const char* name = NULL,
  12. uint32 flags = B_WILL_DRAW);
  13. ~BitmapView();
  14. virtual void AttachedToWindow();
  15. status_t InitCheck();
  16. BBitmap* Bitmap() const;
  17. status_t SetBitmap(const char* filename);
  18. status_t SetBitmap(const BBitmap* bitmap);
  19. void SetSquare(bool isSquare);
  20. virtual BSize MinSize();
  21. virtual BSize MaxSize();
  22. virtual BSize PreferredSize();
  23. virtual void Draw(BRect frame);
  24. private:
  25. BRect _ViewBounds();
  26. BBitmap* fBitmap;
  27. bool fIsSquare;
  28. float fWidth;
  29. float fHeight;
  30. };
  31. #endif // _BITMAP_VIEW_H