home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / outline.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  8.2 KB  |  233 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.    outline.h --- includes for the outline widget hack.
  20.    Created: Terry Weissman <terry@netscape.com>, 24-Jun-95.
  21.  */
  22.  
  23.  
  24. #ifndef __xfe_outline_h_
  25. #define __xfe_outline_h_
  26.  
  27. #ifdef    __cplusplus
  28. extern "C" {
  29. #endif
  30.  
  31. #include "msgcom.h"
  32. #include "icons.h"
  33. #include "dragdrop.h"
  34.  
  35. typedef int fe_OutlineType;
  36.  
  37. #define FE_OUTLINE_String        0x01
  38. #define FE_OUTLINE_Chopped        0x02
  39. #define FE_OUTLINE_Icon        0x04
  40. #define FE_OUTLINE_Box        0x08
  41.  
  42. /* these two tell the outline which columns (note you can have multiple)
  43.    are supposed to be indented, and, optional are to show an 
  44.    additional control to toggle between indented mode 
  45.    and non indented mode. */
  46.  
  47. #define FE_OUTLINE_IndentedColumn    0x10
  48. #define FE_OUTLINE_IndentToggle    0x20
  49. #define FE_OUTLINE_IndentLines    0x40
  50.  
  51. #define FE_OUTLINE_ChoppedString    (FE_OUTLINE_String | FE_OUTLINE_Chopped)
  52. #define FE_OUTLINE_IconString    (FE_OUTLINE_Icon | FE_OUTLINE_String)
  53. #define FE_OUTLINE_IconChoppedString     (FE_OUTLINE_Icon | FE_OUTLINE_ChoppedString)
  54.  
  55. typedef enum {
  56.   FE_OUTLINE_Leaf,
  57.   FE_OUTLINE_Folded,
  58.   FE_OUTLINE_Expanded
  59. } fe_OutlineFlippyType;
  60.  
  61. typedef enum {
  62.   FE_OUTLINE_Default,
  63.   FE_OUTLINE_Bold,
  64.   FE_OUTLINE_Italic
  65. } fe_OutlineTextStyle;
  66.  
  67. typedef struct fe_OutlineDesc {
  68.   fe_OutlineFlippyType flippy; 
  69.   int depth;
  70.   fe_OutlineType *type;        /* What to draw in this column. */
  71.   fe_icon **icons;
  72.   const char **str;        /* Used only if the corresponding entry in
  73.                    the type array is FE_OUTLINE_String. */
  74.   fe_OutlineTextStyle style;    /* What tag to use to paint any strings.
  75.                    The datafunc *must* fill this in.  Choices
  76.                    are (right now) XmFONTLIST_DEFAULT_TAG,
  77.                    "BOLD", and "ITALIC". */
  78.   const char **column_headers;    /* headers for the various columns. */
  79.   int numcolumns;
  80.   XP_Bool selected;
  81. } fe_OutlineDesc;
  82.  
  83. typedef struct fe_OutlineHeaderDesc {
  84.   fe_OutlineType type[10];
  85.   const char **header_strings;
  86.   fe_icon *icons[10];
  87. } fe_OutlineHeaderDesc;
  88.  
  89. typedef Boolean (*fe_OutlineGetDataFunc)(Widget, void* closure, int row,
  90.                      fe_OutlineDesc* data, int tag);
  91.  
  92. typedef void (*fe_OutlineClickFunc)(Widget, void* closure, int row, int column,
  93.                     const char* header, /* Header for this column */
  94.                     int button, int clicks, Boolean shift,
  95.                     Boolean ctrl, int tag);
  96.  
  97. typedef void (*fe_OutlineIconClickFunc)(Widget, void* closure, int row, int tag);
  98.  
  99.  
  100. /*
  101.  * Be sure to pass fe_OutlineCreate() an ArgList that has at least 5 empty
  102.  * slots that you aren't using, as it will.  Yick.  ###
  103.  */
  104. extern Widget fe_GridCreate(MWContext* context, Widget parent, String name,
  105.                 ArgList av, Cardinal ac,
  106.                 int maxindentdepth, /* Make the indentation
  107.                            icon column deep enough
  108.                            to initially show this
  109.                            many levels. If zero,
  110.                            don't let the user resize
  111.                            it, and it will be
  112.                            resized by calls to
  113.                            fe_OutlineSetMaxDepth().
  114.                            */
  115.                 /* always pass in one less number of actual 
  116.                    number of columns */
  117.                 int numcolumns, 
  118.                 /* for outline, pass in one less number of actual
  119.                    columns for widths (ignore first column), 
  120.                    for grid, pass in widths for all columns */
  121.                 int* columnwidths,
  122.                 fe_OutlineGetDataFunc datafunc,
  123.                 fe_OutlineClickFunc clickfunc,
  124.                 fe_OutlineIconClickFunc iconfunc,
  125.                 void* closure,
  126.                 char** posinfo,
  127.                 int tag /* for multipaned window */,
  128.                 XP_Bool isOutline);
  129.  
  130.  
  131. /* ############### see doc above ################### */
  132. extern Widget fe_OutlineCreate(MWContext* context, Widget parent, String name,
  133.                    ArgList av, Cardinal ac,
  134.                    int maxindentdepth, 
  135.                    int numcolumns, int* columnwidths,
  136.                    fe_OutlineGetDataFunc datafunc,
  137.                    fe_OutlineClickFunc clickfunc,
  138.                    fe_OutlineIconClickFunc iconfunc,
  139.                    void* closure,
  140.                    char** posinfo,
  141.                    int tag);
  142.  
  143.  
  144. /* Set the header strings for the given widget.  The outline code will keep the
  145.    pointers you give it, so you'd better never touch them.  It will pass these
  146.    same pointers back to the clickfunc, so you can write code that compares
  147.    strings instead of remembering magic numbers.  Note that any column
  148.    reordering that may get done by the user is completely hidden from the
  149.    caller; the reordering is a display artifact only. */
  150.  
  151. extern void fe_OutlineSetHeaders(Widget widget, fe_OutlineHeaderDesc *headers);
  152.  
  153. /* Tell the outline whether draw the given header in a highlighted way
  154.    (currently, boldface). */
  155.  
  156. extern void fe_OutlineSetHeaderHighlight(Widget widget, const char* header,
  157.                      XP_Bool value);
  158.  
  159.  
  160. /* Change the text displayed for the given header.  Note the original header
  161.    string is still used for calls that want to manipulate that header; this
  162.    just changes what string is presented for the user.  If the label is
  163.    NULL, then the header is reverted back to its original string. */
  164.  
  165. extern void fe_OutlineChangeHeaderLabel(Widget widget, const char* headername,
  166.                     const char* label);
  167.  
  168.  
  169.  
  170. /* Tells the outline widget that "length" rows starting at "first"
  171.  have been changed.  The outline is now to consider itself to have
  172.  "newnumrows" rows in it.*/
  173.  
  174. extern void fe_OutlineChange(Widget outline, int first, int length,
  175.                  int newnumrows);
  176.  
  177. extern void fe_OutlineSelect(Widget outline, int row, Boolean exclusive);
  178.  
  179. extern void fe_OutlineUnselect(Widget outline, int row);
  180.  
  181. extern void fe_OutlineUnselectAll(Widget outline);
  182.  
  183. extern void fe_OutlineMakeVisible(Widget outline, int visible);
  184.  
  185.  
  186. /* Returns how many items are currently selected.  If sellist is not NULL,
  187.    it gets set with the indices of the selection (up to sizesellist
  188.    entries.) */
  189.  
  190. extern int fe_OutlineGetSelection(Widget outline, MSG_ViewIndex* sellist,
  191.                   int sizesellist);
  192.  
  193.  
  194. /* Tell the outline widget to set the maximum indentation depth.  This should
  195.  only be called if the outline widget was created with maxindentdepth set to
  196.  zero.*/
  197. extern void fe_OutlineSetMaxDepth(Widget outline, int maxdepth);
  198.  
  199.  
  200. /* Given an (x,y) in the root window, return which row it corresponds to in the
  201.    outline (-1 if none). If nearbottom is given, then it is set to TRUE if the
  202.    (x,y) is very near the bottom of the returned row (used by drag'n'drop to
  203.    determine if the cursor should be considered to be between rows.) */
  204. extern int fe_OutlineRootCoordsToRow(Widget outline, int x, int y,
  205.                      XP_Bool* nearbottom);
  206.  
  207.  
  208. /* Enables dragging from this outline widget. */
  209. extern void fe_OutlineEnableDrag(Widget outline, fe_icon *dragicon, fe_dnd_Type dragtype);
  210.  
  211. /* Disables dragging from this outline widget. */
  212. extern void fe_OutlineDisableDrag(Widget outline);
  213.  
  214. /* Handles auto-scrolling during a drag operation.  If you call this, then
  215.    you have to call this for every event on a particular drag.   This routine
  216.    should be called if the given drag operation could possibly be destined
  217.    for this widget. */
  218. extern void fe_OutlineHandleDragEvent(Widget outline, XEvent* event,
  219.                       fe_dnd_Event type,
  220.                       fe_dnd_Source* source);
  221.  
  222.  
  223. /* Helps provide feedback during drag operation.  Up to one row may have a drag
  224.    highlight, which is either a box around it or a line under it.  Setting row
  225.    to a negative value will turn it off entirely. */
  226. extern void fe_OutlineSetDragFeedback(Widget outline, int row, XP_Bool usebox);
  227.  
  228. #ifdef    __cplusplus
  229. }
  230. #endif
  231.  
  232. #endif /* __xfe_outline_h_ */
  233.