From d125d984a631d7bbe18a2e0f7c52921ab27fb881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 22 Aug 2008 12:06:50 +0000 Subject: [PATCH] * IconMenuItem now falls back to the icon of the super type, if a MIME type didn't have one. * Whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27144 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/IconMenuItem.cpp | 34 +++++++++++++++++++------------ 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/kits/tracker/IconMenuItem.cpp b/src/kits/tracker/IconMenuItem.cpp index e3ada34bc5..615d07f565 100644 --- a/src/kits/tracker/IconMenuItem.cpp +++ b/src/kits/tracker/IconMenuItem.cpp @@ -142,10 +142,10 @@ void ModelMenuItem::DrawIcon() { Menu()->PushState(); - + BPoint where(ContentLocation()); // center icon with text. - + float deltaHeight = fHeightDelta < 0 ? -fHeightDelta : 0; where.y += ceil(deltaHeight / 2); @@ -181,12 +181,12 @@ ModelMenuItem::GetContentSize(float *width, float *height) } -status_t +status_t ModelMenuItem::Invoke(BMessage *message) { if (!Menu()) return B_ERROR; - + if (!IsEnabled()) return B_ERROR; @@ -225,7 +225,7 @@ SpecialModelMenuItem::SpecialModelMenuItem(const Model *model, BMenu *menu) } -void +void SpecialModelMenuItem::DrawContent() { Menu()->PushState(); @@ -289,7 +289,7 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message, fDeviceIcon(NULL), fHeightDelta(0) { - BMimeType mime(iconType); + BMimeType mime(iconType); #ifdef __HAIKU__ fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_RGBA32); #else @@ -297,8 +297,12 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message, #endif if (mime.GetIcon(fDeviceIcon, which) != B_OK) { - delete fDeviceIcon; - fDeviceIcon = NULL; + BMimeType super; + mime.GetSupertype(&super); + if (super.GetIcon(fDeviceIcon, which) != B_OK) { + delete fDeviceIcon; + fDeviceIcon = NULL; + } } // IconMenuItem is used in synchronously invoked menus, make sure @@ -321,8 +325,12 @@ IconMenuItem::IconMenuItem(BMenu *submenu, BMessage *message, #endif if (mime.GetIcon(fDeviceIcon, which) != B_OK) { - delete fDeviceIcon; - fDeviceIcon = NULL; + BMimeType super; + mime.GetSupertype(&super); + if (super.GetIcon(fDeviceIcon, which) != B_OK) { + delete fDeviceIcon; + fDeviceIcon = NULL; + } } // IconMenuItem is used in synchronously invoked menus, make sure @@ -374,12 +382,12 @@ IconMenuItem::DrawContent() Menu()->SetDrawingMode(B_OP_ALPHA); Menu()->SetHighColor(0, 0, 0, 64); Menu()->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); - } + } #else Menu()->SetDrawingMode(B_OP_OVER); else - Menu()->SetDrawingMode(B_OP_BLEND); -#endif + Menu()->SetDrawingMode(B_OP_BLEND); +#endif Menu()->DrawBitmapAsync(fDeviceIcon, where); }