Fixed gcc4 warnings and some style violations.
This commit is contained in:
parent
4412809657
commit
90a68e6002
|
@ -29,7 +29,8 @@ ReadNodeIcon(const char* name, icon_size size, bool followSymlink)
|
||||||
|
|
||||||
BNode node(BPath(&ref).Path());
|
BNode node(BPath(&ref).Path());
|
||||||
|
|
||||||
BBitmap* ret = new BBitmap(BRect(0, 0, (float)size - 1, (float)size - 1), B_RGBA32);
|
BBitmap* ret = new BBitmap(BRect(0, 0, (float)size - 1, (float)size - 1),
|
||||||
|
B_RGBA32);
|
||||||
if (BIconUtils::GetIcon(&node, BEOS_ICON_ATTRIBUTE, BEOS_MINI_ICON_ATTRIBUTE,
|
if (BIconUtils::GetIcon(&node, BEOS_ICON_ATTRIBUTE, BEOS_MINI_ICON_ATTRIBUTE,
|
||||||
BEOS_LARGE_ICON_ATTRIBUTE, size, ret) != B_OK) {
|
BEOS_LARGE_ICON_ATTRIBUTE, size, ret) != B_OK) {
|
||||||
delete ret;
|
delete ret;
|
||||||
|
@ -72,7 +73,8 @@ BBitmap* IconFromResources(BResources* res, int32 num, icon_size size)
|
||||||
cspace = B_CMAP8;
|
cspace = B_CMAP8;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBitmap* icon = new BBitmap(BRect(0, 0, size - 1, size - 1), cspace);
|
BBitmap* icon = new BBitmap(BRect(0, 0, (float)size - 1, (float)size - 1),
|
||||||
|
cspace);
|
||||||
if (icon->InitCheck() != B_OK)
|
if (icon->InitCheck() != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -103,28 +105,29 @@ RescaleBitmap(const BBitmap* src, int32 width, int32 height)
|
||||||
|
|
||||||
if (height < 0) {
|
if (height < 0) {
|
||||||
float srcProp = srcSize.Height() / srcSize.Width();
|
float srcProp = srcSize.Height() / srcSize.Width();
|
||||||
height = (int32)(width * srcProp);
|
height = (width * (int32)srcProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
BBitmap* res = new BBitmap(BRect(0, 0, width, height), src->ColorSpace());
|
BBitmap* res = new BBitmap(BRect(0, 0, (float)width, (float)height),
|
||||||
|
src->ColorSpace());
|
||||||
|
|
||||||
float dx = (srcSize.Width() + 1) / (width + 1);
|
float dx = (srcSize.Width() + 1) / ((float)width + 1);
|
||||||
float dy = (srcSize.Height() + 1) / (height + 1);
|
float dy = (srcSize.Height() + 1) / ((float)height + 1);
|
||||||
uint8 bpp = (uint8)(src->BytesPerRow() / srcSize.Width());
|
uint8 bpp = (uint8)(src->BytesPerRow() / (int32)srcSize.Width());
|
||||||
|
|
||||||
int srcYOff = src->BytesPerRow();
|
int32 srcYOff = src->BytesPerRow();
|
||||||
int dstYOff = res->BytesPerRow();
|
int32 dstYOff = res->BytesPerRow();
|
||||||
|
|
||||||
void* dstData = res->Bits();
|
void* dstData = res->Bits();
|
||||||
void* srcData = src->Bits();
|
void* srcData = src->Bits();
|
||||||
|
|
||||||
for (int32 y = 0; y <= height; y++) {
|
for (int32 y = 0; y <= height; y++) {
|
||||||
void* dstRow = (void *)((uint32)dstData + (uint32)(y * dstYOff));
|
void* dstRow = (void*)((uint32)dstData + (uint32)(y * dstYOff));
|
||||||
void* srcRow = (void *)((uint32)srcData + ((uint32)(y * dy) * srcYOff));
|
void* srcRow = (void*)((uint32)srcData + ((uint32)(y * (int32)dy) * srcYOff));
|
||||||
|
|
||||||
for (int32 x = 0; x <= width; x++)
|
for (int32 x = 0; x <= width; x++)
|
||||||
memcpy((void*)((uint32)dstRow + (x * bpp)), (void*)((uint32)srcRow +
|
memcpy((void*)((uint32)dstRow + (x * bpp)), (void*)((uint32)srcRow +
|
||||||
((uint32)(x * dx) * bpp)), bpp);
|
((uint32)(x * (int32)dx) * bpp)), bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -21,32 +21,34 @@
|
||||||
|
|
||||||
#include "ToolButton.h"
|
#include "ToolButton.h"
|
||||||
|
|
||||||
const float kPopUpMarkerSize = 5.0f;
|
const float kPopUpMarkerSize = 5.0f;
|
||||||
const float kPopUpMarkerTop = 0.5f;
|
const float kPopUpMarkerTop = 0.5f;
|
||||||
const float kPopUpMarkerRect = (kPopUpMarkerSize * 2) + 2;
|
const float kPopUpMarkerRect = (kPopUpMarkerSize * 2) + 2;
|
||||||
const uint32 kToolbarIconSize = 16; // this should go on BControlLook
|
const uint32 kToolbarIconSize = 16;
|
||||||
|
// this should go on BControlLook
|
||||||
|
|
||||||
|
|
||||||
ToolButton::ToolButton(const char* name, const char* label, BMessage* message,
|
ToolButton::ToolButton(const char* name, const char* label, BMessage* message,
|
||||||
uint32 flags)
|
uint32 flags)
|
||||||
: BControl(name, label, message,
|
:
|
||||||
flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
BControl(name, label, message,
|
||||||
|
flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
fMenu(NULL),
|
fMenu(NULL),
|
||||||
fPreferredSize(-1, -1)
|
fPreferredSize(-1, -1)
|
||||||
{
|
{
|
||||||
SetFontSize(be_plain_font->Size() * 0.85);
|
SetFontSize(be_plain_font->Size() * 0.85f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ToolButton::ToolButton(const char* label, BMessage* message)
|
ToolButton::ToolButton(const char* label, BMessage* message)
|
||||||
: BControl(NULL, label, message,
|
: BControl(NULL, label, message,
|
||||||
B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE),
|
B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE),
|
||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
fMenu(NULL),
|
fMenu(NULL),
|
||||||
fPreferredSize(-1, -1)
|
fPreferredSize(-1, -1)
|
||||||
{
|
{
|
||||||
SetFontSize(be_plain_font->Size() * 0.85);
|
SetFontSize(be_plain_font->Size() * 0.85f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +58,7 @@ ToolButton::ToolButton(BMessage* archive)
|
||||||
fMenu(NULL),
|
fMenu(NULL),
|
||||||
fPreferredSize(-1, -1)
|
fPreferredSize(-1, -1)
|
||||||
{
|
{
|
||||||
SetFontSize(be_plain_font->Size() * 0.85);
|
SetFontSize(be_plain_font->Size() * 0.85f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +119,7 @@ ToolButton::Draw(BRect updateRect)
|
||||||
uint32 flags = be_control_look->Flags(this);
|
uint32 flags = be_control_look->Flags(this);
|
||||||
|
|
||||||
// Draw background and borders
|
// Draw background and borders
|
||||||
rgb_color button = IsEnabled() ? tint_color(base, 1.07) : base;
|
rgb_color button = IsEnabled() ? tint_color(base, 1.07f) : base;
|
||||||
be_control_look->DrawButtonBackground(this, bounds, updateRect,
|
be_control_look->DrawButtonBackground(this, bounds, updateRect,
|
||||||
button, flags, 0);
|
button, flags, 0);
|
||||||
be_control_look->DrawBorder(this, bounds, updateRect,
|
be_control_look->DrawBorder(this, bounds, updateRect,
|
||||||
|
@ -160,9 +162,11 @@ ToolButton::Draw(BRect updateRect)
|
||||||
float tint = IsEnabled() ? B_DARKEN_4_TINT : B_DARKEN_1_TINT;
|
float tint = IsEnabled() ? B_DARKEN_4_TINT : B_DARKEN_1_TINT;
|
||||||
BPoint center(_Center(bounds));
|
BPoint center(_Center(bounds));
|
||||||
BPoint triangle[3];
|
BPoint triangle[3];
|
||||||
triangle[0] = center + BPoint(-(kPopUpMarkerSize / 2.0), -kPopUpMarkerTop);
|
triangle[0] = center + BPoint(-(kPopUpMarkerSize / 2.0),
|
||||||
|
-kPopUpMarkerTop);
|
||||||
triangle[1] = center + BPoint(kPopUpMarkerSize, -kPopUpMarkerTop);
|
triangle[1] = center + BPoint(kPopUpMarkerSize, -kPopUpMarkerTop);
|
||||||
triangle[2] = center + BPoint(0.0, (kPopUpMarkerSize / 2.0f) - kPopUpMarkerTop);
|
triangle[2] = center + BPoint(0.0, (kPopUpMarkerSize / 2.0f)
|
||||||
|
- kPopUpMarkerTop);
|
||||||
|
|
||||||
uint32 origFlags = Flags();
|
uint32 origFlags = Flags();
|
||||||
SetFlags(origFlags | B_SUBPIXEL_PRECISE);
|
SetFlags(origFlags | B_SUBPIXEL_PRECISE);
|
||||||
|
@ -375,8 +379,8 @@ ToolButton::SetMenu(BPopUpMenu* menu)
|
||||||
BPoint
|
BPoint
|
||||||
ToolButton::_Center(BRect rect)
|
ToolButton::_Center(BRect rect)
|
||||||
{
|
{
|
||||||
BPoint center(roundf((rect.left + rect.right) / 2.0),
|
BPoint center(roundf((rect.left + rect.right) / 2.0f),
|
||||||
roundf((rect.top + rect.bottom) / 2.0));
|
roundf((rect.top + rect.bottom) / 2.0f));
|
||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +413,7 @@ ToolButton::_ValidatePreferredSize()
|
||||||
GetFontHeight(&fontHeight);
|
GetFontHeight(&fontHeight);
|
||||||
|
|
||||||
fPreferredSize.height
|
fPreferredSize.height
|
||||||
+= ceilf((fontHeight.ascent + fontHeight.descent) * 1.5);
|
+= ceilf((fontHeight.ascent + fontHeight.descent) * 1.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bitmap())
|
if (Bitmap())
|
||||||
|
|
|
@ -13,10 +13,11 @@ class BPopUpMenu;
|
||||||
class ToolButton : public BControl {
|
class ToolButton : public BControl {
|
||||||
public:
|
public:
|
||||||
ToolButton(const char* name, const char* label,
|
ToolButton(const char* name, const char* label,
|
||||||
BMessage* message,
|
BMessage* message,
|
||||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE
|
uint32 flags = B_WILL_DRAW | B_NAVIGABLE
|
||||||
| B_FULL_UPDATE_ON_RESIZE);
|
| B_FULL_UPDATE_ON_RESIZE);
|
||||||
ToolButton(const char* label, BMessage* message = NULL);
|
ToolButton(const char* label,
|
||||||
|
BMessage* message = NULL);
|
||||||
ToolButton(BMessage* archive);
|
ToolButton(BMessage* archive);
|
||||||
|
|
||||||
virtual ~ToolButton();
|
virtual ~ToolButton();
|
||||||
|
@ -33,7 +34,7 @@ public:
|
||||||
|
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
const BMessage* message);
|
const BMessage* message);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
|
|
||||||
virtual void SetLabel(const char* string);
|
virtual void SetLabel(const char* string);
|
||||||
|
|
Ŝarĝante…
Reference in New Issue