From 277ddb687a1b67a006142d78361a5db8b2db358e Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Mon, 3 May 2010 20:31:30 +0000 Subject: [PATCH] - support for toolbar added; - some minor gcc4 build warnings cleanup. --- app-editors/vim/patches/vim-7.2.patch | 673 +++++++++++++++++++++++--- 1 file changed, 610 insertions(+), 63 deletions(-) diff --git a/app-editors/vim/patches/vim-7.2.patch b/app-editors/vim/patches/vim-7.2.patch index d0e43c9f4..16bc85527 100644 --- a/app-editors/vim/patches/vim-7.2.patch +++ b/app-editors/vim/patches/vim-7.2.patch @@ -69,7 +69,7 @@ diff -Naur vim72/src/Makefile vim72.haiku/src/Makefile +BEOSGUI_DEFS = -DFEAT_GUI_BEOS +BEOSGUI_IPATH = +BEOSGUI_LIBS_DIR = -+BEOSGUI_LIBS1 = -lbe -lroot -ltracker ++BEOSGUI_LIBS1 = -lbe -lroot -ltracker -lsupc++ -ltranslation +BEOSGUI_LIBS2 = +BEOSGUI_INSTALL = install_normal install_beos_extra +BEOSGUI_TARGETS = installglinks_beos @@ -90,17 +90,18 @@ diff -Naur vim72/src/Makefile vim72.haiku/src/Makefile objects/gui_beval.o: gui_beval.c $(CCC) -o $@ gui_beval.c -@@ -2486,6 +2503,9 @@ +@@ -2486,6 +2503,10 @@ objects/os_beos.o: os_beos.c $(CCC) -o $@ os_beos.c ++# rc -o $@ os_beos.rdef +objects/os_beos.rsrc: os_beos.rdef + cat $< | $(CCC) -E - | grep -v '^#' | rc -o "$@" - + objects/os_qnx.o: os_qnx.c $(CCC) -o $@ os_qnx.c -@@ -2645,6 +2665,60 @@ +@@ -2645,6 +2666,60 @@ ############################################################################### @@ -301,7 +302,17 @@ diff -Naur vim72/src/feature.h vim72.haiku/src/feature.h #if defined(FEAT_MBYTE_IME) && !defined(FEAT_MBYTE) # define FEAT_MBYTE #endif -@@ -768,7 +776,7 @@ +@@ -745,7 +753,8 @@ + || defined(FEAT_GUI_MSWIN) \ + || ((defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \ + && defined(HAVE_XPM)) \ +- || defined(FEAT_GUI_PHOTON)) ++ || defined(FEAT_GUI_PHOTON)\ ++ || defined(FEAT_GUI_BEOS)) + # define FEAT_TOOLBAR + #endif + +@@ -768,7 +777,7 @@ /* * +browse ":browse" command. */ @@ -310,7 +321,7 @@ diff -Naur vim72/src/feature.h vim72.haiku/src/feature.h # define FEAT_BROWSE #endif -@@ -782,6 +790,7 @@ +@@ -782,6 +791,7 @@ && defined(HAVE_X11_XPM_H)) \ || defined(FEAT_GUI_GTK) \ || defined(FEAT_GUI_PHOTON) \ @@ -318,7 +329,7 @@ diff -Naur vim72/src/feature.h vim72.haiku/src/feature.h || defined(FEAT_GUI_MSWIN) \ || defined(FEAT_GUI_MAC) # define FEAT_CON_DIALOG -@@ -798,7 +807,8 @@ +@@ -798,7 +808,8 @@ #if defined(FEAT_GUI_DIALOG) && \ (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \ || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) \ @@ -340,6 +351,28 @@ diff -Naur vim72/src/gui.c vim72.haiku/src/gui.c # define MAY_FORK int dofork = TRUE; #endif +@@ -273,7 +273,7 @@ + gui.menu_width = 0; + # endif + #endif +-#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) ++#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_BEOS)) + gui.toolbar_height = 0; + #endif + #if defined(FEAT_FOOTER) && defined(FEAT_GUI_MOTIF) +@@ -1172,10 +1172,10 @@ + text_area_y += gui.tabline_height; + #endif + +-#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) ++#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_BEOS)) + if (vim_strchr(p_go, GO_TOOLBAR) != NULL) + { +-# ifdef FEAT_GUI_ATHENA ++# if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_BEOS) + gui_mch_set_toolbar_pos(0, text_area_y, + gui.menu_width, gui.toolbar_height); + # endif @@ -1297,7 +1297,11 @@ again: busy = TRUE; @@ -366,6 +399,28 @@ diff -Naur vim72/src/gui.c vim72.haiku/src/gui.c gui_update_cursor(FALSE, TRUE); #if defined(FEAT_XIM) && !defined(HAVE_GTK2) xim_set_status_area(); +@@ -4012,9 +4020,9 @@ + y += gui.menu_height; + #endif + +-#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_ATHENA)) ++#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_BEOS)) + if (vim_strchr(p_go, GO_TOOLBAR) != NULL) +-# ifdef FEAT_GUI_ATHENA ++# if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_BEOS) + y += gui.toolbar_height; + # else + # ifdef FEAT_GUI_MSWIN +@@ -4743,7 +4751,8 @@ + } + + #if ((defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) \ +- || defined(FEAT_GUI_PHOTON)) && defined(FEAT_TOOLBAR)) || defined(PROTO) ++ || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_BEOS)) \ ++ && defined(FEAT_TOOLBAR)) || defined(PROTO) + /* + * This is shared between Athena, Motif and GTK. + */ diff -Naur vim72/src/gui.h vim72.haiku/src/gui.h --- vim72/src/gui.h 2009-04-19 20:53:32.000000000 +0000 +++ vim72.haiku/src/gui.h 2009-04-18 09:16:26.000000000 +0000 @@ -399,6 +454,15 @@ diff -Naur vim72/src/gui.h vim72.haiku/src/gui.h #ifdef FEAT_GUI_MAC ControlHandle id; /* A handle to the scrollbar */ #endif +@@ -435,7 +442,7 @@ + #endif + + #if defined(FEAT_TOOLBAR) \ +- && (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF)) ++ && (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_BEOS)) + int toolbar_height; /* height of the toolbar */ + #endif + @@ -456,6 +463,14 @@ guicolor_T currSpColor; /* Current special text color */ #endif @@ -417,7 +481,7 @@ diff -Naur vim72/src/gui.h vim72.haiku/src/gui.h diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc --- vim72/src/gui_beos.cc 1970-01-01 00:00:00.000000000 +0000 +++ vim72.haiku/src/gui_beos.cc 2009-05-04 21:17:48.000000000 +0000 -@@ -0,0 +1,4185 @@ +@@ -0,0 +1,4583 @@ +/* vi:set ts=8 sts=4 sw=4: + * + * VIM - Vi IMproved by Bram Moolenaar @@ -509,6 +573,7 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc +#include +#include +#include ++#include +#include +#include +#include @@ -519,6 +584,7 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc +#include +#include +#include ++#include +#include +#include +#include @@ -532,6 +598,8 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc +#include +#include +#include ++#include ++#include +#include + +#ifdef __HAIKU__ @@ -552,6 +620,7 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc +class VimFormView; +class VimTextAreaView; +class VimWindow; ++class VimToolbar; + +extern key_map *keyMap; +extern char *keyMapChars; @@ -634,6 +703,16 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + + BMenuBar *menuBar; + VimTextAreaView *textArea; ++ ++#ifdef FEAT_TOOLBAR ++ public: ++ float ToolbarHeight() const; ++ VimToolbar *ToolBar() const ++ { return toolBar; } ++ private: ++ VimToolbar *toolBar; ++#endif ++ +}; + +class VimTextAreaView: public BView @@ -709,6 +788,47 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc +}; + + ++#ifdef FEAT_TOOLBAR ++ ++class VimToolbar : public BBox ++{ ++ static BBitmap *normalButtonsBitmap; ++ static BBitmap *grayedButtonsBitmap; ++ ++ BBitmap *LoadVimBitmap(const char* fileName); ++ bool GetPictureFromBitmap(BPicture *pictureTo, int32 index, BBitmap *bitmapFrom, bool pressed); ++ bool ModifyBitmapToGrayed(BBitmap *bitmap); ++ ++ BList fButtonsList; ++ void InvalidateLayout(); ++ ++ public: ++ VimToolbar(BRect frame, const char * name); ++ ~VimToolbar(); ++ ++ bool PrepareButtonBitmaps(); ++ ++ bool AddButton(int32 index, vimmenu_T *menu); ++ bool RemoveButton(vimmenu_T *menu); ++ bool GrayButton(vimmenu_T *menu, int grey); ++ ++ float ToolbarHeight() const; ++ virtual void AttachedToWindow(); ++}; ++ ++BBitmap *VimToolbar::normalButtonsBitmap = NULL; ++BBitmap *VimToolbar::grayedButtonsBitmap = NULL; ++ ++const float ToolbarMargin = 3.; ++const float ButtonMargin = 3.; ++/* ++class VimToolbarButton : public BPictureButton ++{ ++ ++}; ++*/ ++#endif /*FEAT_TOOLBAR*/ ++ +/* + * For caching the fonts that are used; + * Vim seems rather sloppy in this regard. @@ -1287,6 +1407,9 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + BView(frame, "VimFormView", B_FOLLOW_ALL_SIDES, + B_WILL_DRAW | B_FRAME_EVENTS), + menuBar(NULL), ++#ifdef FEAT_TOOLBAR ++ toolBar(NULL), ++#endif + textArea(NULL) +{ + init(frame); @@ -1302,6 +1425,11 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + delete menuBar; +#endif + } ++ ++#ifdef FEAT_TOOLBAR ++ delete toolBar; ++#endif ++ + if (textArea) { + RemoveChild(textArea); + delete textArea; @@ -1316,6 +1444,12 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + "VimMenuBar"); + + AddChild(menuBar); ++ ++#ifdef FEAT_TOOLBAR ++ toolBar = new VimToolbar(BRect(0,0,0,0), "VimToolBar"); ++ toolBar->PrepareButtonBitmaps(); ++ AddChild(toolBar); ++#endif + + BRect remaining = frame; + textArea = new VimTextAreaView(remaining); @@ -1325,6 +1459,14 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + gui.vimForm = this; +} + ++#ifdef FEAT_TOOLBAR ++ float ++VimFormView::ToolbarHeight() const ++{ ++ return toolBar ? toolBar->ToolbarHeight() : 0.; ++} ++#endif ++ + void +VimFormView::AllAttached() +{ @@ -1342,15 +1484,24 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + * menus are added to the menu bar. + */ + BRect remaining = Bounds(); -+ remaining.top = MenuHeight(); -+ textArea->ResizeTo(remaining.Width(), remaining.Height()); -+ textArea->MoveTo(remaining.left, remaining.top); + +#ifdef FEAT_MENU ++ remaining.top += MenuHeight(); + menuBar->ResizeTo(remaining.right, remaining.top); -+ gui.menu_height = (int) remaining.top; ++ gui.menu_height = (int) MenuHeight(); +#endif ++ ++#ifdef FEAT_TOOLBAR ++ toolBar->MoveTo(remaining.left, remaining.top); ++ toolBar->ResizeTo(remaining.right, ToolbarHeight()); ++ remaining.top += ToolbarHeight(); ++ gui.toolbar_height = ToolbarHeight(); ++#endif ++ textArea->ResizeTo(remaining.Width(), remaining.Height()); ++ textArea->MoveTo(remaining.left, remaining.top); + } ++ ++ + Inherited::AllAttached(); +} + @@ -1815,7 +1966,6 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + VimMenuMsg mm; + mm.guiMenu = NULL; /* in case no pointer in msg */ + m->FindPointer("VimMenu", (void **)&mm.guiMenu); -+ + write_port(gui.vdcmp, VimMsg::Menu, &mm, sizeof(mm)); + } + break; @@ -2644,6 +2794,249 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + +#endif /* FEAT_GUI_DIALOG */ + ++#ifdef FEAT_TOOLBAR ++ ++// some forward declaration required by toolbar functions... ++static BMessage * MenuMessage(vimmenu_T *menu); ++ ++VimToolbar::VimToolbar(BRect frame, const char *name) : ++ BBox(frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER) ++{ ++} ++ ++VimToolbar::~VimToolbar() ++{ ++ int32 count = fButtonsList.CountItems(); ++ for(int32 i = 0; i < count; i++) { ++ delete (BPictureButton*)fButtonsList.ItemAt(i); ++ } ++ fButtonsList.MakeEmpty(); ++ ++ delete normalButtonsBitmap; ++ delete grayedButtonsBitmap; ++ normalButtonsBitmap = NULL; ++ grayedButtonsBitmap = NULL; ++} ++ ++ void ++VimToolbar::AttachedToWindow() ++{ ++ BBox::AttachedToWindow(); ++ ++ SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); ++} ++ ++ float ++VimToolbar::ToolbarHeight() const ++{ ++ float size = NULL == normalButtonsBitmap ? 18. : normalButtonsBitmap->Bounds().Height(); ++ return size + ToolbarMargin * 2 + ButtonMargin * 2 + 1; ++} ++ ++ bool ++VimToolbar::ModifyBitmapToGrayed(BBitmap *bitmap) ++{ ++ float height = bitmap->Bounds().Height(); ++ float width = bitmap->Bounds().Width(); ++ ++ rgb_color *bits = (rgb_color*)bitmap->Bits(); ++ int32 pixels = bitmap->BitsLength() / 4; ++ for(int32 i = 0; i < pixels; i++) { ++ bits[i].red = bits[i].green = ++ bits[i].blue = ((uint32)bits[i].red + bits[i].green + bits[i].blue) / 3; ++ bits[i].alpha /= 4; ++ } ++ ++ return true; ++} ++ ++ bool ++VimToolbar::PrepareButtonBitmaps() ++{ ++ // first try to load potentially customized $VIRUNTIME/bitmaps/builtin-tools.png ++ normalButtonsBitmap = LoadVimBitmap("builtin-tools.png"); ++ if(normalButtonsBitmap == NULL) { ++ // customized not found? dig application resources for "builtin-tools" one ++ normalButtonsBitmap = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "builtin-tools"); ++ } ++ ++ if(normalButtonsBitmap == NULL) { ++ return false; ++ } ++ ++ BMessage archive; ++ normalButtonsBitmap->Archive(&archive); ++ ++ grayedButtonsBitmap = new BBitmap(&archive); ++ if(grayedButtonsBitmap == NULL) { ++ return false; ++ } ++ ++ // modify grayed bitmap ++ ModifyBitmapToGrayed(grayedButtonsBitmap); ++ ++ return true; ++} ++ ++BBitmap *VimToolbar::LoadVimBitmap(const char* fileName) ++{ ++ BBitmap *bitmap = NULL; ++ ++ int mustfree = 0; ++ char_u* runtimePath = vim_getenv((char_u*)"VIMRUNTIME", &mustfree); ++ if(runtimePath != NULL && fileName != NULL) { ++ BString strPath((char*)runtimePath); ++ strPath << "/bitmaps/" << fileName; ++ bitmap = BTranslationUtils::GetBitmap(strPath.String()); ++ } ++ ++ if(mustfree) { ++ vim_free(runtimePath); ++ } ++ ++ return bitmap; ++} ++ ++ bool ++VimToolbar::GetPictureFromBitmap(BPicture *pictureTo, int32 index, BBitmap *bitmapFrom, bool pressed) ++{ ++ float size = bitmapFrom->Bounds().Height() + 1.; ++ ++ BView view(BRect(0, 0, size, size), "", 0, 0); ++ ++ AddChild(&view); ++ view.BeginPicture(pictureTo); ++ ++ view.SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); ++ view.FillRect(view.Bounds()); ++ view.SetDrawingMode(B_OP_OVER); ++ ++ BRect source(0, 0, size - 1, size - 1); ++ BRect destination(source); ++ ++ source.OffsetBy(size * index, 0); ++ destination.OffsetBy(ButtonMargin, ButtonMargin); ++ ++ view.DrawBitmap(bitmapFrom, source, destination); ++ ++ if(pressed) { ++ rgb_color shineColor = ui_color(B_SHINE_COLOR); ++ rgb_color shadowColor = ui_color(B_SHADOW_COLOR); ++ size += ButtonMargin * 2 - 1; ++ view.BeginLineArray(4); ++ view.AddLine(BPoint(0, 0), BPoint(size, 0), shadowColor); ++ view.AddLine(BPoint(size, 0), BPoint(size, size), shineColor); ++ view.AddLine(BPoint(size, size), BPoint(0, size), shineColor); ++ view.AddLine(BPoint(0, size), BPoint(0, 0), shadowColor); ++ view.EndLineArray(); ++ } ++ ++ view.EndPicture(); ++ RemoveChild(&view); ++ ++ return true; ++} ++ ++ bool ++VimToolbar::AddButton(int32 index, vimmenu_T *menu) ++{ ++ BPictureButton *button = NULL; ++ if(!menu_is_separator(menu->name)) { ++ float size = normalButtonsBitmap ? ++ normalButtonsBitmap->Bounds().Height() + 1. + ButtonMargin * 2 : 18.; ++ BRect frame(0, 0, size, size); ++ BPicture pictureOn; ++ BPicture pictureOff; ++ BPicture pictureGray; ++ ++ if(menu->iconfile == NULL && menu->iconidx >= 0 && normalButtonsBitmap) { ++ GetPictureFromBitmap(&pictureOn, menu->iconidx, normalButtonsBitmap, true); ++ GetPictureFromBitmap(&pictureOff, menu->iconidx, normalButtonsBitmap, false); ++ GetPictureFromBitmap(&pictureGray, menu->iconidx, grayedButtonsBitmap, false); ++ } else { ++ ++ char_u buffer[MAXPATHL] = {0}; ++ BBitmap *bitmap = NULL; ++ ++ if(menu->iconfile) { ++ gui_find_iconfile(menu->iconfile, buffer, (char*)"png"); ++ bitmap = BTranslationUtils::GetBitmap((char*)buffer); ++ } ++ ++ if(bitmap == NULL && gui_find_bitmap(menu->name, buffer, (char*)"png") == OK) { ++ bitmap = BTranslationUtils::GetBitmap((char*)buffer); ++ } ++ ++ if(bitmap == NULL) { ++ bitmap = new BBitmap(BRect(0, 0, size, size), B_RGB32); ++ } ++ ++ GetPictureFromBitmap(&pictureOn, 0, bitmap, true); ++ GetPictureFromBitmap(&pictureOff, 0, bitmap, false); ++ ModifyBitmapToGrayed(bitmap); ++ GetPictureFromBitmap(&pictureGray, 0, bitmap, false); ++ ++ delete bitmap; ++ } ++ ++ button = new BPictureButton(frame, (char*)menu->name, ++ &pictureOff, &pictureOn, MenuMessage(menu)); ++ ++ button->SetDisabledOn(&pictureGray); ++ button->SetDisabledOff(&pictureGray); ++ ++ button->SetTarget(gui.vimTextArea); ++ ++ AddChild(button); ++ ++ menu->button = button; ++ } ++ ++ bool result = fButtonsList.AddItem(button, index); ++ InvalidateLayout(); ++ return result; ++} ++ ++ bool ++VimToolbar::RemoveButton(vimmenu_T *menu) ++{ ++ if(menu->button) { ++ if(fButtonsList.RemoveItem(menu->button)) { ++ delete menu->button; ++ menu->button = NULL; ++ } ++ } ++} ++ ++ bool ++VimToolbar::GrayButton(vimmenu_T *menu, int grey) ++{ ++ if(menu->button) { ++ int32 index = fButtonsList.IndexOf(menu->button); ++ if(index >= 0) { ++ menu->button->SetEnabled(grey ? false : true); ++ } ++ } ++} ++ ++ void ++VimToolbar::InvalidateLayout() ++{ ++ int32 offset = ToolbarMargin; ++ int32 count = fButtonsList.CountItems(); ++ for(int32 i = 0; i < count; i++) { ++ BPictureButton *button = (BPictureButton *)fButtonsList.ItemAt(i); ++ if(button) { ++ button->MoveTo(offset, ToolbarMargin); ++ offset += button->Bounds().Width() + ToolbarMargin; ++ } else ++ offset += ToolbarMargin * 3; ++ } ++} ++ ++#endif /*FEAT_TOOLBAR*/ ++ ++ +/* ---------------- ---------------- */ + +// some global variables @@ -3433,7 +3826,7 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + *end = ' '; + } else { + be_fixed_font->GetFamilyAndStyle(&family, &style); -+ vim_snprintf((char*)font_name, buff_size, "%s/%s/%.0f", ++ vim_snprintf(font_name, buff_size, (char*)"%s/%s/%.0f", + family, style, be_fixed_font->Size()); + } + @@ -3594,7 +3987,7 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc +{ + typedef struct GuiColourTable + { -+ char *name; ++ const char *name; + guicolor_T colour; + } GuiColourTable; + @@ -3654,6 +4047,8 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + {"Purple", RGB(0xA0, 0x20, 0xF0)}, + {"SlateBlue", RGB(0x6A, 0x5A, 0xCD)}, + {"Violet", RGB(0xEE, 0x82, 0xEE)}, ++ // NOTE: some entries are zero-allocated for NDDYNAMIC_COLORS ++ // in this table! + }; + + static int endColour = NSTATIC_COLOURS; @@ -3728,7 +4123,9 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + */ + guicolor_T gcolour = RGB(r,g,b); + -+ vim_free(table[newColour].name); ++ //NOTE: see note above in table allocation! We are working here with ++ // dynamically allocated names, not constant ones! ++ vim_free((char*)table[newColour].name); + table[newColour].name = (char *)vim_strsave((char_u *)colour); + table[newColour].colour = gcolour; + @@ -4211,17 +4608,20 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + int mnemonic = 0; + vimmenu_T *parent = menu->parent; + -+ if (parent->submenu_id == NULL) -+ return; ++// printf("parent:%s:%#010x\n", parent->name, parent->submenu_id); ++// if (parent->submenu_id == NULL) ++// return; + -+#ifdef never ++// printf("parent:%s\n", parent->name); ++ ++//#ifdef never + /* why not add separators ? + * richard + */ + /* Don't add menu separator */ -+ if (menu_is_separator(menu->name)) -+ return; -+#endif ++// if (menu_is_separator(menu->name)) ++// return; ++//#endif + + /* TODO: use menu->actext */ + /* This is difficult, since on Be, an accelerator must be a single char @@ -4232,20 +4632,31 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + */ + if (gui.vimWindow->Lock()) + { -+ if ( menu_is_separator(menu->name)) { -+ BSeparatorItem *item = new BSeparatorItem(); -+ parent->submenu_id->AddItem(item); -+ menu->id = item; -+ menu->submenu_id = NULL; -+ } -+ else { -+ BMenuItem *item = new BMenuItem((char *)menu->dname, -+ MenuMessage(menu)); -+ item->SetTarget(gui.vimTextArea); -+ item->SetTrigger((char) menu->mnemonic); -+ parent->submenu_id->AddItem(item); -+ menu->id = item; -+ menu->submenu_id = NULL; ++#ifdef FEAT_TOOLBAR ++ if(menu_is_toolbar(parent->name)) { ++ VimToolbar *toolbar = gui.vimForm->ToolBar(); ++ if(toolbar != NULL) { ++ toolbar->AddButton(idx, menu); ++ } ++ } else ++#endif ++ ++ if (parent->submenu_id != NULL) { ++ if ( menu_is_separator(menu->name)) { ++ BSeparatorItem *item = new BSeparatorItem(); ++ parent->submenu_id->AddItem(item); ++ menu->id = item; ++ menu->submenu_id = NULL; ++ } ++ else { ++ BMenuItem *item = new BMenuItem((char *)menu->dname, ++ MenuMessage(menu)); ++ item->SetTarget(gui.vimTextArea); ++ item->SetTrigger((char) menu->mnemonic); ++ parent->submenu_id->AddItem(item); ++ menu->id = item; ++ menu->submenu_id = NULL; ++ } + } + gui.vimWindow->Unlock(); + } @@ -4260,32 +4671,42 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc +{ + if (gui.vimWindow->Lock()) + { -+ assert(menu->submenu_id == NULL || menu->submenu_id->CountItems() == 0); -+ /* -+ * Detach this menu from its parent, so that it is not deleted -+ * twice once we get to delete that parent. -+ * Deleting a BMenuItem also deletes the associated BMenu, if any -+ * (which does not have any items anymore since they were -+ * removed and deleted before). -+ */ -+ BMenu *bmenu = menu->id->Menu(); -+ if (bmenu) -+ { -+ bmenu->RemoveItem(menu->id); -+ /* -+ * If we removed the last item from the menu bar, -+ * resize it out of sight. -+ */ -+ if (bmenu == gui.vimForm->MenuBar() && bmenu->CountItems() == 0) -+ { -+ bmenu->ResizeTo(-MENUBAR_MARGIN, -MENUBAR_MARGIN); ++#ifdef FEAT_TOOLBAR ++ if(menu->parent && menu_is_toolbar(menu->parent->name)) { ++ VimToolbar *toolbar = gui.vimForm->ToolBar(); ++ if(toolbar != NULL) { ++ toolbar->RemoveButton(menu); + } -+ } -+ delete menu->id; -+ menu->id = NULL; -+ menu->submenu_id = NULL; ++ } else ++#endif ++ { ++ assert(menu->submenu_id == NULL || menu->submenu_id->CountItems() == 0); ++ /* ++ * Detach this menu from its parent, so that it is not deleted ++ * twice once we get to delete that parent. ++ * Deleting a BMenuItem also deletes the associated BMenu, if any ++ * (which does not have any items anymore since they were ++ * removed and deleted before). ++ */ ++ BMenu *bmenu = menu->id->Menu(); ++ if (bmenu) ++ { ++ bmenu->RemoveItem(menu->id); ++ /* ++ * If we removed the last item from the menu bar, ++ * resize it out of sight. ++ */ ++ if (bmenu == gui.vimForm->MenuBar() && bmenu->CountItems() == 0) ++ { ++ bmenu->ResizeTo(-MENUBAR_MARGIN, -MENUBAR_MARGIN); ++ } ++ } ++ delete menu->id; ++ menu->id = NULL; ++ menu->submenu_id = NULL; + -+ gui.menu_height = (int) gui.vimForm->MenuHeight(); ++ gui.menu_height = (int) gui.vimForm->MenuHeight(); ++ } + gui.vimWindow->Unlock(); + } +} @@ -4298,6 +4719,17 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + vimmenu_T *menu, + int grey) +{ ++#ifdef FEAT_TOOLBAR ++ if(menu->parent && menu_is_toolbar(menu->parent->name)) { ++ if (gui.vimWindow->Lock()) { ++ VimToolbar *toolbar = gui.vimForm->ToolBar(); ++ if(toolbar != NULL) { ++ toolbar->GrayButton(menu, grey); ++ } ++ gui.vimWindow->Unlock(); ++ } ++ } else ++#endif + if (menu->id != NULL) + menu->id->SetEnabled(!grey); +} @@ -4612,11 +5044,31 @@ diff -Naur vim72/src/gui_beos.cc vim72.haiku/src/gui_beos.cc + return(1); +} +#endif ++ ++ void ++gui_mch_show_toolbar(int showit) ++{ ++ VimToolbar *toolbar = gui.vimForm->ToolBar(); ++ gui.toolbar_height = (toolbar && showit) ? toolbar->ToolbarHeight() : 0.; ++} ++ ++ void ++gui_mch_set_toolbar_pos(int x, int y, int w, int h) ++{ ++ VimToolbar *toolbar = gui.vimForm->ToolBar(); ++ if(toolbar != NULL) { ++ if (gui.vimWindow->Lock()) { ++ toolbar->MoveTo(x, y); ++ toolbar->ResizeTo(w - 1, h - 1); ++ gui.vimWindow->Unlock(); ++ } ++ } ++} +//} /* extern "C" */ diff -Naur vim72/src/gui_beos.h vim72.haiku/src/gui_beos.h --- vim72/src/gui_beos.h 1970-01-01 00:00:00.000000000 +0000 +++ vim72.haiku/src/gui_beos.h 2009-04-18 09:16:27.000000000 +0000 -@@ -0,0 +1,49 @@ +@@ -0,0 +1,51 @@ +/* vi:set ts=8 sts=4 sw=4: + * + * VIM - Vi IMproved by Bram Moolenaar @@ -4641,6 +5093,7 @@ diff -Naur vim72/src/gui_beos.h vim72.haiku/src/gui_beos.h + +struct BMenu; +struct BMenuItem; ++struct BPictureButton; + +/* Our own Vim-related classes */ + @@ -4659,6 +5112,7 @@ diff -Naur vim72/src/gui_beos.h vim72.haiku/src/gui_beos.h + +typedef struct BMenu BMenu; +typedef struct BMenuItem BMenuItem; ++typedef struct BPictureButton BPictureButton; +typedef struct VimWindow VimWindow; +typedef struct VimFormView VimFormView; +typedef struct VimTextAreaView VimTextAreaView; @@ -4827,7 +5281,7 @@ diff -Naur vim72/src/os_beos.h vim72.haiku/src/os_beos.h diff -Naur vim72/src/os_beos.rdef vim72.haiku/src/os_beos.rdef --- vim72/src/os_beos.rdef 1970-01-01 00:00:00.000000000 +0000 +++ vim72.haiku/src/os_beos.rdef 2009-05-05 21:11:42.000000000 +0000 -@@ -0,0 +1,231 @@ +@@ -0,0 +1,205 @@ +/* + * Vim.rdef + */ @@ -4946,6 +5400,93 @@ diff -Naur vim72/src/os_beos.rdef vim72.haiku/src/os_beos.rdef + +#endif // HAIKU_TARGET_PLATFORM_HAIKU + ++resource(1, "builtin-tools") #'PNG ' array { ++ $"89504E470D0A1A0A0000000D494844520000022E0000001208030000004BB3A5" ++ $"1200000300504C5445000000800000008000808000000080800080008080C0C0" ++ $"C0C0DCC0A6CAF0402000602000802000A02000C02000E0200000400020400040" ++ $"4000604000804000A04000C04000E04000006000206000406000606000806000" ++ $"A06000C06000E06000008000208000408000608000808000A08000C08000E080" ++ $"0000A00020A00040A00060A00080A000A0A000C0A000E0A00000C00020C00040" ++ $"C00060C00080C000A0C000C0C000E0C00000E00020E00040E00060E00080E000" ++ $"A0E000C0E000E0E000000040200040400040600040800040A00040C00040E000" ++ $"40002040202040402040602040802040A02040C02040E0204000404020404040" ++ $"4040604040804040A04040C04040E04040006040206040406040606040806040" ++ $"A06040C06040E06040008040208040408040608040808040A08040C08040E080" ++ $"4000A04020A04040A04060A04080A040A0A040C0A040E0A04000C04020C04040" ++ $"C04060C04080C040A0C040C0C040E0C04000E04020E04040E04060E04080E040" ++ $"A0E040C0E040E0E040000080200080400080600080800080A00080C00080E000" ++ $"80002080202080402080602080802080A02080C02080E0208000408020408040" ++ $"4080604080804080A04080C04080E04080006080206080406080606080806080" ++ $"A06080C06080E06080008080208080408080608080808080A08080C08080E080" ++ $"8000A08020A08040A08060A08080A080A0A080C0A080E0A08000C08020C08040" ++ $"C08060C08080C080A0C080C0C080E0C08000E08020E08040E08060E08080E080" ++ $"A0E080C0E080E0E0800000C02000C04000C06000C08000C0A000C0C000C0E000" ++ $"C00020C02020C04020C06020C08020C0A020C0C020C0E020C00040C02040C040" ++ $"40C06040C08040C0A040C0C040C0E040C00060C02060C04060C06060C08060C0" ++ $"A060C0C060C0E060C00080C02080C04080C06080C08080C0A080C0C080C0E080" ++ $"C000A0C020A0C040A0C060A0C080A0C0A0A0C0C0A0C0E0A0C000C0C020C0C040" ++ $"C0C060C0C080C0C0A0C0C0FFFBF0A0A0A4808080FF000000FF00FFFF000000FF" ++ $"FF00FF00FFFFFFFFFF58D234440000000874524E53FFFFFFFFFFFFFF00DE83BD" ++ $"59000000097048597300000B1200000B1201D2DD7EFC0000070D494441546881" ++ $"DD994B6E23390C86695880F6BDCD19BCCD3AD7CA7DB4CD197C965EE7044619D0" ++ $"F0299192AA5C9907D018762776D12A3DA8AF7E520E64B382FFB792FF004BCD4E" ++ $"DF02C1DC0717347779C3FFDB8D5F43A3705900FE8838FCDB868119C3F3E32EDA" ++ $"BB5A1897CA916A1B566CA49DED7865B2E3E930FC6397A9AAEDE232F10409EA37" ++ $"5B851A70793C020BB70C1B8CB4C436057EFFF6BCACE0BD0CAF75159D21567B6D" ++ $"B2BB9EC73AF7E89C21013E3EF03F1A4CD339BDA77E390523594BE549EA7E55DD" ++ $"E8793B68FEF332D4D3BD72BFE1B2D68D19171A87861F37ADB4163A3FEB87E6A7" ++ $"06411B06146E37D8B60D6E9E176C121A212D81976930BAE5C231A657895D5B80" ++ $"8735AE6BD5068729057FCC318FB5183DC682BB8924AC4D5AB456557F9771D647" ++ $"066E0B378A6491FD65381017DDB2793BD2674A9F64E14950CF67DFD8941D3D5D" ++ $"37DA62B1BB1B9ADFE4452BA3B3C41649D58BE6B77E58065C36B3EEC26C856D7A" ++ $"3E2A332ECFA73E3BBD53EE955F5BB8F939B3F85B749D2DDA003A0A5E546B392D" ++ $"6CE11962C1FD4412D6664C01702B990E4FA5C6591F18F4CDF1913475B1597975" ++ $"498A4BB3B632E7EA7B5F5C2E620A83C4C0ED2AFB7BBD4268157191693455129A" ++ $"BF6BD329C265918F461496EAF23219E5E7B3549977BF036FE1DFEDE9ACB2E7FB" ++ $"819736D9B76152F8C7B6B95E5AE06DA99327C682FBF9289E04B46B306D2519AB" ++ $"6480361D9A8ABDC0F291ABFE8271F916D9A849D505432FEA42D3E4965E5D1C2E" ++ $"B486CE463247C025E54159436982B898395C26759970A9BE9386CB948FC64473" ++ $"A676912AC06DFA53E5A51753C0A4D08F17730E6A734C81F7C94853BC3C8AF44B" ++ $"79A9974B5C18EE6573795C86041E49405ACAE68CC72168AEF9FAF686BF4D5DDC" ++ $"74CB98902AB8D7EA70112E0ACE076B1776DEFB7EA4BBE1B2509784893799BCA4" ++ $"76ED71416971BBCEEA623DF1B21197DB50D2840662853E2A2E19E95C2C6883BA" ++ $"A4B6DB63EDB23A19C536BCBF5E5ECAF329F2D22704C221DEE670113016C540DD" ++ $"C18576B7B0BA202CC2CB85B410F9B085F1D5E3228F00F45880CC221891A04EA1" ++ $"E55B7F181705081B15F12C71A9DC41FBC454489B414F4685D0D80A4E3F3E1789" ++ $"9FFA1D7521509ABCC89BF439E2E28B9BA82E0D97F844AD6A17E969D09F1E3448" ++ $"699EA2B0100FC9793C44E7E1B02DA50BA6A3E621655179E9B858FD32D1E11C75" ++ $"74B567B0CB0AC55B4EA37425106AFDEC1D35F2A1692DF24224E8BBB221840117" ++ $"038871F9DEC385122A83AF2E914B6B06E06B17C605E70F776760B8B45A32292E" ++ $"76D01E710907F0E1F4B4A72ECEE3594D417103762C223D688A4B5497391F9CF0" ++ $"80E1622393B290C0607CF2A1BA4CB84CAE6E8A4B257929242EF4CEE078F48599" ++ $"E712F900417117976DC3021AA9907F084703E885BA48426D5955E432F78B880B" ++ $"DD8AFEFB7BB32B182EDD64844299A74CB8D0C1903ED13594A1D47DA12E34B8B7" ++ $"D223E28F0249C5A5056DA52EAEA7AF2FEEE88C87BEA42364DCC83D40D97059D5" ++ $"2E7BC9A8F62D51EBC9A8B2C0DB01C9E8E80BEB7213F880F032E18240081C1D17" ++ $"03E8585D72FE91BA6805E6707987515D4CE9932F598637EECCC7B8F8134D5DA9" ++ $"8BC7E5F1F86A56DCF13AE022EAD282C6B844010CDC15DAFD331EE5C51FA5537D" ++ $"3C727E704A7A3ED9B53A198DA56E0FEB949F7AA92B0072F552A463CA8C7D6156" ++ $"BB0C7CF00E1EE0029BA41E4D47C8E9E6D5E5089755ED62CDD6B80CF21270F9F5" ++ $"ABE3C2E7202970F3E8695B2CEAD28AD81D7571C9E8FEF5B5C4C59BA94B0B9AE0" ++ $"1204D075F478281CAF3DB9A5A3968D522DC8CB0379C1B4C4BCACBF77C9FE201D" ++ $"4F46D666719016846C9D720CF234C8C968E443867BDBC1C578E927A306D0212E" ++ $"35984D09DCC54B5CDEF770E95FB3B883B439CCD3BE7751DD61D3A3D89EBAECE0" ++ $"32ABCB58EA46010C1D8D70EC7A7AADDB78C1D9154E095E5D2EFAAA87AAF990CC" ++ $"59B9D95E1BE0546747EA6CDFBB381AD2E4E158D02ADFDE022F0E17C9A81E5703" ++ $"E8B07681F12EF9C85D2C71C130BAEF78F670B1435083A37DABDB1D599391952F" ++ $"14BA78F0E1DD7500ADE73CE1A20F00DE2B995652909F22DC7B2784C2394FE6BF" ++ $"01683A0237985717AC5D742297A02E1185D196B8F0BBFE374DB730A561F6F458" ++ $"445E3C2E8155C65501A24612D60997D55DAE3399EF1A9769C7965B2867A0E2E2" ++ $"A31E7759F41835B4E9C7A71120F0EA02E51017BA45FF3253665C5C19AB70BCF6" ++ $"642D5B2423411F8C6B97868B8D9E5BED326AB84637E032B5E94A648AED17C634" ++ $"CC1E178B7D5C661302A891ECBE4E07E6591FD81A9781B3A5A339E749F94BFF32" ++ $"75AED701A01D71099DF832450BF94900492EBA3109273CD9FE02C03909FA6024" ++ $"912D194D339C0EC9D6CCAD7AD166F2C485312E93671150B617B88C8D86DC731A" ++ $"1767E7EEF90FEC3599BB77B416E3EAE7689CF114DBE3E262B898CB34FECE845E" ++ $"4CFAEF79764372DC201F65AC97B792C14FE6F387DBB4F83918273C6E9B866FD9" ++ $"FF17F6CF36F92F1B9E631E8B8F3FBC0000000049454E44AE426082" ++}; ++ diff -Naur vim72/src/os_unix.c vim72.haiku/src/os_unix.c --- vim72/src/os_unix.c 2009-04-19 20:53:35.000000000 +0000 +++ vim72.haiku/src/os_unix.c 2009-04-26 20:57:12.000000000 +0000 @@ -5001,7 +5542,7 @@ diff -Naur vim72/src/os_unix.c vim72.haiku/src/os_unix.c diff -Naur vim72/src/proto/gui_beos.pro vim72.haiku/src/proto/gui_beos.pro --- vim72/src/proto/gui_beos.pro 1970-01-01 00:00:00.000000000 +0000 +++ vim72.haiku/src/proto/gui_beos.pro 2009-05-04 07:23:00.000000000 +0000 -@@ -0,0 +1,80 @@ +@@ -0,0 +1,83 @@ +/* gui_beos.cc - hand crafted */ +void gui_mch_prepare __ARGS((int *argc, char **argv)); +int gui_mch_init __ARGS((void)); @@ -5082,6 +5623,9 @@ diff -Naur vim72/src/proto/gui_beos.pro vim72.haiku/src/proto/gui_beos.pro +void im_set_position __ARGS((int row, int col)); +void im_set_active __ARGS((int activate)); +int im_get_status __ARGS(()); ++ ++void gui_mch_show_toolbar __ARGS((int showit)); ++void gui_mch_set_toolbar_pos __ARGS((int x, int y, int w, int h)); diff -Naur vim72/src/proto/os_beos.pro vim72.haiku/src/proto/os_beos.pro --- vim72/src/proto/os_beos.pro 1970-01-01 00:00:00.000000000 +0000 +++ vim72.haiku/src/proto/os_beos.pro 2009-04-18 09:16:46.000000000 +0000 @@ -5193,13 +5737,16 @@ diff -Naur vim72/src/screen.c vim72.haiku/src/screen.c diff -Naur vim72/src/structs.h vim72.haiku/src/structs.h --- vim72/src/structs.h 2009-04-19 20:53:34.000000000 +0000 +++ vim72.haiku/src/structs.h 2009-04-18 09:16:47.000000000 +0000 -@@ -2239,6 +2239,10 @@ +@@ -2239,6 +2239,13 @@ HMENU submenu_id; /* If this is submenu, add children here */ HWND tearoff_handle; /* hWnd of tearoff if created */ #endif +#if FEAT_GUI_BEOS + BMenuItem *id; /* Id of menu item */ + BMenu *submenu_id; /* If this is submenu, add children here */ ++# ifdef FEAT_TOOLBAR ++ BPictureButton *button; ++# endif +#endif #ifdef FEAT_GUI_MAC /* MenuHandle id; */