home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / htmldlgs / htmldlgs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.7 KB  |  219 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef _HTMLDLGS_H_
  20. #define _HTMLDLGS_H_
  21.  
  22. /*
  23.  * Header for cross platform html dialogs
  24.  *
  25.  *
  26.  */
  27.  
  28. #include "ntypes.h"
  29. #ifndef NSPR20
  30. #include "prarena.h"
  31. #else
  32. #include "plarena.h"
  33. #endif
  34.  
  35. XP_BEGIN_PROTOS
  36.  
  37. /*
  38.  * dialog button flags
  39.  */
  40. #define XP_DIALOG_CANCEL_BUTTON        (1<<0)
  41. #define XP_DIALOG_CONTINUE_BUTTON    (1<<1)
  42. #define XP_DIALOG_OK_BUTTON        (1<<2)
  43. #define XP_DIALOG_NEXT_BUTTON        (1<<3)
  44. #define XP_DIALOG_BACK_BUTTON        (1<<4)
  45. #define XP_DIALOG_FINISHED_BUTTON    (1<<5)
  46. #define XP_DIALOG_FETCH_BUTTON        (1<<6)
  47. #define XP_DIALOG_MOREINFO_BUTTON    (1<<7)
  48.  
  49. /* chunk size for string arenas */
  50. #define XP_STRINGS_CHUNKSIZE 512
  51.  
  52. /*
  53.  * structured types
  54.  */
  55. typedef struct _XPDialogState XPDialogState;
  56. typedef struct _XPDialogInfo XPDialogInfo;
  57. typedef struct _XPPanelDesc XPPanelDesc;
  58. typedef struct _XPPanelInfo XPPanelInfo;
  59. typedef struct _XPPanelState XPPanelState;
  60. typedef struct _XPDialogStrings XPDialogStrings;
  61. typedef struct _XPDialogStringEntry XPDialogStringEntry;
  62.  
  63. typedef PRBool (* XP_HTMLDialogHandler)(XPDialogState *state, char **argv,
  64.                     int argc, unsigned int button);
  65.  
  66. typedef int (* XP_HTMLPanelHandler)(XPPanelState *state, char **argv,
  67.                     int argc, unsigned int button);
  68.  
  69. typedef XPDialogStrings * (* XP_HTMLPanelContent)(XPPanelState *state);
  70.  
  71. typedef void (* XP_PanelFinish)(XPPanelState *state, PRBool cancel);
  72.  
  73. struct _XPDialogState {
  74.     PRArenaPool *arena;
  75.     void *window;
  76.     void *proto_win;
  77.     XPDialogInfo *dialogInfo;
  78.     void *arg;
  79.     void (* deleteCallback)(void *arg);
  80.     void *cbarg;
  81.     PRBool deleted;
  82. };
  83.  
  84. struct _XPDialogInfo {
  85.     unsigned int buttonFlags;
  86.     XP_HTMLDialogHandler handler;
  87.     int width;
  88.     int height;
  89. };
  90.  
  91. #define XP_PANEL_FLAG_FINAL    (1<<0)
  92. #define XP_PANEL_FLAG_FIRST    (1<<1)
  93. #define XP_PANEL_FLAG_ONLY    (1<<2)
  94.  
  95. struct _XPPanelDesc {
  96.     XP_HTMLPanelHandler handler;
  97.     XP_HTMLPanelContent content;
  98.     unsigned int flags;
  99. };
  100.  
  101. struct _XPPanelInfo {
  102.     XPPanelDesc *desc;
  103.     int panelCount;
  104.     XP_PanelFinish finishfunc;
  105.     int width;
  106.     int height;
  107. };
  108.  
  109. struct _XPPanelState {
  110.     PRArenaPool *arena;
  111.     void *window;
  112.     XPPanelDesc *panels;
  113.     XPPanelInfo *info;
  114.     int panelCount;
  115.     int curPanel;
  116.     XPDialogStrings *curStrings;
  117.     XP_PanelFinish finish;
  118.     int titlenum;
  119.     void *arg;
  120.     void (* deleteCallback)(void *arg);
  121.     void *cbarg;
  122.     PRBool deleted;
  123. };
  124.  
  125. struct _XPDialogStrings
  126. {
  127.     PRArenaPool *arena;
  128.     int basestringnum;
  129.     int nargs;
  130.     char **args;
  131.     char *contents;
  132. };
  133.  
  134. struct _XPDialogStringEntry {
  135.     int tag;
  136.     char **strings;
  137.     int nstrings;
  138. };
  139.  
  140. extern XPDialogStringEntry dialogStringTable[];
  141.  
  142. extern XPDialogState *XP_MakeHTMLDialogWithChrome(void *proto_win, 
  143.                           XPDialogInfo *dialogInfo, 
  144.                           int titlenum,
  145.                           XPDialogStrings *strings, 
  146.                           Chrome *chrome, 
  147.                           void *arg, 
  148.                           PRBool utf8CharSet);
  149.  
  150. extern XPDialogState *XP_MakeHTMLDialog(void *proto_win,
  151.                     XPDialogInfo *dialogInfo,
  152.                     int titlenum,
  153.                     XPDialogStrings *strings,
  154.                     void *arg,
  155.                     PRBool utf8CharSet);
  156.  
  157. extern XPDialogState *XP_MakeRawHTMLDialog(void *proto_win,
  158.                        XPDialogInfo *dialogInfo,
  159.                        int titlenum,
  160.                        XPDialogStrings *strings,
  161.                        int handlestring, void *arg);
  162.  
  163. extern int XP_RedrawRawHTMLDialog(XPDialogState *state,
  164.                   XPDialogStrings *strings,
  165.                   int handlestring);
  166.  
  167. extern void XP_HandleHTMLDialog(URL_Struct *url);
  168.  
  169. extern void XP_MakeHTMLPanel(void *proto_win, XPPanelInfo *panelInfo,
  170.                  int titlenum, void *arg);
  171.  
  172. extern void XP_HandleHTMLPanel(URL_Struct *url);
  173.  
  174. extern int XP_PutStringsToStream(NET_StreamClass *stream, char **strings);
  175.  
  176. /*
  177.  * functions for handling html dialog strings
  178.  */
  179. extern XPDialogStrings *XP_GetDialogStrings(int stringtag);
  180.  
  181. extern void XP_SetDialogString(XPDialogStrings *strings, int stringNum,
  182.                 char *string);
  183.  
  184. extern void XP_CopyDialogString(XPDialogStrings *strings, int stringNum,
  185.                 const char *string);
  186.  
  187. extern void XP_FreeDialogStrings(XPDialogStrings *strings);
  188.  
  189. /*
  190.  * return the value of a name value pair in an arg list
  191.  *  used by internal form post processing code for html dialogs
  192.  */
  193. extern char *XP_FindValueInArgs(const char *name, char **av, int ac);
  194.  
  195. extern void XP_MakeHTMLAlert(void *proto_win, char *string);
  196.  
  197. /*
  198.  * These next two functions are internal routines.  Don't use them.
  199.  * They may change at any time.  They are used to invoke HTML dialogs
  200.  * from a javascript native method in the mocha thread.
  201.  */
  202. void *
  203. xp_MakeHTMLDialogPass1(void *proto_win, XPDialogInfo *dialogInfo);
  204.  
  205. XPDialogState *
  206. xp_MakeHTMLDialogPass2(void *proto_win, void *cx, XPDialogInfo *dialogInfo,
  207.                int titlenum, XPDialogStrings *strings,
  208.                void *arg, PRBool utf8CharSet);
  209.  
  210. /*
  211.  * destroy an HTML dialog window that has not had anything written to it yet
  212.  */
  213. void
  214. XP_DestroyHTMLDialogWindow(void *window);
  215.  
  216. XP_END_PROTOS
  217.  
  218. #endif /* _HTMLDLGS_H_ */
  219.