Ticket #968: resourceedit-part1-6.patch
File resourceedit-part1-6.patch, 51.8 KB (added by , 11 years ago) |
---|
-
new file 2001
From 68756dd7915e97dcde34dac678b47e0598792e29 Mon Sep 17 00:00:00 2001 From: Tri-Edge AI <triedgeai@gmail.com> Date: Thu, 3 Jan 2013 18:02:21 +0200 Subject: [PATCH] Added ResourceEdit and modified BColumnListView, BRow and BMenu. --- data/artwork/icons/App_ResourceEdit | Bin 0 -> 23980 bytes headers/os/interface/Menu.h | 3 +- headers/private/interface/ColumnListView.h | 4 +- src/apps/Jamfile | 2 +- src/apps/resourceedit/Constants.h | 42 +++ src/apps/resourceedit/DefaultTypes.cpp | 101 +++++ src/apps/resourceedit/DefaultTypes.h | 66 ++++ src/apps/resourceedit/ImageButton.cpp | 67 ++++ src/apps/resourceedit/ImageButton.h | 32 ++ src/apps/resourceedit/Jamfile | 23 ++ src/apps/resourceedit/MainWindow.cpp | 562 ++++++++++++++++++++++++++++ src/apps/resourceedit/MainWindow.h | 85 +++++ src/apps/resourceedit/ResourceEdit.cpp | 121 ++++++ src/apps/resourceedit/ResourceEdit.h | 42 +++ src/apps/resourceedit/ResourceEdit.rdef | 136 +++++++ src/apps/resourceedit/ResourceListView.cpp | 52 +++ src/apps/resourceedit/ResourceListView.h | 26 ++ src/apps/resourceedit/ResourceRow.cpp | 141 +++++++ src/apps/resourceedit/ResourceRow.h | 43 +++ src/apps/resourceedit/main.cpp | 17 + src/kits/interface/ColumnListView.cpp | 63 +++- src/kits/interface/Menu.cpp | 15 + 22 files changed, 1639 insertions(+), 4 deletions(-) create mode 100644 data/artwork/icons/App_ResourceEdit create mode 100644 src/apps/resourceedit/Constants.h create mode 100644 src/apps/resourceedit/DefaultTypes.cpp create mode 100644 src/apps/resourceedit/DefaultTypes.h create mode 100644 src/apps/resourceedit/ImageButton.cpp create mode 100644 src/apps/resourceedit/ImageButton.h create mode 100644 src/apps/resourceedit/Jamfile create mode 100644 src/apps/resourceedit/MainWindow.cpp create mode 100644 src/apps/resourceedit/MainWindow.h create mode 100644 src/apps/resourceedit/ResourceEdit.cpp create mode 100644 src/apps/resourceedit/ResourceEdit.h create mode 100644 src/apps/resourceedit/ResourceEdit.rdef create mode 100644 src/apps/resourceedit/ResourceListView.cpp create mode 100644 src/apps/resourceedit/ResourceListView.h create mode 100644 src/apps/resourceedit/ResourceRow.cpp create mode 100644 src/apps/resourceedit/ResourceRow.h create mode 100644 src/apps/resourceedit/main.cpp diff --git a/data/artwork/icons/App_ResourceEdit b/data/artwork/icons/App_ResourceEdit new file mode 100644 index 0000000000000000000000000000000000000000..e35ff651ff8057c2c494a0175648b704d98c68be GIT binary patch literal 23980 zcmeHP3vg7`89qyphlsop6?7|5gGC@j9JH2wfV>P3foh$?Ku8v|VUrEX@*Ksjic}O( zlmTBgN(m@bR9aL-LxF*);Gook;sdMWh}ssbR?FyYzwe%V?kji0O)%iVo|(hR{m$c_ z`+xucpL5TDml31J4;wyeXpTVgA*a%$u9JkwLj4(zHn`OK`9w1@Y}oiw9HUn^qH-*s zXl~#ioG(OQ)HOk!6&F2(=yZi_UzVRJst`TV%FC=?=_>E8W~J_`9>RzDa#rn8u>);Y zJ?|p^gt>aT$=m4F3|ZZTgL5E0s(h3)#JCCL2lM)DRv=MSS?D!k^w==__CxM~%)VKo zr41heoMUH+Gi~^-z?$lK-k34kI2>yWvK;3uL7ewx-mT-M`6UqyB}7G0B$Dta;$@;N z9xY7($qowfZAgffA(6Z|EJPdR@nMlHLb(rEYm~E4zZbc4NbBW~mKq(K4C)(tv~9au z9e33X2p6we?dTYvY2NbAyAFo-w+z(k`P}?3L(jGzY4j|JmzG8f5|KjT(-MjD7sTQf zL{|8`5w;x@_DWbgv}LjqMl!OIJ0n{OQ}__zR>BlM6S$Qy;>>H1-3Z&H;~HVDaUltt z8c!tRB?f0TK_QMnKnsyCfdJn`IT@VAkUQX7AeULWQXK}NVcTPLkQ}KV8_;7&+8z#W zY}9<~^F~c~wDU?0CBkH-rX{Y2Bh#R*)F^xka4R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q z+1RCfO*&EUuk<WbP`8a8zkW*R>l*L<m9sH?9WOMS;mZkaM*mL~PM)*7&*LJr1`}?q zMTj2|r6cB2)VVD}G2m{C5dXU$H++eXn~M-fHHhJbMhrtj#<xf(kCtT~X{o|=8;chD z^>noKMx7fi(}BB*pRb{A_+lM5Y2mVB&|<7HTxUrO|4W3E$I9vZdP-d|SmEYGGZq@I zd4}!pe|*&7|Lke_Io#>Hz-T1!SJymm<Kcy|z?jsWL}D_#Y3cb)4+n}&TOxbhtZ;Lp z5vN(2<(IOCx67Oy{IpLF_WbgeX@98vB(PhS)p{9FI0z1QSlu_sGH*xtc!CZ**!OaB z@Hp<(Si1wR$mw<m*{E~d9oz`qZ5NR4`1DS_y=gn#Hyi5^O+~XAZmaQAWv7=@l0N~A zoW45)p4u3UkRIF4K>rV7ax&DUHI~MUDezs!poToTQB!Nvma!V+N1BaC4ZWv94S8~- zCif&-&FT9B$_3M)hCFH1XoTq>{~KE}c{F_j4Q8pwg?|;M-B=4hwKd(s-wSna3x5%C nw}pR38hnwCn+rbxlNCOi#tQGH{nvYqO3C(b)(%Sh0m%OW090~%
-
headers/os/interface/Menu.h
literal 0 HcmV?d00001 diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h index e5ab621..f4dbad6 100644
a b public: 122 122 float MaxContentWidth() const; 123 123 124 124 BMenuItem* FindMarked(); 125 int32 FindMarkedIndex(); 125 126 126 127 BMenu* Supermenu() const; 127 128 BMenuItem* Superitem() const; … … private: 215 216 void _ComputeColumnLayout(int32 index, bool bestFit, 216 217 bool moveItems, BRect& outRect); 217 218 void _ComputeRowLayout(int32 index, bool bestFit, 218 bool moveItems, BRect& outRect); 219 bool moveItems, BRect& outRect); 219 220 void _ComputeMatrixLayout(BRect& outRect); 220 221 221 222 BRect _CalcFrame(BPoint where, bool* scrollOn); -
headers/private/interface/ColumnListView.h
diff --git a/headers/private/interface/ColumnListView.h b/headers/private/interface/ColumnListView.h index 2acbbdb..027154b 100644
a b public: 133 133 134 134 float Height() const; 135 135 bool IsExpanded() const; 136 bool IsSelected() const; 136 137 137 138 private: 138 139 // Blows up into the debugger if the validation fails. … … public: 326 327 // Does not delete row or children at this time. 327 328 // todo: Make delete row and children 328 329 void RemoveRow(BRow* row); 329 330 330 void UpdateRow(BRow* row); 331 bool SwapRows(int32 index1, int32 index2, BRow* 332 parentRow1 = NULL, BRow* parentRow2 = NULL); 331 333 void Clear(); 332 334 333 335 // Appearance (DEPRECATED) -
src/apps/Jamfile
diff --git a/src/apps/Jamfile b/src/apps/Jamfile index 0f90365..4c0f3c0 100644
a b HaikuSubInclude processcontroller ; 48 48 HaikuSubInclude pulse ; 49 49 HaikuSubInclude readonlybootprompt ; 50 50 HaikuSubInclude remotedesktop ; 51 HaikuSubInclude res edit ;51 HaikuSubInclude resourceedit ; 52 52 HaikuSubInclude screenshot ; 53 53 HaikuSubInclude serialconnect ; 54 54 HaikuSubInclude showimage ; -
new file src/apps/resourceedit/Constants.h
diff --git a/src/apps/resourceedit/Constants.h b/src/apps/resourceedit/Constants.h new file mode 100644 index 0000000..4a9766e
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef CONSTANTS_H 6 #define CONSTANTS_H 7 8 9 #define MSG_NEW 'm000' 10 #define MSG_OPEN 'm001' 11 #define MSG_OPEN_DONE 'm002' 12 #define MSG_CLOSE 'm003' 13 #define MSG_SAVE 'm004' 14 #define MSG_SAVEAS 'm005' 15 #define MSG_SAVEAS_DONE 'm006' 16 #define MSG_SAVEALL 'm007' 17 #define MSG_MERGEWITH 'm008' 18 #define MSG_QUIT 'm009' 19 20 #define MSG_UNDO 'm010' 21 #define MSG_REDO 'm011' 22 #define MSG_CUT 'm012' 23 #define MSG_COPY 'm013' 24 #define MSG_PASTE 'm014' 25 #define MSG_CLEAR 'm015' 26 #define MSG_SELECTALL 'm016' 27 28 #define MSG_ADD 'm020' 29 #define MSG_REMOVE 'm021' 30 #define MSG_MOVEUP 'm022' 31 #define MSG_MOVEDOWN 'm023' 32 33 #define MSG_SELECTION 'm030' 34 35 36 // TODO: Remove prior to release. 37 #define DEBUG 1 38 #include <Debug.h> 39 // --- --- 40 41 42 #endif -
new file src/apps/resourceedit/DefaultTypes.cpp
diff --git a/src/apps/resourceedit/DefaultTypes.cpp b/src/apps/resourceedit/DefaultTypes.cpp new file mode 100644 index 0000000..9f7de5d
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "DefaultTypes.h" 8 9 #include <ByteOrder.h> 10 11 12 BString 13 toStringBOOL(const void* data) 14 { 15 if (*(bool*)data) 16 return "✔ true"; 17 else 18 return "✖ false"; 19 } 20 21 22 BString 23 toStringBYTE(const void* data) 24 { 25 return (BString() << *(int8*)data); 26 } 27 28 29 BString 30 toStringSHRT(const void* data) 31 { 32 return (BString() << *(int16*)data); 33 } 34 35 36 BString 37 toStringLONG(const void* data) 38 { 39 return (BString() << *(int32*)data); 40 } 41 42 43 BString 44 toStringLLNG(const void* data) 45 { 46 return (BString() << *(int64*)data); 47 } 48 49 50 BString 51 toStringUBYT(const void* data) 52 { 53 return (BString() << *(uint8*)data); 54 } 55 56 57 BString 58 toStringUSHT(const void* data) 59 { 60 return (BString() << *(uint16*)data); 61 } 62 63 64 BString 65 toStringULNG(const void* data) 66 { 67 return (BString() << *(uint32*)data); 68 } 69 70 71 BString 72 toStringULLG(const void* data) 73 { 74 return (BString() << *(uint64*)data); 75 } 76 77 78 BString 79 toStringRAWT(const void* data) 80 { 81 return "[Raw Data]"; 82 } 83 84 85 int32 86 FindTypeCodeIndex(type_code code) 87 { 88 for (int32 i = 0; kDefaultTypes[i].type != NULL; i++) 89 if (kDefaultTypes[i].typeCode == code) 90 return i; 91 92 return -1; 93 } 94 95 96 void 97 TypeCodeToString(type_code code, char* str) 98 { 99 *(type_code*)str = B_HOST_TO_BENDIAN_INT32(code); 100 str[4] = '\0'; 101 } -
new file src/apps/resourceedit/DefaultTypes.h
diff --git a/src/apps/resourceedit/DefaultTypes.h b/src/apps/resourceedit/DefaultTypes.h new file mode 100644 index 0000000..42ebf87
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef DEFAULT_TYPES_H 6 #define DEFAULT_TYPES_H 7 8 9 #include <String.h> 10 11 12 struct ResourceDataType { 13 const char* type; 14 type_code typeCode; 15 uint32 size; 16 BString (*toString)(const void*); 17 }; 18 19 // TODO: Rework design of this. This one sucks. 20 21 BString toStringBOOL(const void* data); 22 BString toStringBYTE(const void* data); 23 BString toStringSHRT(const void* data); 24 BString toStringLONG(const void* data); 25 BString toStringLLNG(const void* data); 26 BString toStringUBYT(const void* data); 27 BString toStringUSHT(const void* data); 28 BString toStringULNG(const void* data); 29 BString toStringULLG(const void* data); 30 BString toStringRAWT(const void* data); 31 32 char * const kDefaultData[] = { 33 0, 0, 0, 0, 0, 0, 0, 0 34 }; 35 36 #define LINE "", 0, ~0 37 #define END NULL, 0, 0 38 39 const ResourceDataType kDefaultTypes[] = { 40 { "bool", 'BOOL', 1, toStringBOOL }, 41 { LINE }, 42 { "int8", 'BYTE', 1, toStringBYTE }, 43 { "int16", 'SHRT', 2, toStringSHRT }, 44 { "int32", 'LONG', 4, toStringLONG }, 45 { "int64", 'LLNG', 8, toStringLLNG }, 46 { LINE }, 47 { "uint8", 'UBYT', 1, toStringUBYT }, 48 { "uint16", 'USHT', 2, toStringUSHT }, 49 { "uint32", 'ULNG', 4, toStringULNG }, 50 { "uint64", 'ULLG', 8, toStringULLG }, 51 { LINE }, 52 { "raw", 'RAWT', 0, toStringRAWT }, 53 { END } 54 }; 55 56 const int32 kDefaultTypeSelected = 4; 57 // int32 58 59 #undef LINE 60 #undef END 61 62 int32 FindTypeCodeIndex(type_code code); 63 void TypeCodeToString(type_code code, char* str); 64 65 66 #endif -
new file src/apps/resourceedit/ImageButton.cpp
diff --git a/src/apps/resourceedit/ImageButton.cpp b/src/apps/resourceedit/ImageButton.cpp new file mode 100644 index 0000000..7b0b8dd
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "ImageButton.h" 8 9 #include <Bitmap.h> 10 11 12 ImageButton::ImageButton(BRect frame, const char* name, BBitmap* image, 13 BMessage* message, uint32 resizingMode = B_FOLLOW_NONE) 14 : 15 BButton(frame, name, "", message, resizingMode) 16 { 17 fImage = image; 18 19 fDrawPoint.x = ((frame.RightTop().x - frame.LeftTop().x) 20 - (image->Bounds().RightBottom().x + 1)) / 2; 21 22 fDrawPoint.y = ((frame.LeftBottom().y - frame.LeftTop().y) 23 - (image->Bounds().RightBottom().y + 1)) / 2; 24 25 fInnerBounds = Bounds(); 26 fInnerBounds.InsetBy(3, 3); 27 28 SetDrawingMode(B_OP_ALPHA); 29 } 30 31 32 ImageButton::~ImageButton() 33 { 34 35 } 36 37 38 void 39 ImageButton::Draw(BRect updateRect) 40 { 41 BButton::Draw(updateRect); 42 DrawBitmap(fImage, fDrawPoint); 43 44 if (!IsEnabled()) { 45 rgb_color tempColor = HighColor(); 46 SetHighColor(255, 255, 255, 155); 47 FillRect(fInnerBounds, B_SOLID_HIGH); 48 SetHighColor(tempColor); 49 } 50 } 51 52 53 void 54 ImageButton::ResizeTo(float width, float height) 55 { 56 BButton::ResizeTo(width, height); 57 fInnerBounds = Bounds(); 58 fInnerBounds.InsetBy(3, 3); 59 } 60 61 62 void 63 ImageButton::SetBitmap(BBitmap* image) 64 { 65 fImage = image; 66 Invalidate(); 67 } -
new file src/apps/resourceedit/ImageButton.h
diff --git a/src/apps/resourceedit/ImageButton.h b/src/apps/resourceedit/ImageButton.h new file mode 100644 index 0000000..e0c3de8
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef IMAGE_BUTTON_H 6 #define IMAGE_BUTTON_H 7 8 9 #include <Button.h> 10 11 12 class ImageButton : public BButton 13 { 14 public: 15 ImageButton(BRect frame, const char* name, BBitmap* image, 16 BMessage* message, uint32 resizingMode); 17 ~ImageButton(); 18 19 void Draw(BRect updateRect); 20 void ResizeTo(float width, float height); 21 22 void SetBitmap(BBitmap* image); 23 24 private: 25 BBitmap* fImage; 26 BPoint fDrawPoint; 27 BRect fInnerBounds; 28 29 }; 30 31 32 #endif -
new file src/apps/resourceedit/Jamfile
diff --git a/src/apps/resourceedit/Jamfile b/src/apps/resourceedit/Jamfile new file mode 100644 index 0000000..9507e9a
- + 1 SubDir HAIKU_TOP src apps resourceedit ; 2 3 UsePrivateHeaders interface shared ; 4 5 Application ResourceEdit 6 : 7 DefaultTypes.cpp 8 ImageButton.cpp 9 MainWindow.cpp 10 ResourceEdit.cpp 11 ResourceListView.cpp 12 ResourceRow.cpp 13 main.cpp 14 : 15 be 16 tracker 17 translation 18 libcolumnlistview.a 19 $(TARGET_LIBSTDC++) 20 21 : 22 ResourceEdit.rdef 23 ; -
new file src/apps/resourceedit/MainWindow.cpp
diff --git a/src/apps/resourceedit/MainWindow.cpp b/src/apps/resourceedit/MainWindow.cpp new file mode 100644 index 0000000..d6413e3
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "MainWindow.h" 8 9 #include "Constants.h" 10 #include "ImageButton.h" 11 #include "ResourceListView.h" 12 #include "ResourceRow.h" 13 14 #include <Application.h> 15 #include <ColumnListView.h> 16 #include <ColumnTypes.h> 17 #include <Entry.h> 18 #include <FilePanel.h> 19 #include <Menu.h> 20 #include <MenuBar.h> 21 #include <MenuField.h> 22 #include <MenuItem.h> 23 #include <Path.h> 24 #include <PopUpMenu.h> 25 #include <Resources.h> 26 #include <StatusBar.h> 27 #include <String.h> 28 #include <TextControl.h> 29 #include <TranslationUtils.h> 30 31 #include <stdio.h> 32 #include <stdlib.h> 33 34 #include <sys/mman.h> 35 #include <sys/types.h> 36 #include <sys/stat.h> 37 38 #include <fstream> 39 using namespace std; 40 41 42 MainWindow::MainWindow(BRect frame, BEntry* assocEntry) 43 : 44 BWindow(frame, NULL, B_DOCUMENT_WINDOW, 0) 45 { 46 fAssocEntry = assocEntry; 47 48 fSavePanel = NULL; 49 50 fMenuBar = new BMenuBar(BRect(0, 0, 600, 1), "fMenuBar"); 51 52 fFileMenu = new BMenu("File", B_ITEMS_IN_COLUMN); 53 fNewItem = new BMenuItem("New", new BMessage(MSG_NEW), 'N'); 54 fOpenItem = new BMenuItem("Open", new BMessage(MSG_OPEN), 'O'); 55 fCloseItem = new BMenuItem("Close", new BMessage(MSG_CLOSE), 'W'); 56 fSaveItem = new BMenuItem("Save", new BMessage(MSG_SAVE), 'S'); 57 fSaveAsItem = new BMenuItem("Save As" B_UTF8_ELLIPSIS, new 58 BMessage(MSG_SAVEAS)); 59 fSaveAllItem = new BMenuItem("Save All", new BMessage(MSG_SAVEALL), 'S', 60 B_SHIFT_KEY); 61 fMergeWithItem = new BMenuItem("Merge With" B_UTF8_ELLIPSIS, 62 new BMessage(MSG_MERGEWITH), 'M'); 63 fQuitItem = new BMenuItem("Quit", new BMessage(MSG_QUIT), 'Q'); 64 65 fEditMenu = new BMenu("Edit", B_ITEMS_IN_COLUMN); 66 fUndoItem = new BMenuItem("Undo", new BMessage(MSG_UNDO), 'Z'); 67 fRedoItem = new BMenuItem("Redo", new BMessage(MSG_REDO), 'Y'); 68 fCutItem = new BMenuItem("Cut", new BMessage(MSG_CUT), 'X'); 69 fCopyItem = new BMenuItem("Copy", new BMessage(MSG_COPY), 'C'); 70 fPasteItem = new BMenuItem("Paste", new BMessage(MSG_PASTE), 'V'); 71 fClearItem = new BMenuItem("Clear", new BMessage(MSG_CLEAR)); 72 fSelectAllItem = new BMenuItem("Select All", 73 new BMessage(MSG_SELECTALL), 'A'); 74 75 fHelpMenu = new BMenu("Help", B_ITEMS_IN_COLUMN); 76 77 fResourceIDText = new BTextControl(BRect(0, 0, 47, 23).OffsetBySelf(8, 24), 78 "fResourceIDText", NULL, "0", NULL); 79 fResourceTypePopUp = new BPopUpMenu("(Type)"); 80 fResourceTypeMenu = new BMenuField(BRect(0, 0, 1, 1).OffsetBySelf(60, 24), 81 "fResourceTypeMenu", NULL, fResourceTypePopUp); 82 83 for (int32 i = 0; kDefaultTypes[i].type != NULL; i++) { 84 if (kDefaultTypes[i].size == ~(uint32)0) 85 fResourceTypePopUp->AddSeparatorItem(); 86 else 87 fResourceTypePopUp->AddItem( 88 new BMenuItem(kDefaultTypes[i].type, NULL)); 89 } 90 91 fResourceTypePopUp->ItemAt(kDefaultTypeSelected)->SetMarked(true); 92 93 fToolbarView = new BView(BRect(0, 0, 600, 51), "fToolbarView", 94 B_FOLLOW_LEFT_RIGHT, 0); 95 96 fToolbarView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 97 98 BRect toolRect = BRect(0, 0, 23, 23).OffsetBySelf(8, 24); 99 100 fAddButton = new ImageButton(toolRect.OffsetBySelf(200, 0), 101 "fAddButton", BTranslationUtils::GetBitmap('PNG ', "add.png"), 102 new BMessage(MSG_ADD), B_FOLLOW_NONE); 103 fAddButton->ResizeTo(23, 23); 104 105 fRemoveButton = new ImageButton(toolRect.OffsetBySelf(30, 0), 106 "fRemoveButton", BTranslationUtils::GetBitmap('PNG ', "remove.png"), 107 new BMessage(MSG_REMOVE), B_FOLLOW_NONE); 108 fRemoveButton->ResizeTo(23, 23); 109 fRemoveButton->SetEnabled(false); 110 111 fMoveUpButton = new ImageButton(toolRect.OffsetBySelf(30, 0), 112 "fMoveUpButton", BTranslationUtils::GetBitmap('PNG ', "moveup.png"), 113 new BMessage(MSG_MOVEUP), B_FOLLOW_NONE); 114 fMoveUpButton->ResizeTo(23, 23); 115 fMoveUpButton->SetEnabled(false); 116 117 fMoveDownButton = new ImageButton(toolRect.OffsetBySelf(30, 0), 118 "fMoveDownButton", BTranslationUtils::GetBitmap('PNG ', "movedown.png"), 119 new BMessage(MSG_MOVEDOWN), B_FOLLOW_NONE); 120 fMoveDownButton->ResizeTo(23, 23); 121 fMoveDownButton->SetEnabled(false); 122 123 BRect listRect = Bounds(); 124 listRect.SetLeftTop(BPoint(0, 52)); 125 listRect.InsetBy(-1, -1); 126 127 fResourceList = new ResourceListView(listRect, "fResourceList", 128 B_FOLLOW_ALL, 0); 129 130 fResourceList->AddColumn(new BIntegerColumn("ID", 48, 1, 999, 131 B_ALIGN_RIGHT), 0); 132 fResourceList->AddColumn(new BStringColumn("Name", 156, 1, 999, 133 B_TRUNCATE_END, B_ALIGN_LEFT), 1); 134 fResourceList->AddColumn(new BStringColumn("Type", 56, 1, 999, 135 B_TRUNCATE_END, B_ALIGN_CENTER), 2); 136 fResourceList->AddColumn(new BStringColumn("Code", 56, 1, 999, 137 B_TRUNCATE_END, B_ALIGN_CENTER), 3); 138 fResourceList->AddColumn(new BStringColumn("Data", 156, 1, 999, 139 B_TRUNCATE_END, B_ALIGN_LEFT), 4); 140 fResourceList->AddColumn(new BSizeColumn("Size", 74, 1, 999, 141 B_ALIGN_RIGHT), 5); 142 143 fResourceList->SetLatchWidth(0); 144 145 fResourceList->SetTarget(this); 146 fResourceList->SetSelectionMessage(new BMessage(MSG_SELECTION)); 147 148 AddChild(fMenuBar); 149 150 fMenuBar->AddItem(fFileMenu); 151 fFileMenu->AddItem(fNewItem); 152 fFileMenu->AddItem(fOpenItem); 153 fFileMenu->AddItem(fCloseItem); 154 fFileMenu->AddSeparatorItem(); 155 fFileMenu->AddItem(fSaveItem); 156 fFileMenu->AddItem(fSaveAsItem); 157 fFileMenu->AddItem(fSaveAllItem); 158 fFileMenu->AddItem(fMergeWithItem); 159 fFileMenu->AddSeparatorItem(); 160 fFileMenu->AddItem(fQuitItem); 161 162 fMenuBar->AddItem(fEditMenu); 163 fEditMenu->AddItem(fUndoItem); 164 fEditMenu->AddItem(fRedoItem); 165 fEditMenu->AddSeparatorItem(); 166 fEditMenu->AddItem(fCutItem); 167 fEditMenu->AddItem(fCopyItem); 168 fEditMenu->AddItem(fPasteItem); 169 fEditMenu->AddItem(fClearItem); 170 fEditMenu->AddSeparatorItem(); 171 fEditMenu->AddItem(fSelectAllItem); 172 173 fMenuBar->AddItem(fHelpMenu); 174 175 fToolbarView->AddChild(fResourceIDText); 176 fToolbarView->AddChild(fResourceTypeMenu); 177 178 fToolbarView->AddChild(fAddButton); 179 fToolbarView->AddChild(fRemoveButton); 180 fToolbarView->AddChild(fMoveUpButton); 181 fToolbarView->AddChild(fMoveDownButton); 182 183 AddChild(fToolbarView); 184 185 AddChild(fResourceList); 186 187 if (assocEntry != NULL) { 188 _SetTitleFromEntry(); 189 _Load(); 190 } else { 191 SetTitle("ResourceEdit | " B_UTF8_ELLIPSIS); 192 } 193 } 194 195 196 MainWindow::~MainWindow() 197 { 198 199 } 200 201 202 bool 203 MainWindow::QuitRequested() 204 { 205 // TODO: Check if file is saved. 206 207 BMessage* msg = new BMessage(MSG_CLOSE); 208 msg->AddPointer("window", (void*)this); 209 be_app->PostMessage(msg); 210 return true; 211 } 212 213 214 void 215 MainWindow::SelectionChanged() 216 { 217 if (fResourceList->CurrentSelection(NULL) == NULL) { 218 fMoveUpButton->SetEnabled(false); 219 fMoveDownButton->SetEnabled(false); 220 fRemoveButton->SetEnabled(false); 221 } else { 222 fRemoveButton->SetEnabled(true); 223 fMoveUpButton->SetEnabled(!fResourceList->RowAt(0)->IsSelected()); 224 fMoveDownButton->SetEnabled(!fResourceList->RowAt( 225 fResourceList->CountRows() - 1)->IsSelected()); 226 } 227 } 228 229 230 void 231 MainWindow::MessageReceived(BMessage* msg) 232 { 233 switch (msg->what) { 234 case MSG_NEW: 235 be_app->PostMessage(MSG_NEW); 236 break; 237 238 case MSG_OPEN: 239 be_app->PostMessage(MSG_OPEN); 240 break; 241 242 case MSG_CLOSE: 243 PostMessage(B_QUIT_REQUESTED); 244 break; 245 246 case MSG_SAVE: 247 _Save(); 248 break; 249 250 case MSG_SAVEAS: 251 _SaveAs(); 252 break; 253 254 case MSG_SAVEAS_DONE: 255 { 256 entry_ref ref; 257 const char* leaf; 258 259 if (msg->FindRef("directory", &ref) != B_OK) 260 break; 261 262 if (msg->FindString("name", &leaf) != B_OK) 263 break; 264 265 BDirectory dir(&ref); 266 _Save(new BEntry(&dir, leaf)); 267 268 break; 269 } 270 case MSG_SAVEALL: 271 be_app->PostMessage(MSG_SAVEALL); 272 break; 273 274 case MSG_MERGEWITH: 275 PRINT(("[MSG_MERGEWITH]: Not yet implemented.")); 276 // TODO: Implement. 277 // "Merge from..." might be a better idea actually. 278 break; 279 280 case MSG_QUIT: 281 be_app->PostMessage(B_QUIT_REQUESTED); 282 break; 283 284 case MSG_UNDO: 285 // TODO: Implement. 286 PRINT(("[MSG_UNDO]: Not yet implemented.")); 287 break; 288 289 case MSG_REDO: 290 // TODO: Implement. 291 PRINT(("[MSG_REDO]: Not yet implemented.")); 292 break; 293 294 case MSG_CUT: 295 // TODO: Implement. 296 PRINT(("[MSG_CUT]: Not yet implemented.")); 297 break; 298 299 case MSG_COPY: 300 // TODO: Implement. 301 PRINT(("[MSG_COPY]: Not yet implemented.")); 302 break; 303 304 case MSG_PASTE: 305 // TODO: Implement. 306 PRINT(("[MSG_PASTE]: Not yet implemented.")); 307 break; 308 309 case MSG_CLEAR: 310 fResourceList->Clear(); 311 SelectionChanged(); 312 break; 313 314 case MSG_SELECTALL: 315 { 316 for (int32 i = 0; i < fResourceList->CountRows(); i++) 317 fResourceList->AddToSelection(fResourceList->RowAt(i)); 318 319 SelectionChanged(); 320 break; 321 } 322 case MSG_ADD: 323 { 324 // Thank you, François Claus :D Merry Christmas! 325 326 int32 ix = fResourceTypePopUp->FindMarkedIndex(); 327 328 if (ix != -1) { 329 ResourceRow* row = new ResourceRow(); 330 row->SetResourceID(_NextResourceID()); 331 row->SetResourceType(kDefaultTypes[ix].type); 332 row->SetResourceTypeCode(kDefaultTypes[ix].typeCode); 333 row->SetResourceRawData(kDefaultData); 334 row->SetResourceSize(kDefaultTypes[ix].size); 335 fResourceList->AddRow(row); 336 } 337 338 break; 339 } 340 case MSG_REMOVE: 341 { 342 for (int i = 0; i < fResourceList->CountRows(); i++) { 343 BRow* row = fResourceList->RowAt(i); 344 345 if (row->IsSelected()) { 346 fResourceList->RemoveRow(row); 347 i--; 348 } 349 } 350 351 break; 352 } 353 case MSG_MOVEUP: 354 { 355 for (int i = 1; i < fResourceList->CountRows(); i++) { 356 BRow* row = fResourceList->RowAt(i); 357 358 if (row->IsSelected()) 359 fResourceList->SwapRows(i, i - 1); 360 361 } 362 363 fResourceList->ClearSortColumns(); 364 SelectionChanged(); 365 break; 366 } 367 case MSG_MOVEDOWN: 368 { 369 for (int i = fResourceList->CountRows() - 1 - 1; i >= 0; i--) { 370 BRow* row = fResourceList->RowAt(i); 371 372 if (row->IsSelected()) 373 fResourceList->SwapRows(i, i + 1); 374 } 375 376 fResourceList->ClearSortColumns(); 377 SelectionChanged(); 378 break; 379 } 380 case MSG_SELECTION: 381 SelectionChanged(); 382 break; 383 384 default: 385 BWindow::MessageReceived(msg); 386 } 387 } 388 389 390 void 391 MainWindow::_SetTitleFromEntry() 392 { 393 char nameBuffer[B_FILE_NAME_LENGTH]; 394 395 fAssocEntry->GetName(nameBuffer); 396 397 BString title; 398 title << "ResourceEdit | "; 399 title << nameBuffer; 400 SetTitle(title); 401 } 402 403 404 void 405 MainWindow::_SaveAs() 406 { 407 if (fSavePanel == NULL) 408 fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, 409 B_FILE_NODE, false, new BMessage(MSG_SAVEAS_DONE)); 410 411 fSavePanel->Rewind(); 412 fSavePanel->Show(); 413 } 414 415 416 void 417 MainWindow::_Save(BEntry* entry) 418 { 419 if (entry == NULL) { 420 if (fAssocEntry == NULL) { 421 _SaveAs(); 422 return; 423 } else 424 entry = fAssocEntry; 425 } else { 426 if (fAssocEntry == NULL) { 427 fAssocEntry = entry; 428 _SetTitleFromEntry(); 429 } 430 } 431 432 /*BPath path; 433 entry->GetPath(&path); 434 435 // I wouldn't use std:: if BFile had cooler stuff. 436 // Not very comfortable here. 437 438 fstream out(path.Path(), ios::out); 439 440 time_t timeNow = time(0); 441 442 443 out << "/-" << endl; 444 out << " - This file is auto-generated by Haiku ResourceEdit." << endl; 445 out << " - Time: " << ctime((const time_t*)&timeNow); 446 out << " -\" << endl; 447 448 for (int32 i = 0; i < fResourceList->CountRows(); i++) { 449 ResourceRow* row = (ResourceRow*)fResourceList->RowAt(i); 450 451 out << endl; 452 out << "resource"; 453 454 if (true) { 455 // TODO: Implement no-ID cases. 456 457 out << "(" << row->ResourceID(); 458 459 if (row->ResourceName()[0] != '\0') { 460 out << ", \"" << row->ResourceName() << "\"" << endl; 461 } 462 463 out << ") "; 464 } 465 466 if (row->ResourceTypeCode()[0] != '\0') 467 out << "#\'" << row->ResourceTypeCode() << "\' "; 468 469 if (strcmp(row->ResourceType(), "raw") != 0) 470 out << row->ResourceType() << ' ' << row->ResourceData(); 471 else { 472 // TODO: Implement hexdump and import. 473 out << "array {" << endl; 474 out << "\t\"Not yet implemented.\"" << endl; 475 out << "}"; 476 } 477 478 out << endl; 479 } 480 481 out.close();*/ 482 483 // Commented out whole output section. Switching to .rsrc files to 484 // close Part 1 of GCI task. 485 486 // TODO: Implement exporting to .rdef and/or other formats. 487 488 489 BFile* file = new BFile(entry, B_READ_WRITE | B_CREATE_FILE); 490 BResources output(file, true); 491 delete file; 492 493 for (int32 i = 0; i < fResourceList->CountRows(); i++) { 494 ResourceRow* row = (ResourceRow*)fResourceList->RowAt(i); 495 output.AddResource(row->ResourceTypeCode(), row->ResourceID(), 496 row->ResourceRawData(), row->ResourceSize(), row->ResourceName()); 497 } 498 499 output.Sync(); 500 } 501 502 503 void 504 MainWindow::_Load() 505 { 506 /*BPath path; 507 struct stat st; 508 509 fAssocEntry->GetPath(&path); 510 fAssocEntry->GetStat(&st); 511 512 int fd = open(path.Path(), 0); 513 const char* in = (const char*)mmap(NULL, st.st_size, PROT_READ, 514 MAP_SHARED, fd, 0); 515 516 // TODO: Fix stucking bug. 517 // TODO: Parse data. 518 519 for (int32 i = 0; i < st.st_size - 1; i++) { 520 //... 521 }*/ 522 523 // Commented out input section. Same reason as above. 524 525 // TODO: Implement importing from .rdef and/or other formats. 526 527 BFile* file = new BFile(fAssocEntry, B_READ_ONLY); 528 BResources input(file); 529 delete file; 530 531 type_code code; 532 int32 id; 533 const char* name; 534 size_t size; 535 536 for (int32 i = 0; input.GetResourceInfo(i, &code, &id, &name, &size); i++) { 537 ResourceRow* row = new ResourceRow(); 538 row->SetResourceID(id); 539 row->SetResourceName(name); 540 row->SetResourceSize(size); 541 row->SetResourceTypeCode(code); 542 row->SetResourceRawData(input.LoadResource(code, id, &size)); 543 fResourceList->AddRow(row); 544 } 545 } 546 547 548 int32 549 MainWindow::_NextResourceID() 550 { 551 int32 currentID = atoi(fResourceIDText->Text()); 552 int32 nextID = currentID + 1; 553 BString text; 554 555 // Should I check if the ID is already present in the list? 556 // Hmmm... 557 558 text << nextID; 559 fResourceIDText->SetText(text); 560 561 return currentID; 562 } -
new file src/apps/resourceedit/MainWindow.h
diff --git a/src/apps/resourceedit/MainWindow.h b/src/apps/resourceedit/MainWindow.h new file mode 100644 index 0000000..bc1523f
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef MAIN_WINDOW_H 6 #define MAIN_WINDOW_H 7 8 9 #include <Window.h> 10 11 12 class ImageButton; 13 14 class BColumnListView; 15 class BEntry; 16 class BFilePanel; 17 class BMenu; 18 class BMenuBar; 19 class BMenuField; 20 class BMenuItem; 21 class BMessage; 22 class BPopUpMenu; 23 class BTextControl; 24 25 26 class MainWindow : public BWindow { 27 public: 28 MainWindow(BRect frame, BEntry* entry); 29 ~MainWindow(); 30 31 bool QuitRequested(); 32 void MessageReceived(BMessage* msg); 33 void SelectionChanged(); 34 35 private: 36 BEntry* fAssocEntry; 37 38 BMenuBar* fMenuBar; 39 40 BMenu* fFileMenu; 41 BMenuItem* fNewItem; 42 BMenuItem* fOpenItem; 43 BMenuItem* fCloseItem; 44 BMenuItem* fSaveItem; 45 BMenuItem* fSaveAsItem; 46 BMenuItem* fSaveAllItem; 47 BMenuItem* fMergeWithItem; 48 BMenuItem* fQuitItem; 49 50 BMenu* fEditMenu; 51 BMenuItem* fUndoItem; 52 BMenuItem* fRedoItem; 53 BMenuItem* fCutItem; 54 BMenuItem* fCopyItem; 55 BMenuItem* fPasteItem; 56 BMenuItem* fClearItem; 57 BMenuItem* fSelectAllItem; 58 59 BMenu* fHelpMenu; 60 61 BTextControl* fResourceIDText; 62 BPopUpMenu* fResourceTypePopUp; 63 BMenuField* fResourceTypeMenu; 64 65 BView* fToolbarView; 66 ImageButton* fAddButton; 67 ImageButton* fRemoveButton; 68 ImageButton* fMoveUpButton; 69 ImageButton* fMoveDownButton; 70 71 BColumnListView* fResourceList; 72 73 BFilePanel* fSavePanel; 74 75 void _SetTitleFromEntry(); 76 void _SaveAs(); 77 void _Save(BEntry* entry = NULL); 78 void _Load(); 79 80 int32 _NextResourceID(); 81 82 }; 83 84 85 #endif -
new file src/apps/resourceedit/ResourceEdit.cpp
diff --git a/src/apps/resourceedit/ResourceEdit.cpp b/src/apps/resourceedit/ResourceEdit.cpp new file mode 100644 index 0000000..2ff1a57
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "ResourceEdit.h" 8 9 #include "AboutWindow.h" 10 #include "Constants.h" 11 #include "MainWindow.h" 12 13 #include <Entry.h> 14 #include <FilePanel.h> 15 16 17 ResourceEdit::ResourceEdit() 18 : 19 BApplication("application/x-vnd.Haiku-ResourceEdit") 20 { 21 fCascade = BRect(100, 100, 700, 400); 22 fCascadeCount = 0; 23 24 fOpenPanel = new BFilePanel(B_OPEN_PANEL, &be_app_messenger, NULL, 0, true, 25 new BMessage(MSG_OPEN_DONE)); 26 } 27 28 29 ResourceEdit::~ResourceEdit() 30 { 31 32 } 33 34 35 void 36 ResourceEdit::MessageReceived(BMessage* msg) 37 { 38 switch (msg->what) { 39 case MSG_NEW: 40 _CreateWindow(NULL); 41 break; 42 43 case MSG_OPEN: 44 fOpenPanel->Show(); 45 break; 46 47 case MSG_OPEN_DONE: 48 { 49 entry_ref ref; 50 51 while (fOpenPanel->GetNextSelectedRef(&ref) == B_OK) 52 _CreateWindow(new BEntry(&ref)); 53 54 fOpenPanel->Rewind(); 55 56 break; 57 } 58 case MSG_CLOSE: 59 { 60 MainWindow* window; 61 msg->FindPointer("window", (void**)&window); 62 fWindowList.RemoveItem(window); 63 64 if (fWindowList.CountItems() == 0) 65 Quit(); 66 67 break; 68 } 69 case MSG_SAVEALL: 70 { 71 for (int32 i = 0; i < fWindowList.CountItems(); i++) 72 ((MainWindow*)fWindowList.ItemAt(i))->PostMessage(MSG_SAVE); 73 74 break; 75 } 76 default: 77 BApplication::MessageReceived(msg); 78 } 79 } 80 81 82 void 83 ResourceEdit::ArgvReceived(int32 argc, char* argv[]) 84 { 85 for (int32 i = 1; i < argc; i++) 86 _CreateWindow(new BEntry(argv[i])); 87 } 88 89 90 void 91 ResourceEdit::ReadyToRun() 92 { 93 if (fWindowList.CountItems() <= 0) 94 _CreateWindow(NULL); 95 } 96 97 98 void 99 ResourceEdit::_CreateWindow(BEntry* assocEntry) 100 { 101 MainWindow* window = new MainWindow(_Cascade(), assocEntry); 102 103 fWindowList.AddItem(window); 104 105 window->Show(); 106 } 107 108 109 BRect 110 ResourceEdit::_Cascade() 111 { 112 if (fCascadeCount == 8) { 113 fCascade.OffsetBy(-20 * 8, -20 * 8); 114 fCascadeCount = 0; 115 } else { 116 fCascade.OffsetBy(20, 20); 117 fCascadeCount++; 118 } 119 120 return fCascade; 121 } -
new file src/apps/resourceedit/ResourceEdit.h
diff --git a/src/apps/resourceedit/ResourceEdit.h b/src/apps/resourceedit/ResourceEdit.h new file mode 100644 index 0000000..dcdf976
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef RESOURCE_EDIT_H 6 #define RESOURCE_EDIT_H 7 8 9 #include <Application.h> 10 11 12 class MainWindow; 13 14 class BEntry; 15 class BFilePanel; 16 class BMessage; 17 18 19 class ResourceEdit : public BApplication { 20 public: 21 ResourceEdit(); 22 ~ResourceEdit(); 23 24 void MessageReceived(BMessage* msg); 25 26 private: 27 BRect fCascade; 28 uint32 fCascadeCount; 29 BList fWindowList; 30 31 BFilePanel* fOpenPanel; 32 33 void ArgvReceived(int32 argc, char* argv[]); 34 void ReadyToRun(); 35 36 void _CreateWindow(BEntry* assocEntry); 37 BRect _Cascade(); 38 39 }; 40 41 42 #endif -
new file src/apps/resourceedit/ResourceEdit.rdef
diff --git a/src/apps/resourceedit/ResourceEdit.rdef b/src/apps/resourceedit/ResourceEdit.rdef new file mode 100644 index 0000000..58b821c
- + 1 resource app_signature "application/x-vnd.Haiku-ResourceEdit"; 2 3 resource app_name_catalog_entry "x-vnd.Haiku-ResourceEdit:System name:ResourceEdit"; 4 5 resource app_version { 6 major = 0, 7 middle = 1, 8 minor = 0, 9 10 variety = B_APPV_ALPHA, 11 internal = 0, 12 13 short_info = "ResourceEdit", 14 long_info = "ResourceEdit © 2012-2013 Haiku, Inc." 15 }; 16 17 resource app_flags B_SINGLE_LAUNCH; 18 19 resource(1, "BEOS:FILE_TYPES") message { 20 "types" = "text/x-vnd.Be.ResourceDef" 21 }; 22 23 resource vector_icon { 24 $"6E6369660E050102000603399E0F3D9C0ABF82B23B84A94B88504870C900A5FF" 25 $"F5BCEAFFF2FFB3FFE3020106023E49240000000000003CAAAA4940004A3000FF" 26 $"C0FFDD7C6DFFBC040192020006023A4BAE3411A9B629883C6629495368484715" 27 $"00FFF9BAFFFFC104020006023A6A0E3670BCB6D8C13AD0F64A21BC4A0DF300BA" 28 $"DCFFFF2A20F10200060239AAD5343BA5B6E7993C629D4ABB354803A500E99797" 29 $"FFCE323202000602AAB1FB3A081FBE8A26AF5E794C4014448D43FFFDDCAB00DB" 30 $"AB5F02000602B507E13A82E2BAD599B56BB44A7652479FE400116201FE69A403" 31 $"020006023C08200000000000004000004A4000000000FD6AD839004AB9270200" 32 $"06023D4D340000000000004000004A5000000000009CFA80FFF8FAFF02000603" 33 $"B2F679BA14D43A7FB6B38E9E460F5547105A00FFEED58DDBAB5FCFFFEED50401" 34 $"95020012023B8E380000000000004000004A5400C100000001FFFF0199120606" 35 $"AE0BB40BBF4D33C3AFB75DC173BDEFC607C13EC804CA28BD82C118B920C51BBB" 36 $"40BF07B8083AB6BC0605AE02B57D3EB9B9C3EFB7BB44BBB751BD75C936CA8EC1" 37 $"B1402F0A093B593D5BBFCDC93E455BC516C5F160465B435D4544510A045A425E" 38 $"3F5A3D57400A063236323D3A41403E403739330A063A433A4A404D464A464341" 39 $"400A064237423E48424E3F4E3948350604EE532755295528552A532B5229522A" 40 $"52280604EE532456295625562D532E5029502D50250A04B969B771332E502E4E" 41 $"2B0A04B969B5BAB969B7714E2B4E270A043324B969B5BA4E2750240A063124B8" 42 $"BAB5B2B8BAB779312EB677B6ECB67CB63C0606B20831245356295625562D532E" 43 $"3126290804BA28B4D33027302BBA28B8580003C6E8B4D3C6E8B4D3C690B51750" 44 $"2950B59E50B78DC6E8B858C690B814C6E8B8580A04C6F0C5C24E4F514BC9BBC4" 45 $"280A06C4E04F41C507374B394A45C33CC6D1C36F120A030202032020250A0001" 46 $"0130202501178400040A0201012020250A00010030202501178400040A010100" 47 $"2020250A000304050630202501178400040A0401042020250A0501052020250A" 48 $"0601062020250A0C0110000A0D0111000A00030D0E0F123ED413BED4133ED413" 49 $"3ED41347F4A24A588901178400040A0B010C023ED413BED4133ED4133ED41347" 50 $"F4A24A58890A0A010B023ED413BED4133ED4133ED41347F4A24A58890A09010A" 51 $"023ED413BED4133ED4133ED41347F4A24A58890A080109023ED413BED4133ED4" 52 $"133ED41347F4A24A58890A070108023ED413BED4133ED4133ED41347F4A24A58" 53 $"890A0001070A3ED413BED4133ED4133ED41347F4A24A588915FF" 54 }; 55 56 resource(1, "add.png") #'PNG ' array { 57 $"89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D" 58 $"F80000017B494441544889ED95B14EC25014863F6AAB4864C40768D84C184908" 59 $"3E002B899B71742171C7677024716572C207707124260C0E460709A94C86844D" 60 $"144BEF6D716841CA2D5083C6857FBB7FFE73BF7B4F7B5AD8E8BF9588952A5231" 61 $"0B660D1D0D008967DD59559A5CAC2AD56301D2E473A739CDD8330010EF42B31E" 62 $"AD32D000BAEB03005BDA48210190524EEC9D5575B1011FCE07C676700347C42D" 63 $"8B0F1042E0391E00AE70D70014A990261FF2521C0EE5105DF8712925A4C852A2" 64 $"0EB4A7B9012D9A5CCE96AA6FD119AE79646AF3B6B16B7CA7C7203ED53659D796" 65 $"478D1CF0B4F8060934477714DB11735E54731368C0FE72C018466214511D4363" 66 $"D5520112AFFFD6575A4492508BB02300126F35E0812A2F94435E8A2CC7644806" 67 $"6B1BB8A2CF904E2837A00B61880AF0C7BFC1EC1095A8E3929996BAC0900E379C" 68 $"03BDB91D5E97037C75E7D66DA01091EB01CF0BF60040EDF52FEBCF01F13E1503" 69 $"5ADC72C2567020172F78A02B15EF7FE0EB007F8826F2807B60F0833D3652F505" 70 $"AA6A764F51A11AA20000000049454E44AE426082" 71 }; 72 73 resource(2, "remove.png") #'PNG ' array { 74 $"89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D" 75 $"F800000275494441544889ED94C14B93611CC73F7B7D6DF80EDA72BEAFCE2D82" 76 $"57F022099AE065902884791C41052BD7FE804DA48378AF4E49978E199845273D" 77 $"CC90C0759B78085C66186387053A9C4B3417CB4DD6D3C136F5F5DDC04E1DFCC2" 78 $"0F5E9EDFFB7EBEBFEFFB3CEF0BE7FA6FA5C3C551557D1780A78064728B148027" 79 $"A3AAFA5E07C799E1E31ECFC7642824627EBF08C282C1440AC2B398DF2F92A190" 80 $"18F778523A38CD587566F03BAAFA617868E85A8BA2D06CB3E172B974CBDA9A77" 81 $"19A6014B10261EF87CE14EB71B9B24D1E6763B4AEBEBB737F2F9573BF0ABA6C1" 82 $"B0AACE04FBFBAF373734208A4544B188A628B8344D9792496F17740D0F0E86AF" 83 $"B6B454FA3649A2ADB5D5F1736BEBE6523EFF02289579B2D160379BFDBA99C90C" 84 $"A986F50EBB9D7B7D7D03C04087DD4E696FEF447F339361379BDD00BA81A5AA09" 85 $"E2B050974A793545D1554942140A9552651955964FAC894281CFE934D38B8BD1" 86 $"97F01A5804F6AB1A006219A6E574DAAB59AD7A932C230E0EAAD66A26C39B783C" 87 $"3A09534004D8A9B907C74DEAB359AF2ACB7A9310A7A61685025FB6B7799B4854" 88 $"8583C91E18B42A72B9815295A6C8E5CA977366F05A09A4204CDC8270BBCD5639" 89 $"2DC67202CDF9BC6E859EBF47581841966A701F84DB6BA7AB2801CC4074126E00" 90 $"BF6B2608C0631F3C348327806D4E7FB24E4003DD0ABDF1C3937434AD11E280EE" 91 $"C62AF05988CE423461D26F3C7CD60D74D64CB00573F570F7323814037C12A696" 92 $"E15103F468A097937C0722F06D069EEFC027E087C90C47D2C13906A918880894" 93 $"7F76F7814BE5E44158888088811883940E21A0AD26D86832022B019837C0CB92" 94 $"02303F022B67861FD305A0D7045E9685C3777EE55FE0E702E00F037E0BAE5DFC" 95 $"3C830000000049454E44AE426082" 96 }; 97 98 resource(3, "moveup.png") #'PNG ' array { 99 $"89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D" 100 $"F8000001C8494441544889ED933B485B6118861F93D8788F510E27DAE00D259D" 101 $"0485823108723843296E22850E0EBA140AA543C4A18A9442A920EA62068582E2" 102 $"E0AA83E2050415A18B882028ED927AE8693C31510721A8F93B5841E9C9498A2E" 103 $"822FBCC3CFF7F3BCDFF75FE0510F465EC81E57F93AAE32ED85EC7B854B609F50" 104 $"98D4D755A1AFAB6242615302C77DC16D2185316D392044AC4D88589BD0960222" 105 $"A4B02A81FDCEF0D116BE84E7EA8530945B0ECFD58B911616D2312C3B1808F0A1" 106 $"FD9DAFBFB2D90DE2F2965D4F9DC8725E6D997ED4B072C0CC7F077C6AE27DC79B" 107 $"9AC19AD6221017A676573CC1539CFB4CFA1DAF5CD598CD38A0EF39DDAFBBA550" 108 $"9D5A00E2DCD22555763C85B686E2C8996BED178B6903828DBCEAEC94A67C2F9C" 109 $"64610DBF7669B5038FD3E9CF3B3C4B6EEAACDDE4FDF3D4FCE5F4D8EC063F96AE" 110 $"D6451512B2CFFC1823FB70FAD3B8EAD401FE72BAD8620A08A70CF8F80DD5BB4D" 111 $"179053E6C2DDFBD608CAB5E601A761181C63483F210EA02530807CCB09760C8E" 112 $"776018E025549324C8A5790049D04F88CF6B7C4EB12383DF28FE3A552D8D6CE9" 113 $"B7DC4D0F3FC0F20EB404D1EF1B44627BC866F5A328112D41D48A919541138540" 114 $"23A9A73D047633E03CCA5C7F00288AC08FE23A7EB30000000049454E44AE4260" 115 $"82" 116 }; 117 118 resource(4, "movedown.png") #'PNG ' array { 119 $"89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D" 120 $"F8000001E6494441544889ED92DD4B53611CC73F6ED5BC680D978F6B792AC45C" 121 $"E164577A9710E7A6B0BAEAAE0B41F09F08BAEAC66E4421F042AF6A228A2F28BA" 122 $"A42226859B48DD0C247A811C8E1DE2D0081793A9674F174B523BCF966F78515F" 123 $"F8C173CEF7F7FB7E785EE0BF8E5B15A5CC90C0DD7543BC3DEB7707ECFC6F46D6" 124 $"B8FFDC6C4A98645419274A013417D50D37EB030D772ED8FA9FA657FCDA9CD991" 125 $"80EE7D010028AC83B5A6F6C0556AFC2F0079B0726AAF8CCA03E426588A20B979" 126 $"08006B437D44D6C6DE0121C169CD8500F07BD09059B04EDA4FCB2C7E0F556D50" 127 $"0790CA63264C7E6C6FF9E3998EDF6631D8265A1CCEE2F7994BE0BB627F8F5F3F" 128 $"E4594D16D7050B969E99CB7767080159E50EE2691E5FCD9B4F03B704158E5F3F" 129 $"1577E0BB5C2C5980F71193789A97401058D8EA71EE1E8A1924BC192A6BDDB96B" 130 $"D5753990E5EBE38B1C4383841FBD631A7803584A00C0EB34AF6A329CABF5D0EC" 131 $"BD0848757D9E83E130230F17990422C08EEDDA0200A22922DA771ACF0B82559A" 132 $"7DCF9705187BC2D48338A3C00CA0786E0A0970F4B6329B0C23E5D2CE4A86913D" 133 $"ADCC02F700F79E827743FA74A2A991DFE1A96164DF75A202DA01CFBEC3B7419C" 134 $"033A316302698C23077462023A00EF81C3B7A4C1A97E9DF97E9D790D3A8BDCC3" 135 $"970368067C4711FE8FEA273678C1FAFB9AC8FD0000000049454E44AE426082" 136 }; -
new file src/apps/resourceedit/ResourceListView.cpp
diff --git a/src/apps/resourceedit/ResourceListView.cpp b/src/apps/resourceedit/ResourceListView.cpp new file mode 100644 index 0000000..a329d77
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "ResourceListView.h" 8 9 #include "Constants.h" 10 11 #include <ColumnListView.h> 12 #include <Entry.h> 13 14 15 ResourceListView::ResourceListView(BRect rect, const char* name, 16 uint32 resizingMode, uint32 drawFlags, border_style border, 17 bool showHorizontalScrollbar) 18 : 19 BColumnListView(rect, name, resizingMode, drawFlags, border, 20 showHorizontalScrollbar) 21 { 22 23 } 24 25 26 ResourceListView::~ResourceListView() 27 { 28 29 } 30 31 32 void 33 ResourceListView::MessageReceived(BMessage* msg) 34 { 35 switch (msg->what) { 36 case B_SIMPLE_DATA: { 37 entry_ref ref; 38 int32 n = 0; 39 40 // TODO: Implement D&D adding of files. 41 42 while (msg->FindRef("refs", n++, &ref) == B_OK) { 43 PRINT(("%s\n", ref.name)); 44 // ... 45 } 46 47 break; 48 } 49 default: 50 BColumnListView::MessageReceived(msg); 51 } 52 } -
new file src/apps/resourceedit/ResourceListView.h
diff --git a/src/apps/resourceedit/ResourceListView.h b/src/apps/resourceedit/ResourceListView.h new file mode 100644 index 0000000..5551f82
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef RESOURCE_LIST_VIEW_H 6 #define RESOURCE_LIST_VIEW_H 7 8 9 #include <ColumnListView.h> 10 11 12 class ResourceListView : public BColumnListView { 13 public: 14 ResourceListView(BRect rect, const char* name, uint32 resizingMode, 15 uint32 drawFlags, border_style border = B_NO_BORDER, 16 bool showHorizontalScrollbar = true); 17 ~ResourceListView(); 18 19 void MessageReceived(BMessage* msg); 20 21 private: 22 23 }; 24 25 26 #endif -
new file src/apps/resourceedit/ResourceRow.cpp
diff --git a/src/apps/resourceedit/ResourceRow.cpp b/src/apps/resourceedit/ResourceRow.cpp new file mode 100644 index 0000000..ebe5dce
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "ResourceRow.h" 8 9 #include <ColumnListView.h> 10 #include <ColumnTypes.h> 11 12 13 ResourceRow::ResourceRow() 14 : 15 BRow() 16 { 17 fRawData = NULL; 18 19 SetField(new BIntegerField(0), 0); 20 SetField(new BStringField(""), 1); 21 SetField(new BStringField(""), 2); 22 SetField(new BStringField(""), 3); 23 SetField(new BStringField(""), 4); 24 SetField(new BSizeField(0), 5); 25 } 26 27 28 ResourceRow::~ResourceRow() 29 { 30 // ... 31 } 32 33 34 void 35 ResourceRow::SetResourceID(int32 id) 36 { 37 ((BIntegerField*)GetField(0))->SetValue(id); 38 } 39 40 41 void 42 ResourceRow::SetResourceName(const char* name) 43 { 44 ((BStringField*)GetField(1))->SetString(name); 45 } 46 47 48 void 49 ResourceRow::SetResourceType(const char* type) 50 { 51 ((BStringField*)GetField(2))->SetString(type); 52 } 53 54 55 void 56 ResourceRow::SetResourceTypeCode(type_code code) 57 { 58 fTypeCode = code; 59 TypeCodeToString(code, fTypeString); 60 ((BStringField*)GetField(3))->SetString(fTypeString); 61 } 62 63 64 void 65 ResourceRow::SetResourceData(const char* data) 66 { 67 ((BStringField*)GetField(4))->SetString(data); 68 } 69 70 71 void 72 ResourceRow::SetResourceRawData(const void* data) 73 { 74 if (data == NULL) 75 data = kDefaultData; 76 77 fRawData = data; 78 79 int32 ix = FindTypeCodeIndex(ResourceTypeCode()); 80 81 if (ix == -1) 82 SetResourceData("[Unknown Data]"); 83 else 84 SetResourceData(kDefaultTypes[ix].toString(fRawData)); 85 } 86 87 88 void 89 ResourceRow::SetResourceSize(off_t size) 90 { 91 ((BSizeField*)GetField(5))->SetSize(size); 92 } 93 94 95 int32 96 ResourceRow::ResourceID() 97 { 98 return ((BIntegerField*)GetField(0))->Value(); 99 } 100 101 102 const char* 103 ResourceRow::ResourceName() 104 { 105 return ((BStringField*)GetField(1))->String(); 106 } 107 108 109 const char* 110 ResourceRow::ResourceType() 111 { 112 return ((BStringField*)GetField(2))->String(); 113 } 114 115 116 type_code 117 ResourceRow::ResourceTypeCode() 118 { 119 return fTypeCode; 120 } 121 122 123 const char* 124 ResourceRow::ResourceData() 125 { 126 return ((BStringField*)GetField(4))->String(); 127 } 128 129 130 const void* 131 ResourceRow::ResourceRawData() 132 { 133 return fRawData; 134 } 135 136 137 off_t 138 ResourceRow::ResourceSize() 139 { 140 return ((BSizeField*)GetField(5))->Size(); 141 } -
new file src/apps/resourceedit/ResourceRow.h
diff --git a/src/apps/resourceedit/ResourceRow.h b/src/apps/resourceedit/ResourceRow.h new file mode 100644 index 0000000..a9e65ca
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef RESOURCE_ROW_H 6 #define RESOURCE_ROW_H 7 8 9 #include "DefaultTypes.h" 10 11 #include <ColumnListView.h> 12 13 14 class ResourceRow : public BRow { 15 public: 16 ResourceRow(); 17 ~ResourceRow(); 18 19 void SetResourceID(int32 id); 20 void SetResourceName(const char* name); 21 void SetResourceType(const char* type); 22 void SetResourceTypeCode(type_code code); 23 void SetResourceData(const char* data); 24 void SetResourceRawData(const void*); 25 void SetResourceSize(off_t size); 26 27 int32 ResourceID(); 28 const char* ResourceName(); 29 const char* ResourceType(); 30 type_code ResourceTypeCode(); 31 const char* ResourceData(); 32 const void* ResourceRawData(); 33 off_t ResourceSize(); 34 35 private: 36 const void* fRawData; 37 type_code fTypeCode; 38 char fTypeString[8]; 39 40 }; 41 42 43 #endif -
new file src/apps/resourceedit/main.cpp
diff --git a/src/apps/resourceedit/main.cpp b/src/apps/resourceedit/main.cpp new file mode 100644 index 0000000..b370361
- + 1 /* 2 * Copyright 2012-2013 Tri-Edge AI <triedgeai@gmail.com> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "ResourceEdit.h" 8 9 10 int 11 main() 12 { 13 ResourceEdit* app = new ResourceEdit(); 14 app->Run(); 15 delete app; 16 return 0; 17 } -
src/kits/interface/ColumnListView.cpp
diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index 91bf16a..ec8b1af 100644
a b BRow::IsExpanded() const 523 523 } 524 524 525 525 526 bool 527 BRow::IsSelected() const 528 { 529 return fPrevSelected != NULL; 530 } 531 532 526 533 void 527 534 BRow::ValidateFields() const 528 535 { … … BColumnListView::UpdateRow(BRow* row) 1258 1265 } 1259 1266 1260 1267 1268 bool 1269 BColumnListView::SwapRows(int32 index1, int32 index2, BRow* parentRow1, 1270 BRow* parentRow2) 1271 { 1272 BRow* row1 = NULL; 1273 BRow* row2 = NULL; 1274 1275 BRowContainer* container1 = NULL; 1276 BRowContainer* container2 = NULL; 1277 1278 if (parentRow1 == NULL) 1279 container1 = fOutlineView->RowList(); 1280 else 1281 container1 = parentRow1->fChildList; 1282 1283 if (container1 == NULL) 1284 return false; 1285 1286 if (parentRow2 == NULL) 1287 container2 = fOutlineView->RowList(); 1288 else 1289 container2 = parentRow1->fChildList; 1290 1291 if (container2 == NULL) 1292 return false; 1293 1294 row1 = container1->ItemAt(index1); 1295 1296 if (row1 == NULL) 1297 return false; 1298 1299 row2 = container2->ItemAt(index2); 1300 1301 if (row2 == NULL) 1302 return false; 1303 1304 container1->ReplaceItem(index2, row1); 1305 container2->ReplaceItem(index1, row2); 1306 1307 BRect rect1; 1308 BRect rect2; 1309 BRect rect; 1310 1311 fOutlineView->FindRect(row1, &rect1); 1312 fOutlineView->FindRect(row2, &rect2); 1313 1314 rect = rect1 | rect2; 1315 1316 fOutlineView->Invalidate(rect); 1317 1318 return true; 1319 } 1320 1321 1261 1322 void 1262 1323 BColumnListView::ScrollTo(const BRow* row) 1263 1324 { … … OutlineView::AddRow(BRow* row, int32 Index, BRow* parentRow) 4195 4256 4196 4257 row->fParent = parentRow; 4197 4258 4198 if (fMasterView->SortingEnabled() ) {4259 if (fMasterView->SortingEnabled() && !fSortColumns->IsEmpty()) { 4199 4260 // Ignore index here. 4200 4261 if (parentRow) { 4201 4262 if (parentRow->fChildList == NULL) -
src/kits/interface/Menu.cpp
diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 8491d2f..0485f97 100644
a b BMenu::FindMarked() 1107 1107 { 1108 1108 for (int32 i = 0; i < fItems.CountItems(); i++) { 1109 1109 BMenuItem* item = ItemAt(i); 1110 1110 1111 if (item->IsMarked()) 1111 1112 return item; 1112 1113 } … … BMenu::FindMarked() 1115 1116 } 1116 1117 1117 1118 1119 int32 1120 BMenu::FindMarkedIndex() 1121 { 1122 for (int32 i = 0; i < fItems.CountItems(); i++) { 1123 BMenuItem* item = ItemAt(i); 1124 1125 if (item->IsMarked()) 1126 return i; 1127 } 1128 1129 return -1; 1130 } 1131 1132 1118 1133 BMenu* 1119 1134 BMenu::Supermenu() const 1120 1135 {