Return error code when bitmap changes.
This commit is contained in:
parent
1cd3ad8d26
commit
bf2f726629
|
@ -6,6 +6,8 @@
|
|||
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
||||
*/
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <LayoutUtils.h>
|
||||
#include <TranslationUtils.h>
|
||||
|
@ -57,28 +59,38 @@ BitmapView::Bitmap() const
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
status_t
|
||||
BitmapView::SetBitmap(const char* filename)
|
||||
{
|
||||
delete fBitmap;
|
||||
|
||||
fBitmap = BTranslationUtils::GetBitmap(filename);
|
||||
if (fBitmap == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BitmapView::SetBitmap(BBitmap* bitmap)
|
||||
status_t
|
||||
BitmapView::SetBitmap(const BBitmap* bitmap)
|
||||
{
|
||||
delete fBitmap;
|
||||
fBitmap = bitmap;
|
||||
fBitmap = NULL;
|
||||
|
||||
if (fBitmap) {
|
||||
BRect frame(fBitmap->Bounds());
|
||||
|
||||
fWidth = frame.Width();
|
||||
fHeight = frame.Height();
|
||||
if (bitmap != NULL) {
|
||||
fBitmap = new(std::nothrow) BBitmap(bitmap);
|
||||
if (fBitmap == NULL)
|
||||
return B_NO_MEMORY;
|
||||
if (fBitmap->InitCheck() != B_OK)
|
||||
return fBitmap->InitCheck();
|
||||
|
||||
fWidth = fBitmap->Bounds().Width();
|
||||
fHeight = fBitmap->Bounds().Height();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,7 +121,7 @@ BitmapView::PreferredSize()
|
|||
void
|
||||
BitmapView::Draw(BRect frame)
|
||||
{
|
||||
if (!fBitmap)
|
||||
if (fBitmap == NULL)
|
||||
return;
|
||||
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
|
|
|
@ -11,7 +11,7 @@ class BBitmap;
|
|||
|
||||
class BitmapView : public BView {
|
||||
public:
|
||||
BitmapView(const char* name, uint32 flags
|
||||
BitmapView(const char* name = NULL, uint32 flags
|
||||
= B_WILL_DRAW);
|
||||
~BitmapView();
|
||||
|
||||
|
@ -20,8 +20,9 @@ public:
|
|||
status_t InitCheck();
|
||||
|
||||
BBitmap* Bitmap() const;
|
||||
void SetBitmap(const char* filename);
|
||||
void SetBitmap(BBitmap* bitmap);
|
||||
|
||||
status_t SetBitmap(const char* filename);
|
||||
status_t SetBitmap(const BBitmap* bitmap);
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize MaxSize();
|
||||
|
|
Ŝarĝante…
Reference in New Issue