1 // News: Labeling Icons
2 // Version of BiB based on 1.0.2 68K 26.10.2013 source
3 // New features added by Phibrizzo
5 //////////////////////////////////////////////////////////////
7 // AROS PORT by LuKeJerry (at) gmail.com //
8 // -- translated to ENG from 26-09-2011 //
10 //////////////////////////////////////////////////////////////
17 #include <proto/workbench.h>
18 #include <proto/icon.h>
19 #include <proto/exec.h>
20 #include <proto/intuition.h>
21 #include <proto/graphics.h>
22 #include <proto/gadtools.h>
23 #include <proto/dos.h>
24 #include <proto/datatypes.h>
25 #include <proto/diskfont.h>
27 #include <exec/types.h>
28 #include <exec/libraries.h>
29 #include <exec/exec.h>
30 #include <workbench/icon.h>
31 #include <workbench/startup.h>
32 #include <intuition/intuition.h>
33 #include <intuition/imageclass.h>
34 #include <datatypes/datatypes.h>
35 #include <datatypes/pictureclass.h>
37 #include <devices/rawkeycodes.h>
38 #include <aros/detach.h>
43 #include <aros/debug.h>
45 // ------------------------------
48 #define ICON_ACTIVE (1<<7)
49 #define SELECTED_ICON (1<<6)
51 #define TEMPLATE "SPACE/N/K,STATIC/N/K,AUTOREMAP/S,NAMES/S"
53 // ------------------------------
57 #define ARG_AUTOREMAP 2
60 #define BIB_PREFS "ENV:Iconbar.prefs"
63 static BOOL BiB_Exit
=FALSE
, Icon_Remap
=FALSE
, PositionMenuOK
=FALSE
;
64 static BOOL Window_Active
=FALSE
, Window_Open
=FALSE
, MenuWindow_Open
=FALSE
, FirstOpening
=TRUE
;
66 static BOOL B_Labels
=FALSE
;
67 static TEXT IT_Labels
[100]; // buffer for label
71 static LONG WindowHeight
, WindowWidth
, ScreenHeight
, ScreenWidth
, IconWidth
;
72 static LONG Static
=0, Position
, OldPosition
;
73 static LONG IconCounter
, LevelCounter
, CurrentLevel
=0, lbm
=0, rbm
=0, MouseIcon
, Spacing
=5;
74 static LONG Lenght
, BeginningWindow
, EndingWindow
, Window_Max_X
, Window_Max_Y
;
75 static BYTE MovingTable
[8]={0, 4, 7, 9, 10, 9, 7, 4};
76 TEXT version
[]="$VER: BoingIconBar 1.10 (03.03.2016) by Robert 'Phibrizzo' Krajcarz - AROS port by LuKeJerry";
77 static TEXT BufferList
[20];
78 static ULONG WindowMask
=0, MenuMask
=0, WindowSignal
;
80 static IPTR args
[]={ (IPTR
)&Spacing
, (IPTR
)&Static
, 0, 0 };
82 static struct DiskObject
*Icon
[SUM_ICON
];
84 static struct Window
*MainWindow
, *MenuWindow
;
85 static struct Screen
*MyScreen
;
87 static struct BitMap
*BMP_Buffer
, *BMP_DoubleBuffer
;
88 static struct RastPort RP_Buffer
, RP_DoubleBuffer
;
92 static struct Icon_Struct
{
93 LONG Icon_Height
; // height icon
94 LONG Icon_Width
; // width icon
95 LONG Icon_PositionX
; // X position on main window
96 LONG Icon_PositionY
; // Y position on main window
97 LONG Icon_Status
; // status of icon: normal or selected
98 BOOL Icon_OK
; // everything OK with icon
99 TEXT Icon_Path
[255]; // name to path of icon
100 LONG IK_Label_Length
; // length of label under icon in chars
101 STRPTR IK_Label
; // icon label
107 static struct Level_Struct
{
108 TEXT Level_Name
[20]; // name submenu - level name
109 LONG Beginning
; // first icon on menu
110 LONG WindowPos_X
; // X position main window
111 LONG WindowPos_Y
; // Y position main window
114 // --- Define labels fonts
116 static struct TextFont
*TF_XHelvetica
;
117 //struct TextAttr XHelvetica = {"XHelvetica.font", 9, 0, FPF_DISKFONT};
118 static struct TextAttr XHelvetica
= {"arial.font", 9, 0, FPF_DISKFONT
};
120 // --------------------
122 static struct TextAttr Topaz8
= {"topaz.font",8,0,FPF_ROMFONT
};
124 static struct IntuiText Names
= {1, 0, JAM1
, 0, 0, &Topaz8
, BufferList
, NULL
};
125 static struct IntuiText Labels
= {1, 0, JAM1
, 0, 0, &XHelvetica
, IT_Labels
, NULL
};
127 // background pictures
129 static Object
*picture
[3];
130 static struct BitMap
*bm
[3];
132 static struct Struct_BackgroundData
{
134 LONG Height
; // height
140 static BOOL
ReadPrefs(void); // load prefs
141 static void LoadBackground(void); //load background pictures
142 static BOOL
SetWindowParameters(void); // check window sizes
143 static void Decode_Toolbar_IDCMP(struct IntuiMessage
*KomIDCMP
); // decode IDCMP main signals
144 static void Change_State(LONG Mode
); // change icon state
145 static void Insert_Icon(LONG Tryb
, LONG NrIcon
); // draw icon
146 static void Blink_Icon(LONG NrIcon
); // blink the icon
147 static BOOL
OpenMainWindow(void); // open main window
148 static void CloseMainWindow(void); // close main window
149 static void CheckMousePosition(void); // check mouse position
150 static void Show_Selected_Level(void); // change the submenu
151 static void OpenMenuWindow(void); // open menu window
152 static void CloseMenuWindow(void); // close menu window
153 static void Decode_Menu_IDCMP(struct IntuiMessage
*KomIDCMP
); // decode IDCMP menu signals
154 static void Launch_Program(STRPTR Program
); // start the chosed program
155 static void Settings(void); // open the prefs program
156 static void Reload(void); // reload the BiB
157 static void IconLabel(void); // add label to icon
161 int main(int argc
, char *argv
[])
163 LONG retval
= RETURN_OK
;
167 struct IntuiMessage
*KomIDCMP
,CopyIDCMP
;
168 struct RDArgs
*rda
=NULL
;
169 struct DiskObject
*dob
=NULL
;
170 struct NotifyRequest
*NotRequest
= NULL
;
171 struct MsgPort
*BIBport
= NULL
;
173 if (argc
) // reading command line parameters
175 if (!(rda
= ReadArgs(TEMPLATE
, args
, NULL
)))
177 PrintFault(IoErr(), argv
[0]);
178 retval
= RETURN_ERROR
;
182 if (args
[ARG_AUTOREMAP
])
194 Spacing
= *(LONG
*)args
[ARG_SPACE
];
197 if (args
[ARG_STATIC
])
199 Static
= *(LONG
*)args
[ARG_STATIC
];
203 { //reading ToolTypes parameters
205 struct WBStartup
*wbs
=(struct WBStartup
*)argv
;
208 if (wbs
&& wbs
->sm_NumArgs
> 0)
210 wba
= &wbs
->sm_ArgList
[0];
211 if (wba
&& wba
->wa_Lock
&& wba
->wa_Name
)
213 oldcd
=CurrentDir(wba
->wa_Lock
);
214 if ((dob
=GetDiskObjectNew(wba
->wa_Name
)))
218 if ((str
=FindToolType(dob
->do_ToolTypes
, "SPACE")))
221 if ((str
=FindToolType(dob
->do_ToolTypes
, "STATIC")))
224 if ((str
=FindToolType(dob
->do_ToolTypes
, "AUTOREMAP")))
227 if ((str
=FindToolType(dob
->do_ToolTypes
, "NAMES")))
246 Detach(); // must be done after ReadArgs()
248 D(bug("[IconBar] space %d static %d autoremap %d names %d\n", Spacing
, Static
, Icon_Remap
, B_Labels
));
250 // start notification on prefs file
251 BIBport
= CreateMsgPort();
254 NotRequest
= AllocVec(sizeof(struct NotifyRequest
), MEMF_CLEAR
);
257 NotRequest
->nr_Name
= BIB_PREFS
;
258 NotRequest
->nr_Flags
= NRF_SEND_MESSAGE
;
259 NotRequest
->nr_stuff
.nr_Msg
.nr_Port
= BIBport
;
261 if (StartNotify(NotRequest
) == DOSFALSE
)
263 printf("StartNotify failed: %ld\n", IoErr());
264 retval
= RETURN_ERROR
;
270 puts("Can't allocate NotifyRequest");
271 retval
= RETURN_ERROR
;
277 puts("Can't create MsgPort for notification");
278 retval
= RETURN_ERROR
;
282 // ------ Opening font if parameter NAMES is active
286 if((TF_XHelvetica
= OpenDiskFont(&XHelvetica
)) == NULL
)
289 puts("No Arial 9 font. Labelling disabled\n");
293 // ------------------------------
302 FirstOpening
= FALSE
;
307 while (BiB_Exit
==FALSE
)
310 if (GetMsg(BIBport
) != NULL
)
316 if(Window_Open
|| MenuWindow_Open
)
318 WindowSignal
= Wait(WindowMask
| MenuMask
);
320 if(WindowSignal
& WindowMask
)
322 while((KomIDCMP
=GT_GetIMsg(MainWindow
->UserPort
)))
324 CopyMem(KomIDCMP
,&CopyIDCMP
,sizeof(struct IntuiMessage
));
325 GT_ReplyIMsg(KomIDCMP
);
326 Decode_Toolbar_IDCMP(&CopyIDCMP
);
329 if(!(Static
) && Window_Active
== FALSE
)
333 if(WindowSignal
& MenuMask
)
335 while((KomIDCMP
=GT_GetIMsg(MenuWindow
->UserPort
)))
337 CopyMem(KomIDCMP
,&CopyIDCMP
,sizeof(struct IntuiMessage
));
338 GT_ReplyIMsg(KomIDCMP
);
339 Decode_Menu_IDCMP(&CopyIDCMP
);
342 if(MenuWindow_Open
== FALSE
)
349 CheckMousePosition();
352 // ---- end of main loop
356 printf("No prefs\n");
357 retval
= RETURN_ERROR
;
363 EndNotify(NotRequest
); // replies all pending messages
367 DeleteMsgPort(BIBport
);
369 for(x
=0; x
<SUM_ICON
; x
++)
373 FreeDiskObject(Icon
[x
]);
378 FreeBitMap(BMP_Buffer
);
380 FreeBitMap(BMP_DoubleBuffer
);
385 DisposeDTObject(picture
[x
]);
389 CloseFont(TF_XHelvetica
);
399 static BOOL
ReadPrefs(void)
402 LONG x
, LengthText
, NumberCharacters
;
404 Icons
[0].Icon_OK
= FALSE
;
409 if((Prefs
= Open(BIB_PREFS
, MODE_OLDFILE
)))
411 FGets(Prefs
, Icons
[0].Icon_Path
, 255);
413 if(strncmp(Icons
[0].Icon_Path
, "BOING_PREFS", 11) != 0)
416 puts("Prefs error\n");
420 if((MyScreen
=LockPubScreen(NULL
)))
422 while(FGets(Prefs
, Icons
[IconCounter
].Icon_Path
, 255) ) //&& IconCounter < SUM_ICON)
424 NumberCharacters
= strlen(Icons
[IconCounter
].Icon_Path
);
425 Icons
[IconCounter
].Icon_Path
[NumberCharacters
-1] = '\0';
426 if(Icons
[IconCounter
].Icon_Path
[0] == ';')
428 if(NumberCharacters
> 20)
429 NumberCharacters
= 20;
430 Icons
[IconCounter
].Icon_Path
[19] = '\0';
432 for(x
=1; x
<NumberCharacters
; x
++)
434 Levels
[LevelCounter
].Level_Name
[x
-1] = Icons
[IconCounter
].Icon_Path
[x
];
437 strcpy(BufferList
, Levels
[LevelCounter
].Level_Name
);
438 LengthText
= IntuiTextLength(&Names
);
439 if(LengthText
> Lenght
)
442 Levels
[LevelCounter
].Beginning
= IconCounter
;
447 if((Icon
[IconCounter
] = GetIconTags(Icons
[IconCounter
].Icon_Path
,
448 ICONGETA_RemapIcon
, FALSE
,
451 IconControl(Icon
[IconCounter
],
452 ICONCTRLA_GetWidth
, &Icons
[IconCounter
].Icon_Width
,
453 ICONCTRLA_GetHeight
, &Icons
[IconCounter
].Icon_Height
,
454 ICONCTRLA_SetNewIconsSupport
, TRUE
,
457 if(Icons
[IconCounter
].Icon_Width
== 0)
459 Icons
[IconCounter
].Icon_Width
= Icon
[IconCounter
]->do_Gadget
.Width
;
462 if(Icons
[IconCounter
].Icon_Height
== 0)
464 Icons
[IconCounter
].Icon_Height
= Icon
[IconCounter
]->do_Gadget
.Height
;
467 LayoutIcon(Icon
[IconCounter
], MyScreen
, NULL
);
469 // ---------------------- Extract Label from path to icon
471 Icons
[IconCounter
].IK_Label
= FilePart((Icons
[IconCounter
].Icon_Path
));
473 // --------------------------------------------------
475 Icons
[IconCounter
].Icon_OK
= TRUE
;
478 if(IconCounter
== SUM_ICON
)
482 printf("No icon %s.\n", Icons
[IconCounter
].Icon_Path
);
487 ScreenWidth
= MyScreen
->Width
;
488 ScreenHeight
= MyScreen
->Height
;
490 UnlockPubScreen(NULL
, MyScreen
);
492 Levels
[LevelCounter
].Beginning
= IconCounter
;
493 if (SetWindowParameters() == FALSE
)
495 puts("Failed to set window parameters");
499 IconCounter
= Levels
[1].Beginning
;
500 WindowWidth
= Levels
[0].WindowPos_X
;
501 WindowHeight
= Levels
[0].WindowPos_Y
;
502 BeginningWindow
= ScreenWidth
/ 2 - WindowWidth
/ 2;
503 EndingWindow
= ScreenWidth
/ 2 + WindowWidth
/ 2;
506 // add Settings menu entry
507 sprintf(Levels
[LevelCounter
].Level_Name
, _(MSG_MENU_SETTINGS
));
508 sprintf(Names
.IText
, "%s", Levels
[LevelCounter
].Level_Name
);
509 LengthText
= IntuiTextLength(&Names
);
510 if(LengthText
> Lenght
)
514 // add Quit menu entry
515 sprintf(Levels
[LevelCounter
].Level_Name
, _(MSG_MENU_QUIT
));
516 sprintf(Names
.IText
, "%s", Levels
[LevelCounter
].Level_Name
);
517 LengthText
= IntuiTextLength(&Names
);
518 if(LengthText
> Lenght
)
525 puts("Can't lock public screen");
527 return Icons
[0].Icon_OK
;
531 static void LoadBackground(void)
535 STRPTR names
[3] = {"Images:bibgfx/left",
536 "Images:bibgfx/middle",
537 "Images:bibgfx/right"};
541 picture
[x
] = NewDTObject (names
[x
],
542 DTA_GroupID
, GID_PICTURE
,
544 PDTA_DestMode
, PMODE_V43
,
545 OBP_Precision
, PRECISION_IMAGE
,
546 PDTA_Screen
, (IPTR
)MyScreen
,
551 DoDTMethod (picture
[x
], NULL
, NULL
, DTM_PROCLAYOUT
, NULL
, DTSIF_NEWSIZE
);
553 GetDTAttrs (picture
[x
],
554 PDTA_DestBitMap
, (IPTR
)&bm
[x
],
555 DTA_NominalHoriz
, (IPTR
)&BackgroundData
[x
].Width
,
556 DTA_NominalVert
, (IPTR
)&BackgroundData
[x
].Height
,
563 static BOOL
SetWindowParameters(void)
570 Icons
[0].Icon_PositionX
= 0;
572 for(y
=0; y
<(LevelCounter
); y
++)
577 IconCounter
= Levels
[y
+1].Beginning
;
579 for(x
=Levels
[y
].Beginning
; x
<IconCounter
; x
++)
583 if(Icons
[x
].Icon_Height
> WindowHeight
)
585 WindowHeight
= Icons
[x
].Icon_Height
;
588 if(Icons
[x
].Icon_Width
> IconWidth
)
590 IconWidth
= Icons
[x
].Icon_Width
;
593 // ------------- Calculate lenght of Label
595 strcpy(IT_Labels
, Icons
[x
].IK_Label
);
597 for(z
=strlen(Icons
[x
].IK_Label
); z
>1; z
--)
599 IT_Labels
[z
- 1] = '\0';
601 if(IntuiTextLength(&Labels
) < Icons
[x
].Icon_Width
)
603 Icons
[x
].IK_Label_Length
= z
;
608 // ----------------------------------------
610 if((WindowWidth
+ Icons
[x
].Icon_Width
+ 35) > ScreenWidth
)
613 Levels
[y
+1].Beginning
= x
;
617 WindowWidth
= WindowWidth
+ Icons
[x
].Icon_Width
+ Spacing
;
618 Icons
[x
].Icon_PositionY
= 10;
620 if((x
+1) != IconCounter
)
622 Icons
[x
+1].Icon_PositionX
= WindowWidth
;
629 for(x
=Levels
[y
].Beginning
; x
<IconCounter
; x
++)
633 Icons
[x
].Icon_PositionX
= Icons
[x
].Icon_PositionX
+ 15;
634 Icons
[x
].Icon_PositionY
= WindowHeight
/ 2 - Icons
[x
].Icon_Height
/ 2 + 15;
638 Levels
[y
].WindowPos_X
= WindowWidth
+ 30;
639 Levels
[y
].WindowPos_Y
= WindowHeight
+ 20;
641 // ------------- Up the icon if labeling is ON
645 Levels
[y
].WindowPos_Y
= Levels
[y
].WindowPos_Y
+ 10;
648 // ----------------------------------
650 if(Levels
[y
].WindowPos_X
> ScreenWidth
)
651 Levels
[y
].WindowPos_X
= WindowWidth
;
653 if(Window_Max_X
< Levels
[y
].WindowPos_X
)
654 Window_Max_X
= Levels
[y
].WindowPos_X
;
656 if(Window_Max_Y
< Levels
[y
].WindowPos_Y
)
657 Window_Max_Y
= Levels
[y
].WindowPos_Y
;
660 if((MyScreen
=LockPubScreen(NULL
)))
662 BMP_Buffer
= AllocBitMap(Window_Max_X
,
664 GetBitMapAttr(MyScreen
->RastPort
.BitMap
,
666 BMF_MINPLANES
|BMF_CLEAR
,
667 MyScreen
->RastPort
.BitMap
);
669 if (BMP_Buffer
== NULL
)
674 InitRastPort(&RP_Buffer
);
675 RP_Buffer
.BitMap
= BMP_Buffer
;
676 RP_Buffer
.Layer
= NULL
;
678 BMP_DoubleBuffer
= AllocBitMap(IconWidth
+ 8,
680 GetBitMapAttr(MyScreen
->RastPort
.BitMap
,
682 BMF_MINPLANES
|BMF_CLEAR
,
683 MyScreen
->RastPort
.BitMap
);
684 if (BMP_DoubleBuffer
== NULL
)
689 InitRastPort(&RP_DoubleBuffer
);
690 RP_DoubleBuffer
.BitMap
= BMP_DoubleBuffer
;
691 RP_DoubleBuffer
.Layer
= NULL
;
693 UnlockPubScreen(NULL
,MyScreen
);
699 static void Decode_Toolbar_IDCMP(struct IntuiMessage
*KomIDCMP
)
703 switch(KomIDCMP
->Class
)
705 case IDCMP_CLOSEWINDOW
:
709 case IDCMP_MOUSEMOVE
:
710 for(MouseIcon
=Levels
[CurrentLevel
].Beginning
; MouseIcon
<IconCounter
; MouseIcon
++)
712 if(Icons
[MouseIcon
].Icon_OK
)
715 if((ScreenHeight
- MyScreen
->MouseY
) > WindowHeight
)
717 Window_Active
= FALSE
;
720 if(KomIDCMP
->MouseX
> Icons
[MouseIcon
].Icon_PositionX
&&
721 KomIDCMP
->MouseX
< Icons
[MouseIcon
].Icon_PositionX
+ Icons
[MouseIcon
].Icon_Width
&&
722 KomIDCMP
->MouseY
> 0 &&
723 KomIDCMP
->MouseY
< WindowHeight
- 5)
725 if((Icons
[MouseIcon
].Icon_Status
& ICON_ACTIVE
) != ICON_ACTIVE
)
727 for(x
=Levels
[CurrentLevel
].Beginning
; x
<IconCounter
; x
++)
729 Icons
[x
].Icon_Status
= Icons
[x
].Icon_Status
& 0x07;
732 Icons
[MouseIcon
].Icon_Status
= ICON_ACTIVE
| (SELECTED_ICON
* lbm
);
736 Icons
[MouseIcon
].Icon_Status
= Icons
[MouseIcon
].Icon_Status
& 0x07;
742 case IDCMP_MOUSEBUTTONS
:
743 switch (KomIDCMP
->Code
)
746 Icons
[MouseIcon
].Icon_Status
= Icons
[MouseIcon
].Icon_Status
| SELECTED_ICON
;
754 if((Icons
[MouseIcon
].Icon_Status
& (SELECTED_ICON
| ICON_ACTIVE
)) == (SELECTED_ICON
| ICON_ACTIVE
))
756 Blink_Icon(MouseIcon
);
757 Launch_Program(Icons
[MouseIcon
].Icon_Path
);
760 Icons
[MouseIcon
].Icon_Status
= Icons
[MouseIcon
].Icon_Status
& 0xBF; //10001111b
773 switch(KomIDCMP
->Code
)
776 if((KomIDCMP
->Qualifier
) & IEQUALIFIER_LSHIFT
)
783 for(x
=0; x
<SUM_ICON
; x
++)
793 for(x
=Levels
[CurrentLevel
].Beginning
; x
<IconCounter
; x
++)
797 DrawIconState(MainWindow
->RPort
,
800 Icons
[x
].Icon_PositionX
,
801 Icons
[x
].Icon_PositionY
,
803 ICONDRAWA_Frameless
, TRUE
,
804 ICONDRAWA_EraseBackground
, FALSE
,
811 case RAWKEY_NM_WHEEL_DOWN
:
813 if(CurrentLevel
== (LevelCounter
- 2 ))
815 Show_Selected_Level();
819 case RAWKEY_NM_WHEEL_UP
:
822 CurrentLevel
= LevelCounter
- 3;
823 Show_Selected_Level();
832 case IDCMP_INACTIVEWINDOW
:
834 Window_Active
= FALSE
;
839 for(x
=Levels
[CurrentLevel
].Beginning
; x
<IconCounter
; x
++)
841 if(Icons
[x
].Icon_Status
!= 0)
843 Icons
[x
].Icon_Status
= 0;
844 Insert_Icon(IDS_NORMAL
, x
);
850 case IDCMP_INTUITICKS
:
857 static void Change_State(LONG Mode
)
861 for(x
=Levels
[CurrentLevel
].Beginning
; x
<IconCounter
; x
++)
865 if(Icons
[x
].Icon_Status
!= 0)
869 if((Icons
[x
].Icon_Status
& ICON_ACTIVE
) == 0 && Icons
[x
].Icon_Status
< 4)
871 Icons
[x
].Icon_Status
= (Icons
[x
].Icon_Status
- 1) & 0xC7; // 11000111b
875 Icons
[x
].Icon_Status
= (Icons
[x
].Icon_Status
+ 1) & 0xC7;
880 Icons
[x
].Icon_Status
= 0;
883 Insert_Icon((Icons
[x
].Icon_Status
& SELECTED_ICON
) ? IDS_SELECTED
: IDS_NORMAL
, x
);
890 static void Insert_Icon(LONG Mode
, LONG NrIcon
)
892 BltBitMapRastPort(BMP_Buffer
,
893 Icons
[NrIcon
].Icon_PositionX
,
898 Icons
[NrIcon
].Icon_Width
+ 1,
902 DrawIconState(&RP_DoubleBuffer
,
906 Icons
[NrIcon
].Icon_PositionY
- MovingTable
[(Icons
[NrIcon
].Icon_Status
& 0x07)],
908 ICONDRAWA_Frameless
, TRUE
,
909 ICONDRAWA_EraseBackground
, FALSE
,
912 BltBitMapRastPort(BMP_DoubleBuffer
,
916 Icons
[NrIcon
].Icon_PositionX
,
918 Icons
[NrIcon
].Icon_Width
+ 1,
924 static void Blink_Icon(LONG NrIcon
)
926 LONG x
, Mode
=IDS_SELECTED
;
930 Insert_Icon(Mode
, NrIcon
);
933 if(Mode
== IDS_NORMAL
)
941 static BOOL
OpenMainWindow(void)
945 if((MyScreen
=LockPubScreen(NULL
)))
947 BltBitMapRastPort(MyScreen
->RastPort
.BitMap
,
948 ScreenWidth
/ 2 - WindowWidth
/ 2,
949 ScreenHeight
- WindowHeight
,
956 UnlockPubScreen(NULL
,MyScreen
);
959 if(picture
[0] && picture
[1] && picture
[2])
961 y
= WindowWidth
- BackgroundData
[0].Width
- BackgroundData
[2].Width
;
962 a
= y
/ BackgroundData
[1].Width
;
964 BltBitMapRastPort(bm
[0],
969 WindowHeight
- BackgroundData
[0].Height
,
970 BackgroundData
[0].Width
,
971 BackgroundData
[0].Height
,
976 BltBitMapRastPort(bm
[1],
980 BackgroundData
[0].Width
+ x
* BackgroundData
[1].Width
,
981 WindowHeight
- BackgroundData
[1].Height
,
982 BackgroundData
[1].Width
,
983 BackgroundData
[1].Height
,
987 BltBitMapRastPort(bm
[1],
991 BackgroundData
[0].Width
+ x
* BackgroundData
[1].Width
,
992 WindowHeight
- BackgroundData
[1].Height
,
993 y
- BackgroundData
[1].Width
* a
,
994 BackgroundData
[1].Height
,
997 BltBitMapRastPort(bm
[2],
1001 WindowWidth
- BackgroundData
[2].Width
,
1002 WindowHeight
- BackgroundData
[2].Height
,
1003 BackgroundData
[2].Width
,
1004 BackgroundData
[2].Height
,
1009 for(x
=0; x
<WindowWidth
; x
=x
+BackgroundData
[1].Width
)
1011 BltBitMapRastPort(bm
[1],
1016 WindowHeight
- BackgroundData
[1].Height
,
1017 BackgroundData
[1].Width
,
1018 BackgroundData
[1].Height
,
1023 // ---------- Labeling icon if NAMES is ON
1024 if(B_Labels
== TRUE
)
1027 if(Icon_Remap
== TRUE
)
1029 for(x
=Levels
[CurrentLevel
].Beginning
; x
<IconCounter
; x
++)
1033 LayoutIcon(Icon
[x
], MyScreen
, NULL
);
1038 if((MainWindow
=OpenWindowTags(NULL
,
1039 WA_Left
, BeginningWindow
,
1040 WA_Top
, ScreenHeight
- WindowHeight
,
1041 WA_InnerWidth
, WindowWidth
,
1042 WA_InnerHeight
, WindowHeight
,
1043 WA_ReportMouse
, TRUE
,
1045 WA_Borderless
, TRUE
,
1046 WA_SizeGadget
, FALSE
,
1047 WA_Activate
, ((FirstOpening
&& Static
) ? FALSE
: TRUE
),
1048 WA_PubScreenName
, NULL
,
1049 WA_BackFill
, LAYERS_NOBACKFILL
,
1050 WA_Flags
, WFLG_NOCAREREFRESH
|
1053 WA_IDCMP
, IDCMP_NEWSIZE
|
1055 IDCMP_INACTIVEWINDOW
|
1061 WindowMask
= 1 << MainWindow
->UserPort
->mp_SigBit
;
1063 BltBitMapRastPort(BMP_Buffer
,
1071 for(x
=Levels
[CurrentLevel
].Beginning
; x
<IconCounter
; x
++)
1075 DrawIconState(MainWindow
->RPort
,
1078 Icons
[x
].Icon_PositionX
,
1079 Icons
[x
].Icon_PositionY
,
1081 ICONDRAWA_Frameless
, TRUE
,
1082 ICONDRAWA_EraseBackground
, FALSE
,
1089 printf("Can't open main toolbar window\n");
1094 Window_Active
= TRUE
;
1100 static void CloseMainWindow(void)
1104 CloseWindow(MainWindow
);
1105 for(x
=Levels
[CurrentLevel
].Beginning
; x
<IconCounter
; x
++)
1107 Icons
[x
].Icon_Status
= 0;
1110 Window_Open
= FALSE
;
1115 static void CheckMousePosition(void)
1117 if((MyScreen
->MouseY
> ScreenHeight
- 8) &&
1118 Window_Open
== FALSE
&&
1119 MyScreen
->MouseX
> BeginningWindow
&&
1120 MyScreen
->MouseX
< EndingWindow
)
1122 if(OpenMainWindow() == FALSE
)
1128 // LJ: trying to make window active when going to very bottom of the screen
1129 // even in static mode - but it doesn't work because this code is checked
1130 // only in static=0 mode
1133 if ((MyScreen
->MouseY
> ScreenHeight
- 8) &&
1134 Window_Open
== TRUE
&&
1135 MyScreen
->MouseX
> BeginningWindow
&&
1136 MyScreen
->MouseX
< EndingWindow
)
1138 printf("LJ: You're at the very bottom! I should make this window active!\n");
1139 Window_Active
= TRUE
;
1144 static void Show_Selected_Level(void)
1148 IconCounter
= Levels
[CurrentLevel
+1].Beginning
;
1149 WindowWidth
= Levels
[CurrentLevel
].WindowPos_X
;
1150 WindowHeight
= Levels
[CurrentLevel
].WindowPos_Y
;
1151 BeginningWindow
= ScreenWidth
/ 2 - WindowWidth
/ 2;
1152 EndingWindow
= ScreenWidth
/ 2 + WindowWidth
/ 2;
1154 //LJ: delay needed for AROS, otherwise garbage from old icons remains
1155 Delay(10); // 200 ms seems to be enough
1157 if(OpenMainWindow() == FALSE
)
1164 static void OpenMenuWindow(void)
1168 if((MenuWindow
= OpenWindowTags(NULL
,
1169 WA_Left
, MyScreen
->MouseX
,
1170 WA_Top
, MyScreen
->MouseY
,
1171 WA_InnerWidth
, Lenght
+ 1,
1172 WA_InnerHeight
, LevelCounter
* 16,
1173 WA_AutoAdjust
, TRUE
,
1174 WA_ReportMouse
, TRUE
,
1175 WA_Borderless
, TRUE
,
1176 WA_IDCMP
,IDCMP_MOUSEBUTTONS
|
1178 IDCMP_INACTIVEWINDOW
,
1179 WA_Flags
,WFLG_ACTIVATE
|
1184 MenuMask
= 1 << MenuWindow
->UserPort
->mp_SigBit
;
1186 SetAPen(MenuWindow
->RPort
, 1);
1187 Move(MenuWindow
->RPort
, Lenght
, 0);
1188 Draw(MenuWindow
->RPort
, Lenght
, LevelCounter
* 16);
1189 Draw(MenuWindow
->RPort
, 0, LevelCounter
* 16);
1190 SetAPen(MenuWindow
->RPort
, 2);
1191 Draw(MenuWindow
->RPort
, 0, 0);
1192 Draw(MenuWindow
->RPort
, Lenght
, 0);
1195 SetAPen(MenuWindow
->RPort
, 1);
1196 Move(MenuWindow
->RPort
, 0, (LevelCounter
- 2) * 16);
1197 Draw(MenuWindow
->RPort
, Lenght
- 1, (LevelCounter
- 2) * 16);
1199 SetAPen(MenuWindow
->RPort
, 2);
1200 Move(MenuWindow
->RPort
, 0, ((LevelCounter
- 2) * 16) + 1);
1201 Draw(MenuWindow
->RPort
, Lenght
- 1, ((LevelCounter
- 2) * 16) + 1);
1203 for(x
=0; x
<LevelCounter
; x
++)
1205 if(x
== CurrentLevel
)
1210 strcpy(BufferList
, Levels
[x
].Level_Name
);
1212 PrintIText(MenuWindow
->RPort
,
1217 MenuWindow_Open
= TRUE
;
1220 printf("Can't open menu\n");
1224 static void CloseMenuWindow(void)
1226 CloseWindow(MenuWindow
);
1229 if(PositionMenuOK
== TRUE
)
1231 if(Position
== (LevelCounter
- 1))
1235 else if(Position
== (LevelCounter
- 2))
1241 CurrentLevel
= Position
;
1242 Show_Selected_Level();
1248 static void Decode_Menu_IDCMP(struct IntuiMessage
*KomIDCMP
)
1250 LONG x
, kolA
, kolB
, dluG
, x4
;
1254 switch(KomIDCMP
->Class
)
1256 case IDCMP_MOUSEMOVE
:
1257 if(MenuWindow
->MouseX
> 0 &&
1258 MenuWindow
->MouseX
< Lenght
&&
1259 MenuWindow
->MouseY
>0)
1261 Position
= MenuWindow
->MouseY
/ 16;
1268 if(Position
!= OldPosition
)
1270 for(x
=0; x
<LevelCounter
; x
++)
1285 SetAPen(MenuWindow
->RPort
, kolA
);
1286 Move(MenuWindow
->RPort
, dluG
, x4
);
1287 Draw(MenuWindow
->RPort
, dluG
, x4
+ 13);
1288 Draw(MenuWindow
->RPort
, 2, x4
+ 13);
1289 SetAPen(MenuWindow
->RPort
, kolB
);
1290 Draw(MenuWindow
->RPort
, 2, x4
);
1291 Draw(MenuWindow
->RPort
, dluG
, x4
);
1294 if(Position
!= CurrentLevel
&& Position
!= 100)
1295 PositionMenuOK
= TRUE
;
1297 PositionMenuOK
= FALSE
;
1299 OldPosition
= Position
;
1304 case IDCMP_MOUSEBUTTONS
:
1305 switch (KomIDCMP
->Code
)
1308 MenuWindow_Open
= FALSE
;
1314 case IDCMP_INACTIVEWINDOW
:
1315 MenuWindow_Open
= FALSE
;
1321 static void Launch_Program(STRPTR Program
)
1325 // Get current directory lock
1326 oldlock
= CurrentDir(NULL
);
1328 OpenWorkbenchObject(Program
, TAG_DONE
);
1330 // Go back to old directory
1331 CurrentDir(oldlock
);
1335 static void Settings(void)
1337 OpenWorkbenchObject("SYS:Prefs/BoingIconBar", TAG_DONE
);
1341 static void Reload(void)
1345 if (Window_Open
== TRUE
)
1350 for(x
=0; x
<SUM_ICON
; x
++)
1354 FreeDiskObject(Icon
[x
]);
1357 Icons
[x
].Icon_Height
= 0;
1358 Icons
[x
].Icon_Width
= 0;
1359 Icons
[x
].Icon_PositionX
= 0;
1360 Icons
[x
].Icon_PositionY
= 0;
1364 FreeBitMap(BMP_Buffer
);
1365 if(BMP_DoubleBuffer
)
1366 FreeBitMap(BMP_DoubleBuffer
);
1368 if(ReadPrefs() == FALSE
)
1370 puts("Prefs error\n");
1378 FirstOpening
= FALSE
;
1383 static void IconLabel(void)
1387 for(x
=Levels
[CurrentLevel
].Beginning
; x
<IconCounter
; x
++)
1389 for(y
=0; y
<Icons
[x
].IK_Label_Length
; y
++)
1391 IT_Labels
[y
] = Icons
[x
].IK_Label
[y
];
1394 IT_Labels
[y
] = '\0';
1396 pos_x
= Icons
[x
].Icon_PositionX
+ Icons
[x
].Icon_Width
/ 2 - IntuiTextLength(&Labels
) / 2;
1398 Labels
.FrontPen
= 1;
1400 PrintIText(&RP_Buffer
,
1405 Labels
.FrontPen
= 2;
1407 PrintIText(&RP_Buffer
,