[haiku-commits] r36499 - haiku/trunk/src/apps/resedit
- From: darkwyrm@xxxxxxxxx
- To: haiku-commits@xxxxxxxxxxxxx
- Date: Tue, 27 Apr 2010 01:38:42 +0200 (CEST)
Author: darkwyrm
Date: 2010-04-27 01:38:41 +0200 (Tue, 27 Apr 2010)
New Revision: 36499
Changeset: http://dev.haiku-os.org/changeset/36499/haiku
Modified:
haiku/trunk/src/apps/resedit/App.cpp
haiku/trunk/src/apps/resedit/App.h
haiku/trunk/src/apps/resedit/Editor.h
haiku/trunk/src/apps/resedit/ImageEditor.cpp
haiku/trunk/src/apps/resedit/InlineEditor.cpp
haiku/trunk/src/apps/resedit/InlineEditor.h
haiku/trunk/src/apps/resedit/InternalEditors.h
haiku/trunk/src/apps/resedit/Jamfile
haiku/trunk/src/apps/resedit/MiscEditors.cpp
haiku/trunk/src/apps/resedit/NumberEditors.cpp
haiku/trunk/src/apps/resedit/PreviewColumn.cpp
haiku/trunk/src/apps/resedit/PreviewColumn.h
haiku/trunk/src/apps/resedit/ResFields.cpp
haiku/trunk/src/apps/resedit/ResFields.h
haiku/trunk/src/apps/resedit/ResView.cpp
haiku/trunk/src/apps/resedit/ResView.h
haiku/trunk/src/apps/resedit/ResWindow.cpp
haiku/trunk/src/apps/resedit/ResWindow.h
haiku/trunk/src/apps/resedit/ResourceData.cpp
haiku/trunk/src/apps/resedit/ResourceData.h
haiku/trunk/src/apps/resedit/ResourceRoster.cpp
haiku/trunk/src/apps/resedit/ResourceRoster.h
Log:
Adding and deleting resources now implemented
Added drag and drop support to add resources to the current project
Updated e-mail address and copyright information
Converted window registration to use a static variable to simplify and correct
window closing code
Modified: haiku/trunk/src/apps/resedit/App.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/App.cpp 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/App.cpp 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#include "App.h"
#include "ResWindow.h"
@@ -19,25 +19,25 @@
App::App(void)
- : BApplication("application/x-vnd.Haiku-ResEdit"),
- fWindowCount(0)
+ : BApplication("application/x-vnd.Haiku-ResEdit")
{
fOpenPanel = new BFilePanel();
- fSavePanel = new BFilePanel(B_SAVE_PANEL);
}
App::~App(void)
{
delete fOpenPanel;
- delete fSavePanel;
}
void
App::ReadyToRun(void)
{
- if (fWindowCount < 1)
+ // CountWindows() needs to be used instead of fWindowCount because the
registration
+ // message isn't processed in time. One of the windows belong to the
BFilePanels and is
+ // counted in CountWindows().
+ if (CountWindows() < 2)
new ResWindow(BRect(50, 100, 600, 400));
}
@@ -46,16 +46,6 @@
App::MessageReceived(BMessage *msg)
{
switch(msg->what) {
- case M_REGISTER_WINDOW: {
- fWindowCount++;
- break;
- }
- case M_UNREGISTER_WINDOW: {
- fWindowCount--;
- if (fWindowCount == 0)
- PostMessage(B_QUIT_REQUESTED);
- break;
- }
case M_SHOW_OPEN_PANEL: {
// Don't do anything if it's already open
if (fOpenPanel->IsShowing())
@@ -90,20 +80,3 @@
while (msg->FindRef("refs", i++, &ref) == B_OK)
new ResWindow(BRect(50, 100, 600, 400), &ref);
}
-
-
-bool
-App::QuitRequested(void)
-{
- for (int32 i = 0; i < CountWindows(); i++) {
- BWindow *win = WindowAt(i);
- if (fOpenPanel->Window() == win || fSavePanel->Window() == win)
- continue;
-
- if (!win->QuitRequested())
- return false;
- }
-
- return true;
-}
-
Modified: haiku/trunk/src/apps/resedit/App.h
===================================================================
--- haiku/trunk/src/apps/resedit/App.h 2010-04-26 21:57:02 UTC (rev 36498)
+++ haiku/trunk/src/apps/resedit/App.h 2010-04-26 23:38:41 UTC (rev 36499)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#ifndef APP_H
#define APP_H
@@ -12,8 +12,6 @@
#include <FilePanel.h>
enum {
- M_REGISTER_WINDOW = 'regw',
- M_UNREGISTER_WINDOW,
M_SHOW_OPEN_PANEL,
M_SHOW_SAVE_PANEL
};
@@ -27,11 +25,9 @@
void ArgvReceived(int32 argc, char** argv);
void RefsReceived(BMessage *msg);
void ReadyToRun(void);
- bool QuitRequested(void);
private:
- uint32 fWindowCount;
- BFilePanel *fOpenPanel, *fSavePanel;
+ BFilePanel *fOpenPanel;
};
#endif
Modified: haiku/trunk/src/apps/resedit/Editor.h
===================================================================
--- haiku/trunk/src/apps/resedit/Editor.h 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/Editor.h 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#ifndef EDITOR_H
#define EDITOR_H
Modified: haiku/trunk/src/apps/resedit/ImageEditor.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/ImageEditor.cpp 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/ImageEditor.cpp 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2005-2010, Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ *
+ * Author:
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
+ */
#include "InternalEditors.h"
#include "BitmapView.h"
#include "ResourceData.h"
@@ -80,6 +87,8 @@
ResizeTo(MAX(fImageView->Frame().right, fNameBox->Frame().right) + 20,
fImageView->Frame().bottom + fOK->Frame().Height() +
20);
+
+ SetSizeLimits(Bounds().right,30000,Bounds().bottom,30000);
}
Modified: haiku/trunk/src/apps/resedit/InlineEditor.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/InlineEditor.cpp 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/InlineEditor.cpp 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2005-2010, Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ *
+ * Author:
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
+ */
#include "InlineEditor.h"
#include <MessageFilter.h>
#include <Handler.h>
Modified: haiku/trunk/src/apps/resedit/InlineEditor.h
===================================================================
--- haiku/trunk/src/apps/resedit/InlineEditor.h 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/InlineEditor.h 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2005-2010, Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ *
+ * Author:
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
+ */
#ifndef INLINE_EDITOR
#define INLINE_EDITOR
Modified: haiku/trunk/src/apps/resedit/InternalEditors.h
===================================================================
--- haiku/trunk/src/apps/resedit/InternalEditors.h 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/InternalEditors.h 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2005-2010, Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ *
+ * Author:
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
+ */
#ifndef INTERNALEDITORS_H
#define INTERNALEDITORS_H
Modified: haiku/trunk/src/apps/resedit/Jamfile
===================================================================
--- haiku/trunk/src/apps/resedit/Jamfile 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/Jamfile 2010-04-26 23:38:41 UTC (rev
36499)
@@ -22,6 +22,7 @@
NumberEditors.cpp
PreviewColumn.cpp
ResFields.cpp
+ ResListView.cpp
ResourceData.cpp
ResourceRoster.cpp
ResView.cpp
Modified: haiku/trunk/src/apps/resedit/MiscEditors.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/MiscEditors.cpp 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/MiscEditors.cpp 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2005-2010, Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ *
+ * Author:
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
+ */
#include "InternalEditors.h"
#include "ResourceData.h"
#include <Messenger.h>
@@ -138,7 +145,7 @@
be_plain_font->StringWidth("(attr) ") +
15;
float namewidth = be_plain_font->StringWidth("Name: ") +
be_plain_font->StringWidth(fNameBox->Text()) + 15;
- return idwidth + namewidth + 30;
+ return idwidth + namewidth + 100;
}
Modified: haiku/trunk/src/apps/resedit/NumberEditors.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/NumberEditors.cpp 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/NumberEditors.cpp 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2005-2010, Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ *
+ * Author:
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
+ */
#include "InternalEditors.h"
#include "ResourceData.h"
#include <Messenger.h>
Modified: haiku/trunk/src/apps/resedit/PreviewColumn.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/PreviewColumn.cpp 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/PreviewColumn.cpp 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#include "PreviewColumn.h"
#include "ResFields.h"
Modified: haiku/trunk/src/apps/resedit/PreviewColumn.h
===================================================================
--- haiku/trunk/src/apps/resedit/PreviewColumn.h 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/PreviewColumn.h 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#ifndef PREVIEW_COLUMN_H
#define PREVIEW_COLUMN_H
Modified: haiku/trunk/src/apps/resedit/ResFields.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/ResFields.cpp 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/ResFields.cpp 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2005-2010, Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ *
+ * Author:
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
+ */
#include "ResFields.h"
#include "ResourceData.h"
#include <DataIO.h>
Modified: haiku/trunk/src/apps/resedit/ResFields.h
===================================================================
--- haiku/trunk/src/apps/resedit/ResFields.h 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/ResFields.h 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2005-2010, Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ *
+ * Author:
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
+ */
#ifndef RESFIELDS_H
#define RESFIELDS_H
Modified: haiku/trunk/src/apps/resedit/ResView.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/ResView.cpp 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/ResView.cpp 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,23 +1,27 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#include "ResView.h"
#include <Application.h>
+#include <File.h>
#include <ScrollView.h>
-#include <MenuBar.h>
+#include <malloc.h>
#include <Menu.h>
#include <MenuItem.h>
#include <stdio.h>
-#include <ColumnTypes.h>
+#include <TranslatorRoster.h>
+#include <TypeConstants.h>
+#include "ColumnTypes.h"
#include "App.h"
#include "ResourceData.h"
#include "ResFields.h"
+#include "ResListView.h"
#include "ResWindow.h"
#include "PreviewColumn.h"
#include "Editor.h"
@@ -32,6 +36,8 @@
M_SAVE_FILE,
M_SAVE_FILE_AS,
M_QUIT,
+ M_SELECT_FILE,
+ M_DELETE_RESOURCE,
M_EDIT_RESOURCE
};
@@ -52,23 +58,16 @@
sUntitled++;
}
- BMenu *menu = new BMenu("File");
- menu->AddItem(new BMenuItem("New" B_UTF8_ELLIPSIS, new
BMessage(M_NEW_FILE), 'N'));
- menu->AddSeparatorItem();
- menu->AddItem(new BMenuItem("Open" B_UTF8_ELLIPSIS, new
BMessage(M_OPEN_FILE), 'O'));
- menu->AddItem(new BMenuItem("Quit", new BMessage(M_QUIT), 'Q'));
-
BRect r(Bounds());
r.bottom = 16;
fBar = new BMenuBar(r, "bar");
AddChild(fBar);
- fBar->AddItem(menu);
+ BuildMenus(fBar);
r = Bounds();
r.top = fBar->Frame().bottom + 4;
- fListView = new BColumnListView(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);
rgb_color white = { 255,255,255,255 };
@@ -81,11 +80,14 @@
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);
+ fFilePanel = new BFilePanel(B_OPEN_PANEL);
if (ref)
OpenFile(*ref);
}
@@ -95,6 +97,7 @@
{
EmptyDataList();
delete fRef;
+ delete fFilePanel;
}
@@ -104,17 +107,13 @@
for(int32 i = 0; i < fBar->CountItems(); i++)
fBar->SubmenuAt(i)->SetTargetForItems(this);
fListView->SetTarget(this);
+ fFilePanel->SetTarget(BMessenger(this));
}
void
ResView::MessageReceived(BMessage *msg)
{
- if (msg->WasDropped()) {
- be_app->PostMessage(msg);
- return;
- }
-
switch (msg->what) {
case M_NEW_FILE: {
BRect r(100,100,400,400);
@@ -132,6 +131,21 @@
be_app->PostMessage(B_QUIT_REQUESTED);
break;
}
+ case B_REFS_RECEIVED: {
+ int32 i = 0;
+ entry_ref ref;
+ while (msg->FindRef("refs",i++,&ref) == B_OK)
+ AddResource(ref);
+ break;
+ }
+ case M_SELECT_FILE: {
+ fFilePanel->Show();
+ break;
+ }
+ case M_DELETE_RESOURCE: {
+ DeleteSelectedResources();
+ break;
+ }
case M_EDIT_RESOURCE: {
BRow *row = fListView->CurrentSelection();
TypeCodeField *field = (TypeCodeField*)row->GetField(1);
@@ -164,7 +178,6 @@
ResView::OpenFile(const entry_ref &ref)
{
// Add all the 133t resources and attributes of the file
-
BFile file(&ref, B_READ_ONLY);
BResources resources;
if (resources.SetTo(&file) != B_OK)
@@ -174,19 +187,10 @@
resources.PreloadResourceType();
int32 index = 0;
- BRow *row;
+ ResDataRow *row;
ResourceData *resData = new ResourceData();
while (resData->SetFromResource(index, resources)) {
- row = new BRow();
- row->SetField(new BStringField(resData->GetIDString()),0);
- row->SetField(new TypeCodeField(resData->GetType(),resData),1);
- row->SetField(new BStringField(resData->GetName()),2);
- BField *field = gResRoster.MakeFieldForType(resData->GetType(),
-
resData->GetData(),
-
resData->GetLength());
- if (field)
- row->SetField(field,3);
- row->SetField(new BSizeField(resData->GetLength()),4);
+ row = new ResDataRow(resData);
fListView->AddRow(row);
fDataList.AddItem(resData);
resData = new ResourceData();
@@ -201,16 +205,7 @@
resData = new ResourceData();
while (node.GetNextAttrName(attrName) == B_OK) {
if (resData->SetFromAttribute(attrName, node)) {
- row = new BRow();
- row->SetField(new
BStringField(resData->GetIDString()),0);
- row->SetField(new
TypeCodeField(resData->GetType(),resData),1);
- row->SetField(new
BStringField(resData->GetName()),2);
- BField *field =
gResRoster.MakeFieldForType(resData->GetType(),
-
resData->GetData(),
-
resData->GetLength());
- if (field)
- row->SetField(field,3);
- row->SetField(new
BSizeField(resData->GetLength()),4);
+ row = new ResDataRow(resData);
fListView->AddRow(row);
fDataList.AddItem(resData);
resData = new ResourceData();
@@ -222,6 +217,25 @@
void
+ResView::BuildMenus(BMenuBar *menuBar)
+{
+ BMenu *menu = new BMenu("File");
+ menu->AddItem(new BMenuItem("New" B_UTF8_ELLIPSIS, new
BMessage(M_NEW_FILE), 'N'));
+ menu->AddSeparatorItem();
+ menu->AddItem(new BMenuItem("Open" B_UTF8_ELLIPSIS, new
BMessage(M_OPEN_FILE), 'O'));
+ menuBar->AddItem(menu);
+
+ menu = new BMenu("Resource");
+
+ menu->AddItem(new BMenuItem("Add" B_UTF8_ELLIPSIS, new
BMessage(M_SELECT_FILE), 'F'));
+ menu->AddItem(new BMenuItem("Delete", new BMessage(M_DELETE_RESOURCE),
'D'));
+
+
+ menuBar->AddItem(menu);
+}
+
+
+void
ResView::EmptyDataList(void)
{
for (int32 i = 0; i < fDataList.CountItems(); i++) {
@@ -251,3 +265,98 @@
BSizeField *sizeField = (BSizeField*)row->GetField(4);
sizeField->SetSize(resData->GetLength());
}
+
+
+void
+ResView::AddResource(const entry_ref &ref)
+{
+ BFile file(&ref,B_READ_ONLY);
+ if (file.InitCheck() != B_OK)
+ return;
+
+ BString mime;
+ file.ReadAttrString("BEOS:TYPE",&mime);
+
+ if (mime == "application/x-be-resource") {
+ BMessage msg(B_REFS_RECEIVED);
+ msg.AddRef("refs",&ref);
+ be_app->PostMessage(&msg);
+ return;
+ }
+
+ type_code fileType = 0;
+
+ BTranslatorRoster *roster = BTranslatorRoster::Default();
+ translator_info info;
+ if (roster->Identify(&file,NULL,&info,0,mime.String()) == B_OK)
+ fileType = info.type;
+ else
+ fileType = B_RAW_TYPE;
+
+ int32 lastID = -1;
+ for (int32 i = 0; i < fDataList.CountItems(); i++) {
+ ResourceData *resData = (ResourceData*)fDataList.ItemAt(i);
+ if (resData->GetType() == fileType && resData->GetID() > lastID)
+ lastID = resData->GetID();
+ }
+
+ off_t fileSize;
+ file.GetSize(&fileSize);
+
+ if (fileSize < 1)
+ return;
+
+ char *fileData = (char *)malloc(fileSize);
+ file.Read(fileData,fileSize);
+
+ ResourceData *resData = new ResourceData(fileType,lastID + 1, ref.name,
+
fileData,fileSize);
+ fDataList.AddItem(resData);
+
+ ResDataRow *row = new ResDataRow(resData);
+ fListView->AddRow(row);
+
+ fIsDirty = true;
+}
+
+
+void
+ResView::DeleteSelectedResources(void)
+{
+ ResDataRow *selection = (ResDataRow*)fListView->CurrentSelection();
+
+ if (selection)
+ fIsDirty = true;
+
+ while (selection) {
+ ResourceData *data = selection->GetData();
+ fListView->RemoveRow(selection);
+ fDataList.RemoveItem(data);
+ delete data;
+ selection = (ResDataRow*)fListView->CurrentSelection();
+ }
+}
+
+
+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);
+ BField *field = gResRoster.MakeFieldForType(fResData->GetType(),
+
fResData->GetData(),
+
fResData->GetLength());
+ if (field)
+ SetField(field,3);
+ SetField(new BSizeField(fResData->GetLength()),4);
+ }
+}
+
+
+ResourceData *
+ResDataRow::GetData(void) const
+{
+ return fResData;
+}
Modified: haiku/trunk/src/apps/resedit/ResView.h
===================================================================
--- haiku/trunk/src/apps/resedit/ResView.h 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/ResView.h 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,24 +1,27 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#ifndef RESVIEW_H
#define RESVIEW_H
-#include <View.h>
-#include <ColumnListView.h>
#include <Entry.h>
-#include <String.h>
+#include <FilePanel.h>
+#include <List.h>
#include <ListItem.h>
-#include <List.h>
+#include <MenuBar.h>
#include <Resources.h>
+#include <String.h>
+#include <View.h>
+
#include "ResourceRoster.h"
class BMenuBar;
+class ResListView;
class ResView : public BView {
public:
@@ -35,17 +38,33 @@
void OpenFile(const entry_ref &ref);
private:
+ void BuildMenus(BMenuBar *menuBar);
void EmptyDataList(void);
void UpdateRow(BRow *row);
+ void HandleDrop(BMessage *msg);
+ void AddResource(const entry_ref &ref);
+ void DeleteSelectedResources(void);
- BColumnListView *fListView;
+ ResListView *fListView;
entry_ref *fRef;
BString fFileName;
BMenuBar *fBar;
bool fIsDirty;
BList fDataList;
+ BFilePanel *fFilePanel;
};
+class ResDataRow : public BRow
+{
+public:
+ ResDataRow(ResourceData *data);
+
+ ResourceData * GetData(void) const;
+
+private:
+ ResourceData *fResData;
+};
+
extern ResourceRoster gResRoster;
#endif
Modified: haiku/trunk/src/apps/resedit/ResWindow.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/ResWindow.cpp 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/ResWindow.cpp 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,21 +1,23 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#include "ResWindow.h"
#include "ResView.h"
#include "App.h"
+static int32 sWindowCount = 0;
+
ResWindow::ResWindow(const BRect &rect, const entry_ref *ref)
: BWindow(rect,"", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{
- be_app->PostMessage(M_REGISTER_WINDOW);
+ atomic_add(&sWindowCount,1);
ResView *child = new ResView(Bounds(), "resview", B_FOLLOW_ALL,
- B_WILL_DRAW, ref);
+ B_WILL_DRAW,
ref);
AddChild(child);
SetTitle(child->Filename());
@@ -32,7 +34,11 @@
bool
ResWindow::QuitRequested(void)
{
- be_app->PostMessage(M_UNREGISTER_WINDOW);
+ atomic_add(&sWindowCount,-1);
+
+ if (sWindowCount == 0)
+ be_app->PostMessage(B_QUIT_REQUESTED);
+ // be_app->PostMessage(M_UNREGISTER_WINDOW);
return true;
}
Modified: haiku/trunk/src/apps/resedit/ResWindow.h
===================================================================
--- haiku/trunk/src/apps/resedit/ResWindow.h 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/ResWindow.h 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2005-2008, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#ifndef RESWIN_H
#define RESWIN_H
Modified: haiku/trunk/src/apps/resedit/ResourceData.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/ResourceData.cpp 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/ResourceData.cpp 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#include "ResourceData.h"
#include "ResFields.h"
Modified: haiku/trunk/src/apps/resedit/ResourceData.h
===================================================================
--- haiku/trunk/src/apps/resedit/ResourceData.h 2010-04-26 21:57:02 UTC (rev
36498)
+++ haiku/trunk/src/apps/resedit/ResourceData.h 2010-04-26 23:38:41 UTC (rev
36499)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#ifndef RESOURCE_DATA_H
#define RESOURCE_DATA_H
Modified: haiku/trunk/src/apps/resedit/ResourceRoster.cpp
===================================================================
--- haiku/trunk/src/apps/resedit/ResourceRoster.cpp 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/ResourceRoster.cpp 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#include "ResourceRoster.h"
#include <Roster.h>
@@ -152,7 +152,7 @@
// temporary code until editors are done
switch (data->GetType()) {
case B_MIME_STRING_TYPE: {
- StringEditor *strEd = new
StringEditor(BRect(100,100,300,200),
+ StringEditor *strEd = new
StringEditor(BRect(100,100,400,200),
data, handler);
strEd->Show();
break;
Modified: haiku/trunk/src/apps/resedit/ResourceRoster.h
===================================================================
--- haiku/trunk/src/apps/resedit/ResourceRoster.h 2010-04-26 21:57:02 UTC
(rev 36498)
+++ haiku/trunk/src/apps/resedit/ResourceRoster.h 2010-04-26 23:38:41 UTC
(rev 36499)
@@ -1,16 +1,16 @@
/*
- * Copyright (c) 2005-2006, Haiku, Inc.
+ * Copyright (c) 2005-2010, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author:
- * DarkWyrm <darkwyrm@xxxxxxxxxxxxx>
+ * DarkWyrm <darkwyrm@xxxxxxxxx>
*/
#ifndef RESROSTER_H
#define RESROSTER_H
#include <List.h>
-#include <ColumnTypes.h>
-#include <ColumnListView.h>
+#include "ColumnTypes.h"
+#include "ColumnListView.h"
class Editor;
class ResourceData;
@@ -18,16 +18,16 @@
class ResourceRoster
{
public:
- ResourceRoster(void);
- ~ResourceRoster(void);
- BField * MakeFieldForType(const int32 &type, const char *data,
- const size_t
&length);
- void SpawnEditor(ResourceData *data, BHandler *handler);
-
+ ResourceRoster(void);
+ ~ResourceRoster(void);
+ BField * MakeFieldForType(const int32 &type, const char
*data,
+ const
size_t &length);
+ void SpawnEditor(ResourceData *data, BHandler
*handler);
+
private:
- void LoadEditors(void);
+ void LoadEditors(void);
- BList fList;
+ BList fList;
};
typedef Editor* create_editor(void);
Other related posts: