home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / navcntr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  9.3 KB  |  291 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 NAVCNTR_H
  20. #define NAVCNTR_H
  21.  
  22. #include "usertlbr.h"
  23.  
  24. //  Window Control IDs for NavCenter.
  25. //  Improves findability.
  26. #define NC_IDW(ID) (AFX_IDW_PANE_LAST - (ID))
  27. #define NC_IDW_MISCVIEW NC_IDW(0)
  28. #define NC_IDW_SELECTOR NC_IDW(1)
  29. #define NC_IDW_OUTLINER NC_IDW(2)
  30. #define NC_IDW_HTMLPANE NC_IDW(3)
  31. #define NC_IDW_DRAGEDGE NC_IDW(5)
  32. #define NC_IDW_NAVMENU NC_IDW(6)
  33.  
  34.  
  35. #define ICONXPOS  5
  36. #define ICONYPOS  5
  37. #define ICONYINC  42
  38. #define SCROLLID 2900
  39. #define ICONBASEID 3000
  40. #define BUTTON_HEIGHT 28
  41. #define BUTTON_WIDTH 28
  42. #define IMAGE_SIZE 23
  43. #define TEXT_HEIGHT 20
  44. #define SCROLLTIMERID 2910
  45. #define NOSCROLL 0
  46. #define SCROLLUP 1
  47. #define SCROLLDOWN 2
  48. #define SCROLLLEFT 3
  49. #define SCROLLRIGHT 4
  50. #define SCROLLSTEP 32
  51. #define MAX_BUTTON_TITLE 54
  52.  
  53. #define EDIT_CONTROL  4000
  54.  
  55. #define IDT_PANESWITCH 40000
  56. #define IDT_SWITCHDELAY    500
  57.  
  58. #include "cxicon.h"
  59. #include "htrdf.h"
  60.  
  61. #define ID_BUTTONEVENT 1000
  62. #define ID_MOUSE_MOVE  1001
  63.  
  64. class CRDFContentView;
  65.  
  66. class CSelectorButton : public CLinkToolbarButton
  67. {
  68. friend class CSelector;
  69.  
  70. protected:
  71.     CView* pView;    // View including the HTML pane
  72.     CRDFContentView* m_pTreeView; // Pointer straight to the RDF Tree view.
  73.     CPaneCX* m_pPane;
  74.     CSelector* m_pSelector;
  75.     HT_View m_HTView; // Pointer to HT_View if one exists.  Could be NULL.
  76.     HT_Pane m_Pane; // This is the button's popup menu pane.
  77.     // The Selector Button actually has two HT_Nodes, two HT_Views, and two HT_Panes. One set is the pane in
  78.     // which the button is found (along with all the other buttons).  The second set is for the popup menu
  79.     // that comes up on a timed mouse down on the button.  
  80.     // m_HTView is used with the pane that contains all the buttons.
  81.     // m_Pane is used for the popup menu.
  82.     // The base class has an m_Node member variable.  This is the popup variable's top node in its selected
  83.     // HT_View.  -- Dave H.
  84.  
  85. public:
  86.     CSelectorButton(CSelector* pSelector) 
  87.         :m_pSelector(pSelector), pView(NULL), m_pPane(NULL), 
  88.          m_HTView(NULL) {};
  89.     
  90.     ~CSelectorButton();
  91.  
  92.     void SetHTView(HT_View v) { m_HTView = v; }
  93.     virtual HT_View GetHTView() { return m_HTView; }
  94.  
  95.     CView* GetView() { return pView; }
  96.  
  97.     virtual BOOL UseLargeIcons() { return TRUE; }
  98.  
  99.     virtual void OnAction(void);
  100.  
  101.     int Create(CWnd *pParent, int nToolbarStyle, CSize noviceButtonSize, CSize advancedButtonSize,
  102.                LPCTSTR pButtonText, LPCTSTR pToolTipText, 
  103.                LPCTSTR pStatusText,
  104.                CSize bitmapSize, int nMaxTextChars, int nMinTextChars, 
  105.                HT_Resource pNode, DWORD dwButtonStyle = 0, CView* view = NULL, CPaneCX* pane = NULL);
  106.  
  107.     void SetDepressed(BOOL b) { m_bDepressed = b; Invalidate(); }
  108.  
  109.     CRDFContentView* GetTreeView() { return m_pTreeView; }    // Returns only the tree
  110.  
  111.     void SetTreeView(CRDFContentView* tree) { m_pTreeView = tree; } // Sets the tree view
  112.  
  113.     virtual void DrawPicturesMode(HDC hDC, CRect rect);
  114.         // Overridden because LinkToolbarButtons draw text with the pictures always.  We
  115.         // want to revert to ToolbarButton behavior.
  116.  
  117.     virtual void DrawPicturesAndTextMode(HDC hDC, CRect rect);
  118.         // Overridden to ensure bitmap is drawn on top rather than on side (as is the case
  119.         // with LinkToolbar buttons).
  120.  
  121.     virtual CSize GetButtonSizeFromChars(CString s, int c);
  122.         // Overridden to put the bitmap on top.
  123.  
  124.     virtual void GetPicturesAndTextModeTextRect(CRect &rect);
  125.         // more bitmap on top goodness
  126.  
  127.     virtual void GetPicturesModeTextRect(CRect &rect);
  128.         // gotta have that bitmap on top
  129.  
  130.     virtual CPoint RequestMenuPlacement()
  131.     {
  132.         CPoint point(GetRequiredButtonSize().cx, 0);
  133.         ClientToScreen(&point);
  134.         return point;  // Want it to open on the side.
  135.     }
  136.  
  137.     void DisplayMenuOnDrag();
  138.         // Called when the user mouses over a selector button and NO TREE IS DISPLAYED (i.e., just the
  139.         // selector is showing in a docked view.
  140.  
  141.     virtual BOOL CreateRightMouseMenu();
  142.         // Overridden to bring up context menus.
  143.  
  144. };
  145.  
  146. class CSelectorDropTarget : public COleDropTarget
  147. {
  148. public:
  149. //Construction
  150.     CSelectorDropTarget(CSelector* parentFrame);
  151.     ~CSelectorDropTarget();
  152.     BOOL        OnDrop(CWnd *, COleDataObject *, DROPEFFECT, CPoint);
  153.     DROPEFFECT  OnDragEnter(CWnd *, COleDataObject *, DWORD, CPoint);
  154.     DROPEFFECT  OnDragOver(CWnd *, COleDataObject *, DWORD, CPoint);
  155.     void        OnDragLeave(CWnd *);
  156.     CSaveCX*        pSaveContext;
  157.     char        fileName[_MAX_PATH];
  158.     CFile* fd;
  159.     CSelector* m_pParent;
  160.     CString        m_url;
  161. private:
  162.     int m_nIsOKDrop;
  163. };
  164.  
  165. class CNavSelScrollButton : public CButton
  166. {
  167. public:
  168.     CNavSelScrollButton(HBITMAP hBmp, int width, int index, int height);
  169.     HBITMAP m_hbmp;
  170.     int m_buttonID;
  171.     int m_index;
  172.     int m_width;
  173.     int m_height;
  174.     BOOL m_selected;
  175.     CRect m_boundBox;
  176.     DECLARE_DYNCREATE(CNavSelScrollButton)
  177.     void setBoundingBox(int left, int top, int right, int bottom) {
  178.          m_boundBox.SetRect(left, top, right, bottom);
  179.     }
  180.     void AdjustPos(){    MoveWindow(m_boundBox);}
  181.     BOOL IsPtInRect(POINT &pt) 
  182.     { if (PtInRect(&m_boundBox, pt)) return TRUE;
  183.       else return FALSE;}
  184.     virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct );
  185. // Overrides
  186.     // ClassWizard generated virtual function overrides
  187.     //{{AFX_VIRTUAL(CButton)
  188.  
  189.     //}}AFX_VIRTUAL
  190.     DECLARE_MESSAGE_MAP()
  191. };
  192.  
  193.  
  194. class CSelector : public CView
  195. {
  196.  
  197. friend class CSelectorButton;
  198. public:
  199.     DECLARE_DYNAMIC(CSelector)
  200.     CSelector();
  201.     virtual ~CSelector();
  202.     void AddViewContext(const char* pTitle, CView* pView, CRDFContentView* pTree, 
  203.                         CPaneCX* htmlPane, HT_View theView);
  204.     CView* GetCurrentView(); // Gets the view including the HTML pane
  205.     CSelectorButton* GetCurrentButton();
  206.  
  207.     void SetCurrentView(CSelectorButton* pButton);
  208.     void SelectNthView(int i);
  209.     
  210.     void PopulatePane();
  211.     void DestroyViews();
  212.     void ConstructView(HT_View v);
  213.     HT_Pane GetHTPane() {return m_Pane;}
  214.     void ShowScrollButton(CSelectorButton* button);
  215.     void OnDraw( CDC* pDC );
  216.     int GetScrollDirection() {return m_scrollDirection;}
  217.     void ScrollSelector();
  218.     void StopScrolling() {m_scrollDirection = NOSCROLL;}
  219.     void UnSelectAll();
  220.     HBRUSH GetNormalBrush() {return hBrush;}
  221.     HBRUSH GetHtBrush() {return hHtBrush;}
  222.  
  223.     void SetDragButton(CSelectorButton* pButton) { m_pDragButton = pButton; };
  224.     CSelectorButton* GetDragButton() { return m_pDragButton; }
  225.     UINT GetSwitchTimer() { return m_hPaneSwitchTimer; }
  226.     void KillSwitchTimer() { KillTimer(IDT_PANESWITCH); m_hPaneSwitchTimer = 0; }
  227.     void SetSwitchTimer() { m_hPaneSwitchTimer = SetTimer(IDT_PANESWITCH, IDT_SWITCHDELAY, NULL); }
  228.  
  229.     CSelectorButton* GetButtonFromPoint(CPoint point, BOOL& onButton);
  230.     
  231.     afx_msg void OnRButtonUp ( UINT nFlags, CPoint point );
  232.     afx_msg void OnLButtonDown (UINT nFlags, CPoint point );
  233.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  234.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  235.  
  236.     // function needed for NavFram.cpp
  237.     void RearrangeIcons();
  238.  
  239.     BOOL IsTreeVisible();  // Whether or not the tree view is currently showing.
  240.  
  241. protected:
  242.     int m_scrollDirection;
  243.     CSelectorButton * m_pCurButton;
  244.     CView* m_pCurView; // The entire view (including the HTML pane)
  245.     CRDFCommandMap m_MenuCommandMap;    // Command map for back-end generated right mouse menu commands.
  246.     
  247.     CSelectorDropTarget * m_pDropTarget;
  248.     CNavSelScrollButton* m_scrollUp;
  249.     CNavSelScrollButton* m_scrollDown;
  250.     HBITMAP m_hScrollBmp;
  251.     SIZE m_hScrollBmpSize;
  252.     CRect m_boundingBox;
  253.     int m_xpos;
  254.     int m_ypos;
  255.     int m_scrollPos;
  256.     HBRUSH hBrush;
  257.     HBRUSH hHtBrush;
  258.  
  259.     CSelectorButton* m_pDragButton; // The button that is currently hovered over in a drag.
  260.     UINT m_hPaneSwitchTimer;
  261.  
  262.     CPoint m_PointHit;    // The point hit on a mouse down on the selector bar (not on one of the buttons).
  263.  
  264.     HT_Pane m_Pane; // RDF Pane associated with this NavCenter frame.
  265.     HT_Notification m_Notification; // Notification struct that is tossed around.
  266.     //{{AFX_MSG(CMainFrame)
  267.     afx_msg void OnSize( UINT nType, int cx, int cy );
  268.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  269.     afx_msg BOOL OnEraseBkgnd( CDC* pDC );
  270.     afx_msg void OnParentNotify( UINT message, LPARAM lParam );
  271.     afx_msg void OnTimer(UINT id);
  272.     afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  273.     afx_msg BOOL OnCommand( WPARAM wParam, LPARAM lParam );
  274.     //}}AFX_MSG
  275.     DECLARE_MESSAGE_MAP()
  276. };
  277.  
  278.  
  279.  
  280. extern "C"  {
  281. //  Netlib API to the stream that will save the file to disk.
  282. NET_StreamClass *ContextSaveStream(int iFormatOut, void *pDataObj, URL_Struct *pUrl, MWContext *pContext);
  283.  
  284. unsigned int MCFSaveReady(NET_StreamClass *stream);
  285. int MCFSaveWrite(NET_StreamClass *stream, const char *pWriteData, int32 iDataLength);
  286. void MCFSaveComplete(NET_StreamClass *stream);
  287. void MCFSaveAbort(NET_StreamClass *stream, int iStatus);
  288. };
  289.  
  290. #endif
  291.