home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / Button.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.1 KB  |  143 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.    Button.h -- class definition for XFE_Button.
  20.    Created: Chris McAfee <mcafee@netscape.com>, Wed Nov  6 11:11:42 PST 1996
  21.  */
  22.  
  23.  
  24.  
  25. #ifndef _xfe_button_h
  26. #define _xfe_button_h
  27.  
  28. #include "Component.h"
  29. #include "IconGroup.h"
  30. #include "Menu.h"
  31. #include "Frame.h"
  32.  
  33. #define MAX_ICON_GROUPS 4
  34.  
  35. typedef struct XFE_DoCommandArgs
  36. {
  37. public:
  38.   CommandType       cmd;
  39.   void*             callData;
  40.   XFE_CommandInfo*  info;
  41.  
  42.   XFE_DoCommandArgs(CommandType command, void* cd = NULL, 
  43.                     XFE_CommandInfo* i = NULL)
  44.     : cmd(command), callData(cd), info(i) {}
  45.  
  46. } XFE_doCommandArgs;
  47.  
  48. class XFE_Button : public XFE_Component
  49. {
  50. public:
  51.  
  52.     XFE_Button(XFE_Frame *            frame,
  53.                Widget                parent,
  54.                const char *            name,
  55.                IconGroup *            iconGroup,
  56.                IconGroup *            iconGroup2 = NULL,
  57.                IconGroup *            iconGroup3 = NULL,
  58.                IconGroup *            iconGroup4 = NULL);
  59.  
  60.     XFE_Button(XFE_Frame *            frame,
  61.                Widget                parent,
  62.                const char *            name,
  63.                MenuSpec *            menu_spec,
  64.                IconGroup *            iconGroup,
  65.                IconGroup *            iconGroup2 = NULL,
  66.                IconGroup *            iconGroup3 = NULL,
  67.                IconGroup *            iconGroup4 = NULL);
  68.  
  69.     XFE_Button(XFE_Frame *            frame,
  70.                Widget                parent,
  71.                const char *            name,
  72.                dynamenuCreateProc    generateProc,
  73.                void *                generateArg,
  74.                IconGroup *            iconGroup,
  75.                IconGroup *            iconGroup2 = NULL,
  76.                IconGroup *            iconGroup3 = NULL,
  77.                IconGroup *            iconGroup4 = NULL);
  78.  
  79.     ~XFE_Button();
  80.  
  81.     const char *    getName()        { return m_name; }
  82.     CommandType        getCmd()        { return m_cmd; }
  83.     void *            getCallData()    { return m_callData; }
  84.  
  85.     void            setCmd        (CommandType cmd) { m_cmd = cmd; }
  86.     void            setCallData    (void * callData) { m_callData = callData; }
  87.  
  88.     static const char *doCommandCallback;
  89.     
  90.   void setLabel    (char *label);
  91.  
  92.   void setPixmap (IconGroup * icons);
  93.  
  94.   int getIconGroupIndex();
  95.   
  96.   // Give a complete list of replacements with each call
  97.   void setIconGroups (IconGroup *iconGroup,
  98.                       IconGroup *iconGroup2 = NULL,
  99.                       IconGroup *iconGroup3 = NULL,
  100.                       IconGroup *iconGroup4 = NULL);
  101.  
  102.   void useIconGroup (int index);
  103.  
  104.   void setMenuSpec(MenuSpec *menu_spec);
  105.  
  106.   void setPretendSensitive(Boolean sensitive);
  107.  
  108.   // tooltip
  109.   void setToplevel(XFE_Component *top) { m_toplevel = top;}
  110.  
  111.   Boolean isPretendSensitive();
  112.  
  113.   void setPopupDelay(int delay);
  114.  
  115.     void                configureEnabled();
  116.  
  117. protected:
  118.  
  119.     // The button name
  120.     const char * m_name;
  121.     
  122.     // For now allow up to four possible icons groups
  123.     // where each icon group can have up to four states
  124.     IconGroup  *m_icons[MAX_ICON_GROUPS];
  125.  
  126.     int m_currentIconGroup;
  127.  
  128.     // The command executed by this button
  129.     CommandType        m_cmd;
  130.     void *            m_callData;
  131.  
  132.     static void    activate_cb            (Widget,XtPointer,XtPointer);
  133.     static void    sub_menu_cb            (Widget,XtPointer,XtPointer);
  134.     Widget        createButton        (Widget,WidgetClass);
  135.     
  136.     static  void tip_cb(Widget, XtPointer, XtPointer cb_data);
  137.     virtual void tipCB(Widget, XtPointer cb_data);
  138. };
  139.  
  140. extern void fe_buttonSetPixmaps(Widget button,IconGroup * group);
  141.  
  142. #endif /* _xfe_button_h */
  143.