<malloc.h> -> <stdlib.h>
Style fixes, no functional change git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36502 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
#include "ResWindow.h"
|
#include "ResWindow.h"
|
||||||
|
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
+128
-172
@@ -1,13 +1,13 @@
|
|||||||
#include "BitmapView.h"
|
#include "BitmapView.h"
|
||||||
|
#include <Alert.h>
|
||||||
|
#include <BitmapStream.h>
|
||||||
|
#include <Clipboard.h>
|
||||||
|
#include <Font.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
#include <TranslatorRoster.h>
|
#include <TranslatorRoster.h>
|
||||||
#include <TranslatorFormats.h>
|
#include <TranslatorFormats.h>
|
||||||
#include <Clipboard.h>
|
|
||||||
#include <BitmapStream.h>
|
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <Font.h>
|
|
||||||
#include <Alert.h>
|
|
||||||
|
|
||||||
// TODO: Add support for labels
|
// TODO: Add support for labels
|
||||||
|
|
||||||
@@ -22,12 +22,14 @@ enum
|
|||||||
CLIP_PRODUCTIVE = 3
|
CLIP_PRODUCTIVE = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void SetRGBColor(rgb_color *col, uint8 r, uint8 g, uint8 b, uint8 a = 255);
|
inline void SetRGBColor(rgb_color *col, uint8 r, uint8 g, uint8 b, uint8 a = 255);
|
||||||
|
|
||||||
void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a)
|
|
||||||
{
|
void
|
||||||
if(col)
|
SetRGBColor(rgb_color *col, uint8 r, uint8 g, uint8 b, uint8 a)
|
||||||
{
|
{
|
||||||
|
if (col) {
|
||||||
col->red = r;
|
col->red = r;
|
||||||
col->green = g;
|
col->green = g;
|
||||||
col->blue = b;
|
col->blue = b;
|
||||||
@@ -35,6 +37,7 @@ void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BitmapView::BitmapView(BRect frame, const char *name, BMessage *mod, BBitmap *bitmap,
|
BitmapView::BitmapView(BRect frame, const char *name, BMessage *mod, BBitmap *bitmap,
|
||||||
const char *label, border_style borderstyle, int32 resize, int32 flags)
|
const char *label, border_style borderstyle, int32 resize, int32 flags)
|
||||||
: BView(frame, name, resize, flags)
|
: BView(frame, name, resize, flags)
|
||||||
@@ -85,36 +88,39 @@ BitmapView::BitmapView(BRect frame, const char *name, BMessage *mod, BBitmap *bi
|
|||||||
float totalheight = fh.ascent + fh.descent + fh.leading;
|
float totalheight = fh.ascent + fh.descent + fh.leading;
|
||||||
float yoffset = (Bounds().Height() - 10 - (totalheight * 4)) / 2;
|
float yoffset = (Bounds().Height() - 10 - (totalheight * 4)) / 2;
|
||||||
fNoPhotoOffsets[0].Set((Bounds().Width() - fNoPhotoWidths[0]) / 2, totalheight + yoffset);
|
fNoPhotoOffsets[0].Set((Bounds().Width() - fNoPhotoWidths[0]) / 2, totalheight + yoffset);
|
||||||
fNoPhotoOffsets[1].Set( (Bounds().Width()-fNoPhotoWidths[1])/2,fNoPhotoOffsets[0].y+totalheight);
|
fNoPhotoOffsets[1].Set((Bounds().Width() - fNoPhotoWidths[1]) / 2,
|
||||||
fNoPhotoOffsets[2].Set( (Bounds().Width()-fNoPhotoWidths[2])/2,fNoPhotoOffsets[1].y+totalheight);
|
fNoPhotoOffsets[0].y + totalheight);
|
||||||
fNoPhotoOffsets[3].Set( (Bounds().Width()-fNoPhotoWidths[3])/2,fNoPhotoOffsets[2].y+totalheight);
|
fNoPhotoOffsets[2].Set((Bounds().Width() - fNoPhotoWidths[2]) / 2,
|
||||||
|
fNoPhotoOffsets[1].y + totalheight);
|
||||||
|
fNoPhotoOffsets[3].Set((Bounds().Width() - fNoPhotoWidths[3]) / 2,
|
||||||
|
fNoPhotoOffsets[2].y + totalheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BitmapView::~BitmapView(void)
|
BitmapView::~BitmapView(void)
|
||||||
{
|
{
|
||||||
delete fPopUpMenu;
|
delete fPopUpMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::AttachedToWindow(void)
|
|
||||||
|
void
|
||||||
|
BitmapView::AttachedToWindow(void)
|
||||||
{
|
{
|
||||||
SetTarget((BHandler*)Window());
|
SetTarget((BHandler*)Window());
|
||||||
fPopUpMenu->SetTargetForItems(this);
|
fPopUpMenu->SetTargetForItems(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::SetBitmap(BBitmap *bitmap)
|
|
||||||
{
|
void
|
||||||
if(bitmap && bitmap->IsValid())
|
BitmapView::SetBitmap(BBitmap *bitmap)
|
||||||
{
|
{
|
||||||
|
if (bitmap && bitmap->IsValid()) {
|
||||||
if (fBitmap == bitmap)
|
if (fBitmap == bitmap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fBitmap = bitmap;
|
fBitmap = bitmap;
|
||||||
}
|
} else {
|
||||||
else
|
if (!fBitmap)
|
||||||
{
|
|
||||||
if(fBitmap==NULL)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fBitmap = NULL;
|
fBitmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,20 +129,22 @@ void BitmapView::SetBitmap(BBitmap *bitmap)
|
|||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::SetEnabled(bool value)
|
|
||||||
{
|
void
|
||||||
if(fEnabled!=value)
|
BitmapView::SetEnabled(bool value)
|
||||||
{
|
{
|
||||||
|
if (fEnabled != value) {
|
||||||
fEnabled = value;
|
fEnabled = value;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void BitmapView::SetLabel(const char *label)
|
void
|
||||||
{
|
BitmapView::SetLabel(const char *label)
|
||||||
if(fLabel.Compare(label)!=0)
|
|
||||||
{
|
{
|
||||||
|
if (fLabel.Compare(label) != 0) {
|
||||||
fLabel = label;
|
fLabel = label;
|
||||||
|
|
||||||
CalculateBitmapRect();
|
CalculateBitmapRect();
|
||||||
@@ -146,10 +154,11 @@ void BitmapView::SetLabel(const char *label)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void BitmapView::SetStyle(border_style style)
|
|
||||||
{
|
void
|
||||||
if(fBorderStyle!=style)
|
BitmapView::SetStyle(border_style style)
|
||||||
{
|
{
|
||||||
|
if (fBorderStyle != style) {
|
||||||
fBorderStyle = style;
|
fBorderStyle = style;
|
||||||
|
|
||||||
CalculateBitmapRect();
|
CalculateBitmapRect();
|
||||||
@@ -158,10 +167,11 @@ void BitmapView::SetStyle(border_style style)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::SetFixedSize(bool isfixed)
|
|
||||||
{
|
void
|
||||||
if(fFixedSize!=isfixed)
|
BitmapView::SetFixedSize(bool isfixed)
|
||||||
{
|
{
|
||||||
|
if (fFixedSize != isfixed) {
|
||||||
fFixedSize = isfixed;
|
fFixedSize = isfixed;
|
||||||
|
|
||||||
CalculateBitmapRect();
|
CalculateBitmapRect();
|
||||||
@@ -170,16 +180,15 @@ void BitmapView::SetFixedSize(bool isfixed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::MessageReceived(BMessage *msg)
|
|
||||||
{
|
void
|
||||||
if(msg->WasDropped() && AcceptsDrops())
|
BitmapView::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
|
if (msg->WasDropped() && AcceptsDrops()) {
|
||||||
// We'll handle two types of drops: those from Tracker and those from ShowImage
|
// We'll handle two types of drops: those from Tracker and those from ShowImage
|
||||||
if(msg->what==B_SIMPLE_DATA)
|
if (msg->what == B_SIMPLE_DATA) {
|
||||||
{
|
|
||||||
int32 actions;
|
int32 actions;
|
||||||
if(msg->FindInt32("be:actions",&actions)==B_OK)
|
if (msg->FindInt32("be:actions", &actions) == B_OK) {
|
||||||
{
|
|
||||||
// ShowImage drop. This is a negotiated drag&drop, so send a reply
|
// ShowImage drop. This is a negotiated drag&drop, so send a reply
|
||||||
BMessage reply(B_COPY_TARGET), response;
|
BMessage reply(B_COPY_TARGET), response;
|
||||||
reply.AddString("be:types", "image/jpeg");
|
reply.AddString("be:types", "image/jpeg");
|
||||||
@@ -188,17 +197,17 @@ void BitmapView::MessageReceived(BMessage *msg)
|
|||||||
msg->SendReply(&reply, &response);
|
msg->SendReply(&reply, &response);
|
||||||
|
|
||||||
// now, we've gotten the response
|
// now, we've gotten the response
|
||||||
if(response.what==B_MIME_DATA)
|
if (response.what == B_MIME_DATA) {
|
||||||
{
|
|
||||||
// Obtain and translate the received data
|
// Obtain and translate the received data
|
||||||
uint8 *imagedata;
|
uint8 *imagedata;
|
||||||
ssize_t datasize;
|
ssize_t datasize;
|
||||||
|
|
||||||
// Try JPEG first
|
// Try JPEG first
|
||||||
if(response.FindData("image/jpeg",B_MIME_DATA,(const void **)&imagedata,&datasize)!=B_OK)
|
if (response.FindData("image/jpeg", B_MIME_DATA,
|
||||||
{
|
(const void **)&imagedata, &datasize) != B_OK) {
|
||||||
// Try PNG next and piddle out if unsuccessful
|
// Try PNG next and piddle out if unsuccessful
|
||||||
if(response.FindData("image/png",B_PNG_FORMAT,(const void **)&imagedata,&datasize)!=B_OK)
|
if (response.FindData("image/png", B_PNG_FORMAT,
|
||||||
|
(const void **)&imagedata, &datasize) != B_OK)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,12 +221,10 @@ void BitmapView::MessageReceived(BMessage *msg)
|
|||||||
BBitmap *bmp;
|
BBitmap *bmp;
|
||||||
if (bstream.DetachBitmap(&bmp) != B_OK)
|
if (bstream.DetachBitmap(&bmp) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetBitmap(bmp);
|
SetBitmap(bmp);
|
||||||
|
|
||||||
if (fConstrainDrops)
|
if (fConstrainDrops)
|
||||||
ConstrainBitmap();
|
ConstrainBitmap();
|
||||||
|
|
||||||
Invoke();
|
Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,17 +232,14 @@ void BitmapView::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if(msg->FindRef("refs",&ref)==B_OK)
|
if (msg->FindRef("refs", &ref) == B_OK) {
|
||||||
{
|
|
||||||
// Tracker drop
|
// Tracker drop
|
||||||
BBitmap *bmp = BTranslationUtils::GetBitmap(&ref);
|
BBitmap *bmp = BTranslationUtils::GetBitmap(&ref);
|
||||||
if(bmp)
|
if (bmp) {
|
||||||
{
|
|
||||||
SetBitmap(bmp);
|
SetBitmap(bmp);
|
||||||
|
|
||||||
if (fConstrainDrops)
|
if (fConstrainDrops)
|
||||||
ConstrainBitmap();
|
ConstrainBitmap();
|
||||||
|
|
||||||
Invoke();
|
Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,17 +249,14 @@ void BitmapView::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
switch (msg->what)
|
switch (msg->what)
|
||||||
{
|
{
|
||||||
case M_REMOVE_IMAGE:
|
case M_REMOVE_IMAGE: {
|
||||||
{
|
BAlert *alert = new BAlert("Mr. Peeps!", "This cannot be undone. Remove the image?",
|
||||||
BAlert *alert=new BAlert("Mr. Peeps!","This cannot be undone. Remove the image?","Remove",
|
"Remove", "Cancel");
|
||||||
"Cancel");
|
|
||||||
int32 value = alert->Go();
|
int32 value = alert->Go();
|
||||||
if(value==0)
|
if (value == 0) {
|
||||||
{
|
|
||||||
SetBitmap(NULL);
|
SetBitmap(NULL);
|
||||||
|
|
||||||
if(Target())
|
if (Target()) {
|
||||||
{
|
|
||||||
BMessenger msgr(Target());
|
BMessenger msgr(Target());
|
||||||
|
|
||||||
msgr.SendMessage(new BMessage(M_BITMAP_REMOVED));
|
msgr.SendMessage(new BMessage(M_BITMAP_REMOVED));
|
||||||
@@ -266,19 +267,19 @@ void BitmapView::MessageReceived(BMessage *msg)
|
|||||||
case M_PASTE_IMAGE:
|
case M_PASTE_IMAGE:
|
||||||
{
|
{
|
||||||
PasteBitmap();
|
PasteBitmap();
|
||||||
|
|
||||||
Invoke();
|
Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BView::MessageReceived(msg);
|
BView::MessageReceived(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::Draw(BRect rect)
|
|
||||||
|
void
|
||||||
|
BitmapView::Draw(BRect rect)
|
||||||
{
|
{
|
||||||
if (fBitmap)
|
if (fBitmap)
|
||||||
DrawBitmap(fBitmap, fBitmap->Bounds(), fBitmapRect);
|
DrawBitmap(fBitmap, fBitmap->Bounds(), fBitmapRect);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
SetHighColor(0, 0, 0, 80);
|
SetHighColor(0, 0, 0, 80);
|
||||||
SetDrawingMode(B_OP_ALPHA);
|
SetDrawingMode(B_OP_ALPHA);
|
||||||
DrawString("Drop", fNoPhotoOffsets[0]);
|
DrawString("Drop", fNoPhotoOffsets[0]);
|
||||||
@@ -288,8 +289,7 @@ void BitmapView::Draw(BRect rect)
|
|||||||
SetDrawingMode(B_OP_COPY);
|
SetDrawingMode(B_OP_COPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fBorderStyle==B_FANCY_BORDER)
|
if (fBorderStyle == B_FANCY_BORDER) {
|
||||||
{
|
|
||||||
rgb_color base= { 216, 216, 216, 255 };
|
rgb_color base= { 216, 216, 216, 255 };
|
||||||
rgb_color work;
|
rgb_color work;
|
||||||
|
|
||||||
@@ -346,23 +346,22 @@ void BitmapView::Draw(BRect rect)
|
|||||||
|
|
||||||
SetHighColor(tint_color(base, B_DARKEN_2_TINT));
|
SetHighColor(tint_color(base, B_DARKEN_2_TINT));
|
||||||
StrokeRect(r);
|
StrokeRect(r);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Plain border
|
// Plain border
|
||||||
SetHighColor(0, 0, 0);
|
SetHighColor(0, 0, 0);
|
||||||
StrokeRect(fBitmapRect);
|
StrokeRect(fBitmapRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::MouseDown(BPoint pt)
|
|
||||||
|
void
|
||||||
|
BitmapView::MouseDown(BPoint pt)
|
||||||
{
|
{
|
||||||
BPoint mousept;
|
BPoint mousept;
|
||||||
uint32 buttons;
|
uint32 buttons;
|
||||||
|
|
||||||
GetMouse(&mousept, &buttons);
|
GetMouse(&mousept, &buttons);
|
||||||
if(buttons & B_SECONDARY_MOUSE_BUTTON)
|
if (buttons & B_SECONDARY_MOUSE_BUTTON) {
|
||||||
{
|
|
||||||
ConvertToScreen(&mousept);
|
ConvertToScreen(&mousept);
|
||||||
|
|
||||||
mousept.x= (mousept.x>5) ? mousept.x-5 : 0;
|
mousept.x= (mousept.x>5) ? mousept.x-5 : 0;
|
||||||
@@ -382,97 +381,60 @@ void BitmapView::MouseDown(BPoint pt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::FrameResized(float w, float h)
|
|
||||||
|
void
|
||||||
|
BitmapView::FrameResized(float w, float h)
|
||||||
{
|
{
|
||||||
CalculateBitmapRect();
|
CalculateBitmapRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::CalculateBitmapRect(void)
|
|
||||||
{
|
void
|
||||||
if(!fBitmap || fFixedSize)
|
BitmapView::CalculateBitmapRect(void)
|
||||||
{
|
{
|
||||||
|
if (!fBitmap || fFixedSize) {
|
||||||
fBitmapRect = Bounds().InsetByCopy(1, 1);
|
fBitmapRect = Bounds().InsetByCopy(1, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* // Dynamic sizing algorithm
|
|
||||||
// 1) Check to see if either dimension is bigger than the view's display area
|
|
||||||
// 2) If smaller along both axes, make bitmap rect centered and return
|
|
||||||
// 3) Check to see if scaling is to be horizontal or vertical on basis of longer axis
|
|
||||||
// 4) Calculate scaling factor
|
|
||||||
// 5) Scale both axes down by scaling factor, accounting for border width
|
|
||||||
// 6) Center the rectangle in the direction of the smaller axis
|
|
||||||
|
|
||||||
|
|
||||||
uint8 borderwidth=(fBorderStyle==B_FANCY_BORDER)?5:1;
|
|
||||||
|
|
||||||
BRect r(Bounds());
|
|
||||||
r.InsetBy(borderwidth,borderwidth);
|
|
||||||
|
|
||||||
if( (fBitmap->Bounds().Width()<=r.Width()) &&
|
|
||||||
(fBitmap->Bounds().Height()<=r.Height()) )
|
|
||||||
{
|
|
||||||
// Smaller than view, so just center and return
|
|
||||||
fBitmapRect=fBitmap->Bounds();
|
|
||||||
fBitmapRect.OffsetBy( borderwidth+
|
|
||||||
((r.Width()-fBitmapRect.Width()-(borderwidth<<2))/2),
|
|
||||||
((r.Height()-fBitmapRect.Height()-(borderwidth<<2))/2) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
float multiplier=fBitmap->Bounds().Width()/fBitmap->Bounds().Height();
|
|
||||||
float offset;
|
|
||||||
if(multiplier>1)
|
|
||||||
{
|
|
||||||
// Landscape orientation
|
|
||||||
|
|
||||||
// Scale rectangle to bounds width and center height
|
|
||||||
r.bottom=r.top+(r.Width()/multiplier);
|
|
||||||
|
|
||||||
offset= ((Bounds().Height()-(borderwidth<<1)) - r.Height())/2;
|
|
||||||
r.OffsetBy(0,offset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Portrait orientation
|
|
||||||
|
|
||||||
// Scale rectangle to bounds height and center width
|
|
||||||
r.right=r.left+(r.Height()*multiplier);
|
|
||||||
|
|
||||||
offset= ((Bounds().Width()-(borderwidth<<1)) - r.Width())/2;
|
|
||||||
r.OffsetBy(offset,0);
|
|
||||||
}
|
|
||||||
fBitmapRect=r;
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint8 borderwidth = (fBorderStyle == B_FANCY_BORDER) ? 5 : 1;
|
uint8 borderwidth = (fBorderStyle == B_FANCY_BORDER) ? 5 : 1;
|
||||||
|
|
||||||
BRect r(Bounds());
|
BRect r(Bounds());
|
||||||
fBitmapRect= ScaleRectToFit(fBitmap->Bounds(), r.InsetByCopy(borderwidth, borderwidth));
|
fBitmapRect= ScaleRectToFit(fBitmap->Bounds(), r.InsetByCopy(borderwidth, borderwidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::SetAcceptDrops(bool accept)
|
|
||||||
|
void
|
||||||
|
BitmapView::SetAcceptDrops(bool accept)
|
||||||
{
|
{
|
||||||
fAcceptDrops = accept;
|
fAcceptDrops = accept;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::SetAcceptPaste(bool accept)
|
|
||||||
|
void
|
||||||
|
BitmapView::SetAcceptPaste(bool accept)
|
||||||
{
|
{
|
||||||
fAcceptPaste = accept;
|
fAcceptPaste = accept;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::SetConstrainDrops(bool value)
|
|
||||||
|
void
|
||||||
|
BitmapView::SetConstrainDrops(bool value)
|
||||||
{
|
{
|
||||||
fConstrainDrops = value;
|
fConstrainDrops = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::MaxBitmapSize(float *width, float *height) const
|
|
||||||
|
void
|
||||||
|
BitmapView::MaxBitmapSize(float *width, float *height) const
|
||||||
{
|
{
|
||||||
*width = fMaxWidth;
|
*width = fMaxWidth;
|
||||||
*height = fMaxHeight;
|
*height = fMaxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::SetMaxBitmapSize(const float &width, const float &height)
|
|
||||||
|
void
|
||||||
|
BitmapView::SetMaxBitmapSize(const float &width, const float &height)
|
||||||
{
|
{
|
||||||
fMaxWidth = width;
|
fMaxWidth = width;
|
||||||
fMaxHeight = height;
|
fMaxHeight = height;
|
||||||
@@ -480,12 +442,16 @@ void BitmapView::SetMaxBitmapSize(const float &width, const float &height)
|
|||||||
ConstrainBitmap();
|
ConstrainBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::SetBitmapRemovable(bool isremovable)
|
|
||||||
|
void
|
||||||
|
BitmapView::SetBitmapRemovable(bool isremovable)
|
||||||
{
|
{
|
||||||
fRemovableBitmap = isremovable;
|
fRemovableBitmap = isremovable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::ConstrainBitmap(void)
|
|
||||||
|
void
|
||||||
|
BitmapView::ConstrainBitmap(void)
|
||||||
{
|
{
|
||||||
if (!fBitmap || fMaxWidth < 1 || fMaxHeight < 1)
|
if (!fBitmap || fMaxWidth < 1 || fMaxHeight < 1)
|
||||||
return;
|
return;
|
||||||
@@ -505,30 +471,28 @@ void BitmapView::ConstrainBitmap(void)
|
|||||||
fBitmap = new BBitmap(scaled, false);
|
fBitmap = new BBitmap(scaled, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitmapView::ClipboardHasBitmap(void)
|
|
||||||
|
bool
|
||||||
|
BitmapView::ClipboardHasBitmap(void)
|
||||||
{
|
{
|
||||||
BMessage *clip = NULL, flattened;
|
BMessage *clip = NULL, flattened;
|
||||||
uint8 clipval = CLIP_NONE;
|
uint8 clipval = CLIP_NONE;
|
||||||
bool returnval;
|
bool returnval;
|
||||||
|
|
||||||
if(be_clipboard->Lock())
|
if (be_clipboard->Lock()) {
|
||||||
{
|
|
||||||
clip = be_clipboard->Data();
|
clip = be_clipboard->Data();
|
||||||
if(!clip->IsEmpty())
|
if (!clip->IsEmpty()) {
|
||||||
{
|
|
||||||
returnval = (clip->FindMessage("image/bitmap", &flattened) == B_OK);
|
returnval = (clip->FindMessage("image/bitmap", &flattened) == B_OK);
|
||||||
if (returnval)
|
if (returnval)
|
||||||
clipval = CLIP_BEOS;
|
clipval = CLIP_BEOS;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
BString string;
|
BString string;
|
||||||
returnval = (clip->FindString("class", &string) == B_OK && string == "BBitmap");
|
returnval = (clip->FindString("class", &string) == B_OK && string == "BBitmap");
|
||||||
|
|
||||||
// Try method Gobe Productive uses if that, too, didn't work
|
// Try method Gobe Productive uses if that, too, didn't work
|
||||||
if (returnval)
|
if (returnval)
|
||||||
clipval = CLIP_SHOWIMAGE;
|
clipval = CLIP_SHOWIMAGE;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
returnval = (clip->FindMessage("image/x-vnd.Be-bitmap", &flattened) == B_OK);
|
returnval = (clip->FindMessage("image/x-vnd.Be-bitmap", &flattened) == B_OK);
|
||||||
if (returnval)
|
if (returnval)
|
||||||
clipval = CLIP_SHOWIMAGE;
|
clipval = CLIP_SHOWIMAGE;
|
||||||
@@ -542,7 +506,9 @@ bool BitmapView::ClipboardHasBitmap(void)
|
|||||||
return (clipval != CLIP_NONE)?true:false;
|
return (clipval != CLIP_NONE)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBitmap *BitmapView::BitmapFromClipboard(void)
|
|
||||||
|
BBitmap *
|
||||||
|
BitmapView::BitmapFromClipboard(void)
|
||||||
{
|
{
|
||||||
BMessage *clip = NULL, flattened;
|
BMessage *clip = NULL, flattened;
|
||||||
BBitmap *bitmap;
|
BBitmap *bitmap;
|
||||||
@@ -560,16 +526,14 @@ BBitmap *BitmapView::BitmapFromClipboard(void)
|
|||||||
status_t status = clip->FindMessage("image/bitmap", &flattened);
|
status_t status = clip->FindMessage("image/bitmap", &flattened);
|
||||||
|
|
||||||
// If that didn't work, try ShowImage-style
|
// If that didn't work, try ShowImage-style
|
||||||
if(status!=B_OK)
|
if (status != B_OK) {
|
||||||
{
|
|
||||||
BString string;
|
BString string;
|
||||||
status = clip->FindString("class", &string);
|
status = clip->FindString("class", &string);
|
||||||
|
|
||||||
// Try method Gobe Productive uses if that, too, didn't work
|
// Try method Gobe Productive uses if that, too, didn't work
|
||||||
if (status == B_OK && string == "BBitmap")
|
if (status == B_OK && string == "BBitmap")
|
||||||
clipval = CLIP_SHOWIMAGE;
|
clipval = CLIP_SHOWIMAGE;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
status = clip->FindMessage("image/x-vnd.Be-bitmap", &flattened);
|
status = clip->FindMessage("image/x-vnd.Be-bitmap", &flattened);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
clipval = CLIP_PRODUCTIVE;
|
clipval = CLIP_PRODUCTIVE;
|
||||||
@@ -582,10 +546,8 @@ BBitmap *BitmapView::BitmapFromClipboard(void)
|
|||||||
|
|
||||||
be_clipboard->Unlock();
|
be_clipboard->Unlock();
|
||||||
|
|
||||||
switch(clipval)
|
switch (clipval) {
|
||||||
{
|
case CLIP_SHOWIMAGE: {
|
||||||
case CLIP_SHOWIMAGE:
|
|
||||||
{
|
|
||||||
// Showimage does it a slightly different way -- it dumps the BBitmap
|
// Showimage does it a slightly different way -- it dumps the BBitmap
|
||||||
// data directly to the clipboard message instead of packaging it in
|
// data directly to the clipboard message instead of packaging it in
|
||||||
// a bitmap like everyone else.
|
// a bitmap like everyone else.
|
||||||
@@ -614,22 +576,19 @@ BBitmap *BitmapView::BitmapFromClipboard(void)
|
|||||||
bitmap = new BBitmap(frame, cspace, true);
|
bitmap = new BBitmap(frame, cspace, true);
|
||||||
|
|
||||||
status = datamsg.FindData("_data", B_RAW_TYPE, (const void **)&buffer, &bufferLength);
|
status = datamsg.FindData("_data", B_RAW_TYPE, (const void **)&buffer, &bufferLength);
|
||||||
if(status!=B_OK)
|
if (status != B_OK) {
|
||||||
{
|
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(bitmap->Bits(), buffer, bufferLength);
|
memcpy(bitmap->Bits(), buffer, bufferLength);
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
case CLIP_PRODUCTIVE:
|
case CLIP_PRODUCTIVE:
|
||||||
// Productive doesn't name the packaged BBitmap data message the same, but
|
// Productive doesn't name the packaged BBitmap data message the same, but
|
||||||
// uses exactly the same data format.
|
// uses exactly the same data format.
|
||||||
|
|
||||||
case CLIP_BEOS:
|
case CLIP_BEOS: {
|
||||||
{
|
|
||||||
const void *buffer;
|
const void *buffer;
|
||||||
int32 bufferLength;
|
int32 bufferLength;
|
||||||
|
|
||||||
@@ -647,14 +606,12 @@ BBitmap *BitmapView::BitmapFromClipboard(void)
|
|||||||
bitmap = new BBitmap(frame, cspace, true);
|
bitmap = new BBitmap(frame, cspace, true);
|
||||||
|
|
||||||
status = flattened.FindData("_data", B_RAW_TYPE, (const void **)&buffer, &bufferLength);
|
status = flattened.FindData("_data", B_RAW_TYPE, (const void **)&buffer, &bufferLength);
|
||||||
if(status!=B_OK)
|
if (status != B_OK) {
|
||||||
{
|
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(bitmap->Bits(), buffer, bufferLength);
|
memcpy(bitmap->Bits(), buffer, bufferLength);
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -665,7 +622,9 @@ BBitmap *BitmapView::BitmapFromClipboard(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect ScaleRectToFit(const BRect &from, const BRect &to)
|
|
||||||
|
BRect
|
||||||
|
ScaleRectToFit(const BRect &from, const BRect &to)
|
||||||
{
|
{
|
||||||
// Dynamic sizing algorithm
|
// Dynamic sizing algorithm
|
||||||
// 1) Check to see if either dimension is bigger than the view's display area
|
// 1) Check to see if either dimension is bigger than the view's display area
|
||||||
@@ -682,9 +641,7 @@ BRect ScaleRectToFit(const BRect &from, const BRect &to)
|
|||||||
|
|
||||||
BRect r(to);
|
BRect r(to);
|
||||||
|
|
||||||
if( (from.Width()<=r.Width()) &&
|
if ((from.Width() <= r.Width()) && (from.Height() <= r.Height())) {
|
||||||
(from.Height()<=r.Height()) )
|
|
||||||
{
|
|
||||||
// Smaller than view, so just center and return
|
// Smaller than view, so just center and return
|
||||||
r = from;
|
r = from;
|
||||||
r.OffsetBy((to.Width() - r.Width()) / 2, (to.Height() - r.Height()) / 2);
|
r.OffsetBy((to.Width() - r.Width()) / 2, (to.Height() - r.Height()) / 2);
|
||||||
@@ -692,33 +649,32 @@ BRect ScaleRectToFit(const BRect &from, const BRect &to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
float multiplier = from.Width()/from.Height();
|
float multiplier = from.Width()/from.Height();
|
||||||
if(multiplier>1)
|
if (multiplier > 1) {
|
||||||
{
|
|
||||||
// Landscape orientation
|
// Landscape orientation
|
||||||
|
|
||||||
// Scale rectangle to bounds width and center height
|
// Scale rectangle to bounds width and center height
|
||||||
r.bottom = r.top + (r.Width() / multiplier);
|
r.bottom = r.top + (r.Width() / multiplier);
|
||||||
|
|
||||||
r.OffsetBy(0, (to.Height() - r.Height()) / 2);
|
r.OffsetBy(0, (to.Height() - r.Height()) / 2);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Portrait orientation
|
// Portrait orientation
|
||||||
|
|
||||||
// Scale rectangle to bounds height and center width
|
// Scale rectangle to bounds height and center width
|
||||||
r.right = r.left + (r.Height() * multiplier);
|
r.right = r.left + (r.Height() * multiplier);
|
||||||
|
|
||||||
r.OffsetBy((to.Width() - r.Width()) / 2, 0);
|
r.OffsetBy((to.Width() - r.Width()) / 2, 0);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::RemoveBitmap(void)
|
|
||||||
|
void
|
||||||
|
BitmapView::RemoveBitmap(void)
|
||||||
{
|
{
|
||||||
SetBitmap(NULL);
|
SetBitmap(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapView::PasteBitmap(void)
|
|
||||||
|
void
|
||||||
|
BitmapView::PasteBitmap(void)
|
||||||
{
|
{
|
||||||
BBitmap *bmp = BitmapFromClipboard();
|
BBitmap *bmp = BitmapFromClipboard();
|
||||||
if (bmp)
|
if (bmp)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#ifndef BMPVIEW_H
|
#ifndef BMPVIEW_H
|
||||||
#define BMPVIEW_H
|
#define BMPVIEW_H
|
||||||
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Message.h>
|
||||||
#include <Invoker.h>
|
#include <Invoker.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <PopUpMenu.h>
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,11 +5,12 @@
|
|||||||
* Author:
|
* Author:
|
||||||
* DarkWyrm <[email protected]>
|
* DarkWyrm <[email protected]>
|
||||||
*/
|
*/
|
||||||
#include "InternalEditors.h"
|
|
||||||
#include "BitmapView.h"
|
#include "BitmapView.h"
|
||||||
|
#include "InternalEditors.h"
|
||||||
#include "ResourceData.h"
|
#include "ResourceData.h"
|
||||||
#include <TranslationUtils.h>
|
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
|
#include <TranslationUtils.h>
|
||||||
|
|
||||||
#define M_IMAGE_CHANGED 'imch'
|
#define M_IMAGE_CHANGED 'imch'
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,9 @@
|
|||||||
* DarkWyrm <[email protected]>
|
* DarkWyrm <[email protected]>
|
||||||
*/
|
*/
|
||||||
#include "InlineEditor.h"
|
#include "InlineEditor.h"
|
||||||
#include <MessageFilter.h>
|
|
||||||
#include <Handler.h>
|
#include <Handler.h>
|
||||||
|
#include <MessageFilter.h>
|
||||||
|
|
||||||
class EditFilter : public BMessageFilter
|
class EditFilter : public BMessageFilter
|
||||||
{
|
{
|
||||||
@@ -54,8 +55,7 @@ InlineEditor::InlineEditor(BMessenger target, const BRect &frame,
|
|||||||
fCommand(M_INLINE_TEXT)
|
fCommand(M_INLINE_TEXT)
|
||||||
{
|
{
|
||||||
fTextBox = new BTextControl(BRect(0, 0, 1, 1), "inlinebox", NULL, text,
|
fTextBox = new BTextControl(BRect(0, 0, 1, 1), "inlinebox", NULL, text,
|
||||||
new BMessage(fCommand), B_FOLLOW_ALL,
|
new BMessage(fCommand), B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
B_WILL_DRAW);
|
|
||||||
AddChild(fTextBox);
|
AddChild(fTextBox);
|
||||||
fTextBox->SetDivider(0);
|
fTextBox->SetDivider(0);
|
||||||
fTextBox->MakeFocus(true);
|
fTextBox->MakeFocus(true);
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
#ifndef INLINE_EDITOR
|
#ifndef INLINE_EDITOR
|
||||||
#define INLINE_EDITOR
|
#define INLINE_EDITOR
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
#define M_INLINE_TEXT 'intx'
|
#define M_INLINE_TEXT 'intx'
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,11 @@
|
|||||||
*/
|
*/
|
||||||
#include "InternalEditors.h"
|
#include "InternalEditors.h"
|
||||||
#include "ResourceData.h"
|
#include "ResourceData.h"
|
||||||
#include <Messenger.h>
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <Messenger.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
StringEditor::StringEditor(const BRect &frame, ResourceData *data,
|
StringEditor::StringEditor(const BRect &frame, ResourceData *data,
|
||||||
|
|||||||
@@ -7,9 +7,11 @@
|
|||||||
*/
|
*/
|
||||||
#include "InternalEditors.h"
|
#include "InternalEditors.h"
|
||||||
#include "ResourceData.h"
|
#include "ResourceData.h"
|
||||||
#include <Messenger.h>
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <Messenger.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
DoubleEditor::DoubleEditor(const BRect &frame, ResourceData *data,
|
DoubleEditor::DoubleEditor(const BRect &frame, ResourceData *data,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "PreviewColumn.h"
|
#include "PreviewColumn.h"
|
||||||
#include "ResFields.h"
|
#include "ResFields.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
PreviewColumn::PreviewColumn(const char *title, float width,
|
PreviewColumn::PreviewColumn(const char *title, float width,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "ResFields.h"
|
#include "ResFields.h"
|
||||||
#include "ResourceData.h"
|
#include "ResourceData.h"
|
||||||
|
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,16 @@
|
|||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <TranslatorRoster.h>
|
#include <TranslatorRoster.h>
|
||||||
#include <TypeConstants.h>
|
#include <TypeConstants.h>
|
||||||
#include "ColumnTypes.h"
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
#include "ColumnTypes.h"
|
||||||
#include "ResourceData.h"
|
#include "ResourceData.h"
|
||||||
#include "ResFields.h"
|
#include "ResFields.h"
|
||||||
#include "ResListView.h"
|
#include "ResListView.h"
|
||||||
|
|||||||
@@ -6,8 +6,9 @@
|
|||||||
* DarkWyrm <darkwyrm@gmail.com>
|
* DarkWyrm <darkwyrm@gmail.com>
|
||||||
*/
|
*/
|
||||||
#include "ResWindow.h"
|
#include "ResWindow.h"
|
||||||
#include "ResView.h"
|
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
#include "ResView.h"
|
||||||
|
|
||||||
static int32 sWindowCount = 0;
|
static int32 sWindowCount = 0;
|
||||||
|
|
||||||
@@ -38,7 +39,6 @@ ResWindow::QuitRequested(void)
|
|||||||
|
|
||||||
if (sWindowCount == 0)
|
if (sWindowCount == 0)
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
// be_app->PostMessage(M_UNREGISTER_WINDOW);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
#ifndef RESOURCE_DATA_H
|
#ifndef RESOURCE_DATA_H
|
||||||
#define RESOURCE_DATA_H
|
#define RESOURCE_DATA_H
|
||||||
|
|
||||||
#include <Resources.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <Node.h>
|
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
|
#include <Resources.h>
|
||||||
|
#include <Node.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
class ResourceData
|
class ResourceData
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,17 +6,18 @@
|
|||||||
* DarkWyrm <darkwyrm@gmail.com>
|
* DarkWyrm <darkwyrm@gmail.com>
|
||||||
*/
|
*/
|
||||||
#include "ResourceRoster.h"
|
#include "ResourceRoster.h"
|
||||||
#include <Roster.h>
|
|
||||||
#include <Entry.h>
|
|
||||||
#include <Path.h>
|
|
||||||
#include <image.h>
|
|
||||||
#include <Application.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <Directory.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
|
|
||||||
#include "ResourceData.h"
|
#include <Application.h>
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Directory.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
#include <image.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
#include "InternalEditors.h"
|
#include "InternalEditors.h"
|
||||||
|
#include "ResourceData.h"
|
||||||
#include "ResFields.h"
|
#include "ResFields.h"
|
||||||
|
|
||||||
// For the MakeFieldForType temp code
|
// For the MakeFieldForType temp code
|
||||||
|
|||||||
Reference in New Issue
Block a user