From 09a03cb8270174f8b983db85c0f7c91821239cd8 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Tue, 27 Apr 2010 12:27:29 +0000 Subject: [PATCH] -> Style fixes, no functional change git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36502 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/resedit/App.cpp | 1 + src/apps/resedit/BitmapView.cpp | 650 +++++++++++++--------------- src/apps/resedit/BitmapView.h | 12 +- src/apps/resedit/ImageEditor.cpp | 35 +- src/apps/resedit/InlineEditor.cpp | 16 +- src/apps/resedit/InlineEditor.h | 4 +- src/apps/resedit/MiscEditors.cpp | 22 +- src/apps/resedit/NumberEditors.cpp | 8 +- src/apps/resedit/PreviewColumn.cpp | 3 +- src/apps/resedit/ResFields.cpp | 3 +- src/apps/resedit/ResView.cpp | 53 +-- src/apps/resedit/ResWindow.cpp | 10 +- src/apps/resedit/ResourceData.cpp | 8 +- src/apps/resedit/ResourceData.h | 6 +- src/apps/resedit/ResourceRoster.cpp | 29 +- 15 files changed, 413 insertions(+), 447 deletions(-) diff --git a/src/apps/resedit/App.cpp b/src/apps/resedit/App.cpp index 96f80ba1e2..4f20e5f5a9 100644 --- a/src/apps/resedit/App.cpp +++ b/src/apps/resedit/App.cpp @@ -7,6 +7,7 @@ */ #include "App.h" #include "ResWindow.h" + #include int diff --git a/src/apps/resedit/BitmapView.cpp b/src/apps/resedit/BitmapView.cpp index aa1990cdd0..57e928bc96 100644 --- a/src/apps/resedit/BitmapView.cpp +++ b/src/apps/resedit/BitmapView.cpp @@ -1,13 +1,13 @@ #include "BitmapView.h" +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include // TODO: Add support for labels @@ -16,208 +16,215 @@ enum { - CLIP_NONE=0, - CLIP_BEOS=1, - CLIP_SHOWIMAGE=2, - CLIP_PRODUCTIVE=3 + CLIP_NONE = 0, + CLIP_BEOS = 1, + CLIP_SHOWIMAGE = 2, + CLIP_PRODUCTIVE = 3 }; -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) +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) { - if(col) - { - col->red=r; - col->green=g; - col->blue=b; - col->alpha=a; + if (col) { + col->red = r; + col->green = g; + col->blue = b; + col->alpha = a; } } + BitmapView::BitmapView(BRect frame, const char *name, BMessage *mod, BBitmap *bitmap, - const char *label, border_style borderstyle,int32 resize,int32 flags) - : BView(frame, name, resize, flags) + const char *label, border_style borderstyle, int32 resize, int32 flags) + : BView(frame, name, resize, flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - if(bitmap && bitmap->IsValid()) - fBitmap=bitmap; + if (bitmap && bitmap->IsValid()) + fBitmap = bitmap; else - fBitmap=NULL; + fBitmap = NULL; - if(mod) + if (mod) SetMessage(mod); - fLabel=label; - fBorderStyle=borderstyle; - fFixedSize=false; - fEnabled=true; - fRemovableBitmap=false; - fAcceptDrops=true; - fAcceptPaste=true; - fConstrainDrops=true; - fMaxWidth=100; - fMaxHeight=100; + fLabel = label; + fBorderStyle = borderstyle; + fFixedSize = false; + fEnabled = true; + fRemovableBitmap = false; + fAcceptDrops = true; + fAcceptPaste = true; + fConstrainDrops = true; + fMaxWidth = 100; + fMaxHeight = 100; - fPopUpMenu=new BPopUpMenu("deletepopup",false,false); - fPopUpMenu->AddItem(new BMenuItem("Close This Menu",new BMessage(B_CANCEL))); + fPopUpMenu = new BPopUpMenu("deletepopup", false, false); + fPopUpMenu->AddItem(new BMenuItem("Close This Menu", new BMessage(B_CANCEL))); fPopUpMenu->AddSeparatorItem(); - fPasteItem=new BMenuItem("Paste Photo from Clipboard",new BMessage(M_PASTE_IMAGE)); + fPasteItem = new BMenuItem("Paste Photo from Clipboard", new BMessage(M_PASTE_IMAGE)); fPopUpMenu->AddItem(fPasteItem); fPopUpMenu->AddSeparatorItem(); - fRemoveItem=new BMenuItem("Remove Photo",new BMessage(M_REMOVE_IMAGE)); + fRemoveItem = new BMenuItem("Remove Photo", new BMessage(M_REMOVE_IMAGE)); fPopUpMenu->AddItem(fRemoveItem); CalculateBitmapRect(); // Calculate the offsets for each of the words -- the phrase will be center justified - fNoPhotoWidths[0]=StringWidth("Drop"); - fNoPhotoWidths[1]=StringWidth("a"); - fNoPhotoWidths[2]=StringWidth("Photo"); - fNoPhotoWidths[3]=StringWidth("Here"); + fNoPhotoWidths[0] = StringWidth("Drop"); + fNoPhotoWidths[1] = StringWidth("a"); + fNoPhotoWidths[2] = StringWidth("Photo"); + fNoPhotoWidths[3] = StringWidth("Here"); font_height fh; GetFontHeight(&fh); - float totalheight=fh.ascent+fh.descent+fh.leading; - float yoffset=(Bounds().Height()-10-(totalheight*4))/2; - fNoPhotoOffsets[0].Set( (Bounds().Width()-fNoPhotoWidths[0])/2,totalheight+yoffset); - fNoPhotoOffsets[1].Set( (Bounds().Width()-fNoPhotoWidths[1])/2,fNoPhotoOffsets[0].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); + float totalheight = fh.ascent + fh.descent + fh.leading; + float yoffset = (Bounds().Height() - 10 - (totalheight * 4)) / 2; + fNoPhotoOffsets[0].Set((Bounds().Width() - fNoPhotoWidths[0]) / 2, totalheight + yoffset); + fNoPhotoOffsets[1].Set((Bounds().Width() - fNoPhotoWidths[1]) / 2, + fNoPhotoOffsets[0].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) { delete fPopUpMenu; } -void BitmapView::AttachedToWindow(void) + +void +BitmapView::AttachedToWindow(void) { SetTarget((BHandler*)Window()); fPopUpMenu->SetTargetForItems(this); } -void BitmapView::SetBitmap(BBitmap *bitmap) + +void +BitmapView::SetBitmap(BBitmap *bitmap) { - if(bitmap && bitmap->IsValid()) - { - if(fBitmap==bitmap) + if (bitmap && bitmap->IsValid()) { + if (fBitmap == bitmap) return; - - fBitmap=bitmap; - } - else - { - if(fBitmap==NULL) + fBitmap = bitmap; + } else { + if (!fBitmap) return; - - fBitmap=NULL; + fBitmap = NULL; } CalculateBitmapRect(); - if(!IsHidden()) + if (!IsHidden()) Invalidate(); } -void BitmapView::SetEnabled(bool value) + +void +BitmapView::SetEnabled(bool value) { - if(fEnabled!=value) - { - fEnabled=value; + if (fEnabled != value) { + fEnabled = value; Invalidate(); } } + /* -void BitmapView::SetLabel(const char *label) +void +BitmapView::SetLabel(const char *label) { - if(fLabel.Compare(label)!=0) - { - fLabel=label; + if (fLabel.Compare(label) != 0) { + fLabel = label; CalculateBitmapRect(); - if(!IsHidden()) + if (!IsHidden()) Invalidate(); } } */ -void BitmapView::SetStyle(border_style style) + +void +BitmapView::SetStyle(border_style style) { - if(fBorderStyle!=style) - { - fBorderStyle=style; + if (fBorderStyle != style) { + fBorderStyle = style; CalculateBitmapRect(); - if(!IsHidden()) + if (!IsHidden()) Invalidate(); } } -void BitmapView::SetFixedSize(bool isfixed) + +void +BitmapView::SetFixedSize(bool isfixed) { - if(fFixedSize!=isfixed) - { - fFixedSize=isfixed; + if (fFixedSize != isfixed) { + fFixedSize = isfixed; CalculateBitmapRect(); - if(!IsHidden()) + if (!IsHidden()) Invalidate(); } } -void BitmapView::MessageReceived(BMessage *msg) + +void +BitmapView::MessageReceived(BMessage *msg) { - if(msg->WasDropped() && AcceptsDrops()) - { + if (msg->WasDropped() && AcceptsDrops()) { // 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; - 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 BMessage reply(B_COPY_TARGET), response; - reply.AddString("be:types","image/jpeg"); - reply.AddString("be:types","image/png"); + reply.AddString("be:types", "image/jpeg"); + reply.AddString("be:types", "image/png"); - msg->SendReply(&reply,&response); + msg->SendReply(&reply, &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 uint8 *imagedata; ssize_t datasize; // 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 - 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; } // Set up to decode into memory - BMemoryIO memio(imagedata,datasize); - BTranslatorRoster *roster=BTranslatorRoster::Default(); + BMemoryIO memio(imagedata, datasize); + BTranslatorRoster *roster = BTranslatorRoster::Default(); BBitmapStream bstream; - if(roster->Translate(&memio,NULL,NULL,&bstream, B_TRANSLATOR_BITMAP)==B_OK) + if (roster->Translate(&memio, NULL, NULL, &bstream, B_TRANSLATOR_BITMAP) == B_OK) { BBitmap *bmp; - if(bstream.DetachBitmap(&bmp)!=B_OK) + if (bstream.DetachBitmap(&bmp) != B_OK) return; - SetBitmap(bmp); - if(fConstrainDrops) + if (fConstrainDrops) ConstrainBitmap(); - Invoke(); } } @@ -225,17 +232,14 @@ void BitmapView::MessageReceived(BMessage *msg) } entry_ref ref; - if(msg->FindRef("refs",&ref)==B_OK) - { + if (msg->FindRef("refs", &ref) == B_OK) { // Tracker drop - BBitmap *bmp=BTranslationUtils::GetBitmap(&ref); - if(bmp) - { + BBitmap *bmp = BTranslationUtils::GetBitmap(&ref); + if (bmp) { SetBitmap(bmp); - if(fConstrainDrops) + if (fConstrainDrops) ConstrainBitmap(); - Invoke(); } } @@ -243,19 +247,16 @@ void BitmapView::MessageReceived(BMessage *msg) return; } - switch(msg->what) + switch (msg->what) { - case M_REMOVE_IMAGE: - { - BAlert *alert=new BAlert("Mr. Peeps!","This cannot be undone. Remove the image?","Remove", - "Cancel"); - int32 value=alert->Go(); - if(value==0) - { + case M_REMOVE_IMAGE: { + BAlert *alert = new BAlert("Mr. Peeps!", "This cannot be undone. Remove the image?", + "Remove", "Cancel"); + int32 value = alert->Go(); + if (value == 0) { SetBitmap(NULL); - if(Target()) - { + if (Target()) { BMessenger msgr(Target()); msgr.SendMessage(new BMessage(M_BITMAP_REMOVED)); @@ -266,331 +267,292 @@ void BitmapView::MessageReceived(BMessage *msg) case M_PASTE_IMAGE: { PasteBitmap(); - Invoke(); } } BView::MessageReceived(msg); } -void BitmapView::Draw(BRect rect) + +void +BitmapView::Draw(BRect rect) { - if(fBitmap) - DrawBitmap(fBitmap,fBitmap->Bounds(),fBitmapRect); - else - { - SetHighColor(0,0,0,80); + if (fBitmap) + DrawBitmap(fBitmap, fBitmap->Bounds(), fBitmapRect); + else { + SetHighColor(0, 0, 0, 80); SetDrawingMode(B_OP_ALPHA); - DrawString("Drop",fNoPhotoOffsets[0]); - DrawString("a",fNoPhotoOffsets[1]); - DrawString("Photo",fNoPhotoOffsets[2]); - DrawString("Here",fNoPhotoOffsets[3]); + DrawString("Drop", fNoPhotoOffsets[0]); + DrawString("a", fNoPhotoOffsets[1]); + DrawString("Photo", fNoPhotoOffsets[2]); + DrawString("Here", fNoPhotoOffsets[3]); SetDrawingMode(B_OP_COPY); } - - if(fBorderStyle==B_FANCY_BORDER) - { - rgb_color base= {216,216,216,255}; + + if (fBorderStyle == B_FANCY_BORDER) { + rgb_color base= { 216, 216, 216, 255 }; rgb_color work; SetHighColor(base); - StrokeRect(Bounds().InsetByCopy(2,2)); + StrokeRect(Bounds().InsetByCopy(2, 2)); BeginLineArray(12); BRect r(Bounds()); - work=tint_color(base,B_DARKEN_2_TINT); - AddLine(r.LeftTop(),r.RightTop(),work); - AddLine(r.LeftTop(),r.LeftBottom(),work); + work = tint_color(base, B_DARKEN_2_TINT); + AddLine(r.LeftTop(), r.RightTop(), work); + AddLine(r.LeftTop(), r.LeftBottom(), work); r.left++; - work=tint_color(base,B_DARKEN_4_TINT); - AddLine(r.RightTop(),r.RightBottom(),work); - AddLine(r.LeftBottom(),r.RightBottom(),work); + work = tint_color(base, B_DARKEN_4_TINT); + AddLine(r.RightTop(), r.RightBottom(), work); + AddLine(r.LeftBottom(), r.RightBottom(), work); r.right--; r.top++; r.bottom--; - work=tint_color(base,B_LIGHTEN_MAX_TINT); - AddLine(r.LeftTop(),r.RightTop(),work); - AddLine(r.LeftTop(),r.LeftBottom(),work); + work = tint_color(base, B_LIGHTEN_MAX_TINT); + AddLine(r.LeftTop(), r.RightTop(), work); + AddLine(r.LeftTop(), r.LeftBottom(), work); r.left++; - work=tint_color(base,B_DARKEN_3_TINT); - AddLine(r.RightTop(),r.RightBottom(),work); - AddLine(r.LeftBottom(),r.RightBottom(),work); + work = tint_color(base, B_DARKEN_3_TINT); + AddLine(r.RightTop(), r.RightBottom(), work); + AddLine(r.LeftBottom(), r.RightBottom(), work); // this rect handled by the above StrokeRect, so inset a total of 2 pixels r.left++; - r.right-=2; - r.top+=2; - r.bottom-=2; + r.right -= 2; + r.top += 2; + r.bottom -= 2; - work=tint_color(base,B_DARKEN_3_TINT); - AddLine(r.LeftTop(),r.RightTop(),work); - AddLine(r.LeftTop(),r.LeftBottom(),work); + work = tint_color(base, B_DARKEN_3_TINT); + AddLine(r.LeftTop(), r.RightTop(), work); + AddLine(r.LeftTop(), r.LeftBottom(), work); r.left++; - work=tint_color(base,B_LIGHTEN_MAX_TINT); - AddLine(r.RightTop(),r.RightBottom(),work); - AddLine(r.LeftBottom(),r.RightBottom(),work); + work = tint_color(base, B_LIGHTEN_MAX_TINT); + AddLine(r.RightTop(), r.RightBottom(), work); + AddLine(r.LeftBottom(), r.RightBottom(), work); r.right--; r.top++; r.bottom--; EndLineArray(); - SetHighColor(tint_color(base,B_DARKEN_2_TINT)); + SetHighColor(tint_color(base, B_DARKEN_2_TINT)); StrokeRect(r); - } - else - { + } else { // Plain border - SetHighColor(0,0,0); + SetHighColor(0, 0, 0); StrokeRect(fBitmapRect); } } -void BitmapView::MouseDown(BPoint pt) + +void +BitmapView::MouseDown(BPoint pt) { BPoint mousept; uint32 buttons; - GetMouse(&mousept,&buttons); - if(buttons & B_SECONDARY_MOUSE_BUTTON) - { + GetMouse(&mousept, &buttons); + if (buttons & B_SECONDARY_MOUSE_BUTTON) { ConvertToScreen(&mousept); mousept.x= (mousept.x>5) ? mousept.x-5 : 0; mousept.y= (mousept.y>5) ? mousept.y-5 : 0; - if(AcceptsPaste() && ClipboardHasBitmap()) + if (AcceptsPaste() && ClipboardHasBitmap()) fPasteItem->SetEnabled(true); else fPasteItem->SetEnabled(false); - if(fRemovableBitmap && fBitmap) + if (fRemovableBitmap && fBitmap) fRemoveItem->SetEnabled(true); else fRemoveItem->SetEnabled(false); - fPopUpMenu->Go(mousept,true,true,true); + fPopUpMenu->Go(mousept, true, true, true); } } -void BitmapView::FrameResized(float w, float h) + +void +BitmapView::FrameResized(float w, float h) { CalculateBitmapRect(); } -void BitmapView::CalculateBitmapRect(void) + +void +BitmapView::CalculateBitmapRect(void) { - if(!fBitmap || fFixedSize) - { - fBitmapRect=Bounds().InsetByCopy(1,1); + if (!fBitmap || fFixedSize) { + fBitmapRect = Bounds().InsetByCopy(1, 1); 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; + 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; - - 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; - *height=fMaxHeight; + *width = fMaxWidth; + *height = fMaxHeight; } -void BitmapView::SetMaxBitmapSize(const float &width, const float &height) + +void +BitmapView::SetMaxBitmapSize(const float &width, const float &height) { - fMaxWidth=width; - fMaxHeight=height; + fMaxWidth = width; + fMaxHeight = height; 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; - BRect r=ScaleRectToFit(fBitmap->Bounds(),BRect(0,0,fMaxWidth-1,fMaxHeight-1)); - r.OffsetTo(0,0); - - BBitmap *scaled=new BBitmap(r,fBitmap->ColorSpace(),true); - BView *view=new BView(r,"drawview",0,0); - + BRect r = ScaleRectToFit(fBitmap->Bounds(), BRect(0, 0, fMaxWidth - 1, fMaxHeight - 1)); + r.OffsetTo(0, 0); + + BBitmap *scaled = new BBitmap(r, fBitmap->ColorSpace(), true); + BView *view = new BView(r, "drawview", 0, 0); + scaled->Lock(); scaled->AddChild(view); - view->DrawBitmap(fBitmap,fBitmap->Bounds(),scaled->Bounds()); + view->DrawBitmap(fBitmap, fBitmap->Bounds(), scaled->Bounds()); scaled->Unlock(); delete fBitmap; - fBitmap=new BBitmap(scaled,false); + fBitmap = new BBitmap(scaled, false); } -bool BitmapView::ClipboardHasBitmap(void) + +bool +BitmapView::ClipboardHasBitmap(void) { - BMessage *clip=NULL,flattened; - uint8 clipval=CLIP_NONE; + BMessage *clip = NULL, flattened; + uint8 clipval = CLIP_NONE; bool returnval; - if(be_clipboard->Lock()) - { - clip=be_clipboard->Data(); - if(!clip->IsEmpty()) - { - returnval=(clip->FindMessage("image/bitmap",&flattened)==B_OK); - if(returnval) - clipval=CLIP_BEOS; - else - { + if (be_clipboard->Lock()) { + clip = be_clipboard->Data(); + if (!clip->IsEmpty()) { + returnval = (clip->FindMessage("image/bitmap", &flattened) == B_OK); + if (returnval) + clipval = CLIP_BEOS; + else { 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 - if(returnval) - clipval=CLIP_SHOWIMAGE; - else - { - returnval=(clip->FindMessage("image/x-vnd.Be-bitmap",&flattened)==B_OK); - if(returnval) - clipval=CLIP_SHOWIMAGE; + if (returnval) + clipval = CLIP_SHOWIMAGE; + else { + returnval = (clip->FindMessage("image/x-vnd.Be-bitmap", &flattened) == B_OK); + if (returnval) + clipval = CLIP_SHOWIMAGE; else - clipval=CLIP_NONE; + clipval = CLIP_NONE; } } } be_clipboard->Unlock(); } - 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; - if(!be_clipboard->Lock()) - return NULL; - - clip=be_clipboard->Data(); - if(!clip) + if (!be_clipboard->Lock()) return NULL; - uint8 clipval=CLIP_NONE; + clip = be_clipboard->Data(); + if (!clip) + return NULL; + + uint8 clipval = CLIP_NONE; // Try ArtPaint-style storage - 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(status!=B_OK) - { + if (status != B_OK) { BString string; - status=clip->FindString("class",&string); + status = clip->FindString("class", &string); // Try method Gobe Productive uses if that, too, didn't work - if(status==B_OK && string=="BBitmap") - clipval=CLIP_SHOWIMAGE; - else - { - status=clip->FindMessage("image/x-vnd.Be-bitmap",&flattened); - if(status==B_OK) - clipval=CLIP_PRODUCTIVE; + if (status == B_OK && string == "BBitmap") + clipval = CLIP_SHOWIMAGE; + else { + status = clip->FindMessage("image/x-vnd.Be-bitmap", &flattened); + if (status == B_OK) + clipval = CLIP_PRODUCTIVE; else - clipval=CLIP_NONE; + clipval = CLIP_NONE; } } else - clipval=CLIP_BEOS; + clipval = CLIP_BEOS; be_clipboard->Unlock(); - switch(clipval) - { - case CLIP_SHOWIMAGE: - { + switch (clipval) { + case CLIP_SHOWIMAGE: { // Showimage does it a slightly different way -- it dumps the BBitmap // data directly to the clipboard message instead of packaging it in // a bitmap like everyone else. - if(!be_clipboard->Lock()) + if (!be_clipboard->Lock()) return NULL; BMessage datamsg(*be_clipboard->Data()); @@ -601,60 +563,55 @@ BBitmap *BitmapView::BitmapFromClipboard(void) int32 bufferLength; BRect frame; - color_space cspace=B_NO_COLOR_SPACE; + color_space cspace = B_NO_COLOR_SPACE; - status=datamsg.FindRect("_frame",&frame); - if(status!=B_OK) + status = datamsg.FindRect("_frame", &frame); + if (status != B_OK) return NULL; - status=datamsg.FindInt32("_cspace",(int32)cspace); - if(status!=B_OK) + status = datamsg.FindInt32("_cspace", (int32)cspace); + if (status != B_OK) return NULL; - cspace=B_RGBA32; - bitmap=new BBitmap(frame,cspace,true); + cspace = B_RGBA32; + bitmap = new BBitmap(frame, cspace, true); - status=datamsg.FindData("_data",B_RAW_TYPE,(const void **)&buffer, &bufferLength); - if(status!=B_OK) - { + status = datamsg.FindData("_data", B_RAW_TYPE, (const void **)&buffer, &bufferLength); + if (status != B_OK) { delete bitmap; return NULL; } memcpy(bitmap->Bits(), buffer, bufferLength); - return bitmap; } case CLIP_PRODUCTIVE: // Productive doesn't name the packaged BBitmap data message the same, but // uses exactly the same data format. - case CLIP_BEOS: - { + case CLIP_BEOS: { const void *buffer; int32 bufferLength; BRect frame; - color_space cspace=B_NO_COLOR_SPACE; + color_space cspace = B_NO_COLOR_SPACE; - status=flattened.FindRect("_frame",&frame); - if(status!=B_OK) + status = flattened.FindRect("_frame", &frame); + if (status != B_OK) return NULL; - status=flattened.FindInt32("_cspace",(int32)cspace); - if(status!=B_OK) + status = flattened.FindInt32("_cspace", (int32)cspace); + if (status != B_OK) return NULL; - cspace=B_RGBA32; - bitmap=new BBitmap(frame,cspace,true); + cspace = B_RGBA32; + bitmap = new BBitmap(frame, cspace, true); - status=flattened.FindData("_data",B_RAW_TYPE,(const void **)&buffer, &bufferLength); - if(status!=B_OK) - { + status = flattened.FindData("_data", B_RAW_TYPE, (const void **)&buffer, &bufferLength); + if (status != B_OK) { delete bitmap; return NULL; } memcpy(bitmap->Bits(), buffer, bufferLength); - return bitmap; } default: @@ -665,7 +622,9 @@ BBitmap *BitmapView::BitmapFromClipboard(void) return NULL; } -BRect ScaleRectToFit(const BRect &from, const BRect &to) + +BRect +ScaleRectToFit(const BRect &from, const BRect &to) { // Dynamic sizing algorithm // 1) Check to see if either dimension is bigger than the view's display area @@ -675,55 +634,52 @@ BRect ScaleRectToFit(const BRect &from, const BRect &to) // 5) Scale both axes down by scaling factor, accounting for border width // 6) Center the rectangle in the direction of the smaller axis - if(!to.IsValid()) + if (!to.IsValid()) return from; - if(!from.IsValid()) + if (!from.IsValid()) return to; BRect r(to); - if( (from.Width()<=r.Width()) && - (from.Height()<=r.Height()) ) - { + if ((from.Width() <= r.Width()) && (from.Height() <= r.Height())) { // Smaller than view, so just center and return - r=from; - r.OffsetBy( (to.Width()-r.Width())/2, (to.Height()-r.Height())/2 ); + r = from; + r.OffsetBy((to.Width() - r.Width()) / 2, (to.Height() - r.Height()) / 2); return r; } - float multiplier=from.Width()/from.Height(); - if(multiplier>1) - { + float multiplier = from.Width()/from.Height(); + if (multiplier > 1) { // Landscape orientation // Scale rectangle to bounds width and center height - r.bottom=r.top+(r.Width()/multiplier); - - r.OffsetBy(0,(to.Height() - r.Height())/2); - } - else - { + r.bottom = r.top + (r.Width() / multiplier); + r.OffsetBy(0, (to.Height() - r.Height()) / 2); + } else { // Portrait orientation // Scale rectangle to bounds height and center width - r.right=r.left+(r.Height()*multiplier); - - r.OffsetBy((to.Width() - r.Width())/2,0); + r.right = r.left + (r.Height() * multiplier); + r.OffsetBy((to.Width() - r.Width()) / 2, 0); } return r; } -void BitmapView::RemoveBitmap(void) + +void +BitmapView::RemoveBitmap(void) { SetBitmap(NULL); } -void BitmapView::PasteBitmap(void) + +void +BitmapView::PasteBitmap(void) { - BBitmap *bmp=BitmapFromClipboard(); - if(bmp) + BBitmap *bmp = BitmapFromClipboard(); + if (bmp) SetBitmap(bmp); - if(fConstrainDrops) + if (fConstrainDrops) ConstrainBitmap(); } diff --git a/src/apps/resedit/BitmapView.h b/src/apps/resedit/BitmapView.h index 5c661b1c13..879915557b 100644 --- a/src/apps/resedit/BitmapView.h +++ b/src/apps/resedit/BitmapView.h @@ -1,25 +1,25 @@ #ifndef BMPVIEW_H #define BMPVIEW_H -#include #include +#include #include +#include #include #include -#include enum { - M_BITMAP_ADDED='mbma', - M_BITMAP_REMOVED='mbmr' + M_BITMAP_ADDED = 'mbma', + M_BITMAP_REMOVED = 'mbmr' }; class BitmapView : public BView, public BInvoker { public: BitmapView(BRect frame, const char *name, BMessage *mod, BBitmap *bitmap, - const char *label = NULL, border_style = B_PLAIN_BORDER, - int32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP, int32 flags = B_WILL_DRAW); + const char *label = NULL, border_style = B_PLAIN_BORDER, + int32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP, int32 flags = B_WILL_DRAW); ~BitmapView(void); virtual void AttachedToWindow(void); diff --git a/src/apps/resedit/ImageEditor.cpp b/src/apps/resedit/ImageEditor.cpp index fa18215ccf..fc0b035ed6 100644 --- a/src/apps/resedit/ImageEditor.cpp +++ b/src/apps/resedit/ImageEditor.cpp @@ -5,11 +5,12 @@ * Author: * DarkWyrm */ -#include "InternalEditors.h" #include "BitmapView.h" +#include "InternalEditors.h" #include "ResourceData.h" -#include + #include +#include #define M_IMAGE_CHANGED 'imch' @@ -20,16 +21,16 @@ ImageEditor::ImageEditor(const BRect &frame, ResourceData *data, BHandler *owner SetTitle(data->GetName()); // Set up the image and the viewer for such - BMemoryIO memio(data->GetData(),data->GetLength()); + BMemoryIO memio(data->GetData(), data->GetLength()); fImage = BTranslationUtils::GetBitmap(&memio); BRect imgsize; if (fImage) - imgsize = ScaleRectToFit(fImage->Bounds(),BRect(0,0,200,200)); + imgsize = ScaleRectToFit(fImage->Bounds(), BRect(0, 0, 200, 200)); else - imgsize.Set(0,0,200,200); + imgsize.Set(0, 0, 200, 200); - BView *back = new BView(Bounds(),"back",B_FOLLOW_ALL,B_WILL_DRAW); + BView *back = new BView(Bounds(), "back", B_FOLLOW_ALL, B_WILL_DRAW); back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(back); @@ -42,34 +43,34 @@ ImageEditor::ImageEditor(const BRect &frame, ResourceData *data, BHandler *owner be_plain_font->GetHeight(&fh); float strheight = fh.ascent + fh.descent + fh.leading + 5; - fIDBox = new BTextControl(BRect(10,10,10 + (strwidth + labelwidth) + 15, + fIDBox = new BTextControl(BRect(10, 10, 10 + (strwidth + labelwidth) + 15, 10 + strheight), - "id","ID: ",data->GetIDString(), NULL); + "id", "ID: ", data->GetIDString(), NULL); fIDBox->SetDivider(labelwidth + 5); back->AddChild(fIDBox); r = fIDBox->Frame(); r.OffsetBy(r.Width() + 10, 0); r.right = Bounds().right - 10; - fNameBox = new BTextControl(r,"name","Name: ",data->GetName(), NULL, + fNameBox = new BTextControl(r, "name", "Name: ", data->GetName(), NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fNameBox->SetDivider(be_plain_font->StringWidth("Name: ") + 5); back->AddChild(fNameBox); r = imgsize; - r.OffsetTo( (Bounds().Width() - r.Width()) / 2,fNameBox->Frame().bottom + 10); - fImageView = new BitmapView(r,"imageview",new BMessage(M_IMAGE_CHANGED),fImage, + r.OffsetTo( (Bounds().Width() - r.Width()) / 2, fNameBox->Frame().bottom + 10); + fImageView = new BitmapView(r, "imageview", new BMessage(M_IMAGE_CHANGED), fImage, NULL, B_PLAIN_BORDER, B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS); back->AddChild(fImageView); fImageView->SetConstrainDrops(false); // No limit on bitmap size - fImageView->SetMaxBitmapSize(0,0); + fImageView->SetMaxBitmapSize(0, 0); fImageView->SetBitmapRemovable(false); - fOK = new BButton(BRect(10,10,11,11),"ok","Cancel",new BMessage(M_UPDATE_RESOURCE), + fOK = new BButton(BRect(10, 10, 11, 11), "ok", "Cancel", new BMessage(M_UPDATE_RESOURCE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fOK->ResizeToPreferred(); fOK->SetLabel("OK"); @@ -81,14 +82,14 @@ ImageEditor::ImageEditor(const BRect &frame, ResourceData *data, BHandler *owner r = fOK->Frame(); r.OffsetBy(-r.Width() - 10, 0); - fCancel = new BButton(r,"cancel","Cancel",new BMessage(B_QUIT_REQUESTED), + fCancel = new BButton(r, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); back->AddChild(fCancel); ResizeTo(MAX(fImageView->Frame().right, fNameBox->Frame().right) + 20, fImageView->Frame().bottom + fOK->Frame().Height() + 20); - SetSizeLimits(Bounds().right,30000,Bounds().bottom,30000); + SetSizeLimits(Bounds().right, 30000, Bounds().bottom, 30000); } @@ -105,8 +106,8 @@ ImageEditor::MessageReceived(BMessage *msg) fImageView->MessageReceived(msg); } else if (msg->what == M_IMAGE_CHANGED) { fImage = fImageView->GetBitmap(); - BRect r = ScaleRectToFit(fImage->Bounds(), BRect(0,0,200,200)); - fImageView->ResizeTo(r.Width(),r.Height()); + BRect r = ScaleRectToFit(fImage->Bounds(), BRect(0, 0, 200, 200)); + fImageView->ResizeTo(r.Width(), r.Height()); ResizeTo(MAX(fImageView->Frame().right, fNameBox->Frame().right) + 20, fImageView->Frame().bottom + fOK->Frame().Height() + 20); } else diff --git a/src/apps/resedit/InlineEditor.cpp b/src/apps/resedit/InlineEditor.cpp index 36c967ba5b..bc7313bff6 100644 --- a/src/apps/resedit/InlineEditor.cpp +++ b/src/apps/resedit/InlineEditor.cpp @@ -6,14 +6,15 @@ * DarkWyrm */ #include "InlineEditor.h" -#include + #include +#include class EditFilter : public BMessageFilter { public: EditFilter(BTextControl *textbox) - : BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE,B_KEY_DOWN) + : BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN) { fTextBox = textbox; } @@ -25,7 +26,7 @@ public: filter_result Filter(BMessage *msg, BHandler **target) { int32 rawchar; - msg->FindInt32("raw_char",&rawchar); + msg->FindInt32("raw_char", &rawchar); if (rawchar == B_ESCAPE) { BLooper *loop = (*target)->Looper(); @@ -48,20 +49,19 @@ private: InlineEditor::InlineEditor(BMessenger target, const BRect &frame, const char *text) - : BWindow(frame,"InlineEditor",B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, + : BWindow(frame, "InlineEditor", B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS), fMessenger(target), fCommand(M_INLINE_TEXT) { - fTextBox = new BTextControl(BRect(0,0,1,1), "inlinebox",NULL, text, - new BMessage(fCommand), B_FOLLOW_ALL, - B_WILL_DRAW); + fTextBox = new BTextControl(BRect(0, 0, 1, 1), "inlinebox", NULL, text, + new BMessage(fCommand), B_FOLLOW_ALL, B_WILL_DRAW); AddChild(fTextBox); fTextBox->SetDivider(0); fTextBox->MakeFocus(true); fTextBox->ResizeToPreferred(); - fTextBox->ResizeTo(Bounds().Width(),fTextBox->Bounds().Height()); + fTextBox->ResizeTo(Bounds().Width(), fTextBox->Bounds().Height()); ResizeTo(Bounds().Width(), fTextBox->Bounds().Height()); AddCommonFilter(new EditFilter(fTextBox)); diff --git a/src/apps/resedit/InlineEditor.h b/src/apps/resedit/InlineEditor.h index 041949fd74..5499c5c898 100644 --- a/src/apps/resedit/InlineEditor.h +++ b/src/apps/resedit/InlineEditor.h @@ -8,9 +8,9 @@ #ifndef INLINE_EDITOR #define INLINE_EDITOR -#include -#include #include +#include +#include #define M_INLINE_TEXT 'intx' diff --git a/src/apps/resedit/MiscEditors.cpp b/src/apps/resedit/MiscEditors.cpp index 81cadbfab5..21482576a3 100644 --- a/src/apps/resedit/MiscEditors.cpp +++ b/src/apps/resedit/MiscEditors.cpp @@ -7,9 +7,11 @@ */ #include "InternalEditors.h" #include "ResourceData.h" -#include + #include +#include #include + #include StringEditor::StringEditor(const BRect &frame, ResourceData *data, @@ -44,10 +46,10 @@ StringEditor::MessageReceived(BMessage *msg) GetData()->SetID(newid); } GetData()->SetName(fView->GetName()); - GetData()->SetData(fView->GetValue(),strlen(fView->GetValue())); + GetData()->SetData(fView->GetValue(), strlen(fView->GetValue())); BMessage updatemsg(M_UPDATE_RESOURCE); - updatemsg.AddPointer("item",GetData()); + updatemsg.AddPointer("item", GetData()); BMessenger msgr(GetOwner()); msgr.SendMessage(&updatemsg); PostMessage(B_QUIT_REQUESTED); @@ -85,28 +87,28 @@ StringEditView::StringEditView(const BRect &frame) be_plain_font->GetHeight(&fh); float strheight = fh.ascent + fh.descent + fh.leading + 5; - fIDBox = new BTextControl(BRect(10,10,10 + (strwidth + labelwidth) + 15, + fIDBox = new BTextControl(BRect(10, 10, 10 + (strwidth + labelwidth) + 15, 10 + strheight), - "id","ID: ","", NULL); + "id", "ID: ", "", NULL); fIDBox->SetDivider(labelwidth + 5); AddChild(fIDBox); r = fIDBox->Frame(); r.OffsetBy(r.Width() + 10, 0); r.right = Bounds().right - 10; - fNameBox = new BTextControl(r,"name","Name: ","", NULL, + fNameBox = new BTextControl(r, "name", "Name: ", "", NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fNameBox->SetDivider(be_plain_font->StringWidth("Name: ") + 5); AddChild(fNameBox); - r.OffsetBy(0,r.Height() + 10); + r.OffsetBy(0, r.Height() + 10); r.left = 10; - fValueBox = new BTextControl(r,"value","Value: ","", NULL, + fValueBox = new BTextControl(r, "value", "Value: ", "", NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fValueBox->SetDivider(be_plain_font->StringWidth("Value: ") + 5); AddChild(fValueBox); - fOK = new BButton(BRect(10,10,11,11),"ok","Cancel",new BMessage(M_UPDATE_RESOURCE), + fOK = new BButton(BRect(10, 10, 11, 11), "ok", "Cancel", new BMessage(M_UPDATE_RESOURCE), B_FOLLOW_RIGHT); fOK->ResizeToPreferred(); fOK->SetLabel("OK"); @@ -116,7 +118,7 @@ StringEditView::StringEditView(const BRect &frame) fOK->MoveTo(r.right - fOK->Bounds().Width(), r.bottom + 10); r = fOK->Frame(); r.OffsetBy(-r.Width() - 10, 0); - fCancel = new BButton(r,"cancel","Cancel",new BMessage(B_QUIT_REQUESTED), + fCancel = new BButton(r, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT); AddChild(fCancel); } diff --git a/src/apps/resedit/NumberEditors.cpp b/src/apps/resedit/NumberEditors.cpp index 9448135cf9..5fb79f7e93 100644 --- a/src/apps/resedit/NumberEditors.cpp +++ b/src/apps/resedit/NumberEditors.cpp @@ -7,9 +7,11 @@ */ #include "InternalEditors.h" #include "ResourceData.h" -#include + #include +#include #include + #include DoubleEditor::DoubleEditor(const BRect &frame, ResourceData *data, @@ -40,10 +42,10 @@ DoubleEditor::MessageReceived(BMessage *msg) } GetData()->SetName(fView->GetName()); - GetData()->SetData(fView->GetValue(),strlen(fView->GetValue())); + GetData()->SetData(fView->GetValue(), strlen(fView->GetValue())); BMessage updatemsg(M_UPDATE_RESOURCE); - updatemsg.AddPointer("item",GetData()); + updatemsg.AddPointer("item", GetData()); BMessenger msgr(GetOwner()); msgr.SendMessage(&updatemsg); PostMessage(B_QUIT_REQUESTED); diff --git a/src/apps/resedit/PreviewColumn.cpp b/src/apps/resedit/PreviewColumn.cpp index 874c0054c1..408a357999 100644 --- a/src/apps/resedit/PreviewColumn.cpp +++ b/src/apps/resedit/PreviewColumn.cpp @@ -7,6 +7,7 @@ */ #include "PreviewColumn.h" #include "ResFields.h" + #include PreviewColumn::PreviewColumn(const char *title, float width, @@ -19,7 +20,7 @@ void PreviewColumn::DrawField(BField* field, BRect rect, BView* parent) { PreviewField *pField = (PreviewField*)field; - pField->DrawField(rect,parent); + pField->DrawField(rect, parent); } bool diff --git a/src/apps/resedit/ResFields.cpp b/src/apps/resedit/ResFields.cpp index 1c2f1ae817..0634857ad3 100644 --- a/src/apps/resedit/ResFields.cpp +++ b/src/apps/resedit/ResFields.cpp @@ -7,6 +7,7 @@ */ #include "ResFields.h" #include "ResourceData.h" + #include #include @@ -77,7 +78,7 @@ BitmapPreviewField::DrawField(BRect rect, BView *parent) void BitmapPreviewField::SetData(char *data, const size_t &length) { - BMemoryIO memio(data,length); + BMemoryIO memio(data, length); fBitmap = BTranslationUtils::GetBitmap(&memio); } diff --git a/src/apps/resedit/ResView.cpp b/src/apps/resedit/ResView.cpp index 9a01db9992..67f240db06 100644 --- a/src/apps/resedit/ResView.cpp +++ b/src/apps/resedit/ResView.cpp @@ -10,15 +10,16 @@ #include #include #include -#include #include #include -#include #include #include -#include "ColumnTypes.h" + +#include +#include #include "App.h" +#include "ColumnTypes.h" #include "ResourceData.h" #include "ResFields.h" #include "ResListView.h" @@ -70,22 +71,22 @@ ResView::ResView(const BRect &frame, const char *name, const int32 &resize, fListView = new ResListView(r, "gridview", B_FOLLOW_ALL, B_WILL_DRAW, B_FANCY_BORDER); AddChild(fListView); - rgb_color white = { 255,255,255,255 }; + rgb_color white = { 255, 255, 255, 255 }; fListView->SetColor(B_COLOR_BACKGROUND, white); fListView->SetColor(B_COLOR_SELECTION, ui_color(B_MENU_BACKGROUND_COLOR)); float width = be_plain_font->StringWidth("00000") + 20; - fListView->AddColumn(new BStringColumn("ID",width,width,100,B_TRUNCATE_END),0); + fListView->AddColumn(new BStringColumn("ID", width, width, 100, B_TRUNCATE_END), 0); - fListView->AddColumn(new BStringColumn("Type",width,width,100,B_TRUNCATE_END),1); - fListView->AddColumn(new BStringColumn("Name",150,50,300,B_TRUNCATE_END),2); - fListView->AddColumn(new PreviewColumn("Data",150,50,300),3); + fListView->AddColumn(new BStringColumn("Type", width, width, 100, B_TRUNCATE_END), 1); + fListView->AddColumn(new BStringColumn("Name", 150, 50, 300, B_TRUNCATE_END), 2); + fListView->AddColumn(new PreviewColumn("Data", 150, 50, 300), 3); // Editing is disabled for now fListView->SetInvocationMessage(new BMessage(M_EDIT_RESOURCE)); width = be_plain_font->StringWidth("1000 bytes") + 20; - fListView->AddColumn(new BSizeColumn("Size",width,10,100),4); + fListView->AddColumn(new BSizeColumn("Size", width, 10, 100), 4); fFilePanel = new BFilePanel(B_OPEN_PANEL); if (ref) @@ -116,9 +117,9 @@ ResView::MessageReceived(BMessage *msg) { switch (msg->what) { case M_NEW_FILE: { - BRect r(100,100,400,400); + BRect r(100, 100, 400, 400); if (Window()) - r = Window()->Frame().OffsetByCopy(10,10); + r = Window()->Frame().OffsetByCopy(10, 10); ResWindow *win = new ResWindow(r); win->Show(); break; @@ -134,7 +135,7 @@ ResView::MessageReceived(BMessage *msg) case B_REFS_RECEIVED: { int32 i = 0; entry_ref ref; - while (msg->FindRef("refs",i++,&ref) == B_OK) + while (msg->FindRef("refs", i++, &ref) == B_OK) AddResource(ref); break; } @@ -149,12 +150,12 @@ ResView::MessageReceived(BMessage *msg) case M_EDIT_RESOURCE: { BRow *row = fListView->CurrentSelection(); TypeCodeField *field = (TypeCodeField*)row->GetField(1); - gResRoster.SpawnEditor(field->GetResourceData(),this); + gResRoster.SpawnEditor(field->GetResourceData(), this); break; } case M_UPDATE_RESOURCE: { ResourceData *item; - if (msg->FindPointer("item",(void **)&item) != B_OK) + if (msg->FindPointer("item", (void **)&item) != B_OK) break; for (int32 i = 0; i < fListView->CountRows(); i++) { @@ -270,16 +271,16 @@ ResView::UpdateRow(BRow *row) void ResView::AddResource(const entry_ref &ref) { - BFile file(&ref,B_READ_ONLY); + BFile file(&ref, B_READ_ONLY); if (file.InitCheck() != B_OK) return; BString mime; - file.ReadAttrString("BEOS:TYPE",&mime); + file.ReadAttrString("BEOS:TYPE", &mime); if (mime == "application/x-be-resource") { BMessage msg(B_REFS_RECEIVED); - msg.AddRef("refs",&ref); + msg.AddRef("refs", &ref); be_app->PostMessage(&msg); return; } @@ -288,7 +289,7 @@ ResView::AddResource(const entry_ref &ref) BTranslatorRoster *roster = BTranslatorRoster::Default(); translator_info info; - if (roster->Identify(&file,NULL,&info,0,mime.String()) == B_OK) + if (roster->Identify(&file, NULL, &info, 0, mime.String()) == B_OK) fileType = info.type; else fileType = B_RAW_TYPE; @@ -307,10 +308,10 @@ ResView::AddResource(const entry_ref &ref) return; char *fileData = (char *)malloc(fileSize); - file.Read(fileData,fileSize); + file.Read(fileData, fileSize); - ResourceData *resData = new ResourceData(fileType,lastID + 1, ref.name, - fileData,fileSize); + ResourceData *resData = new ResourceData(fileType, lastID + 1, ref.name, + fileData, fileSize); fDataList.AddItem(resData); ResDataRow *row = new ResDataRow(resData); @@ -342,15 +343,15 @@ ResDataRow::ResDataRow(ResourceData *data) : fResData(data) { if (data) { - SetField(new BStringField(fResData->GetIDString()),0); - SetField(new TypeCodeField(fResData->GetType(),fResData),1); - SetField(new BStringField(fResData->GetName()),2); + SetField(new BStringField(fResData->GetIDString()), 0); + SetField(new TypeCodeField(fResData->GetType(), fResData), 1); + SetField(new BStringField(fResData->GetName()), 2); BField *field = gResRoster.MakeFieldForType(fResData->GetType(), fResData->GetData(), fResData->GetLength()); if (field) - SetField(field,3); - SetField(new BSizeField(fResData->GetLength()),4); + SetField(field, 3); + SetField(new BSizeField(fResData->GetLength()), 4); } } diff --git a/src/apps/resedit/ResWindow.cpp b/src/apps/resedit/ResWindow.cpp index 4ea547a2a9..6f0d64c558 100644 --- a/src/apps/resedit/ResWindow.cpp +++ b/src/apps/resedit/ResWindow.cpp @@ -6,15 +6,16 @@ * DarkWyrm */ #include "ResWindow.h" -#include "ResView.h" + #include "App.h" +#include "ResView.h" static int32 sWindowCount = 0; ResWindow::ResWindow(const BRect &rect, const entry_ref *ref) - : BWindow(rect,"", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS) + : BWindow(rect, "", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS) { - atomic_add(&sWindowCount,1); + atomic_add(&sWindowCount, 1); ResView *child = new ResView(Bounds(), "resview", B_FOLLOW_ALL, B_WILL_DRAW, ref); @@ -34,11 +35,10 @@ ResWindow::~ResWindow(void) bool ResWindow::QuitRequested(void) { - atomic_add(&sWindowCount,-1); + atomic_add(&sWindowCount, -1); if (sWindowCount == 0) be_app->PostMessage(B_QUIT_REQUESTED); - // be_app->PostMessage(M_UNREGISTER_WINDOW); return true; } diff --git a/src/apps/resedit/ResourceData.cpp b/src/apps/resedit/ResourceData.cpp index 3f01887f0f..e799268572 100644 --- a/src/apps/resedit/ResourceData.cpp +++ b/src/apps/resedit/ResourceData.cpp @@ -78,8 +78,8 @@ ResourceData::SetFromResource(const int32 &index, BResources &res) fIDString = ""; fIDString << fID; fAttr = false; - char *data = (char *)res.LoadResource(fType,fID,&fLength); - SetData(data,fLength); + char *data = (char *)res.LoadResource(fType, fID, &fLength); + SetData(data, fLength); return true; } @@ -127,7 +127,7 @@ ResourceData::SetTo(const type_code &code, const int32 &id, fIDString = ""; fIDString << fID; fName = name; - SetData(data,length); + SetData(data, length); } @@ -158,7 +158,7 @@ ResourceData::SetData(const char *data, const size_t &size) if (size > 0) { fData = (char *)malloc(size); - memcpy(fData,data,size); + memcpy(fData, data, size); } else fData = NULL; diff --git a/src/apps/resedit/ResourceData.h b/src/apps/resedit/ResourceData.h index ae86ee2c3d..884c90b533 100644 --- a/src/apps/resedit/ResourceData.h +++ b/src/apps/resedit/ResourceData.h @@ -8,10 +8,10 @@ #ifndef RESOURCE_DATA_H #define RESOURCE_DATA_H -#include -#include -#include #include +#include +#include +#include class ResourceData { diff --git a/src/apps/resedit/ResourceRoster.cpp b/src/apps/resedit/ResourceRoster.cpp index dc92b93bb6..b058ba8384 100644 --- a/src/apps/resedit/ResourceRoster.cpp +++ b/src/apps/resedit/ResourceRoster.cpp @@ -6,17 +6,18 @@ * DarkWyrm */ #include "ResourceRoster.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "ResourceData.h" +#include +#include +#include +#include +#include +#include +#include +#include + #include "InternalEditors.h" +#include "ResourceData.h" #include "ResFields.h" // For the MakeFieldForType temp code @@ -89,7 +90,7 @@ ResourceRoster::MakeFieldForType(const int32 &type, const char *data, case B_TIFF_FORMAT: case B_PNG_FORMAT: case B_JPEG_FORMAT: { - BMemoryIO memio(data,length); + BMemoryIO memio(data, length); BBitmap *bitmap = BTranslationUtils::GetBitmap(&memio); if (bitmap) { BitmapPreviewField *field = new BitmapPreviewField(bitmap); @@ -127,13 +128,13 @@ ResourceRoster::LoadEditors(void) continue; char *temp; - if (get_image_symbol(addon,"description",B_SYMBOL_TYPE_DATA,(void **)(&temp)) != B_OK) { + if (get_image_symbol(addon, "description", B_SYMBOL_TYPE_DATA, (void **)(&temp)) != B_OK) { unload_add_on(addon); continue; } create_editor *createFunc; - if (get_image_symbol(addon,"instantiate_editor",B_SYMBOL_TYPE_TEXT,(void **)(&createFunc)) != B_OK) { + if (get_image_symbol(addon, "instantiate_editor", B_SYMBOL_TYPE_TEXT, (void **)(&createFunc)) != B_OK) { delete temp; unload_add_on(addon); continue; @@ -152,7 +153,7 @@ ResourceRoster::SpawnEditor(ResourceData *data, BHandler *handler) // temporary code until editors are done switch (data->GetType()) { case B_MIME_STRING_TYPE: { - StringEditor *strEd = new StringEditor(BRect(100,100,400,200), + StringEditor *strEd = new StringEditor(BRect(100, 100, 400, 200), data, handler); strEd->Show(); break; @@ -164,7 +165,7 @@ ResourceRoster::SpawnEditor(ResourceData *data, BHandler *handler) case B_TIFF_FORMAT: case B_PNG_FORMAT: case B_JPEG_FORMAT: { - ImageEditor *imgEd = new ImageEditor(BRect(100,100,300,200), + ImageEditor *imgEd = new ImageEditor(BRect(100, 100, 300, 200), data, handler); imgEd->Show(); break;