home *** CD-ROM | disk | FTP | other *** search
- /* File: Server.h
- * Purpose: Definitions for the PopUp Server and satellite PopUp handlers
- * Author: © Copyright 1993 Jason Williams
- * All rights reserved
- */
-
- /* NOTES
- * See the end of this file for information on global functions which you
- * are allowed to call from within PopUp handlers.
- */
-
- #ifndef __pu_server_h
- #define __pu_server_h
-
- #ifndef __dl_wimp_h
- #include "DeskLib:Wimp.h"
- #endif
-
-
- /* Maximum number of handlers, Maximum number of open PopUp windows at any
- * time. NOTE that to increase these numbers you may also need to change
- * the PopUpManager module
- */
-
- #define MAX_HANDLERS 20
- #define MAX_INSTANTIATIONS 32
-
-
- typedef enum
- {
- REASON_OPEN = 0,
- REASON_CLOSE,
- REASON_EVENT,
-
- REASON_FONTON,
- REASON_FONTOFF
- } popup_reasoncodes;
-
-
- typedef struct
- {
- event_pollmask pollmask;
- window_handle basewindow;
- task_handle clienttask;
- int openx, openy;
- char appflags;
- } ctrl_block;
-
-
- typedef struct
- {
- int handle; /* PopUp handle for this instantiation */
- int appflags; /* Application flags */
- int handlerindex; /* Index of owning handler in htable */
- void *workspace; /* Pointer to its instantiation wspace */
- ctrl_block ctrlblock; /* Control block */
- } instantdata;
-
-
- typedef int (*handler_proc)(int reasoncode,
- ctrl_block *ctrl,
- void *privateworkspace,
- event_pollblock *pollblock);
-
- typedef struct
- {
- char name[12];
- int flags;
- handler_proc proc;
- int workspacesize;
- } handler_info;
-
-
-
- typedef struct
- {
- int popuphandle;
- char popupname[12];
- int openx, openy;
- char appflags, res1, res2, res3;
-
- char popupdata[208]; /* Individual PopUp data goes here */
- } msg_popupopen;
-
-
- typedef struct
- {
- int popuphandle;
- } msg_popupclose;
-
- typedef enum
- {
- /* message_POPUPRQ = 0x46D40, - defined in DeskLib:Wimp.h */
- /* message_POPUPSTATE, */
- /* message_POPUPCLOSED, */
- message_POPUPOPEN = 0x46D43,
- message_POPUPCLOSE
- } popup_messages;
-
-
- typedef enum
- {
- SWI_PopUp_Open = 0x46D40,
- SWI_PopUp_Close,
- SWI_PopUp_Register,
- SWI_PopUp_Deregister,
- SWI_PopUp_Kill
- } popup_swinumbers;
-
-
- #define APPFLAGS_ISLEAF (0x01)
- #define APPFLAGS_ISSTATIC (0x02)
-
-
- /*
- * Global server variables
- */
-
- extern handler_info *handlertable[];
- extern char eventdata[];
- extern event_pollblock *event;
- extern task_handle servertask;
-
-
- /*
- * Prototypes for functions defined in c.Server:
- * User PopUp handlers SHOULD NOT call any of these functions
- */
-
- extern void InstallPopUps(void);
- extern void DeinstallPopUps(void);
- extern int NewInstantiation(int popuphandle, int handlerindex, int appflags);
- extern void LoseInstantiation(int popuphandle);
- extern int CallHandler(int popuphandle, int reasoncode, BOOL handleishandle);
- extern BOOL PopUp_Open(task_handle client, msg_popupopen *m);
- extern void PopUp_Close(int popuphandle, BOOL killmenu);
- extern BOOL HandleWimpEvent(void);
- extern int CalculateMask(int basemask);
- extern void TaskDying(int taskhandle);
- extern void Template_RMAInit(void);
- extern void Template_RMAFree(void);
-
-
-
-
- /* ------------------------------------------------------------------------
- * Prototypes for USER functions defined in c.Server:
- * User PopUp handlers may call any of the following functions if they wish
- */
-
- /* SendState
- * Packages the given PopUp-specific data section of the application params
- * into a message_PopUpState, and sends it back to the client task.
- */
- extern void SendState(void *statedata, int statesize);
-
-
- /* ImDragging
- * If you wish to start a drag operation in your handler, you MUST call
- * this function as you do so - this tells the server that you are the
- * handler to call back when the drag finishes - if you do not call this
- * then the server will not call you (and will fail to process the drag
- * finish event)
- */
- extern void ImDragging(void);
-
-
- /* SetIconText
- * Equivalent to DeskLib's Icon_SetText, with one VERY IMPORTANT difference
- * - it handles strings terminated with CR (13) instead of NUL (0), which
- * may be passed in from BASIC and assembler client tasks.
- * You therefore MUST use this version instead of Icon_SetText!!!
- */
- extern void SetIconText(window_handle w, icon_handle i, char *text);
- #define Icon_SetText SetIconText
-
-
- /* ShowStaticPopUp
- * If you are providing a static PopUp, you will need to open it at
- * the x and y position requested by the user. To make this easier,
- * and help to share such code, this function is provided, which simply
- * opens the given window at the given top-left position.
- *
- * This function also repels your window about 64 OS units from the
- * edges of the screen (as is automatically done for standalone MENU
- * popups) - Please use this to retain consistency.
- */
- extern void ShowStaticPopUp(window_handle window, int openx, int openy);
-
-
- /* KillMe
- * Will kill off the current PopUp
- * If a PopUp wishes to let everyone know that it has closed, then
- * it MUST call KillMe(). This should only be necessary on event_CLOSE
- * Wimp events, or if a 'cancel' button is clicked, etc.
- * (You do not need to call this function if you are told to close with
- * a REASON_CLOSE)
- *
- * If you do not call this function, then you will continue to recieve
- * WIMP events, and will tie up one static-instantiation slot. (bad)
- *
- * VERY IMPORTANT NOTE:
- * This call removes your PopUp instantiation information, which means
- * after the call you cannot rely on the passed-in ctrl block and
- * private workspace any more. (The former may have been changed and the
- * latter WILL have been deallocated). This should therefore be the very
- * last thing in your code before you return control for the last time.
- */
- extern void KillMe(void);
-
-
- /* Template_RMAFind
- * The same as Template_Find
- * However it actually clones into malloc() and RMA static memory chunks
- * so that the indirected data is always paged in.
- * THIS SHOULD ONLY be called if your PopUp is to be shown as a menu LEAF
- * (because otherwise you will most likely be overwriting/overwritten by
- * another PopUp in these static memory areas)
- * i.e. only use it:
- * if ((ctrl->appflags & APPFLAGS_ISLEAF) != 0)
- * If this is not the case, or if it is a Static PopUp, then use the normal
- * Template_Find or Template_Clone.
- *
- * NOTE: Only 1024 bytes of RMA space are available for your indirected
- * data (this does not include the window definition block). If you need
- * more memory than this for your indirected strings (shame on you!) then
- * you will need to change the constant at the top of Template.c
- */
- extern window_block *Template_RMAFind(char *name);
-
-
- /* ReportMessage
- * Uses the 'Report' PopUp to report a message.
- * 'flags' should be one of the #defined values below, and affects
- * what buttons will appear on the report window.
- * 'ok' and 'cancel' are the strings (< 12 chars) to place into the buttons
- * 'msg' is the message to report.
- * This is used by SaveAs to report the 'Drag to a directory' error.
- *
- * NOTE that this is a MENU PopUp, and will therefore kill any existing
- * Menu PopUp! If calling from a static PopUp, take care.
- */
- extern BOOL ReportMessage(int flags, char *ok, char *cancel, char *msg);
-
- #define reportflag_CANCELONLY 1
- #define reportflag_OKONLY 2
- #define reportflag_OKANDCANCEL 3
-
-
- /* For REASON_OPEN, the pollblock contains a PopUpOpen message.
- * The definition of this includes the message header, the PopUp handle,
- * then the application parameter block header, followed (at offset 48 into
- * the complete WIMP message) by the PopUp-specific data.
- * Note that the pollblock includes a word at the front (event type), so
- * this shifts our data to offset 52 within the passed pollblock,
- * i.e. ((int) pollblock)+52 is the base address of the PopUp specific data
- */
- #define POPUP_DATA_OFFSET 52
-
- /* wimpversion
- * If you ever need to know which WIMP version you are running under,
- * check this variable - Numbers < 300 indicate RISC OS 2.
- * NOTE this will not be necessary very often, as two template files
- * are used, so you can define most OS-dependant stuff differently for
- * the 2 versions of the windows.
- * SaveAs uses this value to correct for RISC OS 2 not returning the 'drag'
- * button event properly.
- */
- extern unsigned int wimpversion;
-
- #endif
-