home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / scroller.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.6 KB  |  161 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.    scroller.c --- defines a subclass of XmScrolledWindow
  20.    Created: Jamie Zawinski <jwz@netscape.com>, 23-Jul-94.
  21.  */
  22.  
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include "mozilla.h"
  27. #include "scroller.h"
  28. #include "scrollerP.h"
  29.  
  30. #include <Xm/ScrollBarP.h>
  31.  
  32. static void scroller_resize (Widget);
  33.  
  34. #if XmVersion >= 2000
  35.  
  36. /*
  37.  * There is a backward compatibility bug in motif 2.0 that prevents
  38.  * the XmScrolledWindow class from behaving just as the motif 1.2
  39.  * one.  For whatever reasons, the mozilla scrolling code depends on
  40.  * the 1.2 behavior.  Fixing the problem in Mozilla should not be
  41.  * hard.  The logic in scroll.c should probably be updated to work
  42.  * with both motif 1.2 and 2.0.
  43.  *
  44.  * The current hackery solution (yes its disgusting) is to use the
  45.  * XmScrolledWindow code from 1.2.  In defense of Netscape:  The only
  46.  * reason whay such a sickening solution was used, was to make the
  47.  * free mozilla date with building motif 2.0 code.
  48.  *
  49.  * -ramiro
  50.  *
  51.  */
  52. #ifdef FEATURE_MOTIF20_SCROLLED_WINDOW_HACKING
  53. #define SCROLLER_SC_CLASS_REC        xmHackedWindowClassRec
  54. #define SCROLLER_SC_CONSTRAINT_SIZE    0
  55. #else
  56. #define SCROLLER_SC_CLASS_REC        xmScrolledWindowClassRec
  57. #define SCROLLER_SC_CONSTRAINT_SIZE    sizeof(XmScrolledWindowConstraintRec)
  58. #endif /* FEATURE_MOTIF20_SCROLLED_WINDOW_HACKING */
  59.  
  60. #else
  61.  
  62. #define SCROLLER_SC_CLASS_REC        xmScrolledWindowClassRec
  63. #define SCROLLER_SC_CONSTRAINT_SIZE    0
  64.  
  65. #endif /* XmVersion >= 2000 */
  66.  
  67. ScrollerClassRec scrollerClassRec =
  68. {
  69.   {
  70.     /* core_class fields      */
  71.     /* superclass         */    (WidgetClass) &SCROLLER_SC_CLASS_REC,
  72.     /* class_name         */    "Scroller",
  73.     /* widget_size        */    sizeof(ScrollerRec),
  74.     /* class_initialize   */    NULL,
  75.     /* class_partinit     */    NULL /* ClassPartInitialize */,
  76.     /* class_inited       */    FALSE,
  77.     /* initialize         */    NULL /* Initialize */,
  78.     /* Init hook      */    NULL,
  79.     /* realize            */    XtInheritRealize /* Realize */,
  80.     /* actions          */    NULL /* ScrolledWActions */,
  81.     /* num_actions      */    0 /* XtNumber(ScrolledWActions) */,
  82.     /* resources          */    NULL /* resources */,
  83.     /* num_resources      */    0 /* XtNumber(resources) */,
  84.     /* xrm_class          */    NULLQUARK,
  85.     /* compress_motion      */    TRUE,
  86.     /* compress_exposure  */    TRUE,
  87.     /* compress_enterleave*/    TRUE,
  88.     /* visible_interest   */    FALSE,
  89.     /* destroy            */    NULL,
  90.     /* resize             */    scroller_resize,
  91.     /* expose             */    XtInheritExpose /* (XtExposeProc) Redisplay */,
  92.     /* set_values         */    NULL /* (XtSetValuesFunc )SetValues */,
  93.     /* set values hook    */    NULL,
  94.     /* set values almost  */    XtInheritSetValuesAlmost,
  95.     /* get values hook    */    NULL,
  96.     /* accept_focus       */    NULL,
  97.     /* Version            */    XtVersion,
  98.     /* PRIVATE cb list    */    NULL,
  99.     /* tm_table          */    XtInheritTranslations,
  100.     /* query_geometry     */    XtInheritQueryGeometry /* QueryProc */,
  101.     /* display_accelerator*/    NULL,
  102.     /* extension          */    NULL,
  103.   },
  104.   {
  105. /* composite_class fields */
  106.     /* geometry_manager   */    XtInheritGeometryManager /*(XtGeometryHandler )GeometryManager*/,
  107.     /* change_managed     */    XtInheritChangeManaged /*(XtWidgetProc) ChangeManaged*/,
  108.     /* insert_child      */    XtInheritInsertChild /*(XtArgsProc) InsertChild*/,    
  109.     /* delete_child      */    XtInheritDeleteChild,
  110.     /* Extension          */    NULL,
  111.   },{
  112. /* Constraint class Init */
  113.     NULL,
  114.     0,
  115.     SCROLLER_SC_CONSTRAINT_SIZE,
  116.     NULL,
  117.     NULL,
  118.     NULL,
  119.     NULL
  120.       
  121.   },
  122. /* Manager Class */
  123.    {        
  124.       XmInheritTranslations/*ScrolledWindowXlations*/,     /* translations        */    
  125.       NULL /*get_resources*/,            /* get resources            */
  126.       0 /*XtNumber(get_resources)*/,        /* num get_resources       */
  127.       NULL,                    /* get_cont_resources     */
  128.       0,                    /* num_get_cont_resources */
  129.       XmInheritParentProcess,                   /* parent_process         */
  130.       NULL,                    /* extension           */    
  131.    },
  132.  
  133.  {
  134. /* Scrolled Window class - none */     
  135.      NULL
  136.  },
  137.  
  138.  {
  139. /* Scroller class - none */     
  140.      /* mumble */               0
  141.  }
  142. };
  143.  
  144. WidgetClass scrollerClass = (WidgetClass)&scrollerClassRec;
  145.  
  146.  
  147. static void scroller_resize (Widget widget)
  148. {
  149.   Scroller scroller = (Scroller) widget;
  150.  
  151.   /* Invoke the resize procedure of the superclass.
  152.      Probably there's some nominally more portable way to do this
  153.      (yeah right, like any of these slot names could possibly change
  154.      and have any existing code still work.)
  155.    */
  156.   widget->core.widget_class->core_class.superclass->core_class.resize (widget);
  157.  
  158.   /* Now run our callback (yeah, I should use a real callback, so sue me.) */
  159.   scroller->scroller.resize_hook (widget, scroller->scroller.resize_arg);
  160. }
  161.