From fa8d1c38f2320f28ffec92bc26a512b2beb8f58a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Fri, 11 Jan 2008 23:49:42 +0000 Subject: [PATCH] First pass at building for Haiku. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23426 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- 3rdparty/mmu_man/themes/CompareMessages.cpp | 10 ++-- 3rdparty/mmu_man/themes/DumpMessage.cpp | 58 +++++++++++++++++-- 3rdparty/mmu_man/themes/FileUtils.cpp | 4 +- 3rdparty/mmu_man/themes/ParseMessage.cpp | 8 ++- 3rdparty/mmu_man/themes/ThemeAddonItem.cpp | 30 +++++++++- .../mmu_man/themes/ThemeInterfaceView.cpp | 21 ++++++- 6 files changed, 112 insertions(+), 19 deletions(-) diff --git a/3rdparty/mmu_man/themes/CompareMessages.cpp b/3rdparty/mmu_man/themes/CompareMessages.cpp index bde953d586..c81d534817 100644 --- a/3rdparty/mmu_man/themes/CompareMessages.cpp +++ b/3rdparty/mmu_man/themes/CompareMessages.cpp @@ -8,16 +8,15 @@ /* returns true if == */ bool CompareMessages(BMessage &a, BMessage &b) { - void *cookie = NULL; - const char *name; + char *name; type_code code; - int32 count, i; + int32 count, index, i; const void *adata, *bdata; ssize_t asize, bsize; if (a.what != b.what) return false; - while (a.GetNextName(&cookie, &name, &code, &count) == B_OK) { + for (index = 0; a.GetInfo(B_ANY_TYPE, index, &name, &code, &count) == B_OK; i++) { for (i = 0; i < count; i++) { if (a.FindData(name, code, i, &adata, &asize) != B_OK) return false; @@ -29,9 +28,8 @@ bool CompareMessages(BMessage &a, BMessage &b) return false; } } - cookie = NULL; /* cross compare */ - while (b.GetNextName(&cookie, &name, &code, &count) == B_OK) { + for (index = 0; b.GetInfo(B_ANY_TYPE, index, &name, &code, &count) == B_OK; i++) { type_code acode; int32 acount; if (a.GetInfo(name, &acode, &acount) < B_OK) diff --git a/3rdparty/mmu_man/themes/DumpMessage.cpp b/3rdparty/mmu_man/themes/DumpMessage.cpp index 4ff75a073e..76a085aa63 100644 --- a/3rdparty/mmu_man/themes/DumpMessage.cpp +++ b/3rdparty/mmu_man/themes/DumpMessage.cpp @@ -58,9 +58,8 @@ bool LookUpFieldName(const char **name, const char *field_name, BMessage *names) status_t DumpMessageToStream(BMessage *message, BDataIO &stream, int tabCount, BMessage *names) { - int32 index; - void *cookie = NULL; - const char *field_name; + int32 field, index; + char *field_name; type_code field_code; int32 field_count; char buffer[80]; @@ -93,10 +92,10 @@ status_t DumpMessageToStream(BMessage *message, BDataIO &stream, int tabCount, B // stream.Write(tabs+2, tabCount-2); stream.Write(buffer, strlen(buffer)); - while (message->GetNextName(&cookie, + for (field = 0; message->GetInfo(B_ANY_TYPE, field, &field_name, &field_code, - &field_count) == B_OK) { + &field_count) == B_OK; field++) { if (LookUpFieldName(&easy_name, field_name, names)) { stream.Write(tabs+1, tabCount); stream.Write("// ", 3); @@ -121,6 +120,7 @@ status_t DumpMessageToStream(BMessage *message, BDataIO &stream, int tabCount, B DumpMessageToStream(&m, stream, tabCount, names); } break; +#ifdef B_BEOS_VERSION_DANO case 'FONt': { BFont f; @@ -140,6 +140,54 @@ status_t DumpMessageToStream(BMessage *message, BDataIO &stream, int tabCount, B stream.Write("\n", 1); } break; +#else + case 'FONt': + { + BFont f; + const void *data; + ssize_t len; + if (message->FindData(field_name, index, &data, &len) >= B_OK) { + if (len <= (ssize_t)sizeof(f)) { + // Hack: only Dano has BFont : public BFlattenable + memcpy((void *)&f, data, len); + //stream << f; + font_family family; + font_style style; + font_height height; + f.GetFamilyAndStyle(&family, &style); + f.GetHeight(&height); + BString s; + s << "BFont(" << family; + s << "/" << style << "/" << f.Size(); + s << ", shear=" << f.Shear(); + s << ", rot=" << f.Rotation(); + s << ", height=" << height.ascent; + s << "+" << height.descent; + s << "+" << height.leading << ")"; + stream.Write(s.String(), s.Length()); + } // else too big + } + stream.Write("\n", 1); + } + break; + case B_RGB_COLOR_TYPE: + { + rgb_color c; + const void *data; + ssize_t len; + if (message->FindData(field_name, index, &data, &len) >= B_OK) { + if (len <= (ssize_t)sizeof(c)) { + // Hack + memcpy((void *)&c, data, len); + sprintf(buffer, "rgb_color(%d,%d,%d,%d)", + c.red, c.green, c.blue, c.alpha); + stream.Write(buffer, strlen(buffer)); + } // else too big + } + stream.Write("\n", 1); + } + break; +#endif case B_BOOL_TYPE: { bool value; diff --git a/3rdparty/mmu_man/themes/FileUtils.cpp b/3rdparty/mmu_man/themes/FileUtils.cpp index 5ad8f972fd..98be7d7de1 100644 --- a/3rdparty/mmu_man/themes/FileUtils.cpp +++ b/3rdparty/mmu_man/themes/FileUtils.cpp @@ -165,7 +165,7 @@ status_t escape_find_directory(BString *dir) status_t unescape_find_directory(BString *dir) { - status_t err; + status_t err = B_ERROR; int32 s, e; BString tok; BPath path; @@ -180,7 +180,9 @@ status_t unescape_find_directory(BString *dir) _BORK(B_DESKTOP_DIRECTORY); _BORK(B_TRASH_DIRECTORY); +#ifdef B_BEOS_VERSION_DANO _BORK(B_ROOT_DIRECTORY); +#endif _BORK(B_BEOS_DIRECTORY); _BORK(B_BEOS_SYSTEM_DIRECTORY); diff --git a/3rdparty/mmu_man/themes/ParseMessage.cpp b/3rdparty/mmu_man/themes/ParseMessage.cpp index 4785dfd671..2ba518e8c2 100644 --- a/3rdparty/mmu_man/themes/ParseMessage.cpp +++ b/3rdparty/mmu_man/themes/ParseMessage.cpp @@ -5,6 +5,8 @@ #include #include #include +#include + #include "DumpMessage.h" #define MAX_TEXT_LINE_INPUT_SIZE 4096 @@ -192,7 +194,7 @@ status_t Parse_Msg_rgb_color(BMessage *msg, TextLineInputDataIO *st, char *name) if (!has_alpha) v.alpha = 255; //msg->AddRGBColor(name, v); - msg->AddData(name, (type_code)'RGBC', &v, 4); + msg->AddData(name, B_RGB_COLOR_TYPE, &v, 4); return B_OK; } @@ -255,7 +257,11 @@ status_t Parse_Msg_BFont(BMessage *msg, TextLineInputDataIO *st, char *name) f.SetFamilyAndStyle(ff, fs); f.SetSize(size); //f.PrintToStream(); +#ifdef B_BEOS_VERSION_DANO msg->AddFlat(name, &f); +#else + msg->AddData(name, 'FONt', (void *)&f, sizeof(f)); +#endif return B_OK; } diff --git a/3rdparty/mmu_man/themes/ThemeAddonItem.cpp b/3rdparty/mmu_man/themes/ThemeAddonItem.cpp index fcf0a82f34..4f59dde4d7 100644 --- a/3rdparty/mmu_man/themes/ThemeAddonItem.cpp +++ b/3rdparty/mmu_man/themes/ThemeAddonItem.cpp @@ -2,10 +2,20 @@ #include "ThemeInterfaceView.h" #include "ThemeManager.h" #include "UITheme.h" +#include +#ifdef B_ZETA_VERSION #include +#else +#define _T(v) v +#define B_LANGUAGE_CHANGED '_BLC' +#define B_PREF_APP_SET_DEFAULTS 'zPAD' +#define B_PREF_APP_REVERT 'zPAR' +#define B_PREF_APP_ADDON_REF 'zPAA' +#endif #include #include #include +#include #include #include @@ -24,10 +34,16 @@ ThemeAddonItem::ThemeAddonItem(BRect bounds, ThemeInterfaceView *iview, int32 id tman = iview->GetThemeManager(); fAddonName = tman->AddonName(id); BString tip(tman->AddonDescription(id)); +#ifdef B_BEOS_VERSION_DANO SetToolTipText(tip.String()); SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR); SetLowUIColor(B_UI_PANEL_BACKGROUND_COLOR); SetHighUIColor(B_UI_PANEL_TEXT_COLOR); +#else + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); +#endif BMessage *apply = new BMessage(CB_APPLY); apply->AddInt32("addon", id); BMessage *save = new BMessage(CB_SAVE); @@ -35,14 +51,18 @@ ThemeAddonItem::ThemeAddonItem(BRect bounds, ThemeInterfaceView *iview, int32 id BMessage *prefs = new BMessage(BTN_PREFS); prefs->AddInt32("addon", id); fApplyBox = new BCheckBox(BRect(CTRL_OFF_X, CTRL_OFF_Y, CTRL_OFF_X+50, CTRL_OFF_Y+30), "apply", _T("Apply"), apply); - fApplyBox->SetToolTipText(_T("Use this information from themes")); fApplyBox->SetValue((tman->AddonFlags(id) & Z_THEME_ADDON_DO_SET_ALL)?B_CONTROL_ON:B_CONTROL_OFF); fSaveBox = new BCheckBox(BRect(CTRL_OFF_X+50+CTRL_SPACING, CTRL_OFF_Y, CTRL_OFF_X+100+CTRL_SPACING, CTRL_OFF_Y+30), "save", _T("Save"), save); - fSaveBox->SetToolTipText(_T("Save this information to themes")); fSaveBox->SetValue((tman->AddonFlags(id) & Z_THEME_ADDON_DO_RETRIEVE)?B_CONTROL_ON:B_CONTROL_OFF); +#ifdef B_BEOS_VERSION_DANO + fApplyBox->SetToolTipText(_T("Use this information from themes")); + fSaveBox->SetToolTipText(_T("Save this information to themes")); +#endif #ifdef HAVE_PREF_BTN fPrefsBtn = new BButton(BRect(CTRL_OFF_X+100+CTRL_SPACING*2, CTRL_OFF_Y, CTRL_OFF_X+150+CTRL_SPACING*2, CTRL_OFF_Y+30), "prefs", _T("Preferences"), prefs); +#ifdef B_BEOS_VERSION_DANO fPrefsBtn->SetToolTipText(_T("Run the preferences panel for this topic.")); +#endif #endif BFont fnt; GetFont(&fnt); @@ -95,12 +115,16 @@ void ThemeAddonItem::Draw(BRect) void ThemeAddonItem::RelocalizeStrings() { fApplyBox->SetLabel(_T("Apply")); - fApplyBox->SetToolTipText(_T("Use this information from themes")); fSaveBox->SetLabel(_T("Save")); +#ifdef B_BEOS_VERSION_DANO + fApplyBox->SetToolTipText(_T("Use this information from themes")); fSaveBox->SetToolTipText(_T("Save this information to themes")); +#endif #ifdef HAVE_PREF_BTN fPrefsBtn->SetLabel(_T("Preferences")); +#ifdef B_BEOS_VERSION_DANO fPrefsBtn->SetToolTipText(_T("Run the preferences panel for this topic.")); +#endif #endif RelayoutButtons(); } diff --git a/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp b/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp index 489dd4b5ef..755a3d4418 100644 --- a/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp +++ b/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp @@ -1,16 +1,25 @@ -#include #include #include #include #include #include #include +#include +#ifdef B_ZETA_VERSION +#include #include -#include #include +#else +#define _T(v) v +#define B_PREF_APP_ENABLE_REVERT 'zPAE' +#define B_PREF_APP_SET_DEFAULTS 'zPAD' +#define B_PREF_APP_REVERT 'zPAR' +#define B_PREF_APP_ADDON_REF 'zPAA' +#endif +#include #include #include -#include +#include #include #include @@ -21,6 +30,8 @@ #include #include +#include + #include "UITheme.h" #include "TextInputAlert.h" @@ -103,7 +114,11 @@ ThemeInterfaceView::AllAttached() BView::AllAttached(); fPopupInvoker = new BInvoker(new BMessage(kReallyCreateTheme), this); +#ifdef B_BEOS_VERSION_DANO SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR); +#else + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); +#endif fThemeManager = new ThemeManager; fThemeManager->LoadThemes();