home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 6
/
AACD06.ISO
/
AACD
/
Programming
/
MUI
/
MUICusReq1_2
/
ASC
/
MUICustomRequest.ASC
< prev
Wrap
Text File
|
1999-08-16
|
9KB
|
267 lines
;
; MUI Custom Request, (C) Robert Hutchinson - Satanic Dreams Software 1999.
; Now Freeware.
;
; Use it how you want, but please leave this text-block here and send,
; any updates no matter how small to:
;
; loki@sds.in2home.co.uk
;
; Should be included when object generation starts. As:
; XINCLUDE "MUICustomRequest.BB2"
;
; And MUIObjects in the compiler set to at least 1000 :)
; Also requires, MUI2.RES (found at: http://www.satanicdreams.freeserve.co.uk)
; And EFMUILib (AmiNet).
;
; And lastly, you must open a bitmap (#4) and palette (#4) with imagery
; that this routine should use before you include it in your code.
;
; V1.0 - Initial version.
; V1.1 - Now uses imagery.
; V1.2 - Added transparency to image.
;
;--- Custom Spacing.. Change these to alter spacing between objects in
; the custom requester.
;
#MUI_SP_TopVirt = 0
#MUI_SP_BotVirt = 0
#MUI_SP_LeftHoriz = 0
#MUI_SP_RightHoriz = 5
#MUI_SP_ImageSpace = 4
;--- MUI Custom Request object tree.
;
#MUI_CusReq_Window = 950
#MUI_GP_CusReq1 = 951
#MUI_CusRHBar = 952
#MUI_GP_CusReq5 = 953
#MUI_TopRect = 954
#MUI_GP_CusReq6 = 955
#MUI_LeftRect = 956
#MUI_ImageBitmap = 957
#MUI_ImageRect = 958
#MUI_CusRText = 959
#MUI_RightRect = 960
#MUI_BotRect = 961
#MUI_GP_CusReq2 = 962
#MUI_FromButton = 963
#MUI_ToButton = 970
;--- Notifies...
;
#MUI_NT_Button1 = 2000
#MUI_NT_Button2 = 2001
#MUI_NT_Button3 = 2002
#MUI_NT_Button4 = 2003
#MUI_NT_Button5 = 2004
#MUI_NT_Button6 = 2005
#MUI_NT_Button7 = 2006
#MUI_NT_Button8 = 2007
;-####################################################################
;-# CUSTOM REQUESTER OBJECTS #
;-# #
;-# Upto 8 buttons in a requester though only! #
;-# Thats all that is allowed ATM. Sorry. #
;-####################################################################
;
MUIMakeObject #MUI_CusRHBar,#MUIO_HBar,1,0
MUIAddTags #MUI_CusRText,#MUIA_Text_Contents,Null("ABC")
MUINewObject #MUI_CusRText,"Text.mui",0
MUIAddTags #MUI_ImageBitmap,#MUIA_Bitmap_Transparent,0
MUIAddTags #MUI_ImageBitmap,#MUIA_FixWidth,#BMP_Width,#MUIA_FixHeight,#BMP_Height
MUIBitmapObject #MUI_ImageBitmap,4,4
MUIAddTags #MUI_TopRect ,#MUIA_FixHeight,#MUI_SP_TopVirt
MUINewObject #MUI_TopRect ,"Rectangle.mui",0
MUIAddTags #MUI_BotRect ,#MUIA_FixHeight,#MUI_SP_BotVirt
MUINewObject #MUI_BotRect ,"Rectangle.mui",0
MUIAddTags #MUI_LeftRect ,#MUIA_FixWidth,#MUI_SP_LeftHoriz
MUINewObject #MUI_LeftRect ,"Rectangle.mui",0
MUIAddTags #MUI_RightRect,#MUIA_FixWidth,#MUI_SP_RightHoriz
MUINewObject #MUI_RightRect,"Rectangle.mui",0
MUIAddTags #MUI_ImageRect,#MUIA_FixWidth,#MUI_SP_ImageSpace
MUINewObject #MUI_ImageRect,"Rectangle.mui",0
MUIAddObjsHGroup #MUI_GP_CusReq6,#MUI_LeftRect,#MUI_ImageBitmap,#MUI_ImageRect,#MUI_CusRText,#MUI_RightRect
MUICreateHGroup #MUI_GP_CusReq6
MUIAddObjsVGroup #MUI_GP_CusReq5,#MUI_TopRect,#MUI_GP_CusReq6,#MUI_BotRect
MUIAddTags #MUI_GP_CusReq5,#MUIA_Frame,#MUIV_Frame_Text
MUICreateVGroup #MUI_GP_CusReq5
For TMP=#MUI_FromButton To #MUI_ToButton
MUIAddTags TMP,#MUIA_Weight,100
MUISimpleButton TMP,Str$(TMP)
MUIAddObjHGroup #MUI_GP_CusReq2,TMP
Next
MUICreateHGroup #MUI_GP_CusReq2
MUIAddTags #MUI_GP_CusReq1,#MUIA_Frame,#MUIV_Frame_Button
MUIAddObjsVGroup #MUI_GP_CusReq1,#MUI_GP_CusReq5,#MUI_CusRHBar,#MUI_GP_CusReq2
MUICreateVGroup #MUI_GP_CusReq1
MUIAddTags #MUI_CusReq_Window,#MUIA_Window_SizeGadget,False
MUIAddTags #MUI_CusReq_Window,#MUIA_Window_CloseGadget,False
MUICreateWindow #MUI_CusReq_Window,Titlee$,"",#MUI_GP_CusReq1
MUIAddSubWindow #MUI_CusReq_Window
MUISet #MUI_CusReq_Window,#MUIA_Window_ID,False
;-####################################################################
;-# SPECIAL |-> TEXT <-| STRIPPER FUNCTIONS! #
;-# #
;-# Returns the text between ||`s :) #
;-# FOR EXAMPLE: #
;-# Ret$=StripValue{"Cool|Yeah|Woooo",3} #
;-# RETURNS: #
;-# Ret$="Woooo" #
;-####################################################################
;
Function.s StripValue{Strin$,GetValue}
DimLen=Len(Strin$)
For TMP=0 To DimLen+1
Strip$=Mid$(Strin$,TMP,1)
If Strip$="|" OR TMP=DimLen+1
GetValue-1
If GetValue=0
TMP-1
For A=TMP To 1 Step -1
If Done<>1
Stripp$=Mid$(Strin$,A,1)
If Stripp$<>"|"
XVal$=Stripp$+XVal$
Else
Done=1
EndIf
EndIf
Next
EndIf
EndIf
Next
Function Return XVal$
End Function
;-####################################################################
;-# FIND THE AMOUNT OF ENTRIES IN A STRING, FORMATTED: #
;-# "<text>|<text>|<text>" IE: this would be 3.. #
;-# Note: this routine doesn`t take into account 0.., #
;-# so the above WOULD return 3 not 2. #
;-####################################################################
;
Function.w FindValue{Strin$}
ArgCount.w
DimLen=Len(Strin$)
For TMP=0 To DimLen
Strip$=Mid$(Strin$,TMP,1)
If Strip$="|"
ArgCount+1
EndIf
Next
Function Return ArgCount+1
End Function
Dim ButNames$(5)
;-###################################################################
;-# SYNOPSIS: MUICustomRequest{Title$,Body$,LockObj,Buttons$} #
;-# #
;-# INPUTS: Title$ - A string containing the title of the requester #
;-# Body$ - The body of the requestor (Text in center) #
;-# LokObj - A window number to lock. Parent Window. #
;-# Passing -1 will cause no window to lock. #
;-# Buttons$ - A standard buttons text. IE, "<Text>|<Text>" #
;-# Each separated by an | or symbol #
;-# #
;-# RETURNS: 0-7 for button hits. #
;-# #
;-# INFO: This is the main routine, can be called whenever. #
;-# It opens a requester, locking it`s parent window behind it#
;-###################################################################
;
Function.w MUICustomRequest{Titlee$,Body$,LockObj,Buttons$}
SHARED ButNames$()
ReqSpacing$=" "
;--- Show all buttons by default..
;
For TMP=#MUI_FromButton To #MUI_ToButton
MUISet TMP,#MUIA_ShowMe,True
Next
NBod$=Body$ : Tity$=Titlee$ ;hehehe
;--- Get the buttons...
;
NumBut=FindValue{Buttons$}
For TMP=1 To NumBut
ButNames$(TMP-1)=StripValue{Buttons$,TMP}
Next
;--- Hide the buttons that arnt being shown
;
Var=(NumBut-1)+#MUI_FromButton
For TMP=#MUI_ToButton To #MUI_FromButton Step -1
If Var<TMP
MUISet TMP,#MUIA_ShowMe,False
EndIf
Next
;--- Set up the params...
;
MUISet #MUI_CusReq_Window,#MUIA_Window_Title,&Tity$
MUISet #MUI_CusRText,#MUIA_Text_Contents,&NBod$
For TMP=1 To NumBut
MUISet #MUI_FromButton+(TMP-1),#MUIA_Text_Contents,&ButNames$(TMP-1)
Next
;--- Put parent window to sleep.
;
If LockObj<>-1
MUISet LockObj,#MUIA_Window_Sleep,True
EndIf
;--- Open the requester window
;
MUIOpenWindow #MUI_CusReq_Window
;--- Lock in a continuous loop
;
Repeat
EV=MUIEvent
VWait
Until EV>=#MUI_NT_Button1 AND EV<=#MUI_NT_Button8
;--- Close the git :)
;
MUICloseWindow #MUI_CusReq_Window
;--- Unlock the parent window
;
If LockObj<>-1
MUISet LockObj,#MUIA_Window_Sleep,False
EndIf
;--- Return the event!
;
Function Return EV-#MUI_NT_Button1
End Function
;########################################################################