<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:
DarkWyrm
2010-04-27 12:27:29 +00:00
parent c497ec3773
commit 09a03cb827
15 changed files with 413 additions and 447 deletions
+1
View File
@@ -7,6 +7,7 @@
*/ */
#include "App.h" #include "App.h"
#include "ResWindow.h" #include "ResWindow.h"
#include <Entry.h> #include <Entry.h>
int int
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -1,25 +1,25 @@
#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
{ {
M_BITMAP_ADDED='mbma', M_BITMAP_ADDED = 'mbma',
M_BITMAP_REMOVED='mbmr' M_BITMAP_REMOVED = 'mbmr'
}; };
class BitmapView : public BView, public BInvoker class BitmapView : public BView, public BInvoker
{ {
public: public:
BitmapView(BRect frame, const char *name, BMessage *mod, BBitmap *bitmap, BitmapView(BRect frame, const char *name, BMessage *mod, BBitmap *bitmap,
const char *label = NULL, border_style = B_PLAIN_BORDER, const char *label = NULL, border_style = B_PLAIN_BORDER,
int32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP, int32 flags = B_WILL_DRAW); int32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP, int32 flags = B_WILL_DRAW);
~BitmapView(void); ~BitmapView(void);
virtual void AttachedToWindow(void); virtual void AttachedToWindow(void);
+18 -17
View File
@@ -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'
@@ -20,16 +21,16 @@ ImageEditor::ImageEditor(const BRect &frame, ResourceData *data, BHandler *owner
SetTitle(data->GetName()); SetTitle(data->GetName());
// Set up the image and the viewer for such // 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); fImage = BTranslationUtils::GetBitmap(&memio);
BRect imgsize; BRect imgsize;
if (fImage) if (fImage)
imgsize = ScaleRectToFit(fImage->Bounds(),BRect(0,0,200,200)); imgsize = ScaleRectToFit(fImage->Bounds(), BRect(0, 0, 200, 200));
else 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)); back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(back); AddChild(back);
@@ -42,34 +43,34 @@ ImageEditor::ImageEditor(const BRect &frame, ResourceData *data, BHandler *owner
be_plain_font->GetHeight(&fh); be_plain_font->GetHeight(&fh);
float strheight = fh.ascent + fh.descent + fh.leading + 5; 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), 10 + strheight),
"id","ID: ",data->GetIDString(), NULL); "id", "ID: ", data->GetIDString(), NULL);
fIDBox->SetDivider(labelwidth + 5); fIDBox->SetDivider(labelwidth + 5);
back->AddChild(fIDBox); back->AddChild(fIDBox);
r = fIDBox->Frame(); r = fIDBox->Frame();
r.OffsetBy(r.Width() + 10, 0); r.OffsetBy(r.Width() + 10, 0);
r.right = Bounds().right - 10; 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); B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fNameBox->SetDivider(be_plain_font->StringWidth("Name: ") + 5); fNameBox->SetDivider(be_plain_font->StringWidth("Name: ") + 5);
back->AddChild(fNameBox); back->AddChild(fNameBox);
r = imgsize; r = imgsize;
r.OffsetTo( (Bounds().Width() - r.Width()) / 2,fNameBox->Frame().bottom + 10); r.OffsetTo( (Bounds().Width() - r.Width()) / 2, fNameBox->Frame().bottom + 10);
fImageView = new BitmapView(r,"imageview",new BMessage(M_IMAGE_CHANGED),fImage, fImageView = new BitmapView(r, "imageview", new BMessage(M_IMAGE_CHANGED), fImage,
NULL, B_PLAIN_BORDER, B_FOLLOW_NONE, NULL, B_PLAIN_BORDER, B_FOLLOW_NONE,
B_WILL_DRAW | B_FRAME_EVENTS); B_WILL_DRAW | B_FRAME_EVENTS);
back->AddChild(fImageView); back->AddChild(fImageView);
fImageView->SetConstrainDrops(false); fImageView->SetConstrainDrops(false);
// No limit on bitmap size // No limit on bitmap size
fImageView->SetMaxBitmapSize(0,0); fImageView->SetMaxBitmapSize(0, 0);
fImageView->SetBitmapRemovable(false); 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); B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
fOK->ResizeToPreferred(); fOK->ResizeToPreferred();
fOK->SetLabel("OK"); fOK->SetLabel("OK");
@@ -81,14 +82,14 @@ ImageEditor::ImageEditor(const BRect &frame, ResourceData *data, BHandler *owner
r = fOK->Frame(); r = fOK->Frame();
r.OffsetBy(-r.Width() - 10, 0); 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); B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
back->AddChild(fCancel); back->AddChild(fCancel);
ResizeTo(MAX(fImageView->Frame().right, fNameBox->Frame().right) + 20, ResizeTo(MAX(fImageView->Frame().right, fNameBox->Frame().right) + 20,
fImageView->Frame().bottom + fOK->Frame().Height() + 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); fImageView->MessageReceived(msg);
} else if (msg->what == M_IMAGE_CHANGED) { } else if (msg->what == M_IMAGE_CHANGED) {
fImage = fImageView->GetBitmap(); fImage = fImageView->GetBitmap();
BRect r = ScaleRectToFit(fImage->Bounds(), BRect(0,0,200,200)); BRect r = ScaleRectToFit(fImage->Bounds(), BRect(0, 0, 200, 200));
fImageView->ResizeTo(r.Width(),r.Height()); fImageView->ResizeTo(r.Width(), r.Height());
ResizeTo(MAX(fImageView->Frame().right, fNameBox->Frame().right) + 20, ResizeTo(MAX(fImageView->Frame().right, fNameBox->Frame().right) + 20,
fImageView->Frame().bottom + fOK->Frame().Height() + 20); fImageView->Frame().bottom + fOK->Frame().Height() + 20);
} else } else
+8 -8
View File
@@ -6,14 +6,15 @@
* 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
{ {
public: public:
EditFilter(BTextControl *textbox) 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; fTextBox = textbox;
} }
@@ -25,7 +26,7 @@ public:
filter_result Filter(BMessage *msg, BHandler **target) filter_result Filter(BMessage *msg, BHandler **target)
{ {
int32 rawchar; int32 rawchar;
msg->FindInt32("raw_char",&rawchar); msg->FindInt32("raw_char", &rawchar);
if (rawchar == B_ESCAPE) { if (rawchar == B_ESCAPE) {
BLooper *loop = (*target)->Looper(); BLooper *loop = (*target)->Looper();
@@ -48,20 +49,19 @@ private:
InlineEditor::InlineEditor(BMessenger target, const BRect &frame, InlineEditor::InlineEditor(BMessenger target, const BRect &frame,
const char *text) 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), B_ASYNCHRONOUS_CONTROLS),
fMessenger(target), fMessenger(target),
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);
fTextBox->ResizeToPreferred(); fTextBox->ResizeToPreferred();
fTextBox->ResizeTo(Bounds().Width(),fTextBox->Bounds().Height()); fTextBox->ResizeTo(Bounds().Width(), fTextBox->Bounds().Height());
ResizeTo(Bounds().Width(), fTextBox->Bounds().Height()); ResizeTo(Bounds().Width(), fTextBox->Bounds().Height());
AddCommonFilter(new EditFilter(fTextBox)); AddCommonFilter(new EditFilter(fTextBox));
+2 -2
View File
@@ -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'
+12 -10
View File
@@ -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,
@@ -44,10 +46,10 @@ StringEditor::MessageReceived(BMessage *msg)
GetData()->SetID(newid); GetData()->SetID(newid);
} }
GetData()->SetName(fView->GetName()); GetData()->SetName(fView->GetName());
GetData()->SetData(fView->GetValue(),strlen(fView->GetValue())); GetData()->SetData(fView->GetValue(), strlen(fView->GetValue()));
BMessage updatemsg(M_UPDATE_RESOURCE); BMessage updatemsg(M_UPDATE_RESOURCE);
updatemsg.AddPointer("item",GetData()); updatemsg.AddPointer("item", GetData());
BMessenger msgr(GetOwner()); BMessenger msgr(GetOwner());
msgr.SendMessage(&updatemsg); msgr.SendMessage(&updatemsg);
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
@@ -85,28 +87,28 @@ StringEditView::StringEditView(const BRect &frame)
be_plain_font->GetHeight(&fh); be_plain_font->GetHeight(&fh);
float strheight = fh.ascent + fh.descent + fh.leading + 5; 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), 10 + strheight),
"id","ID: ","", NULL); "id", "ID: ", "", NULL);
fIDBox->SetDivider(labelwidth + 5); fIDBox->SetDivider(labelwidth + 5);
AddChild(fIDBox); AddChild(fIDBox);
r = fIDBox->Frame(); r = fIDBox->Frame();
r.OffsetBy(r.Width() + 10, 0); r.OffsetBy(r.Width() + 10, 0);
r.right = Bounds().right - 10; 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); B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fNameBox->SetDivider(be_plain_font->StringWidth("Name: ") + 5); fNameBox->SetDivider(be_plain_font->StringWidth("Name: ") + 5);
AddChild(fNameBox); AddChild(fNameBox);
r.OffsetBy(0,r.Height() + 10); r.OffsetBy(0, r.Height() + 10);
r.left = 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); B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fValueBox->SetDivider(be_plain_font->StringWidth("Value: ") + 5); fValueBox->SetDivider(be_plain_font->StringWidth("Value: ") + 5);
AddChild(fValueBox); 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); B_FOLLOW_RIGHT);
fOK->ResizeToPreferred(); fOK->ResizeToPreferred();
fOK->SetLabel("OK"); fOK->SetLabel("OK");
@@ -116,7 +118,7 @@ StringEditView::StringEditView(const BRect &frame)
fOK->MoveTo(r.right - fOK->Bounds().Width(), r.bottom + 10); fOK->MoveTo(r.right - fOK->Bounds().Width(), r.bottom + 10);
r = fOK->Frame(); r = fOK->Frame();
r.OffsetBy(-r.Width() - 10, 0); 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_RIGHT);
AddChild(fCancel); AddChild(fCancel);
} }
+5 -3
View File
@@ -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,
@@ -40,10 +42,10 @@ DoubleEditor::MessageReceived(BMessage *msg)
} }
GetData()->SetName(fView->GetName()); GetData()->SetName(fView->GetName());
GetData()->SetData(fView->GetValue(),strlen(fView->GetValue())); GetData()->SetData(fView->GetValue(), strlen(fView->GetValue()));
BMessage updatemsg(M_UPDATE_RESOURCE); BMessage updatemsg(M_UPDATE_RESOURCE);
updatemsg.AddPointer("item",GetData()); updatemsg.AddPointer("item", GetData());
BMessenger msgr(GetOwner()); BMessenger msgr(GetOwner());
msgr.SendMessage(&updatemsg); msgr.SendMessage(&updatemsg);
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
+2 -1
View File
@@ -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,
@@ -19,7 +20,7 @@ void
PreviewColumn::DrawField(BField* field, BRect rect, BView* parent) PreviewColumn::DrawField(BField* field, BRect rect, BView* parent)
{ {
PreviewField *pField = (PreviewField*)field; PreviewField *pField = (PreviewField*)field;
pField->DrawField(rect,parent); pField->DrawField(rect, parent);
} }
bool bool
+2 -1
View File
@@ -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>
@@ -77,7 +78,7 @@ BitmapPreviewField::DrawField(BRect rect, BView *parent)
void void
BitmapPreviewField::SetData(char *data, const size_t &length) BitmapPreviewField::SetData(char *data, const size_t &length)
{ {
BMemoryIO memio(data,length); BMemoryIO memio(data, length);
fBitmap = BTranslationUtils::GetBitmap(&memio); fBitmap = BTranslationUtils::GetBitmap(&memio);
} }
+27 -26
View File
@@ -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"
@@ -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); fListView = new ResListView(r, "gridview", B_FOLLOW_ALL, B_WILL_DRAW, B_FANCY_BORDER);
AddChild(fListView); 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_BACKGROUND, white);
fListView->SetColor(B_COLOR_SELECTION, ui_color(B_MENU_BACKGROUND_COLOR)); fListView->SetColor(B_COLOR_SELECTION, ui_color(B_MENU_BACKGROUND_COLOR));
float width = be_plain_font->StringWidth("00000") + 20; 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("Type", width, width, 100, B_TRUNCATE_END), 1);
fListView->AddColumn(new BStringColumn("Name",150,50,300,B_TRUNCATE_END),2); fListView->AddColumn(new BStringColumn("Name", 150, 50, 300, B_TRUNCATE_END), 2);
fListView->AddColumn(new PreviewColumn("Data",150,50,300),3); fListView->AddColumn(new PreviewColumn("Data", 150, 50, 300), 3);
// Editing is disabled for now // Editing is disabled for now
fListView->SetInvocationMessage(new BMessage(M_EDIT_RESOURCE)); fListView->SetInvocationMessage(new BMessage(M_EDIT_RESOURCE));
width = be_plain_font->StringWidth("1000 bytes") + 20; 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); fFilePanel = new BFilePanel(B_OPEN_PANEL);
if (ref) if (ref)
@@ -116,9 +117,9 @@ ResView::MessageReceived(BMessage *msg)
{ {
switch (msg->what) { switch (msg->what) {
case M_NEW_FILE: { case M_NEW_FILE: {
BRect r(100,100,400,400); BRect r(100, 100, 400, 400);
if (Window()) if (Window())
r = Window()->Frame().OffsetByCopy(10,10); r = Window()->Frame().OffsetByCopy(10, 10);
ResWindow *win = new ResWindow(r); ResWindow *win = new ResWindow(r);
win->Show(); win->Show();
break; break;
@@ -134,7 +135,7 @@ ResView::MessageReceived(BMessage *msg)
case B_REFS_RECEIVED: { case B_REFS_RECEIVED: {
int32 i = 0; int32 i = 0;
entry_ref ref; entry_ref ref;
while (msg->FindRef("refs",i++,&ref) == B_OK) while (msg->FindRef("refs", i++, &ref) == B_OK)
AddResource(ref); AddResource(ref);
break; break;
} }
@@ -149,12 +150,12 @@ ResView::MessageReceived(BMessage *msg)
case M_EDIT_RESOURCE: { case M_EDIT_RESOURCE: {
BRow *row = fListView->CurrentSelection(); BRow *row = fListView->CurrentSelection();
TypeCodeField *field = (TypeCodeField*)row->GetField(1); TypeCodeField *field = (TypeCodeField*)row->GetField(1);
gResRoster.SpawnEditor(field->GetResourceData(),this); gResRoster.SpawnEditor(field->GetResourceData(), this);
break; break;
} }
case M_UPDATE_RESOURCE: { case M_UPDATE_RESOURCE: {
ResourceData *item; ResourceData *item;
if (msg->FindPointer("item",(void **)&item) != B_OK) if (msg->FindPointer("item", (void **)&item) != B_OK)
break; break;
for (int32 i = 0; i < fListView->CountRows(); i++) { for (int32 i = 0; i < fListView->CountRows(); i++) {
@@ -270,16 +271,16 @@ ResView::UpdateRow(BRow *row)
void void
ResView::AddResource(const entry_ref &ref) ResView::AddResource(const entry_ref &ref)
{ {
BFile file(&ref,B_READ_ONLY); BFile file(&ref, B_READ_ONLY);
if (file.InitCheck() != B_OK) if (file.InitCheck() != B_OK)
return; return;
BString mime; BString mime;
file.ReadAttrString("BEOS:TYPE",&mime); file.ReadAttrString("BEOS:TYPE", &mime);
if (mime == "application/x-be-resource") { if (mime == "application/x-be-resource") {
BMessage msg(B_REFS_RECEIVED); BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs",&ref); msg.AddRef("refs", &ref);
be_app->PostMessage(&msg); be_app->PostMessage(&msg);
return; return;
} }
@@ -288,7 +289,7 @@ ResView::AddResource(const entry_ref &ref)
BTranslatorRoster *roster = BTranslatorRoster::Default(); BTranslatorRoster *roster = BTranslatorRoster::Default();
translator_info info; 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; fileType = info.type;
else else
fileType = B_RAW_TYPE; fileType = B_RAW_TYPE;
@@ -307,10 +308,10 @@ ResView::AddResource(const entry_ref &ref)
return; return;
char *fileData = (char *)malloc(fileSize); char *fileData = (char *)malloc(fileSize);
file.Read(fileData,fileSize); file.Read(fileData, fileSize);
ResourceData *resData = new ResourceData(fileType,lastID + 1, ref.name, ResourceData *resData = new ResourceData(fileType, lastID + 1, ref.name,
fileData,fileSize); fileData, fileSize);
fDataList.AddItem(resData); fDataList.AddItem(resData);
ResDataRow *row = new ResDataRow(resData); ResDataRow *row = new ResDataRow(resData);
@@ -342,15 +343,15 @@ ResDataRow::ResDataRow(ResourceData *data)
: fResData(data) : fResData(data)
{ {
if (data) { if (data) {
SetField(new BStringField(fResData->GetIDString()),0); SetField(new BStringField(fResData->GetIDString()), 0);
SetField(new TypeCodeField(fResData->GetType(),fResData),1); SetField(new TypeCodeField(fResData->GetType(), fResData), 1);
SetField(new BStringField(fResData->GetName()),2); SetField(new BStringField(fResData->GetName()), 2);
BField *field = gResRoster.MakeFieldForType(fResData->GetType(), BField *field = gResRoster.MakeFieldForType(fResData->GetType(),
fResData->GetData(), fResData->GetData(),
fResData->GetLength()); fResData->GetLength());
if (field) if (field)
SetField(field,3); SetField(field, 3);
SetField(new BSizeField(fResData->GetLength()),4); SetField(new BSizeField(fResData->GetLength()), 4);
} }
} }
+5 -5
View File
@@ -6,15 +6,16 @@
* 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;
ResWindow::ResWindow(const BRect &rect, const entry_ref *ref) 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, ResView *child = new ResView(Bounds(), "resview", B_FOLLOW_ALL,
B_WILL_DRAW, ref); B_WILL_DRAW, ref);
@@ -34,11 +35,10 @@ ResWindow::~ResWindow(void)
bool bool
ResWindow::QuitRequested(void) ResWindow::QuitRequested(void)
{ {
atomic_add(&sWindowCount,-1); atomic_add(&sWindowCount, -1);
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;
} }
+4 -4
View File
@@ -78,8 +78,8 @@ ResourceData::SetFromResource(const int32 &index, BResources &res)
fIDString = ""; fIDString = "";
fIDString << fID; fIDString << fID;
fAttr = false; fAttr = false;
char *data = (char *)res.LoadResource(fType,fID,&fLength); char *data = (char *)res.LoadResource(fType, fID, &fLength);
SetData(data,fLength); SetData(data, fLength);
return true; return true;
} }
@@ -127,7 +127,7 @@ ResourceData::SetTo(const type_code &code, const int32 &id,
fIDString = ""; fIDString = "";
fIDString << fID; fIDString << fID;
fName = name; fName = name;
SetData(data,length); SetData(data, length);
} }
@@ -158,7 +158,7 @@ ResourceData::SetData(const char *data, const size_t &size)
if (size > 0) { if (size > 0) {
fData = (char *)malloc(size); fData = (char *)malloc(size);
memcpy(fData,data,size); memcpy(fData, data, size);
} }
else else
fData = NULL; fData = NULL;
+3 -3
View File
@@ -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
{ {
+15 -14
View File
@@ -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
@@ -89,7 +90,7 @@ ResourceRoster::MakeFieldForType(const int32 &type, const char *data,
case B_TIFF_FORMAT: case B_TIFF_FORMAT:
case B_PNG_FORMAT: case B_PNG_FORMAT:
case B_JPEG_FORMAT: { case B_JPEG_FORMAT: {
BMemoryIO memio(data,length); BMemoryIO memio(data, length);
BBitmap *bitmap = BTranslationUtils::GetBitmap(&memio); BBitmap *bitmap = BTranslationUtils::GetBitmap(&memio);
if (bitmap) { if (bitmap) {
BitmapPreviewField *field = new BitmapPreviewField(bitmap); BitmapPreviewField *field = new BitmapPreviewField(bitmap);
@@ -127,13 +128,13 @@ ResourceRoster::LoadEditors(void)
continue; continue;
char *temp; 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); unload_add_on(addon);
continue; continue;
} }
create_editor *createFunc; 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; delete temp;
unload_add_on(addon); unload_add_on(addon);
continue; continue;
@@ -152,7 +153,7 @@ ResourceRoster::SpawnEditor(ResourceData *data, BHandler *handler)
// temporary code until editors are done // temporary code until editors are done
switch (data->GetType()) { switch (data->GetType()) {
case B_MIME_STRING_TYPE: { 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); data, handler);
strEd->Show(); strEd->Show();
break; break;
@@ -164,7 +165,7 @@ ResourceRoster::SpawnEditor(ResourceData *data, BHandler *handler)
case B_TIFF_FORMAT: case B_TIFF_FORMAT:
case B_PNG_FORMAT: case B_PNG_FORMAT:
case B_JPEG_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); data, handler);
imgEd->Show(); imgEd->Show();
break; break;