home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / AttachPanel.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.4 KB  |  218 lines

  1. /* -*- Mode: C++; tab-width: 8; 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.    AttachPanel.h -- class definitions for attachment panel and icon
  20.    Created: Alastair Gourlay(SGI) c/o Dora Hsu<dora@netscape.com>, 26 Nov 1996
  21.  */
  22.  
  23.  
  24.  
  25. #ifndef _ATTACH_PANEL_H
  26. #define _ATTACH_PANEL_H
  27.  
  28. // Classes in this file:
  29. //      XFE_AttachPanel
  30. //      XFE_AttachPanelItem
  31. //
  32.  
  33. #include "MNView.h"
  34. #include "Component.h"
  35. #include <Xm/Xm.h>
  36.  
  37. class XFE_AttachPanelItem;
  38.  
  39. //
  40. // XFE_AttachPanel - attachment window
  41. //
  42.  
  43. class XFE_AttachPanel : public XFE_Component {
  44. public:
  45.     XFE_AttachPanel(MWContext*);
  46.     virtual ~XFE_AttachPanel();
  47.  
  48.     // widget interfaces
  49.     virtual void createWidgets(Widget);
  50.     operator Widget() { return getBaseWidget(); };
  51.     Widget pane() { return _pane; };
  52.     void armedWidget(Widget w) { _armedWidget=w; };
  53.     MWContext *context() { return _context; };
  54.     virtual void mapPane();
  55.     virtual void unmapPane();
  56.     virtual void doubleClickCb(int);
  57.     void multiClickEnabled(int v) { _multiClickEnabled=v; };
  58.     int multiClickEnabled() { return _multiClickEnabled; };
  59.     XtTranslations iconTranslations() { return _iconTranslations; };
  60.     int isAttachPanelWidget(Widget);
  61.  
  62.     // item list management
  63.     XFE_AttachPanelItem **items();
  64.     int numItems();
  65.     void addItem(XFE_AttachPanelItem*,int pos=-1);
  66.     void addItem(const char *,const char *itemLabel=NULL,const char *itemType=NULL,int pos=-1);
  67.     void removeItem(XFE_AttachPanelItem*);
  68.     void removeItem(int);
  69.     void removeAllItems();
  70.     int findItem(XFE_AttachPanelItem*);
  71.     XFE_AttachPanelItem* currentSelection() { return _currentSelection; };
  72.     int currentSelectionPos() { return findItem(_currentSelection); };
  73.     void selectItem(XFE_AttachPanelItem*);
  74.     void deselectItem(XFE_AttachPanelItem*);
  75.     void traverseItem(int);
  76.     void scrollToItem(int);
  77.  
  78.     // display management
  79.     void updateDisplay();
  80.     int getPreferredHeight();
  81.     
  82. protected:
  83.     MWContext* _context;
  84.     // Motif information
  85.     Widget _parent;
  86.     Widget _top;
  87.     Widget _topClip;
  88.     Widget _topScrollBar;
  89.     Widget _pane;
  90.     Widget _popupMenu;
  91.     Widget _popupParent;
  92.     XtIntervalId _resizeProcId;
  93.     XtIntervalId _traversalProcId;
  94.     int _inDestructor;
  95.     int _firstExpose;
  96.     Time _popupLastEventTime;
  97.     Widget _armedWidget;
  98.     Widget _traversalWidget;
  99.     int _multiClickEnabled;
  100.     XtTranslations _iconTranslations;
  101.     int _prefHeight;
  102.  
  103.     // panel contents    
  104.     XFE_AttachPanelItem **_items;
  105.     int _numItems;
  106.     int _allocItems;
  107.     XFE_AttachPanelItem *_currentSelection;
  108.  
  109.     // per-class settings
  110.     static const int _allocIncrement;
  111.     static const int _marginWidth;
  112.     static const int _marginHeight;
  113.     static const int _horizSpacing;
  114.     
  115.     // internal display management
  116.     void layout();
  117.     virtual void realize();
  118.     virtual void updateSelectionUI() { };    
  119.  
  120.     // internal popup menu management
  121.     void initializePopupMenu();
  122.     
  123.     // internal callback stubs
  124.     static void ExposeCb(Widget,XtPointer,XtPointer);
  125.     static void InputCb(Widget,XtPointer,XtPointer);
  126.     static void ScrollTraversalCb(Widget,XtPointer,XtPointer);
  127.     static void ScrollTraversalProc(XtPointer,XtIntervalId*);
  128.     static void ScrollResizeCb(Widget,XtPointer,XtPointer);
  129.     static void ScrollResizeProc(XtPointer,XtIntervalId*);
  130.     static void PopupProc(Widget,XtPointer,XEvent*,Boolean*);
  131.     static void PopdownCb(Widget,XtPointer,XtPointer);
  132.  
  133.     // internal callback methods
  134.     void inputCb(XEvent*);
  135.     void scrollTraversalProc(Widget);
  136.     void scrollResizeProc();
  137. private:
  138. };
  139.  
  140.  
  141. //
  142. // XFE_AttachPanelItem
  143. //
  144.  
  145. class XFE_AttachPanelItem
  146. {
  147. public:
  148.     XFE_AttachPanelItem(XFE_AttachPanel*,const char *data=NULL,const char *dataLabel=NULL,const char *dataType=NULL);
  149.     ~XFE_AttachPanelItem();
  150.     const char *dataLabel();
  151.     const char *dataType();
  152.     const char *data();
  153.     void calculatePrefGeometry();
  154.     Widget label() { return _label; };
  155.     Widget image() { return _image; };
  156.     int prefWidth() { return _prefWidth; };
  157.     int prefHeight() { return _prefHeight; };
  158.     int imageWidth() { return _imageWidth; };
  159.     int imageHeight() { return _imageHeight; };
  160.     int labelWidth() { return _labelWidth; };
  161.     int labelHeight() { return _labelHeight; };
  162.     void layout(int,int,unsigned int,unsigned int);
  163.     void realize();
  164.     void show();
  165.     void hide();
  166.     void traverse();
  167.     void scrollVisible();
  168.     void select(int selected=TRUE);
  169.     void inParentDestructor();
  170.     int beingDestroyed() { return _beingDestroyed; };
  171. protected:
  172.     XFE_AttachPanel *_attachPanel;
  173.     int _inParentDestructor;
  174.     int _beingDestroyed;
  175.     char *_data;
  176.     char *_dataLabel;
  177.     char *_dataType;
  178.     unsigned int _prefWidth;
  179.     unsigned int _prefHeight;
  180.     unsigned int _imageWidth;
  181.     unsigned int _imageHeight;
  182.     unsigned int _labelWidth;
  183.     unsigned int _labelHeight;
  184.     
  185.     static Pixmap _audioPixmap;
  186.     static Pixmap _binaryPixmap;
  187.     static Pixmap _imagePixmap;
  188.     static Pixmap _messagePixmap;
  189.     static Pixmap _moviePixmap;
  190.     static Pixmap _textPixmap;
  191.     static Pixmap _unknownPixmap;
  192.     static Pixmap _urlPixmap;
  193.     static Pixmap _vcardPixmap;
  194.     static Cursor _cursor;
  195.  
  196.     Widget _parent;
  197.     Widget _image;
  198.     Widget _label;
  199.  
  200.     // internal methods
  201.     Pixmap iconPixmap();
  202.     
  203.     // internal callback stubs
  204.     static void ActivateCb(Widget,XtPointer,XtPointer);
  205.     static void ArmCb(Widget,XtPointer,XtPointer);
  206.     static void DisarmCb(Widget,XtPointer,XtPointer);
  207.  
  208.     // internal callback methods
  209.     void activateCb();
  210.     void doubleClickCb();
  211.     void armCb(Widget);
  212.     void disarmCb();
  213. private:
  214. };
  215.  
  216.  
  217. #endif // _ATTACH_PANEL_H
  218.