Main Page | Class Hierarchy | Class List | File List | Class Members

Flu_Helpers.h

00001 // $Id: Flu_Helpers.h,v 1.8 2005/08/29 19:18:18 jbryan Exp $
00002 
00003 /***************************************************************
00004  *                FLU - FLTK Utility Widgets 
00005  *  Copyright (C) 2002 Ohio Supercomputer Center, Ohio State University
00006  *
00007  * This file and its content is protected by a software license.
00008  * You should have received a copy of this license with this file.
00009  * If not, please contact the Ohio Supercomputer Center immediately:
00010  * Attn: Jason Bryan Re: FLU 1224 Kinnear Rd, Columbus, Ohio 43212
00011  * 
00012  ***************************************************************/
00013 
00014 
00015 
00016 #ifndef _FLU_HELPERS_H
00017 #define _FLU_HELPERS_H
00018 
00019 #include <FL/Fl.H>
00020 #include <FL/Fl_Window.H>
00021 #include <FL/Fl_Button.H>
00022 #include <FL/Fl_Valuator.H>
00023 #include <FL/Fl_Menu_.H>
00024 #include <FL/Fl_Menu_Item.H>
00025 #include "FLU/Flu_Enumerations.h"
00026 
00027 /* Convenience routine to hide all open windows. This will (eventually) cause FLTK to exit() */
00028 inline static void fl_exit()
00029 { while( Fl::first_window() ) Fl::first_window()->hide(); }
00030 
00031 /* Set the active state of the menu entry (if it exists) at 'fullname' to 'active'
00032  */
00033 FLU_EXPORT void fl_Set_Menu_Item_Active_State( Fl_Menu_* menu, const char* fullname, bool active );
00034 
00035 /* Return the index of the full menu entry 'fullname' in the menu 'menu', or
00036    -1 if 'fullname' does not exist in 'menu'.
00037 */
00038 FLU_EXPORT int fl_Full_Find_In_Menu( const Fl_Menu_* menu, const char* fullname );
00039 inline int fl_Full_Find_In_Menu( const Fl_Menu_& menu, const char* fullname )
00040 { return fl_Full_Find_In_Menu( &menu, fullname ); }
00041 
00042 /* Return the menu item at the full menu entry 'fullname' in the menu 'menu', or
00043    NULL if 'fullname' does not exist in 'menu'.
00044 */
00045 inline const Fl_Menu_Item *fl_Full_Find_Item_In_Menu( const Fl_Menu_* menu, const char* fullname )
00046 {
00047   int index = fl_Full_Find_In_Menu( menu, fullname );
00048   return (index != -1) ? &(((Fl_Menu_Item*)menu->menu())[index]) : 0;
00049 }
00050 inline const Fl_Menu_Item *fl_Full_Find_Item_In_Menu( const Fl_Menu_& menu, const char* fullname )
00051 { return fl_Full_Find_Item_In_Menu( &menu, fullname ); }
00052 
00053 /* Return the index of the menu entry 'name' in the menu 'menu', or
00054    -1 if 'name' does not exist in 'menu'.
00055 */
00056 FLU_EXPORT int fl_Find_In_Menu( const Fl_Menu_* menu, const char* name );
00057 inline int fl_Find_In_Menu( const Fl_Menu_& menu, const char* name )
00058 { return fl_Find_In_Menu( &menu, name ); }
00059 
00060 /* Convenience callback for an Fl_Widget to show an Fl_Window. "arg" MUST be an instance or descendent of Fl_Window */
00061 inline static void fl_Show_Window_Callback( Fl_Widget* w, void* arg )
00062 { ((Fl_Window*)arg)->show(); }
00063 
00064 /* Convenience callback for an Fl_Widget to hide an Fl_Window. "arg" MUST be an instnace or descendent of Fl_Window */
00065 inline static void fl_Hide_Window_Callback( Fl_Widget* w, void* arg )
00066 { ((Fl_Window*)arg)->hide(); }
00067 
00068 /* Convenience callback for an Fl_Button to activate/deactivate another widget based on its value. "w" MUST be an instance or descendent of Fl_Button. "arg" MUST be an instance or descendent of Fl_Widget. */
00069 inline static void fl_Activate_On_Value_Callback( Fl_Widget* w, void *arg )
00070 { if( ((Fl_Button*)w)->value() ) ((Fl_Widget*)arg)->activate(); else ((Fl_Widget*)arg)->deactivate(); }
00071 
00072 /* Convenience callback for an Fl_Widget to hide an Fl_Window. "arg" MUST be an instance or descendent of Fl_Window.
00073    Before the window is hidden, its user_data() field is set to the widget that invoked the callback.
00074    The user_data() can then be used to determine which widget closed the window.
00075 */
00076 inline static void fl_Hide_Window_And_Set_User_Data_Callback( Fl_Widget* w, void* arg )
00077 { ((Fl_Window*)arg)->user_data( w ); ((Fl_Window*)arg)->hide(); }
00078 
00079 /* Convenience callback to get the value of an Fl_Button and store it (as an int) into "arg". ONLY use this for an Fl_Button and "arg" MUST point to an int. */
00080 inline static void fl_Get_Button_Value_Callback( Fl_Widget* w, void* arg )
00081 { *((int*)arg) = ((Fl_Button*)w)->value(); }
00082 
00083 /* Convenience callback to get the value of an Fl_Valuator and store it (as a float) into "arg". ONLY use this for an Fl_Valuator and "arg" MUST point to a float. */
00084 inline static void fl_Get_Valuator_Value_Callback( Fl_Widget* w, void* arg )
00085 { *((float*)arg) = ((Fl_Valuator*)w)->value(); }
00086 
00087 #endif

Generated on Mon Sep 26 07:54:04 2005 for FLTK Utility Library and Widget Collection (FLU) by doxygen 1.3.5