home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
d
/
drawedit
/
!DrawEdit
/
Source61
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1997-03-05
|
22KB
|
756 lines
*****************************************************************
* Initiallisation code *
*****************************************************************
!version$="1.61 (05-Mar-1997)"
"Wimp_Initialise",200,&4B534154,"DrawEdit"
riscos%,myid%
_Heap_Initialise
6stack% =
_Heap_Claim(4) :
this is the main stack
unloaded%=
Block% 256
Iiconbar_icon%=
_Icon_Create(-1,0,0,88,68,%10000000000010,"!DrawEdit")
_ErrorHandler
"MenuUtil_Initialise",010,0
_TemplatesLoad
_Menu_CreateMain
_ScreenReadSize
n%=-4
_Icon_Write(info%,7,version$)
*****************************************************************
* Wimp Poll *
*****************************************************************
"Wimp_Poll",,Block%
reason%
reason%
)
2 :
"Wimp_OpenWindow",,Block%
!*
3 :
"Wimp_CloseWindow",,Block%
"7
6 :
_MouseClick(Block%!12,Block%!16,Block%!8)
#>
7 :
_DragBoxEnd(
_Icon_Read(save%,0)) :
End of drag
$6
8 :
_KeyPressed(Block%!0,Block%!4,Block%!24)
9 :
_Menu_Decode
&$
17,18,19:
_Message_Receive
*****************************************************************
* Menu definitions *
*****************************************************************
_Menu_CreateMain
"MenuUtil_New",,"DrawEdit"
menu_iconbar%
1!
"MenuUtil_Add",,"Info"
2&
"MenuUtil_SubMenu",,info%
"MenuUtil_Dots",,
4'
"MenuUtil_Add",,"Quit","Quit"
"MenuUtil_New",,"DrawEdit"
menu_window%
7
"MenuUtil_Add",,"Info"
8&
"MenuUtil_SubMenu",,info%
95
"MenuUtil_Add",,"Save
","Save"
menu_save%
:&
"MenuUtil_SubMenu",,save%
;'
"MenuUtil_Fade",,unloaded%
_Menu_Decode
handler$,handler%,adjust%
"MenuUtil_Decode",,Block%
handler%,adjust%
handler$=$handler%
handler$
C"
"Quit" :
_CloseDown
D1
"Save" :
_Window_Open(save%,-1,-1)
adjust%
"MenuUtil_Show"
*****************************************************************
* Template definitions *
*****************************************************************
_TemplatesLoad
Version 1.48
template_Block% 6000
make sure maxws% is large enough for all icons
Q/maxws%=6204:
ws% maxws%:curws%=ws%
"Wimp_OpenTemplate",,"<DrawEdit$Dir>.Templates"
"Wimp_LoadTemplate",,template_Block%,ws%,ws%+maxws%,-1,"info",0
,,curws%
"Wimp_CreateWindow",,template_Block%
info%
"Wimp_LoadTemplate",,template_Block%,curws%,ws%+maxws%,-1,"save",0
,,curws%
"Wimp_CreateWindow",,template_Block%
save%
"Wimp_LoadTemplate",,template_Block%,curws%,ws%+maxws%,-1,"options",0
,,curws%
"Wimp_CreateWindow",,template_Block%
main%
"Wimp_CloseTemplate"
*****************************************************************
* Mouse actions *
*****************************************************************
_MouseClick(window%,icon%,button%)
window_height%
window%=-2
icon%=iconbar_icon%
button%
d6
"MenuUtil_Show",menu_iconbar%,Block%
e)
_Window_Open(main%,-1,-1)
window%
save%
icon%
mB
1 :
_DragSave(save%) :
Start drag operation
main%
button%
r:
2 :
"MenuUtil_Show",menu_window%,Block%
*****************************************************************
* Actions when message is received from the WIMP *
*****************************************************************
_Message_Receive
Version 1.58
Block%!16
0 :
_CloseDown
1 :
_Message_Data_Save
2 :
_Message_AcknowlegeSave
3 :
_Message_LoadOpen(Block%)
10 :
_Message_DesktopSave(Block%!20)
&502 :
_HelpDefinitions
&400C2 :
_Message_NewTask
&400CC :
_Window_Iconise
_Message_Data_Save
)Block%!0=(48+
("<Wimp$Scrap> "))
Block%!12=Block%!8
"Block%!16=2 :
DataSaveAck
$(Block%+44)="<Wimp$Scrap>"
"Wimp_SendMessage",17,Block%,Block%!4
_Message_NewTask
newtaskid%=Block%!4
/newtask$=
_Convert_BlockToString(Block%+28)
newtask$="DrawEdit"
newtaskid%<>myid%
_CloseDown
_Message_LoadOpen(Block%)
Block%!40
&AFF
_Drawfile_Load(
_Convert_BlockToString(Block%+44)) :
loads the file
_Window_Open(main%,-1,-1)
2002,""
_CloseDown
Version 1.64
"Wimp_CloseDown"
_Message_DesktopSave(file%)
Block%!12=Block%!8:
"Wimp_SendMessage",19,Block%,Block%!4:
The above line acknowledges the message if an error occurs, thereby
aborting the desktop save.
#file%,"Run <DrawEdit$Dir>.!RunImage"
_Message_AcknowlegeSave
Version 1.61
pathname$
0pathname$=
_Convert_BlockToString(Block%+44)
_Icon_Write(save%,0,pathname$)
_Drawfile_Save(pathname$)
Block%!0=40+
pathname$+4
Block%!0+=4-(Block%!0
$Block%!16=3 :
Message_DataLoad
Block%!36=0
Block%!40=&FF8
$(Block%+44)=pathname$+
"Wimp_SendMessage",18,Block%,senderwindow%,sendericon%
*****************************************************************
* Error Handling *
*****************************************************************
_ErrorHandler
sel%
"Wimp_DragBox",,-1
error$=
2001 : error$="Could not extend block."+" at Line "+
2002 : error$="This File type ("+
~Block%!40+") cannot be handled by DrawEdit."
2003 : error$=file$+" is too long to be handled by DrawEdit or Draw. Split it up, and reload it.":
#file%
2004 : error$="The concatenated data is too long to be handled by DrawEdit or Draw. Split it up, and reload it.":
#file%
: error$="Error "+
)+" at Line "+
)+": "+
!Block%=
:$(Block%+4)=error$
"Wimp_ReportError",Block%,%10011,"DrawEdit"
,sel%
sel%=2
_CloseDown
*****************************************************************
* Drag routines *
*****************************************************************
_DragSave(window%)
Version 1.60
LOCAL offset_x%,offset_y%
!Block%=window%
"Wimp_GetWindowState",,Block%
offset_x%=Block%!4-Block%!20
!offset_y%=Block%!16-Block%!24
QBlock%!0=window% :
Window owning the icon
MBlock%!4=1 :
Icon to be dragged
"Wimp_GetIconState",,Block%
Block%!0=Block%!8+offset_x%
Block%!4=Block%!12+offset_y%
Block%!8=Block%!16+offset_x%
!Block%!12=Block%!20+offset_y%
SYS "Wimp_DragBox",,Block%
"DragASprite_Start",%11001111,1,"file_aff",Block%
_DragBoxEnd(leafname$)
"DragASprite_Stop"
pointer%
pointer%=
leafname$
pointer%>0
leafname$,pointer%,1)<>"."
pointer%-=1
$leafname$=
leafname$,pointer%+1)
"Wimp_GetPointerInfo",,Block%
senderwindow%=Block%!12
sendericon%=Block%!16
Block%!20=senderwindow%
Block%!24=sendericon%
Block%!28=Block%!0
Block%!32=Block%!4
Block%!0=44+
leafname$
Block%!0+=4-(Block%!0
Block%!4=0
Block%!8=0
Block%!12=0
$Block%!16=1 :
Message_DataSave
+Block%!36=0 :
Length of proposed save
Block%!40=&AFF
$(Block%+44)=leafname$+
"Wimp_SendMessage",17,Block%,senderwindow%,sendericon%
*****************************************************************
* Icon handling *
*****************************************************************
_Icon_Read(window%,icon%)
result$
Block%!0=window%
Block%!4=icon%
"Wimp_GetIconState",,Block%
(Block%!24
(1<<8))<>0
result$=$(Block%!28)
result$=$(Block%+28)
=result$
_Icon_Write(window%,icon%,text$)
BBlock%!0=window%:Block%!4=icon%:
"Wimp_GetIconState",,Block%
(text$)>(Block%!36)-1
((Block%!24)
(1<<9))=(1<<9)
Right-justified
' text$="
text$,(Block%!36)-2)
#
Left-justified or centred
/ text$=
text$,(Block%!36)-1):
text$)="
^ Ensures the text can't overflow the maximum space in the icon.
$(Block%!28)<>text$
/ $(Block%!28)=text$:Block%!8=0:Block%!12=0
"Wimp_SetIconState",,Block%
"Wimp_GetCaretPosition",,Block%
Block%!0=window%
Block%!4=icon%
If this icon owns the caret, then put it at the end.
"Wimp_SetCaretPosition",window%,icon%,0,0,-1,
(text$)
_Icon_State_Selected(window%,icon%)
sel%
sel%=
+BBlock%!0=window%:Block%!4=icon%:
"Wimp_GetIconState",,Block%
((Block%!24)
(1<<21))=(1<<21)
sel%=
- =sel%
_Icon_Alter_Flags(window%,icon%,bit%,sel%)
Bl