slider.h

Go to the documentation of this file.
00001 #ifndef SLIDER_CLASS
00002 #define SLIDER_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : slider                                                            *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *  Purpose:                                                                   *
00010 *                                                                             *
00011 *    Serves as a horizontal or vertical controller for displaying other parts *
00012 *  of an on-screen object.  These either have a plain bar that can be clicked *
00013 *  on (with a grabbable control knob as well), or they can also have arrows   *
00014 *  for making small position adjustments.                                     *
00015 *                                                                             *
00016 *******************************************************************************
00017 * Copyright (c) 1991-$now By Author.  This program is free software; you can  *
00018 * redistribute it and/or modify it under the terms of the GNU General Public  *
00019 * License as published by the Free Software Foundation; either version 2 of   *
00020 * the License or (at your option) any later version.  This is online at:      *
00021 *     http://www.fsf.org/copyleft/gpl.html                                    *
00022 * Please send any updates to: fred@gruntose.com                               *
00023 \*****************************************************************************/
00024 
00025 #include "dll_wp_active.h"
00026 
00027 #include <basis/istring.h>
00028 #include <wp_passive/worker.h>
00029 
00030 enum slider_orientation { HORIZONTAL_SLIDER, VERTICAL_SLIDER };
00031 
00032 class WP_ACTIVE_CLASS_STYLE slider : public worker
00033 {
00034 public:
00035   slider(manager &parent, const c_point &origin, const char *name,
00036       slider_orientation h_or_v, double minValue, double maxValue,
00037       double granularity = 0.0, const color &foreground = colors::WHITE,
00038       const color &background = colors::BLACK);
00039     // creates a sliding control bar.  if granularity is non-zero, then the
00040     // slider has arrows and can be moved in single granularity sized
00041     // increments.  Otherwise the slider is moved only by hitting the slider
00042     // bar.  The default value of the slider after construction is the
00043     // "minValue" of the slider.
00044 
00045   ~slider();
00046 
00047   IMPLEMENT_CLASS_NAME("slider");
00048 
00049   double value();
00050   void value(double value, bool trigger_event = true);
00051     // observes or modifies the position of the slider.  it can be modified
00052     // with or without an invocation of the slider_moved_event.
00053 
00054   virtual void slider_moved_event(double value);
00055     // this function is triggered when the user moves the bar of the slider or
00056     // when a program calls set_value and wants to trigger the callback.
00057 
00058   static void slider_callback(window_handle w, slider *the_slider,
00059           XmScaleCallbackStruct *call_data);
00060   static void less_arrow_callback(window_handle w, slider *the_slider,
00061           XmAnyCallbackStruct *call_data);
00062   static void more_arrow_callback(window_handle w, slider *the_slider,
00063           XmAnyCallbackStruct *call_data);
00064 
00065 private:
00066   window_handle maximum_Arrow;
00067   window_handle minimum_Arrow;
00068   window_handle slider_w;
00069   istring maximum_ArrowName;
00070   istring minimum_ArrowName;
00071   istring sliderName;
00072 
00073   double current_value;
00074   double minimum_value;
00075   double maximum_value;
00076   double granularity;
00077 
00078   window_handle create_holder
00079     (window_handle parent, const char *name, slider_orientation h_or_v);
00080 
00081   window_handle create_slider(window_handle parent, const char *name,
00082       slider_orientation h_or_v, int minimum_value, int maximum_Value);
00083 
00084   void check_value(double value);
00085 
00086   double round_to_granularity
00087     (double unrounded, double minimum_value, double granularity);
00088 
00089   int real_orientation(slider_orientation to_translate);
00090 };
00091 
00092 #endif

Generated on Fri Nov 28 04:29:04 2008 for HOOPLE Libraries by  doxygen 1.5.1