REM > BootEditCode:Click

DEF FNClick_IBar_2
PROCMenu_IconBar("IBar")
=0

DEF FNClick_IBar_4
 IF Boot_Loaded% THEN
  PROCWind_OpenC("Main")
  PROCWind_SetFocus("Main")
 ELSE
  ERROR Erro_Info%, "%DropBootHere"
 ENDIF
=1

DEF FNClick_IBar_1
=FNClick_IBar_4

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNClick_Main_Help
PROCWimp_SupplyHelp
=1

DEF FNClick_Main_Boot
PROCBoot_Scan
PROCWind_OpenC("Boot")
PROCWind_SetFocus("Boot")
IF Z% = 1 THEN PROCWind_Close("Main")
=1

DEF FNClick_Main_Resources
OSCLI("Filer_OpenDir " + Boot_Path$ + ".Resources")
=1

DEF FNClick_Main_Library
OSCLI("Filer_OpenDir " + Boot_Path$ + ".Library")
=1

DEF FNClick_Main_Utils
OSCLI("Filer_OpenDir " + Boot_Path$ + ".Utils")
=1

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNClick_Boot_Help
=FNClick_Main_Help

DEF FNClick_Boot_PreDesktop
PROCBoot_Scan
=1

DEF FNClick_Boot_PreDesk
PROCBoot_Scan
=1

DEF FNClick_Boot_Desktop
PROCBoot_Scan
=1

DEF FNClick_Boot_Tasks
PROCBoot_Scan
=1

DEF FNClick_Boot_Add
 IF Boot_Editing% = 1 OR Boot_Editing% = 3 THEN
  PROCWind_SetText("Add", "Title", "")
  PROCMenu_Window("Add")
 ELSE
  ERROR Erro_Info%, "%ToAdd"
 ENDIF
=1

DEF FNClick_Boot_Remove
PROCMenu_Window("Remove")
PROCWind_SetFocus("Remove")
=1

DEF FNClick_Boot_Edit
 CASE Boot_Editing% OF
  WHEN 1: PROCBoot_Edit("PreDesktop", 0)
  WHEN 3: PROCBoot_Edit("Desktop", 0)
 ENDCASE
=1

DEF FNClick_Boot_Open
 CASE Boot_Editing% OF
  WHEN 2: OSCLI "Filer_OpenDir " + Boot_Path$ + ".Choices.Boot.PreDesk"
  WHEN 4: OSCLI "Filer_OpenDir " + Boot_Path$ + ".Choices.Boot.Tasks"
 ENDCASE
=1

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNClick_BootPane
LOCAL List%, YPos%, Numb%

List% = FNHeap_Find(0, "BootList")
IF !List% = 0 THEN =0

SYS"Wimp_GetWindowState",, B% + 12
YPos% = (-(Y% + (B%!36 - B%!28)) / List_High%) + 1
IF YPos% > !List% THEN =0

 CASE TRUE OF

  WHEN Z% > 255
   REM click

    IF Z% = 256 THEN

     !(List% + 4 + 80 * (YPos% - 1)) = !(List% + 4 + 80 * (YPos% - 1)) EOR 1
     SYS"Wimp_ForceRedraw", W%, 0, -(YPos% * List_High%), 65536, -((YPos% - 1) * List_High%)

    ELSE

      IF (!(List% + 4 + 80 * (YPos% - 1)) AND 1) = 0 THEN

        FOR Item% = 1 TO !List%
          IF (!(List% + 4 + 80 * (Item% - 1)) AND 1) AND (Item% <> YPos%) THEN
           !(List% + 4 + 80 * (Item% - 1)) = !(List% + 4 + 80 * (Item% - 1)) AND NOT(1)
           SYS"Wimp_ForceRedraw", W%, 0, -(Item% * List_High%), 65536, -((Item% - 1) * List_High%)
          ENDIF
        NEXT

       !(List% + 4 + 80 * (YPos% - 1)) = !(List% + 4 + 80 * (YPos% - 1)) OR 1
       SYS"Wimp_ForceRedraw", W%, 0, -(YPos% * List_High%), 65536, -((YPos% - 1) * List_High%)
      ENDIF

    ENDIF

    FOR Item% = 1 TO !List%
     IF (!(List% + 4 + 80 * (Item% - 1)) AND 1) THEN Numb% += 1
    NEXT

   PROCWind_IconGrey("Boot", "Remove",  -(Numb% = 0))
   PROCWind_IconGrey("Boot", "Edit",    -((Numb% <> 1) OR (Boot_Editing% = 2) OR (Boot_Editing% = 4)))

  WHEN Z% > 15
   REM drag

    FOR Item% = 1 TO !List%
     IF (!(List% + 4 + 80 * (Item% - 1)) AND 1) THEN Numb% += 1
    NEXT

    B%!400 = X% - 18
    B%!404 = Y% - 18
    B%!408 = X% + 18
    B%!412 = Y% + 18
     IF Numb% = 1 THEN
      SYS"DragASprite_Start", %1000101, 1, List% + 4 + 80 * (YPos% - 1) + 05, B% + 400
     ELSE
      SYS"DragASprite_Start", %1000101, 1, "multifile", B% + 400
     ENDIF

  WHEN Z% = 2
   REM menu

   PROCMenu_Show("Boot", X% - 64, Y%)

  OTHERWISE
   REM double-click

    CASE Boot_Editing% OF
     WHEN 1: PROCBoot_Edit("PreDesktop", YPos%)
     WHEN 2: OSCLI("Filer_Run " + Boot_Path$ + ".Choices.Boot.PreDesk." + $(List% + 4 + 80 * (YPos% - 1) + 20))
     WHEN 3: PROCBoot_Edit("Desktop", YPos%)
     WHEN 4: OSCLI("Filer_Run " + Boot_Path$ + ".Choices.Boot.Tasks." + $(List% + 4 + 80 * (YPos% - 1) + 20))
    ENDCASE

 ENDCASE
=1

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNClick_Add_Cancel
SYS"Wimp_CreateMenu",, -1
=1

DEF FNClick_Add_OK
LOCAL File%, File$

IF FNWind_GetText("Add", "Title") = "" THEN ERROR Erro_Warn%, "%NoTitle"

IF Boot_Editing% = 1 THEN File$ = "PreDesktop" ELSE File$ = "Desktop"

File% = OPENOUT("Pipe:$." + File$)
BPUT#File%, "|Start " + FNWind_GetText("Add", "Title")
BPUT#File%, ""
BPUT#File%, "|End"
CLOSE#File%
REM  IF File$ = "PreDesktop" THEN
REM   OSCLI"SetType Pipe:$." + File$ + " FEB"
REM  ELSE
REM   OSCLI"SetType Pipe:$." + File$ + " FEA"
REM  ENDIF
OSCLI"SetType Pipe:$." + File$ + " FFF"
OSCLI"Filer_Run Pipe:$." + File$

=FNClick_Add_Cancel

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNClick_Remove_Cancel
=FNClick_Add_Cancel

DEF FNClick_Remove_Remove
 CASE Boot_Editing% OF
  WHEN 1: PROCBoot_Remove("PreDesktop")
  WHEN 2: PROCBoot_Delete("PreDesk")
  WHEN 3: PROCBoot_Remove("Desktop")
  WHEN 4: PROCBoot_Delete("Tasks")
 ENDCASE
=FNClick_Add_Cancel
