diff --git a/src/apps/deskcalc/CalcIcon.h b/src/apps/deskcalc/CalcIcon.h deleted file mode 100644 index 4f85e0ebbd..0000000000 --- a/src/apps/deskcalc/CalcIcon.h +++ /dev/null @@ -1,71 +0,0 @@ -const uint32 kIconWidth = 16; -const uint32 kIconHeight = 16; -const color_space kIconFormat = B_RGBA32; - -const unsigned char kIconBits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x40, 0x40, 0x40, 0xff, - 0x30, 0x30, 0x30, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x40, 0x40, 0x40, 0xff, 0x40, 0x40, 0x40, 0xff, - 0x05, 0xb7, 0x05, 0xff, 0x00, 0xff, 0x00, 0xff, 0x30, 0x30, 0x30, 0xff, 0x00, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xff, 0xa0, 0xa0, 0xa0, 0xff, 0x78, 0x78, 0x78, 0xff, 0x98, 0x98, 0x98, 0xff, - 0x40, 0x40, 0x40, 0xff, 0x40, 0x40, 0x40, 0xff, 0x40, 0x40, 0x40, 0xff, 0x00, 0xff, 0x00, 0xff, - 0x40, 0x40, 0x40, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, - 0xa0, 0xa0, 0xa0, 0xff, 0xb9, 0xb9, 0xb9, 0xff, 0x98, 0x98, 0x98, 0xff, 0x78, 0x78, 0x78, 0xff, - 0x98, 0x98, 0x98, 0xff, 0x98, 0x98, 0x98, 0xff, 0x40, 0x40, 0x40, 0xff, 0x40, 0x40, 0x40, 0xff, - 0x20, 0x20, 0x20, 0xff, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x78, 0x78, 0x78, 0xff, - 0xb9, 0xb9, 0xb9, 0xff, 0x98, 0x98, 0x98, 0xff, 0x78, 0x78, 0x78, 0xff, 0xb9, 0xb9, 0xb9, 0xff, - 0x78, 0x78, 0x78, 0xff, 0xa0, 0xa0, 0xa0, 0xff, 0x78, 0x78, 0x78, 0xff, 0x20, 0x20, 0x20, 0xff, - 0x5c, 0x5c, 0x5c, 0xff, 0x01, 0x01, 0x01, 0xff, 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x98, 0x98, 0x98, 0xff, 0xb9, 0xb9, 0xb9, 0xff, - 0x98, 0x98, 0x98, 0xff, 0x78, 0x78, 0x78, 0xff, 0xb9, 0xb9, 0xb9, 0xff, 0x78, 0x78, 0x78, 0xff, - 0xa0, 0xa0, 0xa0, 0xff, 0x78, 0x78, 0x78, 0xff, 0x20, 0x20, 0x20, 0xff, 0x5c, 0x5c, 0x5c, 0xff, - 0x01, 0x01, 0x01, 0xff, 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xff, 0xde, 0xde, 0xde, 0xff, 0x78, 0x78, 0x78, 0xff, 0x98, 0x98, 0x98, 0xff, - 0x78, 0x78, 0x78, 0xff, 0xb9, 0xb9, 0xb9, 0xff, 0x78, 0x78, 0x78, 0xff, 0x78, 0x78, 0x78, 0xff, - 0x98, 0x98, 0x98, 0xff, 0x20, 0x20, 0x20, 0xff, 0x5c, 0x5c, 0x5c, 0xff, 0x01, 0x01, 0x01, 0xff, - 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xff, 0x70, 0x70, 0x70, 0xff, 0x20, 0x20, 0x20, 0xff, 0xde, 0xde, 0xde, 0xff, - 0x98, 0x98, 0x98, 0xff, 0x78, 0x78, 0x78, 0xff, 0x98, 0x98, 0x98, 0xff, 0x98, 0x98, 0x98, 0xff, - 0x20, 0x20, 0x20, 0xff, 0x5c, 0x5c, 0x5c, 0xff, 0x01, 0x01, 0x01, 0xff, 0x80, 0x80, 0x80, 0xff, - 0x80, 0x80, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x01, 0x01, 0xff, 0x00, 0x00, 0x00, 0xff, 0x70, 0x70, 0x70, 0xff, 0x70, 0x70, 0x70, 0xff, - 0x20, 0x20, 0x20, 0xff, 0xb5, 0xb5, 0xb5, 0xff, 0x98, 0x98, 0x98, 0xff, 0x20, 0x20, 0x20, 0xff, - 0x5c, 0x5c, 0x5c, 0xff, 0x01, 0x01, 0x01, 0xff, 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, - 0x70, 0x70, 0x70, 0xff, 0x70, 0x70, 0x70, 0xff, 0x20, 0x20, 0x20, 0xff, 0x5c, 0x5c, 0x5c, 0xff, - 0x01, 0x01, 0x01, 0xff, 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x3b, 0x3b, 0x3b, 0xff, 0x01, 0x01, 0x01, 0xff, - 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0xff, 0x80, 0x80, 0x80, 0xff, - 0x80, 0x80, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp index e6540f2eaa..db47260df6 100644 --- a/src/apps/deskcalc/CalcView.cpp +++ b/src/apps/deskcalc/CalcView.cpp @@ -17,18 +17,21 @@ #include #include +#include +#include #include #include #include +#include #include #include #include #include #include #include +#include #include "CalcApplication.h" -#include "CalcIcon.h" #include "CalcOptionsWindow.h" #include "ExpressionParser.h" #include "ExpressionTextView.h" @@ -84,8 +87,11 @@ CalcView::CalcView(BRect frame, rgb_color rgbBaseColor) fKeypadDescription(strdup(kDefaultKeypadDescription)), fKeypad(NULL), - fCalcIcon(new BBitmap(BRect(0, 0, kIconWidth - 1, kIconHeight - 1), - 0, kIconFormat)), +#ifdef __HAIKU__ + fCalcIcon(new BBitmap(BRect(0, 0, 15, 15), 0, B_RGBA32)), +#else + fCalcIcon(new BBitmap(BRect(0, 0, 15, 15), 0, B_CMAP8)), +#endif fAboutItem(NULL), fOptionsItem(NULL), @@ -112,8 +118,7 @@ CalcView::CalcView(BRect frame, rgb_color rgbBaseColor) // create pop-up menu system _CreatePopUpMenu(); - // copy calculator icon into bitmap - memcpy(fCalcIcon->Bits(), kIconBits, fCalcIcon->BitsLength()); + _FetchAppIcon(fCalcIcon); } @@ -131,8 +136,11 @@ CalcView::CalcView(BMessage* archive) fKeypadDescription(strdup(kDefaultKeypadDescription)), fKeypad(NULL), - fCalcIcon(new BBitmap(BRect(0, 0, kIconWidth - 1, kIconHeight - 1), - 0, kIconFormat)), +#ifdef __HAIKU__ + fCalcIcon(new BBitmap(BRect(0, 0, 15, 15), 0, B_RGBA32)), +#else + fCalcIcon(new BBitmap(BRect(0, 0, 15, 15), 0, B_CMAP8)), +#endif fAboutItem(NULL), fOptionsItem(NULL), @@ -153,8 +161,7 @@ CalcView::CalcView(BMessage* archive) // create pop-up menu system _CreatePopUpMenu(); - // copy calculator icon into bitmap - memcpy(fCalcIcon->Bits(), kIconBits, fCalcIcon->BitsLength()); + _FetchAppIcon(fCalcIcon); } @@ -265,8 +272,12 @@ CalcView::Draw(BRect updateRect) SetHighColor(fBaseColor); FillRect(updateRect & expressionRect); - SetDrawingMode(B_OP_ALPHA); - SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); + if (fCalcIcon->ColorSpace() == B_RGBA32) { + SetDrawingMode(B_OP_ALPHA); + SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); + } else { + SetDrawingMode(B_OP_OVER); + } BPoint iconPos; iconPos.x = expressionRect.right - (expressionRect.Width() @@ -1038,5 +1049,14 @@ CalcView::_ShowKeypad(bool show) ResizeTo(fWidth, height); } - - + +void +CalcView::_FetchAppIcon(BBitmap* into) +{ + app_info info; + be_roster->GetAppInfo(kAppSig, &info); + BFile file(&info.ref, B_READ_ONLY); + BAppFileInfo appInfo(&file); + if (appInfo.GetIcon(into, B_MINI_ICON) < B_OK) + memset(into->Bits(), 0, into->BitsLength()); +} diff --git a/src/apps/deskcalc/CalcView.h b/src/apps/deskcalc/CalcView.h index bbfd1b8786..4391218122 100644 --- a/src/apps/deskcalc/CalcView.h +++ b/src/apps/deskcalc/CalcView.h @@ -84,6 +84,7 @@ class CalcView : public BView { BRect _KeypadRect() const; void _ShowKeypad(bool show); + void _FetchAppIcon(BBitmap* into); // grid dimensions int16 fColums;