<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:
parent
c497ec3773
commit
09a03cb827
@ -7,6 +7,7 @@
|
||||
*/
|
||||
#include "App.h"
|
||||
#include "ResWindow.h"
|
||||
|
||||
#include <Entry.h>
|
||||
|
||||
int
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,25 +1,25 @@
|
||||
#ifndef BMPVIEW_H
|
||||
#define BMPVIEW_H
|
||||
|
||||
#include <Message.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Message.h>
|
||||
#include <Invoker.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
#include <PopUpMenu.h>
|
||||
|
||||
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);
|
||||
|
||||
|
@ -5,11 +5,12 @@
|
||||
* Author:
|
||||
* DarkWyrm <darkwyrm@gmail.com>
|
||||
*/
|
||||
#include "InternalEditors.h"
|
||||
#include "BitmapView.h"
|
||||
#include "InternalEditors.h"
|
||||
#include "ResourceData.h"
|
||||
#include <TranslationUtils.h>
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <TranslationUtils.h>
|
||||
|
||||
#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
|
||||
|
@ -6,14 +6,15 @@
|
||||
* DarkWyrm <darkwyrm@gmail.com>
|
||||
*/
|
||||
#include "InlineEditor.h"
|
||||
#include <MessageFilter.h>
|
||||
|
||||
#include <Handler.h>
|
||||
#include <MessageFilter.h>
|
||||
|
||||
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));
|
||||
|
@ -8,9 +8,9 @@
|
||||
#ifndef INLINE_EDITOR
|
||||
#define INLINE_EDITOR
|
||||
|
||||
#include <Window.h>
|
||||
#include <TextControl.h>
|
||||
#include <Messenger.h>
|
||||
#include <TextControl.h>
|
||||
#include <Window.h>
|
||||
|
||||
#define M_INLINE_TEXT 'intx'
|
||||
|
||||
|
@ -7,9 +7,11 @@
|
||||
*/
|
||||
#include "InternalEditors.h"
|
||||
#include "ResourceData.h"
|
||||
#include <Messenger.h>
|
||||
|
||||
#include <Message.h>
|
||||
#include <Messenger.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -7,9 +7,11 @@
|
||||
*/
|
||||
#include "InternalEditors.h"
|
||||
#include "ResourceData.h"
|
||||
#include <Messenger.h>
|
||||
|
||||
#include <Message.h>
|
||||
#include <Messenger.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
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);
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
#include "PreviewColumn.h"
|
||||
#include "ResFields.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
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
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
#include "ResFields.h"
|
||||
#include "ResourceData.h"
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <TranslationUtils.h>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -10,15 +10,16 @@
|
||||
#include <Application.h>
|
||||
#include <File.h>
|
||||
#include <ScrollView.h>
|
||||
#include <malloc.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <stdio.h>
|
||||
#include <TranslatorRoster.h>
|
||||
#include <TypeConstants.h>
|
||||
#include "ColumnTypes.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,15 +6,16 @@
|
||||
* DarkWyrm <darkwyrm@gmail.com>
|
||||
*/
|
||||
#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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -8,10 +8,10 @@
|
||||
#ifndef RESOURCE_DATA_H
|
||||
#define RESOURCE_DATA_H
|
||||
|
||||
#include <Resources.h>
|
||||
#include <String.h>
|
||||
#include <Node.h>
|
||||
#include <fs_attr.h>
|
||||
#include <Resources.h>
|
||||
#include <Node.h>
|
||||
#include <String.h>
|
||||
|
||||
class ResourceData
|
||||
{
|
||||
|
@ -6,17 +6,18 @@
|
||||
* DarkWyrm <darkwyrm@gmail.com>
|
||||
*/
|
||||
#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 "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;
|
||||
|
Loading…
Reference in New Issue
Block a user