home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / AACD / Programming / CanDo / Decks1 / Quickies / AppEvent.ctx < prev    next >
Encoding:
Text File  |  1999-08-16  |  2.5 KB  |  83 lines

  1. Card "Card#1"
  2.     AfterAttachment
  3.         Nop ; we don't want any see thru parts
  4.         Transparent Off
  5.         Nop ; we want fast drag feedback
  6.         FastFeedBack On
  7.         Nop ; lets make it so we don't draw on the borders of the window
  8.         Let Left =WindowBorderLeft
  9.         Let Top  =WindowBorderTop
  10.         Let Width=WindowWidth-WindowBorderLeft-WindowBorderRight-1
  11.         Let Height=WindowHeight-WindowBorderTop-WindowBorderBottom-1
  12.         InstallClipRegion Left,Top,Width,Height,ONLY 
  13.         Nop ; lets get an initial brush incase someone draws before
  14.         Nop ; dropping an icon on us.  don't forget to fill in offsets
  15.         ClipBrush 25,25,1,1,"MyBrush"
  16.         Let WidthOffset=0
  17.         Let HeightOffset=0
  18.     EndScript
  19.     Window "UserWindow"
  20.         Definition
  21.             Origin 25,25
  22.             Size 320,100
  23.             Title "Workbench 2.0 AppEvents..."
  24.             NumberOfColors 2
  25.             DefaultColors 0,1,0
  26.             WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR 
  27.             WindowFlags ACTIVATE TOFRONT WORKBENCH 
  28.             VisualEffects NONE ,WAIT 
  29.         EndScript
  30.         OnCloseButton
  31.             Quit
  32.         EndScript
  33.         OnAppEvent
  34.             Nop ; we get passed thru Arg1 the icons dropped on us
  35.             Nop ; get a clean slate to draw on
  36.             ClearWindow
  37.             Nop ; we need a variable to work with
  38.             Local IconName
  39.             Nop ; parse off the iconname
  40.             Let IconName=GetWord(Arg1,1,Char(10))
  41.             Nop ; a directory maybe?
  42.             If GetChars(IconName,NumberOfChars(IconName),1)="/" ; a directory?
  43.                 Nop ; if it is a directory then we need to trim
  44.                 Nop ; the '/' off the end of the name or the
  45.                 Nop ; icon system will get confused. :-(
  46.                 Let IconName=GetChars(IconName,1,NumberOfChars(IconName)-1)
  47.             EndIf
  48.             Nop ; changed the window title to show the iconname
  49.             SetWindowTitle "Icon : "||IconName
  50.             Nop ; load the icon
  51.             LoadIcon IconName,"MyIcon"
  52.             Nop ; clip out the image
  53.             ClipIconImage "MyIcon","MyBrush"
  54.             Nop ; get rid of the icon
  55.             Flush "MyIcon"
  56.             Nop ; figure out the size of the icon image
  57.             GetBufferInfo "MyBrush",Width,Height
  58.             Nop ; we really want to know the center offset of the image
  59.             Let WidthOffset=Width%2
  60.             Let HeightOffset=Height%2
  61.             Nop ; show the icon image where it was dropped
  62.             ShowBrush "MyBrush",MouseX-WidthOffset,MouseY-HeightOffset
  63.         EndScript
  64.     EndObj
  65.     AreaButton "DrawingArea"
  66.         Definition
  67.             Origin 0,0
  68.             Size 320,100
  69.             Border NONE ,2,1
  70.             Highlight NONE 
  71.             ButtonFlags NONE 
  72.         EndScript
  73.         OnClick
  74.             Nop ; show the image right heerrreee....
  75.             ShowBrush "MyBrush",MouseX-WidthOffset,MouseY-HeightOffset
  76.         EndScript
  77.         OnDrag
  78.             Nop ; and then show it over here.
  79.             ShowBrush "MyBrush",MouseX-WidthOffset,MouseY-HeightOffset
  80.         EndScript
  81.     EndObj
  82. EndObj
  83.