* Tracker wrote icons with the wrong type at several places.
* Also replaced all B_COLOR_8_BIT with the B_CMAP8 constant. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16909 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2147,13 +2147,13 @@ FSGetDeskDir(BDirectory *deskDir, dev_t dev)
|
||||
LoadResource('ICON', kResDeskIcon, &size);
|
||||
|
||||
if (data)
|
||||
deskDir->WriteAttr(kAttrLargeIcon, B_COLOR_8_BIT_TYPE, 0, data, size);
|
||||
deskDir->WriteAttr(kAttrLargeIcon, 'ICON', 0, data, size);
|
||||
|
||||
data = GetTrackerResources()->
|
||||
LoadResource('MICN', kResDeskIcon, &size);
|
||||
|
||||
if (data)
|
||||
deskDir->WriteAttr(kAttrMiniIcon, B_COLOR_8_BIT_TYPE, 0, data, size);
|
||||
deskDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, data, size);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@@ -2631,7 +2631,6 @@ FSCreateTrashDirs()
|
||||
|
||||
roster.Rewind();
|
||||
while (roster.GetNextVolume(&volume) == B_OK) {
|
||||
|
||||
if (volume.IsReadOnly() || !volume.IsPersistent())
|
||||
continue;
|
||||
|
||||
@@ -2645,13 +2644,13 @@ FSCreateTrashDirs()
|
||||
const void* data = GetTrackerResources()->
|
||||
LoadResource('ICON', kResTrashIcon, &size);
|
||||
if (data) {
|
||||
trashDir.WriteAttr(kAttrLargeIcon, B_COLOR_8_BIT_TYPE, 0,
|
||||
trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0,
|
||||
data, size);
|
||||
}
|
||||
data = GetTrackerResources()->
|
||||
LoadResource('MICN', kResTrashIcon, &size);
|
||||
if (data) {
|
||||
trashDir.WriteAttr(kAttrMiniIcon, B_COLOR_8_BIT_TYPE, 0,
|
||||
trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0,
|
||||
data, size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1049,8 +1049,8 @@ TDraggableIconButton::AttachedToWindow()
|
||||
else
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
fIcon = new BBitmap(BRect(0, 0, 31, 31), B_COLOR_8_BIT);
|
||||
fIcon->SetBits(kLargeNewGroupIcon, fIcon->BitsLength(), 0, B_COLOR_8_BIT);
|
||||
fIcon = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
|
||||
fIcon->SetBits(kLargeNewGroupIcon, fIcon->BitsLength(), 0, B_CMAP8);
|
||||
// calculate correct frame for icon and label
|
||||
// sets icon rect and label rect for drawing
|
||||
ResizeToPreferred();
|
||||
@@ -1250,14 +1250,14 @@ TContentsMenu::AttachedToWindow()
|
||||
fDownBtn->SetTarget(this, Window());
|
||||
|
||||
// cache the new group icon
|
||||
fSmallGroupIcon = new BBitmap(BRect(0, 0, 15, 15), B_COLOR_8_BIT);
|
||||
fSmallGroupIcon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
|
||||
fSmallGroupIcon->SetBits(kSmallNewGroupIcon, fSmallGroupIcon->BitsLength(),
|
||||
0, B_COLOR_8_BIT);
|
||||
0, B_CMAP8);
|
||||
|
||||
// cache the symlink icon
|
||||
BMimeType symlink("application/x-vnd.Be-symlink");
|
||||
if (symlink.InitCheck() == B_OK) {
|
||||
fSymlinkIcon = new BBitmap(BRect(0, 0, 15, 15), B_COLOR_8_BIT);
|
||||
fSymlinkIcon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
|
||||
if (symlink.GetIcon(fSymlinkIcon, B_MINI_ICON) != B_OK)
|
||||
fSymlinkIcon = NULL;
|
||||
} else
|
||||
|
||||
@@ -34,29 +34,29 @@ All rights reserved.
|
||||
|
||||
// menu items with small icons.
|
||||
|
||||
#include "IconCache.h"
|
||||
#include "IconMenuItem.h"
|
||||
|
||||
#include <Debug.h>
|
||||
#include <Menu.h>
|
||||
#include <NodeInfo.h>
|
||||
|
||||
#include "IconCache.h"
|
||||
#include "IconMenuItem.h"
|
||||
|
||||
|
||||
ModelMenuItem::ModelMenuItem(const Model *model, const char *title,
|
||||
BMessage *message, char shortcut, uint32 modifiers,
|
||||
bool drawText, bool extraPad)
|
||||
: BMenuItem(title, message, shortcut, modifiers),
|
||||
fModel(*model),
|
||||
fHeightDelta(0),
|
||||
fDrawText(drawText),
|
||||
fExtraPad(extraPad)
|
||||
BMessage *message, char shortcut, uint32 modifiers,
|
||||
bool drawText, bool extraPad)
|
||||
: BMenuItem(title, message, shortcut, modifiers),
|
||||
fModel(*model),
|
||||
fHeightDelta(0),
|
||||
fDrawText(drawText),
|
||||
fExtraPad(extraPad)
|
||||
{
|
||||
ThrowOnInitCheckError(&fModel);
|
||||
// The 'fExtraPad' field is used to when this menu item is added to
|
||||
// a menubar instead of a menu. Menus and MenuBars space out items
|
||||
// differently (more space around items in a menu). This class wants
|
||||
// to be able to space item the same, no matter where they are. The
|
||||
// fExtraPad field allows for that.
|
||||
// The 'fExtraPad' field is used to when this menu item is added to
|
||||
// a menubar instead of a menu. Menus and MenuBars space out items
|
||||
// differently (more space around items in a menu). This class wants
|
||||
// to be able to space item the same, no matter where they are. The
|
||||
// fExtraPad field allows for that.
|
||||
|
||||
if (model->IsRoot())
|
||||
SetLabel(model->Name());
|
||||
@@ -189,10 +189,11 @@ ModelMenuItem::Invoke(BMessage *message)
|
||||
clone.AddInt64("when", system_time());
|
||||
clone.AddPointer("source", this);
|
||||
|
||||
if ((modifiers() & B_OPTION_KEY) == 0)
|
||||
if ((modifiers() & B_OPTION_KEY) == 0) {
|
||||
// if option not held, remove refs to close to prevent closing
|
||||
// parent window
|
||||
clone.RemoveData("nodeRefsToClose");
|
||||
}
|
||||
|
||||
return BInvoker::Invoke(&clone);
|
||||
}
|
||||
@@ -226,8 +227,8 @@ SpecialModelMenuItem::DrawContent()
|
||||
|
||||
|
||||
IconMenuItem::IconMenuItem(const char *label, BMessage *message, BBitmap *icon)
|
||||
: PositionPassingMenuItem(label, message),
|
||||
fDeviceIcon(icon)
|
||||
: PositionPassingMenuItem(label, message),
|
||||
fDeviceIcon(icon)
|
||||
{
|
||||
// IconMenuItem is used in synchronously invoked menus, make sure
|
||||
// we invoke with a timeout
|
||||
@@ -236,12 +237,12 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message, BBitmap *icon)
|
||||
|
||||
|
||||
IconMenuItem::IconMenuItem(const char *label, BMessage *message,
|
||||
const BNodeInfo *nodeInfo, icon_size which)
|
||||
: PositionPassingMenuItem(label, message),
|
||||
fDeviceIcon(NULL)
|
||||
const BNodeInfo *nodeInfo, icon_size which)
|
||||
: PositionPassingMenuItem(label, message),
|
||||
fDeviceIcon(NULL)
|
||||
{
|
||||
if (nodeInfo) {
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_COLOR_8_BIT);
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_CMAP8);
|
||||
if (nodeInfo->GetTrackerIcon(fDeviceIcon, B_MINI_ICON)) {
|
||||
delete fDeviceIcon;
|
||||
fDeviceIcon = NULL;
|
||||
@@ -255,12 +256,12 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message,
|
||||
|
||||
|
||||
IconMenuItem::IconMenuItem(const char *label, BMessage *message,
|
||||
const char *iconType, icon_size which)
|
||||
: PositionPassingMenuItem(label, message),
|
||||
fDeviceIcon(NULL)
|
||||
const char *iconType, icon_size which)
|
||||
: PositionPassingMenuItem(label, message),
|
||||
fDeviceIcon(NULL)
|
||||
{
|
||||
BMimeType mime(iconType);
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_COLOR_8_BIT);
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_CMAP8);
|
||||
|
||||
if (mime.GetIcon(fDeviceIcon, which) != B_OK) {
|
||||
delete fDeviceIcon;
|
||||
@@ -274,12 +275,12 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message,
|
||||
|
||||
|
||||
IconMenuItem::IconMenuItem(BMenu *submenu, BMessage *message,
|
||||
const char *iconType, icon_size which)
|
||||
: PositionPassingMenuItem(submenu, message),
|
||||
fDeviceIcon(NULL)
|
||||
const char *iconType, icon_size which)
|
||||
: PositionPassingMenuItem(submenu, message),
|
||||
fDeviceIcon(NULL)
|
||||
{
|
||||
BMimeType mime(iconType);
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_COLOR_8_BIT);
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_CMAP8);
|
||||
|
||||
if (mime.GetIcon(fDeviceIcon, which) != B_OK) {
|
||||
delete fDeviceIcon;
|
||||
|
||||
@@ -1327,7 +1327,7 @@ Model::TrackIconSource(icon_size size)
|
||||
else
|
||||
rect.Set(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1);
|
||||
|
||||
BBitmap bitmap(rect, B_COLOR_8_BIT);
|
||||
BBitmap bitmap(rect, B_CMAP8);
|
||||
|
||||
BModelOpener opener(this);
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ AddOnePartitionAsMenuItem(Partition *partition, void *castToParams)
|
||||
|
||||
AddOneAsMenuItemParams *params = (AddOneAsMenuItemParams *)castToParams;
|
||||
BBitmap *icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1),
|
||||
B_COLOR_8_BIT);
|
||||
B_CMAP8);
|
||||
get_device_icon(partition->GetDevice()->Name(), icon->Bits(), B_MINI_ICON);
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ MountMenu::AddDynamicItem(add_state)
|
||||
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
|
||||
if (volume.IsShared()) {
|
||||
needSeparator = true;
|
||||
BBitmap *icon = new BBitmap(BRect(0, 0, 15, 15), B_COLOR_8_BIT);
|
||||
BBitmap *icon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
|
||||
fs_info info;
|
||||
if (fs_stat_dev(volume.Device(), &info) != B_OK) {
|
||||
PRINT(("Cannot get mount menu item icon; bad device ID\n"));
|
||||
|
||||
@@ -158,8 +158,8 @@ TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID,
|
||||
// whole mime type is installed and all attributes are set; nulls can
|
||||
// be passed for attributes that don't matter; returns true if anything
|
||||
// had to be changed
|
||||
BBitmap largeIcon(BRect(0, 0, 31, 31), B_COLOR_8_BIT);
|
||||
BBitmap miniIcon(BRect(0, 0, 15, 15), B_COLOR_8_BIT);
|
||||
BBitmap largeIcon(BRect(0, 0, 31, 31), B_CMAP8);
|
||||
BBitmap miniIcon(BRect(0, 0, 15, 15), B_CMAP8);
|
||||
char tmp[B_MIME_TYPE_LENGTH];
|
||||
|
||||
BMimeType mime(type);
|
||||
|
||||
+164
-79
@@ -74,11 +74,16 @@ extern _IMPEXP_BE const uint32 MINI_ICON_TYPE;
|
||||
|
||||
FILE *logFile = NULL;
|
||||
|
||||
static const float kMinSeparatorStubX = 10;
|
||||
static const float kStubToStringSlotX = 5;
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
const rgb_color kBlack = {0, 0, 0, 255};
|
||||
const rgb_color kWhite = {255, 255, 255, 255};
|
||||
|
||||
|
||||
uint32
|
||||
HashString(const char *string, uint32 seed)
|
||||
{
|
||||
@@ -94,6 +99,7 @@ HashString(const char *string, uint32 seed)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
AttrHashString(const char *string, uint32 type)
|
||||
{
|
||||
@@ -113,6 +119,7 @@ AttrHashString(const char *string, uint32 type)
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ValidateStream(BMallocIO *stream, uint32 key, int32 version)
|
||||
{
|
||||
@@ -126,6 +133,7 @@ ValidateStream(BMallocIO *stream, uint32 key, int32 version)
|
||||
return test_key == key && test_version == version;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DisallowFilenameKeys(BTextView *textView)
|
||||
{
|
||||
@@ -133,6 +141,7 @@ DisallowFilenameKeys(BTextView *textView)
|
||||
textView->DisallowChar('/');
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DisallowMetaKeys(BTextView *textView)
|
||||
{
|
||||
@@ -149,6 +158,7 @@ DisallowMetaKeys(BTextView *textView)
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
void
|
||||
PoseInfo::EndianSwap(void *castToThis)
|
||||
{
|
||||
@@ -170,6 +180,7 @@ PoseInfo::EndianSwap(void *castToThis)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PoseInfo::PrintToStream()
|
||||
{
|
||||
@@ -177,26 +188,31 @@ PoseInfo::PrintToStream()
|
||||
fInitedDirectory, fLocation.x, fLocation.y));
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
size_t
|
||||
ExtendedPoseInfo::Size() const
|
||||
{
|
||||
return sizeof(ExtendedPoseInfo) + fNumFrames * sizeof(FrameLocation);
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
ExtendedPoseInfo::Size(int32 count)
|
||||
{
|
||||
return sizeof(ExtendedPoseInfo) + count * sizeof(FrameLocation);
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
ExtendedPoseInfo::SizeWithHeadroom() const
|
||||
{
|
||||
return sizeof(ExtendedPoseInfo) + (fNumFrames + 1) * sizeof(FrameLocation);
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
ExtendedPoseInfo::SizeWithHeadroom(size_t oldSize)
|
||||
{
|
||||
@@ -213,34 +229,41 @@ ExtendedPoseInfo::SizeWithHeadroom(size_t oldSize)
|
||||
bool
|
||||
ExtendedPoseInfo::HasLocationForFrame(BRect frame) const
|
||||
{
|
||||
for (int32 index = 0; index < fNumFrames; index++)
|
||||
for (int32 index = 0; index < fNumFrames; index++) {
|
||||
if (fLocations[index].fFrame == frame)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
BPoint
|
||||
ExtendedPoseInfo::LocationForFrame(BRect frame) const
|
||||
{
|
||||
for (int32 index = 0; index < fNumFrames; index++)
|
||||
for (int32 index = 0; index < fNumFrames; index++) {
|
||||
if (fLocations[index].fFrame == frame)
|
||||
return fLocations[index].fLocation;
|
||||
}
|
||||
|
||||
TRESPASS();
|
||||
return BPoint(0, 0);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ExtendedPoseInfo::SetLocationForFrame(BPoint newLocation, BRect frame)
|
||||
{
|
||||
for (int32 index = 0; index < fNumFrames; index++)
|
||||
for (int32 index = 0; index < fNumFrames; index++) {
|
||||
if (fLocations[index].fFrame == frame) {
|
||||
if (fLocations[index].fLocation == newLocation)
|
||||
return false;
|
||||
|
||||
fLocations[index].fLocation = newLocation;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
fLocations[fNumFrames].fFrame = frame;
|
||||
fLocations[fNumFrames].fLocation = newLocation;
|
||||
fLocations[fNumFrames].fWorkspaces = 0xffffffff;
|
||||
@@ -248,6 +271,7 @@ ExtendedPoseInfo::SetLocationForFrame(BPoint newLocation, BRect frame)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ExtendedPoseInfo::EndianSwap(void *castToThis)
|
||||
{
|
||||
@@ -275,29 +299,37 @@ ExtendedPoseInfo::EndianSwap(void *castToThis)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ExtendedPoseInfo::PrintToStream()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
OffscreenBitmap::OffscreenBitmap(BRect frame)
|
||||
: fBitmap(NULL)
|
||||
:
|
||||
fBitmap(NULL)
|
||||
{
|
||||
NewBitmap(frame);
|
||||
}
|
||||
|
||||
|
||||
OffscreenBitmap::OffscreenBitmap()
|
||||
: fBitmap(NULL)
|
||||
:
|
||||
fBitmap(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
OffscreenBitmap::~OffscreenBitmap()
|
||||
{
|
||||
delete fBitmap;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OffscreenBitmap::NewBitmap(BRect bounds)
|
||||
{
|
||||
@@ -319,21 +351,25 @@ OffscreenBitmap::NewBitmap(BRect bounds)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BView *
|
||||
OffscreenBitmap::BeginUsing(BRect frame)
|
||||
{
|
||||
if (!fBitmap || fBitmap->Bounds() != frame)
|
||||
NewBitmap(frame);
|
||||
|
||||
fBitmap->Lock();
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OffscreenBitmap::DoneUsing()
|
||||
{
|
||||
fBitmap->Unlock();
|
||||
}
|
||||
|
||||
|
||||
BBitmap *
|
||||
OffscreenBitmap::Bitmap() const
|
||||
{
|
||||
@@ -342,6 +378,7 @@ OffscreenBitmap::Bitmap() const
|
||||
return fBitmap;
|
||||
}
|
||||
|
||||
|
||||
BView *
|
||||
OffscreenBitmap::View() const
|
||||
{
|
||||
@@ -432,11 +469,11 @@ FadeRGBA32Vertical(uint32 *bits, int32 width, int32 height, int32 from, int32 to
|
||||
|
||||
|
||||
DraggableIcon::DraggableIcon(BRect rect, const char *name, const char *mimeType,
|
||||
icon_size size, const BMessage *message, BMessenger target, uint32 resizeMask,
|
||||
uint32 flags)
|
||||
: BView(rect, name, resizeMask, flags),
|
||||
fMessage(*message),
|
||||
fTarget(target)
|
||||
icon_size size, const BMessage *message, BMessenger target,
|
||||
uint32 resizeMask, uint32 flags)
|
||||
: BView(rect, name, resizeMask, flags),
|
||||
fMessage(*message),
|
||||
fTarget(target)
|
||||
{
|
||||
fBitmap = new BBitmap(Bounds(), kDefaultIconDepth);
|
||||
BMimeType mime(mimeType);
|
||||
@@ -451,16 +488,18 @@ DraggableIcon::DraggableIcon(BRect rect, const char *name, const char *mimeType,
|
||||
}
|
||||
|
||||
|
||||
DraggableIcon::~DraggableIcon()
|
||||
{
|
||||
delete fBitmap;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DraggableIcon::SetTarget(BMessenger target)
|
||||
{
|
||||
fTarget = target;
|
||||
}
|
||||
|
||||
DraggableIcon::~DraggableIcon()
|
||||
{
|
||||
delete fBitmap;
|
||||
}
|
||||
|
||||
BRect
|
||||
DraggableIcon::PreferredRect(BPoint offset, icon_size size)
|
||||
@@ -470,6 +509,7 @@ DraggableIcon::PreferredRect(BPoint offset, icon_size size)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DraggableIcon::AttachedToWindow()
|
||||
{
|
||||
@@ -480,6 +520,7 @@ DraggableIcon::AttachedToWindow()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DraggableIcon::MouseDown(BPoint point)
|
||||
{
|
||||
@@ -501,8 +542,8 @@ DraggableIcon::MouseDown(BPoint point)
|
||||
view->SetHighColor(0, 0, 0, 0);
|
||||
view->FillRect(view->Bounds());
|
||||
view->SetDrawingMode(B_OP_ALPHA);
|
||||
view->SetHighColor(0, 0, 0, 128); // set the level of transparency by
|
||||
// value
|
||||
view->SetHighColor(0, 0, 0, 128);
|
||||
// set the level of transparency by value
|
||||
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
|
||||
view->DrawBitmap(fBitmap);
|
||||
view->Sync();
|
||||
@@ -510,12 +551,14 @@ DraggableIcon::MouseDown(BPoint point)
|
||||
DragMessage(&fMessage, dragBitmap, B_OP_ALPHA, point, fTarget.Target(0));
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DraggableIcon::DragStarted(BMessage *)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DraggableIcon::Draw(BRect)
|
||||
{
|
||||
@@ -523,29 +566,34 @@ DraggableIcon::Draw(BRect)
|
||||
DrawBitmap(fBitmap);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char *name,
|
||||
const char *text, uint32 resizeFlags, uint32 flags)
|
||||
: BStringView(bounds, name, text, resizeFlags, flags),
|
||||
fBitmap(NULL),
|
||||
fOrigBitmap(NULL)
|
||||
const char *text, uint32 resizeFlags, uint32 flags)
|
||||
: BStringView(bounds, name, text, resizeFlags, flags),
|
||||
fBitmap(NULL),
|
||||
fOrigBitmap(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char *name,
|
||||
const char *text, BBitmap *inBitmap, uint32 resizeFlags, uint32 flags)
|
||||
: BStringView(bounds, name, text, resizeFlags, flags),
|
||||
fBitmap(NULL),
|
||||
fOrigBitmap(inBitmap)
|
||||
const char *text, BBitmap *inBitmap, uint32 resizeFlags, uint32 flags)
|
||||
: BStringView(bounds, name, text, resizeFlags, flags),
|
||||
fBitmap(NULL),
|
||||
fOrigBitmap(inBitmap)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FlickerFreeStringView::~FlickerFreeStringView()
|
||||
{
|
||||
delete fBitmap;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FlickerFreeStringView::Draw(BRect)
|
||||
{
|
||||
@@ -583,28 +631,28 @@ FlickerFreeStringView::Draw(BRect)
|
||||
edge_info eInfo;
|
||||
switch (Alignment()) {
|
||||
case B_ALIGN_LEFT:
|
||||
{
|
||||
// If the first char has a negative left edge give it
|
||||
// some more room by shifting that much more to the right.
|
||||
font.GetEdges(Text(), 1, &eInfo);
|
||||
loc.x = bounds.left + (2 - eInfo.left);
|
||||
break;
|
||||
}
|
||||
{
|
||||
// If the first char has a negative left edge give it
|
||||
// some more room by shifting that much more to the right.
|
||||
font.GetEdges(Text(), 1, &eInfo);
|
||||
loc.x = bounds.left + (2 - eInfo.left);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_ALIGN_CENTER:
|
||||
{
|
||||
float width = StringWidth(Text());
|
||||
float center = (bounds.right - bounds.left) / 2;
|
||||
loc.x = center - (width/2);
|
||||
break;
|
||||
}
|
||||
{
|
||||
float width = StringWidth(Text());
|
||||
float center = (bounds.right - bounds.left) / 2;
|
||||
loc.x = center - (width/2);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_ALIGN_RIGHT:
|
||||
{
|
||||
float width = StringWidth(Text());
|
||||
loc.x = bounds.right - width - 2;
|
||||
break;
|
||||
}
|
||||
{
|
||||
float width = StringWidth(Text());
|
||||
loc.x = bounds.right - width - 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
loc.y = bounds.bottom - (1 + height.descent);
|
||||
offscreen->MovePenTo(loc);
|
||||
@@ -616,6 +664,7 @@ FlickerFreeStringView::Draw(BRect)
|
||||
fBitmap->DoneUsing();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FlickerFreeStringView::AttachedToWindow()
|
||||
{
|
||||
@@ -628,6 +677,7 @@ FlickerFreeStringView::AttachedToWindow()
|
||||
SetLowColor(B_TRANSPARENT_32_BIT);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FlickerFreeStringView::SetViewColor(rgb_color color)
|
||||
{
|
||||
@@ -638,6 +688,7 @@ FlickerFreeStringView::SetViewColor(rgb_color color)
|
||||
_inherited::SetViewColor(B_TRANSPARENT_32_BIT);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FlickerFreeStringView::SetLowColor(rgb_color color)
|
||||
{
|
||||
@@ -648,10 +699,12 @@ FlickerFreeStringView::SetLowColor(rgb_color color)
|
||||
_inherited::SetLowColor(B_TRANSPARENT_32_BIT);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
TitledSeparatorItem::TitledSeparatorItem(const char *label)
|
||||
: BMenuItem(label, 0)
|
||||
: BMenuItem(label, 0)
|
||||
{
|
||||
_inherited::SetEnabled(false);
|
||||
}
|
||||
@@ -661,20 +714,20 @@ TitledSeparatorItem::~TitledSeparatorItem()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TitledSeparatorItem::SetEnabled(bool)
|
||||
{
|
||||
// leave disabled
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TitledSeparatorItem::GetContentSize(float *width, float *height)
|
||||
{
|
||||
_inherited::GetContentSize(width, height);
|
||||
}
|
||||
|
||||
const float kMinSeparatorStubX = 10;
|
||||
const float kStubToStringSlotX = 5;
|
||||
|
||||
inline rgb_color
|
||||
ShiftMenuBackgroundColor(float by)
|
||||
@@ -682,6 +735,7 @@ ShiftMenuBackgroundColor(float by)
|
||||
return tint_color(ui_color(B_MENU_BACKGROUND_COLOR), by);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TitledSeparatorItem::Draw()
|
||||
{
|
||||
@@ -774,18 +828,21 @@ TitledSeparatorItem::Draw()
|
||||
parent->PopState();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
ShortcutFilter::ShortcutFilter(uint32 shortcutKey, uint32 shortcutModifier,
|
||||
uint32 shortcutWhat, BHandler *target)
|
||||
: BMessageFilter(B_KEY_DOWN),
|
||||
fShortcutKey(shortcutKey),
|
||||
fShortcutModifier(shortcutModifier),
|
||||
fShortcutWhat(shortcutWhat),
|
||||
fTarget(target)
|
||||
uint32 shortcutWhat, BHandler *target)
|
||||
: BMessageFilter(B_KEY_DOWN),
|
||||
fShortcutKey(shortcutKey),
|
||||
fShortcutModifier(shortcutModifier),
|
||||
fShortcutWhat(shortcutWhat),
|
||||
fTarget(target)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
filter_result
|
||||
ShortcutFilter::Filter(BMessage *message, BHandler **)
|
||||
{
|
||||
@@ -815,7 +872,10 @@ ShortcutFilter::Filter(BMessage *message, BHandler **)
|
||||
return B_DISPATCH_MESSAGE;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
void
|
||||
@@ -920,6 +980,7 @@ MatchArchivedVolume(BVolume *result, const BMessage *message, int32 index)
|
||||
return B_DEV_BAD_DRIVE_NUM;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StringFromStream(BString *string, BMallocIO *stream, bool endianSwap)
|
||||
{
|
||||
@@ -940,6 +1001,7 @@ StringFromStream(BString *string, BMallocIO *stream, bool endianSwap)
|
||||
string->UnlockBuffer(length);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StringToStream(const BString *string, BMallocIO *stream)
|
||||
{
|
||||
@@ -948,12 +1010,14 @@ StringToStream(const BString *string, BMallocIO *stream)
|
||||
stream->Write(string->String(), (size_t)string->Length() + 1);
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
ArchiveSize(const BString *string)
|
||||
{
|
||||
return string->Length() + 1 + (ssize_t)sizeof(int32);
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
CountRefs(const BMessage *message)
|
||||
{
|
||||
@@ -964,6 +1028,7 @@ CountRefs(const BMessage *message)
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static entry_ref *
|
||||
EachEntryRefCommon(BMessage *message, entry_ref *(*func)(entry_ref *, void *),
|
||||
void *passThru, int32 maxCount)
|
||||
@@ -986,17 +1051,20 @@ EachEntryRefCommon(BMessage *message, entry_ref *(*func)(entry_ref *, void *),
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ContainsEntryRef(const BMessage *message, const entry_ref *ref)
|
||||
{
|
||||
entry_ref match;
|
||||
for (int32 index = 0; (message->FindRef("refs", index, &match) == B_OK); index++)
|
||||
for (int32 index = 0; (message->FindRef("refs", index, &match) == B_OK); index++) {
|
||||
if (*ref == match)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
entry_ref *
|
||||
EachEntryRef(BMessage *message, entry_ref *(*func)(entry_ref *, void *),
|
||||
void *passThru)
|
||||
@@ -1006,13 +1074,15 @@ EachEntryRef(BMessage *message, entry_ref *(*func)(entry_ref *, void *),
|
||||
|
||||
typedef entry_ref *(*EachEntryIteratee)(entry_ref *, void *);
|
||||
|
||||
const entry_ref *EachEntryRef(const BMessage *message,
|
||||
const entry_ref *(*func)(const entry_ref *, void *), void *passThru)
|
||||
const entry_ref *
|
||||
EachEntryRef(const BMessage *message, const entry_ref *(*func)(const entry_ref *, void *),
|
||||
void *passThru)
|
||||
{
|
||||
return EachEntryRefCommon(const_cast<BMessage *>(message),
|
||||
(EachEntryIteratee)func, passThru, -1);
|
||||
}
|
||||
|
||||
|
||||
entry_ref *
|
||||
EachEntryRef(BMessage *message, entry_ref *(*func)(entry_ref *, void *),
|
||||
void *passThru, int32 maxCount)
|
||||
@@ -1020,6 +1090,7 @@ EachEntryRef(BMessage *message, entry_ref *(*func)(entry_ref *, void *),
|
||||
return EachEntryRefCommon(message, func, passThru, maxCount);
|
||||
}
|
||||
|
||||
|
||||
const entry_ref *
|
||||
EachEntryRef(const BMessage *message, const entry_ref *(*func)(const entry_ref *, void *),
|
||||
void *passThru, int32 maxCount)
|
||||
@@ -1028,16 +1099,19 @@ EachEntryRef(const BMessage *message, const entry_ref *(*func)(const entry_ref *
|
||||
(EachEntryIteratee)func, passThru, maxCount);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TruncateLeaf(BString *string)
|
||||
{
|
||||
for (int32 index = string->Length(); index >= 0; index--)
|
||||
for (int32 index = string->Length(); index >= 0; index--) {
|
||||
if ((*string)[index] == '/') {
|
||||
string->Truncate(index + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int64
|
||||
StringToScalar(const char *text)
|
||||
{
|
||||
@@ -1059,9 +1133,10 @@ StringToScalar(const char *text)
|
||||
} else if (strstr(buffer, "byte") || strstr(buffer, "BYTE")) {
|
||||
val = strtoll(buffer, &end, 10);
|
||||
val *= kGBSize;
|
||||
} else
|
||||
} else {
|
||||
// no suffix, try plain byte conversion
|
||||
val = strtoll(buffer, &end, 10);
|
||||
}
|
||||
|
||||
delete [] buffer;
|
||||
return val;
|
||||
@@ -1078,6 +1153,7 @@ operator==(const rgb_color &a, const rgb_color &b)
|
||||
&& a.alpha == b.alpha;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
operator!=(const rgb_color &a, const rgb_color &b)
|
||||
{
|
||||
@@ -1086,6 +1162,7 @@ operator!=(const rgb_color &a, const rgb_color &b)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static BRect
|
||||
LineBounds(BPoint where, float length, bool vertical)
|
||||
{
|
||||
@@ -1100,14 +1177,16 @@ LineBounds(BPoint where, float length, bool vertical)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
SeparatorLine::SeparatorLine(BPoint where, float length, bool vertical, const char *name)
|
||||
: BView(LineBounds(where, length, vertical), name,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW)
|
||||
: BView(LineBounds(where, length, vertical), name,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SeparatorLine::Draw(BRect)
|
||||
{
|
||||
@@ -1126,6 +1205,7 @@ SeparatorLine::Draw(BRect)
|
||||
EndLineArray();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HexDump(const void *buf, int32 length)
|
||||
{
|
||||
@@ -1140,7 +1220,6 @@ HexDump(const void *buf, int32 length)
|
||||
printf( "0x%06x: ", (int)offset);
|
||||
|
||||
for (index = 0; index < kBytesPerLine; index++) {
|
||||
|
||||
if (remain-- > 0)
|
||||
printf("%02x%c", buffer[index], remain > 0 ? ',' : ' ');
|
||||
else
|
||||
@@ -1150,7 +1229,6 @@ HexDump(const void *buf, int32 length)
|
||||
remain = length;
|
||||
printf(" \'");
|
||||
for (index = 0; index < kBytesPerLine; index++) {
|
||||
|
||||
if (remain-- > 0)
|
||||
printf("%c", buffer[index] > ' ' ? buffer[index] : '.');
|
||||
else
|
||||
@@ -1161,11 +1239,11 @@ HexDump(const void *buf, int32 length)
|
||||
length -= kBytesPerLine;
|
||||
if (length <= 0)
|
||||
break;
|
||||
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EnableNamedMenuItem(BMenu *menu, const char *itemName, bool on)
|
||||
{
|
||||
@@ -1174,6 +1252,7 @@ EnableNamedMenuItem(BMenu *menu, const char *itemName, bool on)
|
||||
item->SetEnabled(on);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MarkNamedMenuItem(BMenu *menu, const char *itemName, bool on)
|
||||
{
|
||||
@@ -1182,6 +1261,7 @@ MarkNamedMenuItem(BMenu *menu, const char *itemName, bool on)
|
||||
item->SetMarked(on);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EnableNamedMenuItem(BMenu *menu, uint32 commandName, bool on)
|
||||
{
|
||||
@@ -1190,6 +1270,7 @@ EnableNamedMenuItem(BMenu *menu, uint32 commandName, bool on)
|
||||
item->SetEnabled(on);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MarkNamedMenuItem(BMenu *menu, uint32 commandName, bool on)
|
||||
{
|
||||
@@ -1198,6 +1279,7 @@ MarkNamedMenuItem(BMenu *menu, uint32 commandName, bool on)
|
||||
item->SetMarked(on);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeleteSubmenu(BMenuItem *submenuItem)
|
||||
{
|
||||
@@ -1217,6 +1299,7 @@ DeleteSubmenu(BMenuItem *submenuItem)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GetAppSignatureFromAttr(BFile *file, char *result)
|
||||
{
|
||||
@@ -1226,12 +1309,9 @@ GetAppSignatureFromAttr(BFile *file, char *result)
|
||||
// the resource fork is scanned to read the attribute
|
||||
|
||||
#ifdef B_APP_FILE_INFO_IS_FAST
|
||||
|
||||
BAppFileInfo appFileInfo(file);
|
||||
return appFileInfo.GetSignature(result);
|
||||
|
||||
#else
|
||||
|
||||
ssize_t readResult = file->ReadAttr(kAttrAppSignature, B_MIME_STRING_TYPE,
|
||||
0, result, B_MIME_TYPE_LENGTH);
|
||||
|
||||
@@ -1239,10 +1319,10 @@ GetAppSignatureFromAttr(BFile *file, char *result)
|
||||
return (status_t)readResult;
|
||||
|
||||
return B_OK;
|
||||
|
||||
#endif
|
||||
#endif // B_APP_FILE_INFO_IS_FAST
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GetAppIconFromAttr(BFile *file, BBitmap *result, icon_size size)
|
||||
{
|
||||
@@ -1252,12 +1332,9 @@ GetAppIconFromAttr(BFile *file, BBitmap *result, icon_size size)
|
||||
// the resource fork is scanned to read the icons
|
||||
|
||||
#ifdef B_APP_FILE_INFO_IS_FAST
|
||||
|
||||
BAppFileInfo appFileInfo(file);
|
||||
return appFileInfo.GetIcon(result, size);
|
||||
|
||||
#else
|
||||
|
||||
const char *attrName = size == B_LARGE_ICON ? kAttrLargeIcon : kAttrMiniIcon;
|
||||
uint32 type = size == B_LARGE_ICON ? LARGE_ICON_TYPE : MINI_ICON_TYPE;
|
||||
char buffer[1024];
|
||||
@@ -1268,17 +1345,16 @@ GetAppIconFromAttr(BFile *file, BBitmap *result, icon_size size)
|
||||
return err;
|
||||
|
||||
ssize_t readResult = file->ReadAttr(attrName, type, 0, buffer, (size_t)ainfo.size);
|
||||
|
||||
if (readResult <= 0)
|
||||
return (status_t)readResult;
|
||||
|
||||
result->SetBits(buffer, result->BitsLength(), 0, B_COLOR_8_BIT);
|
||||
result->SetBits(buffer, result->BitsLength(), 0, B_CMAP8);
|
||||
|
||||
return B_OK;
|
||||
|
||||
#endif
|
||||
#endif // B_APP_FILE_INFO_IS_FAST
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GetFileIconFromAttr(BNode *file, BBitmap *result, icon_size size)
|
||||
{
|
||||
@@ -1286,6 +1362,7 @@ GetFileIconFromAttr(BNode *file, BBitmap *result, icon_size size)
|
||||
return fileInfo.GetIcon(result, size);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PrintToStream(rgb_color color)
|
||||
{
|
||||
@@ -1303,6 +1380,7 @@ EachMenuItem(BMenu *menu, bool recursive, BMenuItem *(*func)(BMenuItem *))
|
||||
BMenuItem *result = (func)(item);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (recursive) {
|
||||
BMenu *submenu = menu->SubmenuAt(index);
|
||||
if (submenu)
|
||||
@@ -1313,6 +1391,7 @@ EachMenuItem(BMenu *menu, bool recursive, BMenuItem *(*func)(BMenuItem *))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
extern const BMenuItem *
|
||||
EachMenuItem(const BMenu *menu, bool recursive, BMenuItem *(*func)(const BMenuItem *))
|
||||
{
|
||||
@@ -1322,6 +1401,7 @@ EachMenuItem(const BMenu *menu, bool recursive, BMenuItem *(*func)(const BMenuIt
|
||||
BMenuItem *result = (func)(item);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (recursive) {
|
||||
BMenu *submenu = menu->SubmenuAt(index);
|
||||
if (submenu)
|
||||
@@ -1332,18 +1412,21 @@ EachMenuItem(const BMenu *menu, bool recursive, BMenuItem *(*func)(const BMenuIt
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
PositionPassingMenuItem::PositionPassingMenuItem(const char *title,
|
||||
BMessage *message, char shortcut, uint32 modifiers)
|
||||
: BMenuItem(title, message, shortcut, modifiers)
|
||||
BMessage *message, char shortcut, uint32 modifiers)
|
||||
: BMenuItem(title, message, shortcut, modifiers)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PositionPassingMenuItem::PositionPassingMenuItem(BMenu *menu,
|
||||
BMessage *message)
|
||||
: BMenuItem(menu, message)
|
||||
BMessage *message)
|
||||
: BMenuItem(menu, message)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PositionPassingMenuItem::Invoke(BMessage *message)
|
||||
{
|
||||
@@ -1376,8 +1459,7 @@ PositionPassingMenuItem::Invoke(BMessage *message)
|
||||
|
||||
// use the window position only, if the item was invoked from the menu
|
||||
// menu->Window() points to the window the item was invoked from
|
||||
if (dynamic_cast<BContainerWindow *>(menu->Window()) == NULL)
|
||||
{
|
||||
if (dynamic_cast<BContainerWindow *>(menu->Window()) == NULL) {
|
||||
LooperAutoLocker lock(menu);
|
||||
if (lock.IsLocked()) {
|
||||
BPoint invokeOrigin(menu->Window()->Frame().LeftTop());
|
||||
@@ -1388,6 +1470,7 @@ PositionPassingMenuItem::Invoke(BMessage *message)
|
||||
return BInvoker::Invoke(&clone);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BootedInSafeMode()
|
||||
{
|
||||
@@ -1405,6 +1488,7 @@ _ThrowOnError(status_t error, const char *DEBUG_ONLY(file), int32 DEBUG_ONLY(lin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_ThrowIfNotSize(ssize_t size, const char *DEBUG_ONLY(file), int32 DEBUG_ONLY(line))
|
||||
{
|
||||
@@ -1414,6 +1498,7 @@ _ThrowIfNotSize(ssize_t size, const char *DEBUG_ONLY(file), int32 DEBUG_ONLY(lin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_ThrowOnError(status_t error, const char *DEBUG_ONLY(debugString),
|
||||
const char *DEBUG_ONLY(file), int32 DEBUG_ONLY(line))
|
||||
|
||||
@@ -75,7 +75,7 @@ const int64 kTBSize = kGBSize * kKBSize;
|
||||
|
||||
const int32 kMiniIconSeparator = 3;
|
||||
|
||||
const color_space kDefaultIconDepth = B_COLOR_8_BIT;
|
||||
const color_space kDefaultIconDepth = B_CMAP8;
|
||||
|
||||
// misc typedefs, constants and structs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user