|
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
|
00001 /********************************************************************************
00002 * *
00003 * Utility functions *
00004 * *
00005 *********************************************************************************
00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or *
00009 * modify it under the terms of the GNU Lesser General Public *
00010 * License as published by the Free Software Foundation; either *
00011 * version 2.1 of the License, or (at your option) any later version. *
00012 * *
00013 * This library is distributed in the hope that it will be useful, *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
00016 * Lesser General Public License for more details. *
00017 * *
00018 * You should have received a copy of the GNU Lesser General Public *
00019 * License along with this library; if not, write to the Free Software *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
00021 ********************************************************************************/
00022 #ifndef FXEXUTILS_H
00023 #define FXEXUTILS_H
00024 namespace FXEX {
00025
00026 /**
00027 * The FXUtils namespace encapsulates some useful functions, into a single collection.
00028 */
00029 namespace FXUtils {
00030
00031 /**
00032 * Save the machine dependant endianness value to the stream
00033 */
00034 extern FXAPI void saveEndianness(FXStream& store);
00035
00036 /**
00037 * Load the machine dependant endianness value from the stream,
00038 * and setup stream to swap the bytes if the stream byte order
00039 * is non-native to the CPU architecture
00040 */
00041 extern FXAPI void loadEndianness(FXStream& store);
00042
00043 /**
00044 * Create a random seed for use with fxrandom.
00045 * It is based on the current time, so its a _reasonably_ random seed
00046 */
00047 extern FXAPI FXuint fxrandomseed();
00048
00049 /**
00050 * A useful function calls for generating random numbers
00051 * generate an integer/float number between [lowerBound,upperBound).
00052 */
00053 extern FXAPI FXint fxrand(FXint upperBound,FXint lowerBound=0);
00054 /// Returns a float rather than an int.
00055 extern FXAPI FXfloat fxrand(FXfloat upperBound,FXfloat lowerBound=0.0);
00056
00057 /**
00058 * Set the font of all children - this is recursive
00059 */
00060 extern FXAPI void setFontOfChildren(FXComposite* w,FXFont* f);
00061
00062 /**
00063 * Enable every widget and its children
00064 */
00065 extern FXAPI void enableWindow(FXWindow* w);
00066
00067 /**
00068 * Disable every widget and its children
00069 */
00070 extern FXAPI void disableWindow(FXWindow* w);
00071
00072 /// set the flags appropriately for the platform
00073 extern FXAPI FXuint fxfilemode(FXFilePermission permissions);
00074
00075 /// load an image from a file
00076 extern FXAPI FXbool loadFileImage(const FXString& file,FXImage *img);
00077
00078 /// load an icon from a file
00079 extern FXAPI FXbool loadFileIcon(const FXString& file,FXIcon *ico);
00080
00081 /**
00082 * Load an image from a file; return an FXImage.
00083 * ... dont forget to delete the image, when finished with...
00084 */
00085 extern FXAPI FXImage* loadImage(const FXString& file);
00086
00087 /**
00088 * Load an icon from a file; return an FXIcon
00089 * ... dont forget to delete the icon, when finished with...
00090 */
00091 extern FXAPI FXIcon* loadIcon(const FXString& file);
00092
00093 /**
00094 * For anyone that uses images/icons with transparency here is a pretty
00095 * good function to have. A function I wrote called blendIcon is below.
00096 * Basically it takes and icon and applies the transparency blend for you
00097 * and sets the color back to the icon. When using icons/images with
00098 * gradient transparencies (such as those used for drop shadows) on menus
00099 * and buttons they will look perfect. It should be somewhat optimized so
00100 * that no floating point math is needed. Here is a simple example of how
00101 * to use it:
00102 *
00103 * FXPNGIcon *icon = new FXPNGIcon(getApp(), my_icon);
00104 * blendIcon(icon, getApp()->getBaseColor());
00105 * FXButton *button = new FXButton(this, "Click", icon);
00106 */
00107 extern FXAPI FXIcon* blendIcon(FXIcon *icon, FXColor baseColor);
00108
00109
00110 }; // namespace FXUtils
00111 }; // namespace FXEX
00112
00113 #endif // FXEXUTILS_H