home *** CD-ROM | disk | FTP | other *** search
- { CCdev.p}
- { Copyright ⌐ 1991, Michael J. Conrad}
- {}
- { An object which handles the basic cdev interface.}
- { If you need to, override this object's methods. You}
- { should never need to modify this object specifically.}
-
- UNIT CCdev;
-
- INTERFACE
-
- USES
- CCdevIntf, DialogUtils;
-
- FUNCTION main (message: integer; {Message to cdev}
- item: integer; {Which item was pressed?}
- numItems: integer; {How manu items in Control Panel}
- cpID: integer; {Control Panel id}
- event: EventRecord; {The event record for our event}
- cdevValue: Longint; {Place to store globals, send messages}
- dlg: DialogPtr): longint; {Pointer to the CP's dialog}
-
- IMPLEMENTATION
-
- CONST
- undoDev = 9; {For Undo menu commands}
- cutDev = 10; {For Cut menu commands}
- copyDev = 11; {For Copy menu commands}
- pasteDev = 12; {For Past menu commands}
- clearDev = 13; {For Clear menu commands}
-
- FUNCTION Runable: Boolean;
- external;
- FUNCTION NewCdev: CCdev;
- external;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Init;
- BEGIN
- status := longint(SELF);
- InitDialogUtils;
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Hit (item: integer);
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Close;
- BEGIN
- DisposHandle(Handle(SELF));
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.UpDate;
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Activate;
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Deactivate;
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Idle;
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Key (theChar: char);
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.DoCmdKey (theChar: char);
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- FUNCTION CCdev.Message (msg, item: integer): longint;
- VAR
- result: longint;
-
- BEGIN
- CASE msg OF
- initDev:
- Init;
- hitDev:
- Hit(item - lastItem);
- closeDev:
- status := 0;
- nulDev:
- Idle;
- updateDev:
- Update;
- activDev:
- Activate;
- deactivDev:
- Deactivate;
- keyEvtDev:
- BEGIN
- IF BitAnd(event.modifiers, cmdKey) <> 0 THEN
- Key(char(BitAnd(event.message, charCodeMask)))
- ELSE IF event.message <> autoKey THEN
- DoCmdKey(char(BitAnd(event.message, charCodeMask)));
- END;
- undoDev:
- Undo;
- cutDev:
- Cut;
- copyDev:
- Copy;
- pasteDev:
- Paste;
- clearDev:
- Clear;
- OTHERWISE
- ;
- END;
-
- result := status;
- IF result <> longint(SELF) THEN
- Close;
- Message := result;
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Undo;
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Cut;
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Copy;
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Paste;
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.Clear;
- BEGIN
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.PostCdevEvent (theEvent: EventRecord);
- BEGIN
- event := theEvent;
- END;
-
- {------------------------------------------------------------------------------------------}
-
- PROCEDURE CCdev.ICdev (d: DialogPtr;
- rNum: integer;
- resID: integer;
- items: integer);
- BEGIN
- dp := d;
- refNum := rNum;
- rsrcID := resID;
- lastItem := items;
- END;
-
- {------------------------------------------------------------------------------------------}
-
- {$S %_MethTables}
- {$Push}
- {$N-}
- PROCEDURE LoadMethTables;
- BEGIN
-
- END;
- {$Pop}
- {$S}
-
- {------------------------------------------------------------------------------------------}
-
- FUNCTION main (message: integer; {Message to cdev}
- item: integer; {Which item was pressed?}
- numItems: integer; {How manu items in Control Panel}
- cpID: integer; {Control Panel id}
- event: EventRecord; {The event record for our event}
- cdevValue: Longint; {Place to store globals, send messages}
- dlg: DialogPtr): longint; {Pointer to the CP's dialog}
-
- VAR
- result: longint;
- cdevObject: CCdev;
-
- BEGIN
- RememberA4;
- SetUpA4;
- LoadMethTables;
-
- IF message = macDev THEN
- main := integer(Runable)
- ELSE
- BEGIN
- IF message = initDev THEN
- BEGIN
- cdevObject := NewCdev;
- cdevObject.ICdev(dlg, DialogPeek(dlg)^.window.windowKind, cpID, numItems);
- END
- ELSE
- cdevObject := CCdev(cdevValue);
-
- result := longint(cdevObject);
- IF result <> 0 THEN
- BEGIN
- cdevObject.PostCdevEvent(event);
- result := cdevObject.Message(message, item);
- END;
- END;
- main := result;
-
- RestoreA4;
- END;
-
- END.