From 9bc882eb893d07aded3cba2e556ab0ed755f2cbb Mon Sep 17 00:00:00 2001 From: olivieradam Date: Mon, 30 Apr 2012 12:42:17 +0000 Subject: [PATCH] BoingIconBar initial commit. By the permission of the author, Robert 'Phibrizzo' Krajcarz, and the author of the AROS port, Lukasz 'Sir_Lucas' Kucharuk and the authors of the preferences, Adam 'Adater' Terlecki and Pawel 'Stefkos' Stefanski. Source is APL licensed. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@44701 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/tools/BoingIconBar/BiB_Eng.guide | 154 +++ workbench/tools/BoingIconBar/Catalogs/bibprefs.cd | 31 + .../BoingIconBar/Catalogs/fran\303\247ais.ct" | 45 + .../tools/BoingIconBar/Catalogs/mmakefile.src | 7 + workbench/tools/BoingIconBar/ENV/Iconbar.prefs | 10 + workbench/tools/BoingIconBar/bibgfx/left | Bin 0 -> 212 bytes workbench/tools/BoingIconBar/bibgfx/middle | Bin 0 -> 146 bytes workbench/tools/BoingIconBar/bibgfx/right | Bin 0 -> 212 bytes workbench/tools/BoingIconBar/iconbar.c | 1346 ++++++++++++++++++++ workbench/tools/BoingIconBar/iconbar_prefs.c | 589 +++++++++ workbench/tools/BoingIconBar/locale.c | 58 + workbench/tools/BoingIconBar/locale.h | 23 + workbench/tools/BoingIconBar/mmakefile.src | 42 + 13 files changed, 2305 insertions(+) create mode 100644 workbench/tools/BoingIconBar/BiB_Eng.guide create mode 100644 workbench/tools/BoingIconBar/Catalogs/bibprefs.cd create mode 100644 "workbench/tools/BoingIconBar/Catalogs/fran\303\247ais.ct" create mode 100644 workbench/tools/BoingIconBar/Catalogs/mmakefile.src create mode 100644 workbench/tools/BoingIconBar/ENV/Iconbar.prefs create mode 100644 workbench/tools/BoingIconBar/bibgfx/left create mode 100644 workbench/tools/BoingIconBar/bibgfx/middle create mode 100644 workbench/tools/BoingIconBar/bibgfx/right create mode 100644 workbench/tools/BoingIconBar/iconbar.c create mode 100644 workbench/tools/BoingIconBar/iconbar_prefs.c create mode 100644 workbench/tools/BoingIconBar/locale.c create mode 100644 workbench/tools/BoingIconBar/locale.h create mode 100644 workbench/tools/BoingIconBar/mmakefile.src diff --git a/workbench/tools/BoingIconBar/BiB_Eng.guide b/workbench/tools/BoingIconBar/BiB_Eng.guide new file mode 100644 index 0000000000..a4d159405b --- /dev/null +++ b/workbench/tools/BoingIconBar/BiB_Eng.guide @@ -0,0 +1,154 @@ +@database BoingIkonBar_guide +@$VER: BIB guide 1.02 (26.04.2012) ©2012 Robert 'Phibrizzo' Krajcarz +@macro title "@{B}@{FG HighLight}" +@macro utitle "@{UB}@{FG Text}" +@node main "BoingIconsBar - description of the program" +@{jcenter} +@{title}Boing Icons Bar@{utitle} + +Version 1.02 + +@{I}This program is distributed as Freeware@{UI} +@{jleft} + + @{" What is it? " link description} + + @{" Installation " link installation} + + @{" How to operate " link configuration} + + @{" History " link history} + + @{" Author " link author} +@endnode +@node description " What is it ? " + + This program creates a toolbar with icons similar to AmiDock, + to which it can be an alternative. + It requires: + + AmigaOS 3.5+ + AmigaOS 4.x + MorphOS 2.x + AROS + + There is a separate version of a program for each system. + + Toolbar supports icon types used in: + + a) AmigaOS 3.5+ + + - plain icons (4 colours) + - MagicWB + - NewIcon + - GlowIcon 32 + - GlowIcon 256 - only with icon.library ver. 46.4.191+ + + b) AmigaOS 4.x + + - plain icons (4 colours) + - MagicWB + - NewIcon + - GlowIcon 32 + - GlowIcon 256 + - PNG - after installing additional PNG plugin + + c) MorphOS 2.x + + - PNG + + d) AROS + +@endnode +@node Installation "Installation" + + Installation of this program is very easy and it can be done manually: + + 1. Copy the settings of the program to ENVARC: and ENV: + + 2. Copy the file, suitable for your operating system, to WBStartup or + to any other place that you like and then run it from user - startup. + + 3. Copy the BiBPrefs file to Sys:Prefs + + In the "bibgfx" folder you can place three gfx files, which can be + used as a background (option): + + left - left edge of the background + middle - middle + right - right edge of the background + + You can only use file "middle", the rest is not required. + + New for AROS: gfx files are installed in SYS:System/Images/bibgfx. + +@endnode +@node configuration "How to operate and configure" +@wordwrap + After running without any parameters the program always runs hidden. + In order for it to be visible you have to go down with your mouse pointer near the middle part of the screen and wait about one second. + + After that time the toolbar with icons should appear on your screen. + The change of the levels can be done using: + + a) scroll in your mouse + b) after pressing the right mouse button and choosing the option form the menu + c) with keys; @{B}F2@{UB} - next level, @{B}F3@{UB} - previous level + + There are additional keyboard shortcuts: + + @{B}LShift + ESC @{UB}- exit program + @{B}F1@{UB} - executing REMAP function on icons to the actual colour palette + ( check AUTOREMAP parameter ) + + + Available options & parameters (valid as icon tooltypes): + + @{FG HighLight}SPACE/N/K@{FG Text} - an interval between the icons measured in pixels, default option is set to 5 pixels + + @{FG HighLight}STATIC/N/K@{FG Text} - if we want our toolbar to be visible after having been run, you have to specify this parameter with a number bigger than 0. This number informs us about the time in seconds after which the window will be displayed on the screen e.g. during the start up of the operating system. + + @{FG HighLight}AUTOREMAP/S@{FG Text} - this parameter is unavailable for MorphOS users. It can happen that the icons might be displayed inappropriately, e.g. after choosing an option from the menu of Workbench "Tools -> ResetWB". Using this parameter causes automatic remapping of icons to the actual colour palette, before displaying the toolbar. + + @{FG HighLight}BACKGROUND/S@{FG Text} - (AROS only) Displays the toolbar background images. + Images are: + SYS:Sytem/Images/bibgfx/left + SYS:Sytem/Images/bibgfx/middle + SYS:Sytem/Images/bibgfx/right + + Additionally, there is a one more parameter for MorphOS users: + + @{FG HighLight}SIZE/N/K@{FG Text} - Icon scaling. Icons will be displayed in their standard size without this parameter. Stating the number bigger than 0, causes icon scaling every 16 pixels e.g. + 1 - icons will have a size of 16 pixels + 2 - 32 pixels + 3 - 48 pixels + etc. + +@endnode +@node history "History" + + 1.0 - first public release + 1.02 - first AROS SVN release + +@endnode +@node author "Author" + + + The author of this program is: + + Robert 'Phibrizzo' Krajcarz - jgn@interia.pl + + Preferences program has been written by: + + Adam 'Adater' Terlecki + Pawel 'Stefkos' Stefanski + + English Translation has been done by: + + Lukasz 'Sir_Lucas' Kucharuk + + AROS-ification, locale by: + + Olivier Adam + +@endnode diff --git a/workbench/tools/BoingIconBar/Catalogs/bibprefs.cd b/workbench/tools/BoingIconBar/Catalogs/bibprefs.cd new file mode 100644 index 0000000000..a0c5cdbbbd --- /dev/null +++ b/workbench/tools/BoingIconBar/Catalogs/bibprefs.cd @@ -0,0 +1,31 @@ +; +MSG_APP (//) +BIBPrefs +; +MSG_DESCRIPTION (//) +BoingIconBar Preferences +; +MSG_TITLE (//) +BoingIconBar Preferences +; +MSG_DOCK (//) +\33cDock +; +MSG_ADD_DOCK (//) +Add +; +MSG_DEL_DOCK (//) +Delete +; +MSG_SAVE (//) +Save +; +MSG_PROGRAMS (//) +\33cPrograms +; +MSG_ADD_P (//) +Add program +; +MSG_DEL_P (//) +Del program +; diff --git "a/workbench/tools/BoingIconBar/Catalogs/fran\303\247ais.ct" "b/workbench/tools/BoingIconBar/Catalogs/fran\303\247ais.ct" new file mode 100644 index 0000000000..d8baafffc9 --- /dev/null +++ "b/workbench/tools/BoingIconBar/Catalogs/fran\303\247ais.ct" @@ -0,0 +1,45 @@ +## version $VER: BIBPrefs.catalog 1.0 (24.04.2012) +## language français +## codeset 0 +; +; +MSG_APP +BIBPrefs +;BIBPrefs +; +MSG_DESCRIPTION +Préférences de BoingIconBar +;BoingIconBar Preferences +; +MSG_TITLE +Préférences BoingIconBar +;BoingIconBar Preferences +; +MSG_DOCK +\33cBarre d'outils +;\33cDock +; +MSG_ADD_DOCK +Ajouter +;Add +; +MSG_DEL_DOCK +Retirer +;Delete +; +MSG_SAVE +Sauver +;Save +; +MSG_PROGRAMS +\33cProgrammes +;\33cPrograms +; +MSG_ADD_P +Ajouter +;Add program +; +MSG_DEL_P +Retirer +;Del program +; diff --git a/workbench/tools/BoingIconBar/Catalogs/mmakefile.src b/workbench/tools/BoingIconBar/Catalogs/mmakefile.src new file mode 100644 index 0000000000..b677b1919e --- /dev/null +++ b/workbench/tools/BoingIconBar/Catalogs/mmakefile.src @@ -0,0 +1,7 @@ +# Copyright © 2003, The AROS Development Team. All rights reserved. +# $Id: mmakefile.src + +include $(TOP)/config/make.cfg + +%build_catalogs mmake=workbench-prefs-iconbar-catalogs \ + name=BIBPrefs subdir=System/Prefs diff --git a/workbench/tools/BoingIconBar/ENV/Iconbar.prefs b/workbench/tools/BoingIconBar/ENV/Iconbar.prefs new file mode 100644 index 0000000000..9d78b3fec7 --- /dev/null +++ b/workbench/tools/BoingIconBar/ENV/Iconbar.prefs @@ -0,0 +1,10 @@ +BOING_PREFS +;Tools +Sys:Utilities/Multiview +SYS:System/Shell +SYS:System/SysMon +;Utils +SYS:Tools/ScreenGrabber +SYS:Tools/Commodities/Exchange +Sys:Prefs/ScreenMode +SYS:Prefs/Zune diff --git a/workbench/tools/BoingIconBar/bibgfx/left b/workbench/tools/BoingIconBar/bibgfx/left new file mode 100644 index 0000000000000000000000000000000000000000..d2e85d2a606dac05ad651e8dee646674f1b66ab2 GIT binary patch literal 212 zcwXxa@N?(olHy`uVBq!ia0vp^j6f{J!VDxcDp&S{1d4;)ofy`glX(f`7zFr)xaKo3 zG%zq^Gcc@RV3^Fn094e@z_5~mVGjetVg`mv28L}63=0_;dKefcGB9*9Ffb|DX#@3g z7I;J!Gca%qgD@k*tT_@uLG}_)Usv`!EK=NNe2jlhVt_(go-U3d9M_X?97s4&(D0Da znc*;N8^6Pe0}BppXmD&$WYl literal 0 HcwPel00001 diff --git a/workbench/tools/BoingIconBar/bibgfx/right b/workbench/tools/BoingIconBar/bibgfx/right new file mode 100644 index 0000000000000000000000000000000000000000..d2e85d2a606dac05ad651e8dee646674f1b66ab2 GIT binary patch literal 212 zcwXxa@N?(olHy`uVBq!ia0vp^j6f{J!VDxcDp&S{1d4;)ofy`glX(f`7zFr)xaKo3 zG%zq^Gcc@RV3^Fn094e@z_5~mVGjetVg`mv28L}63=0_;dKefcGB9*9Ffb|DX#@3g z7I;J!Gca%qgD@k*tT_@uLG}_)Usv`!EK=NNe2jlhVt_(go-U3d9M_X?97s4&(D0Da znc*;N8^6Pe0}BppXmD&$WYl + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SUM_ICON 200 +#define ICON_ACTIVE (1<<7) +#define SELECTED_ICON (1<<6) + +#define TEMPLATE "SPACE/N/K,STATIC/N/K,AUTOREMAP/S,BACKGROUND/S" +#define ARG_SPACE 0 +#define ARG_STATIC 1 +#define ARG_AUTOREMAP 2 +#define ARG_BACKGROUND 3 + +#define BIB_PREFS "ENV:Iconbar.prefs" + +/*****************************************************************************/ + +BOOL BiB_Exit = FALSE, + Icon_Remap = FALSE, + Bar_Background = FALSE, + PositionMenuOK = FALSE, + Image = FALSE, // <--- FIXME: "Image" seems not used at all + Window_Active = FALSE, + Window_Open = FALSE, + MenuWindow_Open = FALSE, + FirstOpening = TRUE; + +int Static = 0, + Spacing = 5, + CurrentLevel = 0, + lbm = 0, + rbm = 0; + +int WindowHeight, + WindowWidth, + ScreenHeight, + ScreenWidth, + IconWidth, + ImageWidth, + ImageHeight, // <--- FIXME: ...also: ImageWidth, ImageHeight not used at all + Position, + OldPosition, + IconCounter, + LevelCounter, + MouseIcon, + Lenght, + BeginningWindow, + EndingWindow, + Window_Max_X, + Window_Max_Y; + +char version[] = "$VER: BoingIconBar 1.02 (26.04.2012) ©2012 Robert 'Phibrizzo' Krajcarz"; + +char Background_name[256], // <-- FIXME: Background_name not used at all, + BufferList[20], // but might be interesting to implement + MovingTable[8] = {0, 4, 7, 9, 10, 9, 7, 4}; + +ULONG WindowMask = 0, + MenuMask = 0, + WindowSignal; + +IPTR args[] = {(LONG)&Spacing, (LONG)&Static, 0, 0}; + +/*****************************************************************************/ + +struct DiskObject *Icon[SUM_ICON]; + +struct Window *Window_struct, *MenuWindow_struct; // FIXME: really ugly _struct names... +struct Screen *Screen_struct; + +struct BitMap *BMP_Buffer, *BMP_DoubleBuffer; +struct RastPort RP_Buffer, RP_DoubleBuffer; + +// struct of icons + +struct Icon_Struct +{ + int Icon_Height; // icon height + int Icon_Width; // icon width + int Icon_PositionX; // X position on main window + int Icon_PositionY; // Y position on main window + int Icon_Status; // status of icon: normal or selected + BOOL Icon_OK; // everything OK with icon + char Icon_Path[255]; // name to path of icon +} Icons_Struct[SUM_ICON]; + +// struct of submenu + +struct Level_Struct +{ + char Level_Name[20]; // name submenu - level name + int Beginning; // first icon on menu + int WindowPos_X; // X position main window + int WindowPos_Y; // Y position main window +} Levels_Struct[11]; + +struct TextAttr Topaz8 = {"topaz.font",8,0,FPF_ROMFONT}; + +struct IntuiText Names = {1,0,JAM1,0,0,&Topaz8,BufferList,NULL}; + +// background pictures + +Object *picture[3]; +struct BitMap *bm[3]; + +struct Struct_BackgroundData +{ + int Width; // width + int Height; // height +} BackgroundData[3]; + + +/*****************************************************************************/ +// functions +int ReadPrefs(void); // load prefs +void LoadBackground(void); //load background pictures +void SetWindowParameters(void); // check window sizes +void Decode_IDCMP(struct IntuiMessage *KomIDCMP); // decode IDCMP main signals +void Change_State(int Reset); // change icon state +void Insert_Icon(int Tryb, int IconNumber); // draw icon +void Blink_Icon(int IconNumber); // blink the icon +BOOL OpenMainWindow(void); // open main window +void CloseMainWindow(void); // close main window +void CheckMousePosition(void); // check mouse position +void Show_Selected_Level(void); // change the submenu +void OpenMenuWindow(void); // open menu window +void CloseMenuWindow(void); // close menu window +void Decode_IDCMP2(struct IntuiMessage *KomIDCMP); // decode IDCMP menu signals +void Launch_Program(char *Program); // start the chosed program +void Settings(void); // open the prefs program +void Reload_BiB(void); // reload the BiB + + +/*****************************************************************************/ + +int main(int argc, char *argv[]) +{ + int x, outt = FALSE; + + struct IntuiMessage *KomIDCMP, KopiaIDCMP; + struct RDArgs *rda = NULL; + struct DiskObject *dob = NULL; + struct NotifyRequest *nr; + struct MsgPort *BIBport; + BOOL notification = FALSE; + BPTR out = BNULL; + int result = RETURN_OK; + + // Read arguments + if (argc) + { + // Started from Shell + if (!(rda = ReadArgs(TEMPLATE, args, NULL))) + { + PrintFault(IoErr(), argv[0]); + return RETURN_FAIL; + } + + if (args[ARG_AUTOREMAP]) Icon_Remap = TRUE; + + if (args[ARG_BACKGROUND]) Bar_Background = TRUE; + + out = Output(); + } else { + // Started from WB: Read ToolTypes + struct WBStartup *wbs=(struct WBStartup*)argv; + struct WBArg *wba=&wbs->sm_ArgList[wbs->sm_NumArgs-1]; + BPTR oldcd; + + if (!(*wba->wa_Name)) + { + return RETURN_FAIL; + } + + oldcd=CurrentDir(wba->wa_Lock); + if ((dob=GetDiskObjectNew(wba->wa_Name))) + { + char *str; + + if ((str=FindToolType(dob->do_ToolTypes, "SPACE"))) + *(ULONG*)args[ARG_SPACE]=(ULONG)atoi(str); + + if ((str=FindToolType(dob->do_ToolTypes, "STATIC"))) + *(ULONG*)args[ARG_STATIC]=(ULONG)atoi(str); + + if ((str=FindToolType(dob->do_ToolTypes, "AUTOREMAP"))) + Icon_Remap = TRUE; + if ((str=FindToolType(dob->do_ToolTypes, "BACKGROUND"))) + Bar_Background = TRUE; + } + + CurrentDir(oldcd); + outt = TRUE; + } + + if (out || outt) + { + Spacing = *(LONG*)args[ARG_SPACE]; + Static = *(LONG*)args[ARG_STATIC]; + } + + + D(bug("[IconBar] Specified options: SPACE=%d, STATIC=%d, AUTOREMAP=%d\n", Spacing, Static, Icon_Remap)); + + // Read the prefs file, fail if it doesn't exist + if(ReadPrefs()) + { + // Set notification of prefs change + if ((BIBport = CreateMsgPort())) + { + if ((nr = AllocMem(sizeof(struct NotifyRequest), MEMF_CLEAR))) + { + nr->nr_Name = BIB_PREFS; + + D(bug("[IconBar] prefs filename: %s\n",nr->nr_Name)); + + nr->nr_Flags = NRF_SEND_MESSAGE; + nr->nr_stuff.nr_Signal.nr_Task = FindTask(NULL); + nr->nr_stuff.nr_Msg.nr_Port = BIBport; + + if (StartNotify(nr) != DOSFALSE) + { + notification = TRUE; + D(bug("[IconBar] Notification started\n")); + } + } + } + if (Bar_Background) + LoadBackground(); + + if(Static) + { + Delay(Static * 50); + OpenMainWindow(); + FirstOpening = FALSE; + } + + // ---- main loop + + while (BiB_Exit==FALSE) + { + if(notification) + { + if (GetMsg(BIBport) != NULL) + { + D(bug("[IconBar] Prefs modified!\n")); + Reload_BiB(); + } + } + + if(Window_Open || MenuWindow_Open) + { + WindowSignal = Wait(WindowMask | MenuMask); + + if(WindowSignal & WindowMask) + { + while((KomIDCMP = GT_GetIMsg(Window_struct->UserPort))) + { + CopyMem(KomIDCMP, &KopiaIDCMP, sizeof(struct IntuiMessage)); + GT_ReplyIMsg(KomIDCMP); + Decode_IDCMP(&KopiaIDCMP); + } + + if(!(Static) && Window_Active == FALSE) CloseMainWindow(); + } + + if(WindowSignal & MenuMask) + { + while((KomIDCMP = GT_GetIMsg(MenuWindow_struct->UserPort))) + { + CopyMem(KomIDCMP, &KopiaIDCMP, sizeof(struct IntuiMessage)); + GT_ReplyIMsg(KomIDCMP); + Decode_IDCMP2(&KopiaIDCMP); + } + + if(MenuWindow_Open == FALSE) CloseMenuWindow(); + } + } else { + Delay(50); + CheckMousePosition(); + } + } // ---- end of main loop + + // ---- close all + CloseMainWindow(); + + for(x=0; x 20) NumChars = 20; + Icons_Struct[IconCounter].Icon_Path[19] = '\0'; + + for (x=1; x Lenght) Lenght = TextLenght; + + D(bug("[IconBar] IntuiTextLenght = %d\n", TextLenght)); + + D(bug("[IconBar] Submenu %d - %s, beginning %d\n", + LevelCounter, Levels_Struct[LevelCounter].Level_Name, Levels_Struct[LevelCounter].Beginning)); + + Levels_Struct[LevelCounter].Beginning = IconCounter; + LevelCounter++; + } else { + D(bug("[IconBar] Loading icon #%d - name: %s\n", IconCounter, Icons_Struct[IconCounter].Icon_Path)); + + if ((Icon[IconCounter] = GetIconTags(Icons_Struct[IconCounter].Icon_Path, + ICONGETA_RemapIcon, FALSE, + TAG_DONE))) + { + IconControl(Icon[IconCounter], + ICONCTRLA_GetWidth, &Icons_Struct[IconCounter].Icon_Width, + ICONCTRLA_GetHeight, &Icons_Struct[IconCounter].Icon_Height, + ICONCTRLA_SetNewIconsSupport, TRUE, + TAG_END); + + if (Icons_Struct[IconCounter].Icon_Width == 0) + { + Icons_Struct[IconCounter].Icon_Width = Icon[IconCounter]->do_Gadget.Width; + } + + if (Icons_Struct[IconCounter].Icon_Height == 0) + { + Icons_Struct[IconCounter].Icon_Height = Icon[IconCounter]->do_Gadget.Height; + } + + LayoutIcon(Icon[IconCounter], Screen_struct, NULL); + + D(bug("[IconBar] Dimension icon #%d: Widht=%d Height=%d\n", + IconCounter, Icons_Struct[IconCounter].Icon_Width, Icons_Struct[IconCounter].Icon_Height)); + + D(bug("[IconBar] Icon %d loaded\n", IconCounter)); + + Icons_Struct[IconCounter].Icon_OK = TRUE; + IconCounter++; + + if (IconCounter == SUM_ICON) break; + } else { + //FIXME: A better error handling might be added + D(bug("[IconBar] Not found icon %s.\n", Icons_Struct[IconCounter].Icon_Path)); + } + } + } + Close(Prefs); + + ScreenWidth = Screen_struct->Width; + ScreenHeight = Screen_struct->Height; + + UnlockPubScreen(NULL, Screen_struct); + + Levels_Struct[LevelCounter].Beginning = IconCounter; + + D(bug("[IconBar] Screen size: Width=%d, Height=%d\n", ScreenWidth, ScreenHeight)); + + SetWindowParameters(); + + IconCounter = Levels_Struct[1].Beginning; + WindowWidth = Levels_Struct[0].WindowPos_X; + WindowHeight = Levels_Struct[0].WindowPos_Y; + + BeginningWindow = (ScreenWidth>>1) - (WindowWidth>>1); + EndingWindow = (ScreenWidth>>1) + (WindowWidth>>1); + + CurrentLevel = 0; + + sprintf(Levels_Struct[LevelCounter].Level_Name, "Settings"); + sprintf(Names.IText, "%s", Levels_Struct[LevelCounter].Level_Name); + + TextLenght = IntuiTextLength(&Names); + + if (TextLenght > Lenght) Lenght = TextLenght; + + LevelCounter++; + + Lenght = Lenght + 10; + } else { + //FIXME: A better error handling might be added + D(bug("[IconBar] Error reading screen parameters\n")); + } + } + + return Icons_Struct[0].Icon_OK; +} + +/*****************************************************************************/ + +void LoadBackground(void) +{ + int x; + + STRPTR name[3] = + { + "SYS:System/Images/bibgfx/left" , + "SYS:System/Images/bibgfx/middle", + "SYS:System/Images/bibgfx/right" + }; + + for (x=0; x<3; x++) + { + picture[x] = NewDTObject (name[x], + DTA_GroupID, GID_PICTURE, + PDTA_Remap, TRUE, + PDTA_DestMode, PMODE_V43, + OBP_Precision, PRECISION_IMAGE, + PDTA_Screen, (ULONG)Screen_struct, + TAG_END); + + if (picture[x]) + { + D(bug("[IconBar] Loading image n. %d - name: %s\n",x,name[x])); + + DoDTMethod(picture[x], NULL, NULL, DTM_PROCLAYOUT, NULL, DTSIF_NEWSIZE); + + GetDTAttrs + ( picture[x], + PDTA_DestBitMap, (LONG)&bm[x], + DTA_NominalHoriz, (LONG)&BackgroundData[x].Width, + DTA_NominalVert, (LONG)&BackgroundData[x].Height, + TAG_END + ); + } + } +} + +/*****************************************************************************/ + +void SetWindowParameters(void) +{ + + int x, y; + + Window_Max_X = 0; + Window_Max_Y = 0; + + Icons_Struct[0].Icon_PositionX = 0; + + for (y=0; y<(LevelCounter); y++) + { + WindowHeight = 0; + WindowWidth = 0; + + IconCounter = Levels_Struct[y+1].Beginning; + + for (x=Levels_Struct[y].Beginning; x WindowHeight) + { + WindowHeight = Icons_Struct[x].Icon_Height; + } + + if (Icons_Struct[x].Icon_Width > IconWidth) + { + IconWidth = Icons_Struct[x].Icon_Width; + } + + if ((WindowWidth + Icons_Struct[x].Icon_Width + 35) > ScreenWidth) + { + D(bug("[IconBar] Exceeding the size of the screen, can't display all icons!\n")); + + IconCounter = x; + Levels_Struct[y+1].Beginning = x; + break; + } + + WindowWidth = WindowWidth + Icons_Struct[x].Icon_Width + Spacing; + + Icons_Struct[x].Icon_PositionY = 10; + + if ((x+1) != IconCounter) + { + Icons_Struct[x+1].Icon_PositionX = WindowWidth; + } + } + else break; + } + + for (x=Levels_Struct[y].Beginning; x>1) - (Icons_Struct[x].Icon_Height>>1) + 15; + } + } + + Levels_Struct[y].WindowPos_X = WindowWidth + 30; + Levels_Struct[y].WindowPos_Y = WindowHeight + 20; + + if (Levels_Struct[y].WindowPos_X > ScreenWidth) + Levels_Struct[y].WindowPos_X = WindowWidth; + + if (Window_Max_X < Levels_Struct[y].WindowPos_X) + Window_Max_X = Levels_Struct[y].WindowPos_X; + + if (Window_Max_Y < Levels_Struct[y].WindowPos_Y) + Window_Max_Y = Levels_Struct[y].WindowPos_Y; + + D(bug("[IconBar] Window size %d: S=%d, W=%d\n", y, Levels_Struct[y].WindowPos_X, Levels_Struct[y].WindowPos_Y)); + } + + D(bug("[IconBar] Maximum window size: S=%d, W=%d\n", Window_Max_X, Window_Max_Y)); + D(bug("[IconBar] Icon width: %d\n", IconWidth)); + + if((Screen_struct=LockPubScreen(NULL)) != NULL) + { + BMP_Buffer = AllocBitMap + ( + Window_Max_X, + Window_Max_Y, + GetBitMapAttr(Screen_struct->RastPort.BitMap, BMA_DEPTH), + BMF_MINPLANES | BMF_CLEAR, + Screen_struct->RastPort.BitMap + ); + + InitRastPort(&RP_Buffer); + RP_Buffer.BitMap = BMP_Buffer; + RP_Buffer.Layer = NULL; + + BMP_DoubleBuffer = AllocBitMap + ( + IconWidth + 8, + Window_Max_Y, + GetBitMapAttr(Screen_struct->RastPort.BitMap, BMA_DEPTH), + BMF_MINPLANES | BMF_CLEAR, + Screen_struct->RastPort.BitMap + ); + + InitRastPort(&RP_DoubleBuffer); + RP_DoubleBuffer.BitMap = BMP_DoubleBuffer; + RP_DoubleBuffer.Layer = NULL; + + UnlockPubScreen(NULL,Screen_struct); + } +} + +/*****************************************************************************/ + +void Decode_IDCMP(struct IntuiMessage *KomIDCMP) +{ + int x; + + // LJ: Temporary disabled mouse cases in function Decode_IDCMP + + switch (KomIDCMP->Class) + { + case IDCMP_CLOSEWINDOW: + BiB_Exit = TRUE; + break; + + case IDCMP_MOUSEMOVE: + for(MouseIcon=Levels_Struct[CurrentLevel].Beginning; MouseIconMouseX, KomIDCMP->MouseY)); + + if((ScreenHeight - Screen_struct->MouseY) > WindowHeight) + { + Window_Active = FALSE; + } + + if(KomIDCMP->MouseX > Icons_Struct[MouseIcon].Icon_PositionX && + KomIDCMP->MouseX < Icons_Struct[MouseIcon].Icon_PositionX + Icons_Struct[MouseIcon].Icon_Width && + KomIDCMP->MouseY > 0 && + KomIDCMP->MouseY < WindowHeight - 5) + { + if((Icons_Struct[MouseIcon].Icon_Status & ICON_ACTIVE) != ICON_ACTIVE) + { + for(x=Levels_Struct[CurrentLevel].Beginning; xCode) + { + case SELECTDOWN: + Icons_Struct[MouseIcon].Icon_Status = Icons_Struct[MouseIcon].Icon_Status | SELECTED_ICON; + lbm = 1; + + D(bug("[IconBar] Icon #%d\n", MouseIcon)); + break; + + case SELECTUP: + lbm = 0; + + if((Icons_Struct[MouseIcon].Icon_Status & (SELECTED_ICON | ICON_ACTIVE)) == (SELECTED_ICON | ICON_ACTIVE)) + { + Blink_Icon(MouseIcon); + + D(bug("[IconBar] Launching program function with param: %s\n", + Icons_Struct[MouseIcon].Icon_Path)); + Launch_Program(Icons_Struct[MouseIcon].Icon_Path); + + D(bug("[IconBar] Icon #%d confirmed\n", MouseIcon)); + } + + Icons_Struct[MouseIcon].Icon_Status = Icons_Struct[MouseIcon].Icon_Status & 0xBF; //10001111b + + break; + + case MENUDOWN: + rbm = 1; + OpenMenuWindow(); + break; + } + + case IDCMP_RAWKEY: + switch(KomIDCMP->Code) + { + case RAWKEY_ESCAPE: + if((KomIDCMP->Qualifier) & IEQUALIFIER_LSHIFT) + { + BiB_Exit = TRUE; + } + break; + + case RAWKEY_F1: + for(x=0; xRPort, + Icon[x], + NULL, + Icons_Struct[x].Icon_PositionX, + Icons_Struct[x].Icon_PositionY, + IDS_NORMAL, + ICONDRAWA_Frameless, TRUE, + ICONDRAWA_EraseBackground, FALSE, + TAG_DONE); + } + } + break; + + case RAWKEY_F2: + case RAWKEY_NM_WHEEL_DOWN: + CurrentLevel++; + if(CurrentLevel == (LevelCounter -1 )) CurrentLevel = 0; + Show_Selected_Level(); + break; + + case RAWKEY_F3: + case RAWKEY_NM_WHEEL_UP: + CurrentLevel--; + if(CurrentLevel < 0) CurrentLevel = LevelCounter - 2; + Show_Selected_Level(); + break; + + case RAWKEY_F4: + Settings(); + break; + } + break; + + case IDCMP_INACTIVEWINDOW: + if(rbm == 0) Window_Active = FALSE; + lbm = 0; + + if(Static) + { + for(x=Levels_Struct[CurrentLevel].Beginning; xRPort, + 0, //Icons_Struct[IconNumber].Icon_PositionX, + 0, + Icons_Struct[IconNumber].Icon_Width + 1, + WindowHeight, + 0xC0); + + DrawIconState(&RP_DoubleBuffer, //Window_struct->RPort, + Icon[IconNumber], + NULL, + 0, //Icons_Struct[IconNumber].Icon_PositionX, + Icons_Struct[IconNumber].Icon_PositionY - MovingTable[(Icons_Struct[IconNumber].Icon_Status & 0x07)], + Tryb, + ICONDRAWA_Frameless, TRUE, + ICONDRAWA_EraseBackground, FALSE, + TAG_DONE); + + BltBitMapRastPort(BMP_DoubleBuffer, + 0, + 0, + Window_struct->RPort, + Icons_Struct[IconNumber].Icon_PositionX, + 0, + Icons_Struct[IconNumber].Icon_Width + 1, + WindowHeight, + 0xC0); +} + +void Blink_Icon(int IconNumber) +{ + int x, Tryb=IDS_SELECTED; + + for(x=0; x<8; x++) + { + Insert_Icon(Tryb, IconNumber); + Delay(3); + + if(Tryb == IDS_NORMAL) Tryb = IDS_SELECTED; + else Tryb = IDS_NORMAL; + } +} + +BOOL OpenMainWindow(void) +{ + int x, y, a; + + if((Screen_struct=LockPubScreen(NULL)) != NULL) + { + BltBitMapRastPort(Screen_struct->RastPort.BitMap, + (ScreenWidth>>1) - (WindowWidth>>1), + ScreenHeight - WindowHeight, + &RP_Buffer, + 0, 0, + Window_Max_X, + Window_Max_Y, + 0xC0); + + UnlockPubScreen(NULL,Screen_struct); + } + + if(picture[0] && picture[1] && picture[2]) + { + y = WindowWidth - BackgroundData[0].Width - BackgroundData[2].Width; + a = y / BackgroundData[1].Width; + + BltBitMapRastPort(bm[0], + 0, + 0, + &RP_Buffer, + 0, + WindowHeight - BackgroundData[0].Height, + BackgroundData[0].Width, + BackgroundData[0].Height, + 0xC0); + + for(x=0; xUserPort->mp_SigBit; + + BltBitMapRastPort(BMP_Buffer, + 0, 0, + Window_struct->RPort, + 0, 0, + WindowWidth, + WindowHeight, + 0xC0); + + for(x=Levels_Struct[CurrentLevel].Beginning; xRPort, + Icon[x], + NULL, + Icons_Struct[x].Icon_PositionX, + Icons_Struct[x].Icon_PositionY, + IDS_NORMAL, + ICONDRAWA_Frameless, TRUE, + ICONDRAWA_EraseBackground, FALSE, + TAG_DONE); + } + } + } else { + D(bug("[IconBar] Can't open main toolbar window\n")); + return FALSE; + } + + Window_Open = TRUE; + Window_Active = TRUE; + + return TRUE; +} + +void CloseMainWindow(void) +{ + D(bug("[IconBar] ClosingMainWindow...\n")); + + int x; + + if(Window_struct) CloseWindow(Window_struct); + + for(x=Levels_Struct[CurrentLevel].Beginning; xMouseY)); + + if((Screen_struct->MouseY == ScreenHeight - 1) && + Window_Open == FALSE && + Screen_struct->MouseX > BeginningWindow && + Screen_struct->MouseX < EndingWindow) + { + D(bug("[IconBar] Opening the window\n")); + if(OpenMainWindow() == FALSE) + { + BiB_Exit = TRUE; + } + } + + // LJ: trying to make window active when going to very bottom of the screen + // even in static mode - but it doesn't work because this code is checked + // only in static=0 mode + + else if ((Screen_struct->MouseY == ScreenHeight - 1) && + Window_Open == TRUE && + Screen_struct->MouseX > BeginningWindow && + Screen_struct->MouseX < EndingWindow) + { + D(bug("[IconBar] You're at the very bottom! I should make this window active!\n")); + Window_Active = TRUE; + } +} + +void Show_Selected_Level(void) +{ + CloseMainWindow(); + + IconCounter = Levels_Struct[CurrentLevel+1].Beginning; + WindowWidth = Levels_Struct[CurrentLevel].WindowPos_X; + WindowHeight = Levels_Struct[CurrentLevel].WindowPos_Y; + BeginningWindow = (ScreenWidth>>1) - (WindowWidth>>1); + EndingWindow = (ScreenWidth>>1) + (WindowWidth>>1); + + //LJ: delay needed for AROS, otherwise garbage from old icons remains + Delay(10); //10 ms seems to be enough + + if(OpenMainWindow() == FALSE) + { + BiB_Exit = TRUE; + } +} + +void OpenMenuWindow(void) +{ + int x; + + if((MenuWindow_struct = OpenWindowTags(NULL, + WA_Left, Screen_struct->MouseX, + WA_Top, Screen_struct->MouseY, + WA_InnerWidth, Lenght + 1, + WA_InnerHeight, LevelCounter << 4, + WA_AutoAdjust, TRUE, + WA_ReportMouse, TRUE, + WA_Borderless, TRUE, + WA_IDCMP,IDCMP_MOUSEBUTTONS| + IDCMP_MOUSEMOVE| + IDCMP_INACTIVEWINDOW, + WA_Flags,WFLG_ACTIVATE| + WFLG_RMBTRAP| + WFLG_SMART_REFRESH, + TAG_END))) + { + MenuMask = 1 << MenuWindow_struct->UserPort->mp_SigBit; + + SetAPen(MenuWindow_struct->RPort, 1); + Move(MenuWindow_struct->RPort, Lenght, 0); + Draw(MenuWindow_struct->RPort, Lenght, LevelCounter << 4); + Draw(MenuWindow_struct->RPort, 0, LevelCounter << 4); + SetAPen(MenuWindow_struct->RPort, 2); + Draw(MenuWindow_struct->RPort, 0, 0); + Draw(MenuWindow_struct->RPort, Lenght, 0); + + SetAPen(MenuWindow_struct->RPort, 1); + Move(MenuWindow_struct->RPort, 0, (LevelCounter - 1) << 4); + Draw(MenuWindow_struct->RPort, Lenght - 1, (LevelCounter - 1) << 4); + + SetAPen(MenuWindow_struct->RPort, 2); + Move(MenuWindow_struct->RPort, 0, ((LevelCounter - 1) << 4) + 1); + Draw(MenuWindow_struct->RPort, Lenght - 1, ((LevelCounter - 1) << 4) + 1); + + for(x=0; xRPort, &Names, 5, (x << 4) + 5); + + D(bug("[IconBar] Level %d: %s\n", x, Levels_Struct[x].Level_Name)); + } + MenuWindow_Open = TRUE; + } + else D(bug("[IconBar] Can't open menu\n")); +} + +void CloseMenuWindow(void) +{ + CloseWindow(MenuWindow_struct); + MenuMask = 0; + + if(PositionMenuOK == TRUE) + { + if(Position == (LevelCounter - 1)) + { + Settings(); + } else { + CurrentLevel = Position; + Show_Selected_Level(); + } + } +} + +void Decode_IDCMP2(struct IntuiMessage *KomIDCMP) +{ + int x, kolA, kolB, dluG, x4; + + dluG = Lenght - 2; + + switch(KomIDCMP->Class) + { + case IDCMP_MOUSEMOVE: + if(MenuWindow_struct->MouseX > 0 && + MenuWindow_struct->MouseX < Lenght && + MenuWindow_struct->MouseY >0) + { + Position = MenuWindow_struct->MouseY >> 4; + } + else + { + Position = 100; + } + + if(Position != OldPosition) + { + for(x=0; xRPort, kolA); + Move(MenuWindow_struct->RPort, dluG, x4); + Draw(MenuWindow_struct->RPort, dluG, x4 + 13); + Draw(MenuWindow_struct->RPort, 2, x4 + 13); + SetAPen(MenuWindow_struct->RPort, kolB); + Draw(MenuWindow_struct->RPort, 2, x4); + Draw(MenuWindow_struct->RPort, dluG, x4); + } + + if(Position != CurrentLevel && Position != 100) + PositionMenuOK = TRUE; + else PositionMenuOK = FALSE; + + OldPosition = Position; + + D(bug("[IconBar] Menu %d, level %d\n", Position, CurrentLevel)); + } + break; + + case IDCMP_MOUSEBUTTONS: //LJ: Adding IDCMP_ seems to do the trick... + switch (KomIDCMP->Code) + { + case MENUUP: + MenuWindow_Open = FALSE; + rbm = 0; + break; + } + break; + + case IDCMP_INACTIVEWINDOW: + MenuWindow_Open = FALSE; + break; + } +} + +void Launch_Program(char *Program) +{ + BPTR oldlock; + + // Get current directory lock + oldlock = CurrentDir(NULL); + + D(bug("[IconBar] Launch_Program %s\n", Program)); + OpenWorkbenchObject(Program, TAG_DONE); + + // Go back to old directory + CurrentDir(oldlock); +} + +void Settings(void) +{ + if (!OpenWorkbenchObject("PROGDIR:BIBPrefs", TAG_DONE)) + OpenWorkbenchObject("SYS:Prefs/BIBPrefs", TAG_DONE); +} + +void Reload_BiB(void) +{ + D(bug("[IconBar] Reloading BiB...\n")); + + int x; + + if (Window_Open == TRUE) + { + D(bug("[IconBar] The Main window is open.. so let's close it...\n")); + CloseMainWindow(); + } + + for(x=0; x + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include + +#include + +#include "locale.h" + +#define CURRENT_SELECTION 23 +//#define ADD_ID 40 +//#define SAVE_ID 41 + +enum { ADD_DOCK = 40, DELETE_DOCK, ADD_PROGRAM, DELETE_PROGRAM, SAVE_PREFS, MAX }; + +#define MAX_PROGRAMS 20 +#define MAX_DOCS 10 +#define MAX_PATH 300 + +static struct DiskObject *disko; + +typedef struct dock { +char name[ 50 ]; +char programs[ MAX_PROGRAMS+1 ][ MAX_PATH ]; +}dock; + +dock docs[ MAX_DOCS ]; + +int saveSettings( char *name ); +int loadList( char *name ); + +void initTable( char *name ) +{ + int i,j; + + D(bug("[IconBarPrefs] clear table\n")); + + for( i=0 ; i < MAX_DOCS ; i++ ) + { + for( j=0; j < MAX_PROGRAMS+1 ; j++ ) + { + docs[ i ].programs[ j ][ 0 ] = 0; + } + } + + loadList( name ); +} + +void deleteTable( char *name ) +{ + int i,j; + + for( i=0 ; i < MAX_DOCS ; i++ ) + { + for( j=0; j < MAX_PROGRAMS ; j++ ) + { + docs[ i ].programs[ j ][ 0 ] = 0; + } + } +} + +/// +/// Structures + +#ifndef __MORPHOS__ +#ifndef __AROS__ +extern struct Library *SysBase; +#endif +#endif + +/// +/// Class data +BOOL running = TRUE; +int var; +Object *app, *win, *Dock, *Programs, *S_Dock; +Object* create_button(char *label, char control) +{ + Object *obj; + + obj = MUI_NewObject(MUIC_Text, + MUIA_Text_Contents, (ULONG)label, + MUIA_Text_PreParse, "\33c", + MUIA_Frame, MUIV_Frame_Button, + MUIA_Background, MUII_ButtonBack, + MUIA_Font, MUIV_Font_Button, + MUIA_InputMode, MUIV_InputMode_RelVerify, + MUIA_Text_HiChar, control, + MUIA_ControlChar, control, + MUIA_CycleChain, TRUE, + MUIA_HorizWeight, 1, + TAG_END); + + return obj; +} +Object *Baton[ MAX ]; + +/// +/// "MUIASL" +void add(void) + { + struct FileRequester *freq; + STRPTR name = NULL; + int docsE = 0, docsS = 0; + + get( Dock, MUIA_List_Entries, &docsE ); + get( Dock, MUIA_List_Active, &docsS ); + + if( docsE < 0 || docsE >= MAX_DOCS ) + { + D(bug("[IconBarPrefs] Doc not selected , cannot create_docks program!\n")); + } + + if ((freq = AllocAslRequestTags(ASL_FileRequest, TAG_END))!=NULL) + { + if (AslRequestTags(freq, + ASLFR_TitleText, _(MSG_ADD_P), + ASLFR_DoPatterns, TRUE, + ASLFR_RejectIcons, TRUE, + TAG_END)) + { + ULONG namelen = strlen(freq->fr_File) + strlen(freq->fr_Drawer) + 4; + + if ((name = AllocVec(namelen + 1, MEMF_ANY | MEMF_CLEAR))!=NULL) + { + int entries = 0; + + get( Programs, MUIA_List_Entries, &entries ); + + if( entries < MAX_PROGRAMS ) + { + strcpy( name, freq->fr_Drawer); + AddPart( name, freq->fr_File, MAX_PATH ); + DoMethod(Programs, MUIM_List_InsertSingle, name, MUIV_List_Insert_Bottom); + strcpy( docs[ docsS ].programs[ entries ], name ); + } + FreeVec( name ); + } + } + FreeAslRequest(freq); + } + return; + } +/// +/// "GUI" + + +long GUI (void) +{ + app = ApplicationObject, + MUIA_Application_Title, _(MSG_APP), + MUIA_Application_Version, (IPTR)version, + MUIA_Application_Description, _(MSG_DESCRIPTION), + MUIA_Application_Base, (IPTR)"BIBPREFS", + MUIA_Application_DiskObject, (IPTR)disko, + SubWindow, win = WindowObject, + MUIA_Window_Title, _(MSG_TITLE), + MUIA_Window_ID, (IPTR)MAKE_ID('B','I','P','8'), + MUIA_Window_SizeGadget, TRUE, + WindowContents, VGroup, + Child, HGroup, + Child, VGroup, + Child, TextObject, MUIA_Text_Contents, _(MSG_DOCK), End, + Child, Dock = ListviewObject, + MUIA_Listview_List, ListObject, + MUIA_Frame, MUIV_Frame_InputList, + MUIA_List_ConstructHook, MUIV_List_ConstructHook_String, + MUIA_List_DestructHook, MUIV_List_DestructHook_String, + End, + End, + Child, HGroup, + Child, Baton[ ADD_DOCK ] = create_button(_(MSG_ADD_DOCK),'1'), + Child, Baton[ DELETE_DOCK ] = create_button(_(MSG_DEL_DOCK),'2'), + End, + Child, S_Dock = StringObject, MUIA_String_AdvanceOnCR, TRUE,StringFrame,End, + Child, TextObject, End, + End, + Child, VGroup, + Child, TextObject, MUIA_Text_Contents, _(MSG_PROGRAMS),End, + Child, Programs = ListviewObject, + MUIA_Listview_List, ListObject, + MUIA_Frame, MUIV_Frame_InputList, + MUIA_List_ConstructHook, MUIV_List_ConstructHook_String, + MUIA_List_DestructHook, MUIV_List_DestructHook_String, + End, + End, + Child, HGroup, + Child, Baton[ ADD_PROGRAM ] = create_button(_(MSG_ADD_P),'4'), + Child, Baton[ DELETE_PROGRAM ] = create_button(_(MSG_DEL_P),'5'), + End, + Child, Baton[ SAVE_PREFS ] = create_button(_(MSG_SAVE),'3'), + End, + End, + End, + End, + End; + return (long)app; +} + +/// + +/// support functions +void load(void) +{ + int vartosc=0; + { + get(S_Dock, MUIA_String_Contents, &vartosc); + var=vartosc; + } +} + +void save(void) +{ + return; +} +/// + +///widelec + +/*nazwê doka + tablicê programów warto by³oby IMHO spi±æ w jak±¶ ³adn± strukturê*/ + +void create_docks(void) +{ + /*wrzuca doki na listê (ca³a tablica, a¿ do NULL + przy u¿yciu struktur mo¿na zamieniæ na MUIM_List_Insert_Single*/ + //DoMethod(Dock, MUIM_List_Insert, docki,-1, MUIV_List_Insert_Bottom); +} + +void change_programs(void) +{ + //DoMethod(Programs, MUIM_List_Redraw, MUIV_List_Redraw_All); /* odrysuwuje listê, nie wiem czy niezbêdne ;-) */ +} + +/// + +/// Notifications +VOID notifications (void) +{ + DoMethod (win, MUIM_Notify, MUIA_Window_CloseRequest, + MUIV_EveryTime, app, 2, MUIM_Application_ReturnID, + MUIV_Application_ReturnID_Quit); + + DoMethod (Baton[5], MUIM_Notify, MUIA_Pressed, FALSE, (LONG)app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit); + + DoMethod (Baton[ ADD_DOCK ], MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ADD_DOCK ); + + DoMethod (Baton[ DELETE_DOCK ], MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, DELETE_DOCK ); + + DoMethod (Baton[ SAVE_PREFS ], MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, SAVE_PREFS ); + + DoMethod (Baton[ ADD_PROGRAM ], MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ADD_PROGRAM ); + + DoMethod (Baton[ DELETE_PROGRAM ], MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, DELETE_PROGRAM ); + + DoMethod (Dock, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, app, 2, MUIM_Application_ReturnID, CURRENT_SELECTION); +} + +/// + +/// "MainLoop" +VOID mainloop (void) +{ + ULONG signals = 0; + + SetAttrs (win, MUIA_Window_Open, TRUE, TAG_END); + + initTable( "ENV:iconbar.prefs" ); + + while (running) + { + switch (DoMethod (app, MUIM_Application_Input, &signals)) + { + case MUIV_Application_ReturnID_Quit: + running = FALSE; + break; + + case ADD_DOCK: + { + char *ptr=NULL; + int ent=0; + + get( Dock, MUIA_List_Entries, &ent ); + + get( S_Dock, MUIA_String_Contents, &ptr ); + + if( ptr != NULL && strlen( ptr ) > 0 && ent < 11 ) + { + int i; + DoMethod(Dock, MUIM_List_InsertSingle, ptr, MUIV_List_Insert_Bottom); + strcpy( docs[ ent ].name, ptr ); + + for( i=0; i < MAX_PROGRAMS ; i++ ) + { + docs[ ent ].programs[ i ][ 0 ] = 0; + } + + nnset( Dock, MUIA_List_Active, MUIV_List_Active_Bottom ); + } + } + break; + + case DELETE_DOCK: + { + int dact=0, dent=0; + + get( Dock, MUIA_List_Active, &dact ); + get( Dock, MUIA_List_Entries, &dent ); + + if( dact >= 0 ) + { + int i; + + for( i=dact ; i < dent ; i++ ) + { + if( strlen( docs[ i+1 ].name ) > 0 ) + { + memcpy( &docs[ i ], &docs[ i+ 1 ], sizeof( dock ) ); + }else{ + docs[ i ].name[ 0 ] = 0; + } + } + + for( i=0; i < MAX_PROGRAMS ; i++ ) + { + if( docs[ dent ].programs[ i ][ 0 ] != 0 ) + { + docs[ dent ].programs[ i ][ 0 ] = 0; + } + } + DoMethod(Dock, MUIM_List_Remove, dact); + } + } + break; + + case ADD_PROGRAM: + { + add(); + } + break; + + case DELETE_PROGRAM: + { + int del=0, ent=0; + int dact=0; + + get( Dock, MUIA_List_Active, &dact ); + get( Programs, MUIA_List_Active, &del ); + get( Programs, MUIA_List_Entries, &ent ); + + if( del >= 0 ) + { + int i; + + for( i=del ; i < ent ; i++ ) + { + if( docs[ dact ].programs[ i+1 ][ 0 ] != 0 ) + { + strcpy( docs[ dact ].programs[ i ], docs[ dact ].programs[ i+1 ] ); + } else { + //FreeVec( docs[ dact ].programs[ i ] ); + docs[ dact ].programs[ i ][ 0 ] = 0; + } + } + DoMethod(Programs, MUIM_List_Remove, MUIV_List_Remove_Selected); + } + } + break; + + case SAVE_PREFS: + { + saveSettings( "ENVARC:iconbar.prefs" ); + saveSettings( "ENV:iconbar.prefs" ); + //save(); + } + break; + + case CURRENT_SELECTION: + { + LONG numer_docka = 0; + int j; + + get(Dock, MUIA_List_Active, &numer_docka); + + if( numer_docka < 0 ) + { + DoMethod(Programs, MUIM_List_Clear, 0); + break; + } + + set(Programs, MUIA_List_Quiet, TRUE); + + DoMethod(Programs, MUIM_List_Clear, 0); + + for( j=0; j < MAX_PROGRAMS ; j++ ) + { + if( docs[numer_docka].programs[ j ][ 0 ] != 0 ) + { + DoMethod(Programs, MUIM_List_InsertSingle, + docs[numer_docka].programs[ j ], MUIV_List_Insert_Bottom); // programs to launch + // D(bug("[IconBar] doc %d changed to: \n", numer_docka,docs[numer_docka].programs[ j ] )); + } + } + + set(Programs, MUIA_List_Quiet, FALSE); /*w³±cza od¶wie¿anie*/ + } + break; + } + if (running && signals) + signals = Wait(signals | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_F); + if (signals & SIGBREAKF_CTRL_C) running = FALSE; + if (signals & SIGBREAKF_CTRL_F) running = FALSE; + } + deleteTable( "ENV:iconbar.prefs" ); + + SetAttrs (win, MUIA_Window_Open, FALSE, TAG_END); + return; +} + +/// + +/// main function +int main (int argc, char **argv) +{ + static struct WBStartup *argmsg; + static struct WBArg *wb_arg; + static STRPTR cxname; + + if (argc) + { + cxname = argv[0]; + } else { + argmsg = (struct WBStartup *)argv; + wb_arg = argmsg->sm_ArgList; + cxname = wb_arg->wa_Name; + } + disko = GetDiskObject(cxname); + + if (GUI()) + { + create_docks(); + load (); + notifications (); + mainloop (); + MUI_DisposeObject (app); + } + return 0; +} +/// + +// +// encode pass +// arguments: +// pass - ptr to password string +// return 1 if ok, 0 nok +// + +// process priority, encoding password, list post local-host/host-local + +int saveSettings( char *name ) +{ + FILE *fp; + + if( ( fp = fopen( name, "wb" ) ) != NULL ) + { + int i, j; + + fprintf( fp, "BOING_PREFS\n" ); + + for( i=0 ; i < MAX_DOCS ; i++ ) + { + if( strlen( docs[ i ].name ) > 0 ) + { + fprintf( fp, ";%s\n", docs[ i ].name ); + + for( j=0; j < MAX_PROGRAMS ; j ++ ) + { + if( docs[ i ].programs[ j ][0] != 0 ) + { + fprintf(fp, "%s\n", docs[ i ].programs[ j ] ); + }else{ + break; + } + } + }else{ + break; + } + } + fclose( fp ); + } + return 1; +} + +int loadList( char *name ) +{ + FILE *fp; + int active = -1; + int entries = 0; + int line = 0; + + if( ( fp = fopen( name, "rb" ) ) != NULL ) + { + char buffer[ 500 ]; + + while( ( fgets( buffer, 300, fp) ) != NULL ) + { + buffer[ strlen( buffer ) -1 ] = 0; + + if( line == 0 ) + { + if( strncmp( buffer, "BOING_PREFS", 11 ) != 0 ) + { + D(bug("[IconBarPrefs] %s: is not BOING BAR configuration file!\n")); + break; + } + } + else + { + if( buffer[ 0 ] == ';' ) + { + active++; + strcpy( docs[ active ].name, &buffer[ 1 ] ); + entries = 0; + DoMethod(Dock, MUIM_List_InsertSingle, &buffer[ 1 ], MUIV_List_Insert_Bottom ); + D(bug("[IconBarPrefs] %s buffer\n", &buffer[ 1 ] )); + } + else + { + { + strcpy( docs[ active ].programs[ entries ], buffer ); + D(bug("[IconBarPrefs] data set %d / %d - %s\n", active, entries, docs[ active ].programs[ entries ] )); + entries++; + } + } + } + line++; + } + fclose( fp ); + } + else + { + D(bug("[IconBarPrefs] cannot open file! %s\n", name )); + } + return 1; +} +/// diff --git a/workbench/tools/BoingIconBar/locale.c b/workbench/tools/BoingIconBar/locale.c new file mode 100644 index 0000000000..92cfda27fb --- /dev/null +++ b/workbench/tools/BoingIconBar/locale.c @@ -0,0 +1,58 @@ +/* + Copyright © 1995-2006 AROS Development Team. All rights reserved. + $Id: locale.c 30792 2009-03-07 22:40:04Z neil $ +*/ + +#include +#include +#include + +#define CATCOMP_ARRAY +#include "strings.h" + +#define CATALOG_NAME "System/Prefs/BIBPrefs.catalog" +#define CATALOG_VERSION 0 + +/*** Variables **************************************************************/ +static struct Catalog *catalog; + + +/*** Functions **************************************************************/ +/* Main *********************************************************************/ +CONST_STRPTR _(ULONG id) +{ + if (LocaleBase != NULL && catalog != NULL) + { + return GetCatalogStr(catalog, id, CatCompArray[id].cca_Str); + } + else + { + return CatCompArray[id].cca_Str; + } +} + +/* Setup ********************************************************************/ +BOOL Locale_Initialize(VOID) +{ + if (LocaleBase != NULL) + { + catalog = OpenCatalog + ( + NULL, CATALOG_NAME, OC_Version, CATALOG_VERSION, TAG_DONE + ); + } + else + { + catalog = NULL; + } + + return TRUE; +} + +VOID Locale_Deinitialize(VOID) +{ + if(LocaleBase != NULL && catalog != NULL) CloseCatalog(catalog); +} + +ADD2INIT(Locale_Initialize, 90); +ADD2EXIT(Locale_Deinitialize, 90); diff --git a/workbench/tools/BoingIconBar/locale.h b/workbench/tools/BoingIconBar/locale.h new file mode 100644 index 0000000000..03c7616c5d --- /dev/null +++ b/workbench/tools/BoingIconBar/locale.h @@ -0,0 +1,23 @@ +#ifndef _LOCALE_H +#define _LOCALE_H + +/* + Copyright © 2003-2006 AROS Development Team. All rights reserved. + $Id: locale.h 30792 2009-03-07 22:40:04Z neil $ +*/ + +#include + +#define CATCOMP_NUMBERS +#include "strings.h" + +/*** Prototypes *************************************************************/ +/* Main *********************************************************************/ +STRPTR _(ULONG ID); /* Get a message, as a STRPTR */ +#define __(id) ((IPTR) _(id)) /* Get a message, as an IPTR */ + +/* Setup ********************************************************************/ +BOOL Locale_Initialize(void); +void Locale_Deinitialize(void); + +#endif /* _LOCALE_H */ diff --git a/workbench/tools/BoingIconBar/mmakefile.src b/workbench/tools/BoingIconBar/mmakefile.src new file mode 100644 index 0000000000..9d97657b56 --- /dev/null +++ b/workbench/tools/BoingIconBar/mmakefile.src @@ -0,0 +1,42 @@ +# Copyright © 2011, The AROS Development Team. All rights reserved. +# $Id: mmakefile.src + +include $(TOP)/config/make.cfg + +FILES := iconbar +PREFS := iconbar_prefs locale +CPFILES := BiB_Eng.guide +ENVFILE := Iconbar.prefs +BIBGFX := bibgfx + +USER_CFLAGS := -fno-strict-aliasing + +#MM- workbench-tools : workbench-tools-iconbar +#MM workbench-tools-iconbar : includes linklibs \ +#MM workbench-tools-iconbar-gfx \ +#MM workbench-tools-iconbar-files \ +#MM workbench-tools-iconbar-env + +#MM- workbench-prefs : workbench-prefs-iconbar +#MM workbench-prefs-iconbar : includes linklibs \ +#MM workbench-prefs-iconbar-catalogs + + +%build_prog mmake=workbench-tools-iconbar \ + progname=BoingIconBar targetdir=$(AROS_TOOLS) \ + files=$(FILES) + +%build_prog mmake=workbench-prefs-iconbar \ + progname=BIBPrefs targetdir=$(AROS_PREFS) \ + files=$(PREFS) uselibs="mui" + +%copy_dir_recursive mmake=workbench-tools-iconbar-gfx \ + src=$(BIBGFX) dst=$(AROS_IMAGES)/$(BIBGFX) + +%copy_files_q mmake=workbench-tools-iconbar-files \ + files=$(CPFILES) dst=$(AROS_HELP) + +%copy_files_q mmake=workbench-tools-iconbar-env \ + files=$(ENVFILE) src=ENV dst=$(AROS_ENVARC) + +%common -- 2.11.4.GIT