home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1987-05-17 | 5.3 KB | 140 lines |
- (*A$+*)
- IMPLEMENTATION MODULE SetBoard;
- FROM SYSTEM IMPORT NULL,ADR,BYTE,ADDRESS,TSIZE;
- FROM Intuition IMPORT WindowPtr,NewWindow,IDCMPFlags,IDCMPFlagSet,WindowFlags,
- WindowFlagSet,GadgetPtr,GadgetFlags,GadgetFlagSet,ActivationFlags,
- ActivationFlagSet,Border,BorderPtr,ScreenFlags,ScreenFlagSet;
- FROM Windows IMPORT OpenWindow;
- FROM EasyGadgets IMPORT EasyBoolImageGadget;
- FROM Strings IMPORT String,Assign,InitStringModule;
- FROM MenuUtils IMPORT NewIText;
- FROM GraphicsLibrary IMPORT Jam1;
-
- VAR
- SetStr,PlayStr:String;
- Images:ARRAY [1..22] OF INTEGER;
-
- (* These variables are defined globally so that the programmer will not have to
- allocate memory for them. The program automatically allocates memory for
- them. This does not insure that it will be chip ram, which it must be for
- intuition to recognize it.*)
-
- PROCEDURE PlaceBoard(VAR MWp:WindowPtr;
- VAR Places:PlaceType);
-
- VAR
- BoardWindow:NewWindow;
- RGadget:GadgetPtr;
-
- BEGIN
- InitStringModule; (* Remember this if you use strings*)
- RGadget:=EasyBoolImageGadget(NULL,3,11,16,10,ADR(Images[12]),ADR(Images[1]),
- GadgetFlagSet{Ga1,GadgetImage},ActivationFlagSet{ToggleSelect,RelVerify});
- RGadget^.GadgetID:=1; (*this is the best way to keep track of gadgets*)
- Places[1]:=RGadget;
- (*keeping an array or some other structure with gadget pointers in it is
- a good idea, since searching the linked list could turn messy.*)
- RGadget:=EasyBoolImageGadget(RGadget,19,11,16,10,ADR(Images[12]),
- ADR(Images[1]),GadgetFlagSet{Ga1,GadgetImage},
- ActivationFlagSet{ToggleSelect,RelVerify});
- (*If you do not set RelVerify or GadgetImmediate you will not get a gadget
- message from intuition at all, ever. Also, Release or Immediate check
- the mousebutton, not the on/off state of the gadget.*)
- RGadget^.GadgetID:=2;
- Places[2]:=RGadget;
- RGadget:=EasyBoolImageGadget(RGadget,35,11,16,10,ADR(Images[12]),
- ADR(Images[1]),GadgetFlagSet{Ga1,GadgetImage},
- ActivationFlagSet{ToggleSelect,RelVerify});
- RGadget^.GadgetID:=3;
- Places[3]:=RGadget;
- RGadget:=EasyBoolImageGadget(RGadget,3,21,16,10,ADR(Images[12]),
- ADR(Images[1]),GadgetFlagSet{Ga1,GadgetImage},
- ActivationFlagSet{ToggleSelect,RelVerify});
- RGadget^.GadgetID:=4;
- Places[4]:=RGadget;
- RGadget:=EasyBoolImageGadget(RGadget,19,21,16,10,ADR(Images[12]),
- ADR(Images[1]),GadgetFlagSet{Ga1,GadgetImage},
- ActivationFlagSet{ToggleSelect,RelVerify});
- RGadget^.GadgetID:=5;
- Places[5]:=RGadget;
- RGadget:=EasyBoolImageGadget(RGadget,35,21,16,10,ADR(Images[12]),
- ADR(Images[1]),GadgetFlagSet{Ga1,GadgetImage},
- ActivationFlagSet{ToggleSelect,RelVerify});
- RGadget^.GadgetID:=6;
- Places[6]:=RGadget;
- RGadget:=EasyBoolImageGadget(RGadget,3,31,16,10,ADR(Images[12]),
- ADR(Images[1]),GadgetFlagSet{Ga1,GadgetImage},
- ActivationFlagSet{ToggleSelect,RelVerify});
- RGadget^.GadgetID:=7;
- Places[7]:=RGadget;
- RGadget:=EasyBoolImageGadget(RGadget,19,31,16,10,ADR(Images[12]),
- ADR(Images[1]),GadgetFlagSet{Ga1,GadgetImage},
- ActivationFlagSet{ToggleSelect,RelVerify});
- RGadget^.GadgetID:=8;
- Places[8]:=RGadget;
- RGadget:=EasyBoolImageGadget(RGadget,35,31,16,10,ADR(Images[12]),
- ADR(Images[1]),GadgetFlagSet{Ga1,GadgetImage},
- ActivationFlagSet{ToggleSelect,RelVerify});
- RGadget^.GadgetID:=9;
- Places[9]:=RGadget;
- Assign(SetStr,"Set Up");
- RGadget:=EasyBoolImageGadget(RGadget,2,42,48,8,NULL,NULL,
- GadgetFlagSet{},ActivationFlagSet{RelVerify});
- RGadget^.GadgetText:=NewIText(SetStr,0,0,CARDINAL(3),CARDINAL(1));
- (*Always remember that when you use text or graphic information you must
- make sure the memory it resides in is allocated for it and doesn't get
- trampled. There are several ways to do this. You can declare the
- information globally, you can use AllocRemember, New, Etc. *)
- RGadget^.GadgetID:=10;
- Assign(PlayStr,"Play");
- RGadget:=EasyBoolImageGadget(RGadget,2,51,32,8,NULL,NULL,
- GadgetFlagSet{},ActivationFlagSet{RelVerify});
- RGadget^.GadgetText:=NewIText(PlayStr,0,0,CARDINAL(3),CARDINAL(1));
- RGadget^.GadgetID:=11;
- WITH BoardWindow DO
- LeftEdge:=500;
- TopEdge:=30;
- Width:=55;
- Height:=60;
- DetailPen:=BYTE(0);
- BlockPen:=BYTE(1);
- Flags:=WindowFlagSet{WindowDrag,Activate,WindowClose};
- IDCMPFlags:=IDCMPFlagSet{GadgetUp,CloseWindowFlag};
- FirstGadget:=RGadget;
- CheckMark:=NULL;
- Title:=NULL;
- BitMap:=NULL;
- Type:=ScreenFlagSet{WBenchScreen};
- (* This sets the window on the current active workbench. *)
- Screen:=NULL;
- (* If you opened your own custom screen this would be the pointer
- to that screen *)
- END;
- MWp:=OpenWindow(BoardWindow);
- END PlaceBoard;
-
- BEGIN
- Images[1]:=-0001H; (* full *)
- Images[2]:=-7fffH;
- Images[3]:=-7c3fH;
- Images[4]:=-700fH;
- Images[5]:=-660fH;
- Images[6]:=-600fH;
- Images[7]:=-700fH;
- Images[8]:=-7c3fH;
- Images[9]:=-7fffH;
- Images[10]:=-0001H;
- Images[11]:=0000H;
- Images[12]:=-0001H; (* empty *)
- Images[13]:=-7fffH;
- Images[14]:=-7fffH;
- Images[15]:=-7fffH;
- Images[16]:=-7fffH;
- Images[17]:=-7fffH;
- Images[18]:=-7fffH;
- Images[19]:=-7fffH;
- Images[20]:=-7fffH;
- Images[21]:=-0001H;
- Images[22]:=0000H;
- END SetBoard.
-