6 (c) 2000, Georges-Edouard Berenger, All Rights Reserved.
7 Copyright (C) 2004 beunited.org
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "IconMenuItem.h"
26 #include <Application.h>
32 IconMenuItem::IconMenuItem(BBitmap
* icon
, const char* title
,
33 BMessage
* msg
, bool drawText
, bool purge
)
34 : BMenuItem(title
, msg
),
44 IconMenuItem::IconMenuItem(BBitmap
* icon
, BMenu
* menu
, bool drawText
, bool purge
)
56 IconMenuItem::IconMenuItem(const char* mime
, const char* title
, BMessage
* msg
, bool drawText
)
57 : BMenuItem(title
, msg
),
65 IconMenuItem::~IconMenuItem()
72 void IconMenuItem::DrawContent()
78 loc
= ContentLocation();
80 Menu()->MovePenTo(loc
);
81 BMenuItem::DrawContent();
87 IconMenuItem::Highlight(bool hilited
)
89 BMenuItem::Highlight(hilited
);
95 IconMenuItem::DrawIcon()
97 // TODO: exact code duplication with TeamBarMenuItem::DrawIcon()
101 BPoint loc
= ContentLocation();
102 BRect frame
= Frame();
104 loc
.y
= frame
.top
+ (frame
.bottom
- frame
.top
- 15) / 2;
106 BMenu
* menu
= Menu();
108 if (fIcon
->ColorSpace() == B_RGBA32
) {
109 menu
->SetDrawingMode(B_OP_ALPHA
);
110 menu
->SetBlendingMode(B_PIXEL_ALPHA
, B_ALPHA_OVERLAY
);
112 menu
->SetDrawingMode(B_OP_OVER
);
114 menu
->DrawBitmap(fIcon
, loc
);
116 menu
->SetDrawingMode(B_OP_COPY
);
121 IconMenuItem::GetContentSize(float* width
, float* height
)
123 BMenuItem::GetContentSize(width
, height
);
124 int limit
= IconMenuItem::MinHeight();
135 IconMenuItem::DefaultIcon(const char* mime
)
137 BRect
rect(0, 0, 15, 15);
138 fIcon
= new BBitmap(rect
, B_COLOR_8_BIT
);
140 BMimeType
mimeType(mime
);
141 if (mimeType
.GetIcon(fIcon
, B_MINI_ICON
) != B_OK
)
145 be_app
->GetAppInfo(&info
);
146 if (BNodeInfo::GetTrackerIcon(&info
.ref
, fIcon
, B_MINI_ICON
) != B_OK
)
153 int IconMenuItem::MinHeight()
155 static int minheight
= -1;