home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / Frame.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  14.1 KB  |  451 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.    Frame.h -- class definitions for FE top level windows.
  20.    Created: Chris Toshok <toshok@netscape.com>, 7-Aug-96.
  21.  */
  22.  
  23.  
  24.  
  25. #ifndef _xfe_frame_h
  26. #define _xfe_frame_h
  27.  
  28. #include "structs.h"
  29. #include "xp_core.h"
  30.  
  31. #ifdef MOZ_TASKBAR
  32. #include "TaskBar.h"
  33. #endif
  34. #include "MenuBar.h"
  35. #include "Component.h"
  36. #include "xfe.h"
  37. #include "mozilla.h"  /* for MWContext ! */
  38. #include "selection.h"
  39. #include "icons.h"
  40.  
  41. #include "Toolbar.h"
  42. #include "Toolbox.h"
  43.  
  44. // define or undefine CLEAN_UP_NEWS for the benefit of
  45. // ThreadFrame, MsgFrame and FolderFrame
  46. #define CLEAN_UP_NEWS 1
  47.  
  48. class XFE_View;
  49. class XFE_Dashboard;
  50. class XFE_Logo;
  51. class XFE_Toolbox;
  52.  
  53. struct fe_colormap;  /* don't include xfe.h here, since it conflicts with our stuff. */
  54.  
  55. typedef enum EFrameType {
  56.   FRAME_BROWSER,
  57.   FRAME_DOWNLOAD,
  58.   FRAME_EDITOR,
  59.   FRAME_HTML_DIALOG,
  60.   FRAME_MAILNEWS_COMPOSE,
  61.   FRAME_MAILNEWS_MSG,
  62.   FRAME_MAILNEWS_THREAD,
  63.   FRAME_MAILNEWS_FOLDER,
  64.   FRAME_MAILNEWS_SEARCH,
  65.   FRAME_MAILNEWS_DOWNLOAD,
  66.   FRAME_LDAP_SEARCH,
  67.   FRAME_MAILFILTER,
  68.   FRAME_ADDRESSBOOK,
  69.   FRAME_BOOKMARK,
  70.   FRAME_HISTORY,
  71.   FRAME_NAVCENTER
  72. } EFrameType;
  73.  
  74. typedef enum {
  75.   XFE_UNSECURE,
  76.   XFE_SECURE,
  77.   XFE_SECURE_MIXED
  78. } XFE_BrowserSecurityStatusType;
  79.  
  80. typedef enum {
  81.   XFE_UNSECURE_UNSIGNED,
  82.   XFE_SECURE_UNSIGNED,
  83.   XFE_UNSECURE_SIGNED,
  84.   XFE_SECURE_SIGNED
  85. } XFE_MailSecurityStatusType;
  86.  
  87.  
  88. class XFE_Frame : public XFE_Component
  89. {
  90. public:
  91.     // friends
  92.     friend void XFE_Frame_busy_timeout(XtPointer, XtIntervalId*);
  93.  
  94.     XFE_Frame(char *name,
  95.             Widget toplevel,
  96.             XFE_Frame *parent_frame,
  97.             EFrameType type,
  98.             Chrome *chromespec = NULL,
  99.             XP_Bool haveHTMLDisplay = False, // do we display html?  used to initialize colormap stuff
  100.             XP_Bool haveMenuBar = True,   // do we have a menu bar?
  101.             XP_Bool haveToolbars = True,  // do we have toolbars
  102.             XP_Bool haveDashboard = True, // do we have the dashboard?
  103.             XP_Bool destroyOnClose = True); // do we destroy the widget tree on close?
  104.  
  105.   virtual ~XFE_Frame();
  106.  
  107.  
  108.   virtual EFrameType getType();
  109.  
  110.   virtual void setTitle(char *title);
  111.   virtual void setIconTitle(const char *icon_title);
  112.   virtual void setIconPixmap(fe_icon *icon);
  113.  
  114.   virtual void    show();
  115.   virtual void    map();
  116.   virtual void    hide();
  117.   virtual XP_Bool isShown();
  118.  
  119.   virtual void    showTitleBar();
  120.   virtual void    hideTitleBar();
  121.   virtual XP_Bool isTitleBarShown();
  122.  
  123.   virtual void queryChrome(Chrome * chrome);
  124.   virtual void respectChrome(Chrome * chrome);
  125.  
  126.   virtual XFE_View *getView();
  127.  
  128.   virtual const char * getTitle();
  129.  
  130.   virtual void position(int x, int y);
  131.   virtual void resize(int width, int height);
  132.   virtual void setWidth(int width);
  133.   virtual void setHeight(int height);
  134.   virtual int getX();
  135.   virtual int getY();
  136.   virtual int getWidth();
  137.   virtual int getHeight();
  138.  
  139.   virtual Widget getViewParent();
  140.   virtual Widget getMainForm();
  141.   virtual Widget getChromeParent();
  142.   virtual Widget getDialogParent();
  143.   virtual fe_colormap *getColormap();
  144.   virtual MWContext *getContext();
  145.  
  146.   virtual void updateToolbar();
  147.   virtual void updateMenuBar();
  148.  
  149.     /* this method is used by MozillaApp to turn off accelerators for
  150.        a particular frame. */
  151.     XP_Bool hotKeysDisabled();
  152.  
  153.   /* These methods match up nicely to their mates in XFE_View.
  154.      All they basically do is wrap around the subview of this 
  155.      frame. */
  156.   virtual XP_Bool isCommandEnabled(CommandType cmd, void *calldata = NULL,
  157.                          XFE_CommandInfo* = NULL);
  158.   virtual void doCommand(CommandType cmd, void *calldata = NULL,
  159.                          XFE_CommandInfo* = NULL);
  160.   virtual XP_Bool handlesCommand(CommandType cmd, void *calldata = NULL,
  161.                          XFE_CommandInfo* = NULL);
  162.   virtual char *commandToString(CommandType cmd, void *calldata = NULL,
  163.                          XFE_CommandInfo* = NULL);
  164.   virtual XP_Bool isCommandSelected(CommandType cmd, void *calldata = NULL,
  165.                          XFE_CommandInfo* = NULL);
  166.   virtual XFE_Command* getCommand(CommandType);
  167.   XFE_View*    widgetToView(Widget w);
  168.  
  169.   virtual Pixel getFGPixel();
  170.   virtual Pixel getBGPixel();
  171.   virtual Pixel getTopShadowPixel();
  172.   virtual Pixel getBottomShadowPixel();
  173.  
  174.   void setCursor(XP_Bool busy);
  175.  
  176.   // Invoked just before we destroy the Frame.
  177.   static const char *beforeDestroyCallback;
  178.   // User did something in this frame.
  179.   static const char *userActivityHere;
  180.   // Encoding for this window has changed.
  181.   static const char *encodingChanged;
  182.  
  183.   // Progress bar cylon notifications
  184.   static const char *progressBarCylonStart;
  185.   static const char *progressBarCylonStop;
  186.   static const char *progressBarCylonTick;
  187.  
  188.   // Progress bar percent notifications
  189.   static const char *progressBarUpdatePercent;
  190.   static const char *progressBarUpdateText;
  191.  
  192.   // Logo animation notifications
  193.   static const char *logoStartAnimation;
  194.   static const char *logoStopAnimation;
  195.  
  196.   // Frame busy notifications.
  197.   static const char *frameBusyCallback;
  198.   static const char *frameNotBusyCallback;
  199.  
  200.   XFE_CALLBACK_DECL(updateBusyState)
  201.   XFE_CALLBACK_DECL(doCommandCallback)
  202.   XFE_CALLBACK_DECL(toplevelWindowChangeOccured)
  203.  
  204.   // Animation notifications
  205.   XFE_CALLBACK_DECL(logoAnimationStartNotice)
  206.   XFE_CALLBACK_DECL(logoAnimationStopNotice)
  207.  
  208.   virtual char *prompt(const char *caption, const char *message, const char *deflt);
  209.  
  210.   // called when all connections when this window are finished.
  211.   // Really should be a notification...
  212.   virtual void allConnectionsComplete();
  213.  
  214.   static const char *allConnectionsCompleteCallback;
  215.  
  216.   static XFE_Frame *getActiveFrame();
  217.  
  218.   /* called when we want to close a window out from under the user. */
  219.   virtual void app_delete_response();
  220.  
  221.   /* called when the user wants to close a window. */
  222.   virtual void delete_response();
  223.  
  224.   // returns False if javascript has said the window is unclosable.
  225.   XP_Bool isWMClosable();
  226.  
  227.   // recomputes the attachments for our chunks.  If force is false,
  228.   // we put off the layout if the Frame is not popped up, until it
  229.   // is popped up.
  230.   void doAttachments(XP_Bool force = False);
  231.  
  232.   // Returns the index for the security status icon
  233.   //    (differs between mail & browser)
  234.   virtual int getSecurityStatus();
  235.  
  236.   void storeProperty (MWContext *context, char *property,
  237.                  const unsigned char *data);
  238.  
  239.   void installRemoteEventHandler ();
  240.   void frameResizeHandler(int width, int height);
  241.  
  242.     // tooltips and doc string
  243.     virtual char *getDocString(CommandType cmd);
  244.     virtual char *getTipString(CommandType cmd);
  245.  
  246.   virtual XFE_Logo *        getLogo                ();
  247.   virtual XFE_Dashboard *    getDashboard        ();
  248.  
  249.   virtual XP_Bool isOkToClose();
  250.   virtual void    doClose();
  251. protected:
  252.     char* geometryPrefName;
  253.     // Next two routines return static data -- copy immediately
  254.     // if for some reason you want to keep them.
  255.     char* getWidthPrefString();
  256.     char* getHeightPrefString();
  257.  
  258.   virtual void setMenubar(MenuSpec *menubar_spec);
  259.   virtual void setToolbar(ToolbarSpec *toolbar_spec);
  260.   virtual void setView(XFE_View *new_view);
  261.  
  262.   /* These two methods allow frame specific chrome to be added
  263.      by subclasses.  setAboveViewArea() places the widget in
  264.      the form above the view but below the toolbar.  
  265.      setBelowViewArea() places the component below the view but above
  266.      the dashboard. */
  267.   virtual void setAboveViewArea(XFE_Component *above_view);
  268.   virtual void setBelowViewArea(XFE_Component *below_view);
  269.  
  270.     // this method does all of the initial work from show() -- basically
  271.     // everything but the XtPopup -- but we need it to be separate since
  272.     // the mail download dialog has to do things before it actually is 
  273.     // shown, but after it is realized.
  274.     void realize();
  275.  
  276.     // this method creates the toplevel shell of this frame.  It handles
  277.     // modality here as well.  So, as an offshoot, we can now support
  278.     // any type of modal window, not just dialogs.
  279.     void createShellAndChromeParent(char *name,
  280.                                     Widget parent);
  281.  
  282.   // The bastard catch all structure from hell.  It is here now, since
  283.   // it represents for all the FE code one toplevel window.
  284.   MWContext *m_context;
  285.   void initializeMWContext(EFrameType frame_type, MWContext *context_to_copy = NULL);
  286.  
  287.   void hackTranslations(Widget widget);
  288.   void hackTextTranslations(Widget widget);
  289.  
  290.   // Add Z order support
  291.   void zaxis_AddSupport();
  292.  
  293.   // baseWidget() in case of a frame points to the shell.
  294.  
  295.   // the widget used as the parent of the view
  296.   Widget m_viewparent; 
  297.  
  298.   // the widget used as the parent of the m_view_parent, toolbox and above_view
  299.   Widget m_mainform;
  300.   
  301.   // the widget used as the parent for all the chrome.
  302.   Widget m_chromeparent;
  303.  
  304.   XFE_MenuBar *            m_menubar;
  305. //  XFE_ToolboxItem *        m_toolbar;
  306.   XFE_Toolbar *            m_toolbar;
  307.   XFE_Toolbox *            m_toolbox;
  308.   XFE_Component *        m_aboveview;
  309.   XFE_View *            m_view;
  310.   XFE_Component *        m_belowview;
  311.   XFE_Dashboard *        m_dashboard;
  312.  
  313.  
  314.   XFE_Logo *            m_activeLogo;
  315.  
  316.   fe_colormap *m_cmap;
  317.  
  318.   void (*m_chrome_close_callback)(void *close_arg);
  319.   void *m_chrome_close_arg;
  320.  
  321.   // Remember if a chromespec is provided to the constructor so that we 
  322.   // can later ignore the user's toolbox and geometry preferences.
  323.   XP_Bool m_chromespec_provided;
  324.   XP_Bool m_first_showing;
  325.  
  326.  
  327.   static void delete_response(Widget, XtPointer, XtPointer);
  328.   static void really_delete(void *data);
  329.  
  330.   // Toolbox snap notice
  331.   XFE_CALLBACK_DECL(toolboxSnapNotice)
  332.  
  333.   // Toolbox swap notice
  334.   XFE_CALLBACK_DECL(toolboxSwapNotice)
  335.  
  336.   // Toolbox close notice
  337.   XFE_CALLBACK_DECL(toolboxCloseNotice)
  338.  
  339.   // Toolbox open notice
  340.   XFE_CALLBACK_DECL(toolboxOpenNotice)
  341.  
  342.   // Toolbox methods
  343.   virtual void        toolboxItemSnap            (XFE_ToolboxItem * item);
  344.   virtual void        toolboxItemSwap            (XFE_ToolboxItem * item);
  345.   virtual void        toolboxItemClose        (XFE_ToolboxItem * item);
  346.   virtual void        toolboxItemOpen        (XFE_ToolboxItem * item);
  347.   virtual void        toolboxItemChangeShowing(XFE_ToolboxItem * item);
  348.  
  349.   virtual void        configureLogo            ();
  350.   virtual void        configureToolbox        ();
  351.  
  352.   //
  353.   // There is a one-to-one correspondence between
  354.   // m_allowresize, m_ismodal, m_topmost, m_bottommost, m_zlock
  355.   // and the Chrome struct.  Perhaps in the future we will just
  356.   // include a Chrome struct.
  357.   //
  358.   XP_Bool m_allowresize;
  359.   XP_Bool m_iswmclosable;
  360.   XP_Bool m_ismodal;
  361.   XP_Bool m_hotkeysdisabled;
  362.   int32 m_lhint;
  363.   int32 m_thint;
  364.   XP_Bool m_topmost;    // used by show()
  365.   XP_Bool m_bottommost; // used by show()
  366.   XP_Bool m_zlock;      // used by show()
  367.   XP_Bool m_remoteenabled;
  368.  
  369. #ifdef NETCASTER_ZAXIS_HACKERY
  370.   time_t m_zaxis_LastStackingChangeTime;
  371.   int m_zaxis_StackingChangesPerSecond;
  372.   XP_Bool m_zaxis_BelowHandlerInstalled;
  373.   XP_Bool m_zaxis_AboveHandlerInstalled;
  374.  
  375.   void zaxis_InstallHandler(Widget shell,int mode);
  376.   void zaxis_RemoveHandler(Widget shell,int mode);
  377.   void zaxis_HandleEvent(Widget shell,int mode);
  378.   static void zaxis_AboveEH(Widget,XtPointer,XEvent *,Boolean *);
  379.   static void zaxis_BelowEH(Widget,XtPointer,XEvent *,Boolean *);
  380. #endif
  381.  
  382.   XFE_Frame *m_parentframe;
  383.  
  384.   EFrameType m_frametype;
  385.   XP_Bool m_haveHTMLDisplay;
  386.   XP_Bool m_destroyOnClose;
  387.  
  388.   XP_Bool m_attachmentsNeeded; // if we defer the attachments, this will be true.
  389.   Widget m_toplevelWidget; // the parent widget to this window
  390.  
  391.   static MenuSpec new_menu_spec[];
  392.   static MenuSpec encoding_menu_spec[];
  393.   static MenuSpec window_menu_spec[];
  394.   static MenuSpec help_menu_spec[];
  395.   static MenuSpec places_menu_spec[];
  396.   static MenuSpec tb_places_menu_spec[];
  397.  
  398.   // shared submenu
  399.   static MenuSpec bookmark_submenu_spec[];
  400.  
  401.   static MenuSpec new_submenu_spec[];
  402.   static MenuSpec newMsg_submenu_spec[];
  403.   static MenuSpec mark_submenu_spec[];
  404.   static MenuSpec addrbk_submenu_spec[];
  405.   static MenuSpec attachments_submenu_spec[];
  406.   static MenuSpec sort_submenu_spec[];
  407.   static MenuSpec threads_submenu_spec[];
  408.   static MenuSpec expand_collapse_submenu_spec[];
  409.   static MenuSpec headers_submenu_spec[];
  410.   static MenuSpec select_submenu_spec[];
  411.   static MenuSpec reply_submenu_spec[];
  412.   static MenuSpec next_submenu_spec[];
  413.   static MenuSpec compose_message_submenu_spec[];
  414.   static MenuSpec compose_article_submenu_spec[];
  415.  
  416. private:
  417.  
  418.   // Event handler used to track the first mapping of iconic frame shells
  419.   static void iconicFrameMappingEH        (Widget,XtPointer,XEvent *,Boolean *);
  420.  
  421.   // Session manager support (WM_COMMAND)
  422.   static XP_List *    sm_getAliveShellFrames        ();
  423.   static char *        sm_getAddressForFrame        (XFE_Frame * frame);
  424.   static void        sm_allocArgvForStringList    (XP_List *,char ***,int *,int);
  425.   static void        sm_freeArgvForStringList    (char **,int);
  426.   static void        sm_freeStringList            (XP_List *);
  427.   static XP_List *    sm_getFrameAddressList        (XP_List *);
  428.   static void        sm_updateSessionCommand        (XFE_Frame * frame);
  429.   static void        sm_saveYourselfCB            (Widget,XtPointer,XtPointer);
  430.   static Widget        sm_getSessionManagerShell    ();
  431.   static void        sm_clearCommandProperties    ();
  432.   
  433.   void                sm_addSaveYourselfCB        ();
  434.  
  435.   static Atom        sm_wm_command;
  436.   static Atom        sm_wm_save_yourself;
  437. };
  438.  
  439. //
  440. //    This a wrapper function that controls busy cursor notification, etc.
  441. //    and calls frame->doCommand() to do the real work. It should not
  442. //    be a member function.
  443. //
  444. void xfe_ExecuteCommand(XFE_Frame* frame,
  445.                         CommandType cmd,
  446.                         void *calldata = NULL,
  447.                         XFE_CommandInfo* = NULL);
  448.  
  449. #endif /* _xfe_frame_h */
  450.  
  451.