|
|
static void initMiscTools( void ) ;
|
Call this function once at the beginning at your program, it will initialize the path manager and the timers.
Note that a window creation calls this function for you.
Example :
KMiscTools::initMiscTools(); |
| static char * makeFilePath(const char *filename ) ; |
Call this function to convert a filename into a local filename. Note that this functions also takes care of locating the current working directory.
leading \\ is also accepted in the path.
Use windows folder separators \\ for multiplatform use.
Example :
char *filename ;
filename = KMiscTools::makeFilePath("data\\images\\superpic.bmp" );
|
static unsigned long getTheTicks( void ) ;
|
Returns the number of ticks since the system started.
This value is system dependent, you shouldn't rely on it for precise operations.
Windows : 1 tick = 1 ms
Mac OS : 1 tick = 16 ms
Example :
unsigned long tickcount ;
tickcount= KMiscTools::getTheTicks( );
|
static char* getUserFolder( void ) ;
|
Returns the path of the user folder.
on windows: C:\Documents and Settings\username\My Documents.
on mac : /Users/username
|
static void messageBox(const char *title, const char *text ) ;
|
Displays a message box.
Mac OS X : Requires the linking of PTK_Resource.rsrc ( you can customise your messagebox in the resources! )
Example :
KMiscTools::messageBox("Problem" , "A big error has occured" ) ; |
static char* getLocale(void ) ;
|
Returns the current language the operating system is running in.
Example :
char *strlocale = KMiscTools::getLocale( ) ;
KMiscTools::messageBox( strlocale , 0 ) ;
//will display en_EN on an american system fr_FR on a french system. |
static void pause( long milliseconds , bool pollevents = false ) ;
|
| pauses the execution of the program
set pollevents to true to also process system events ( recommended , especially for os X , you risk a rainbow wheel not doing so )
Example :
KMiscTools::pause(100 , true ) ;
|
static unsigned long getMilliseconds( void ) ;
|
returns the number of milliseconds since the system started.
This is the most accurate time function of the PTK.
Note for Windows users : Require and hardware clock on the system else it returns 0.
Example :
unsigned long value = KMiscTools::getMilliseconds() ;
|
static void initMillisecond( void ) ;
|
Inits the millisecond hardware timer.
You do not need to call this function if you called KMiscTools::initMiscTools() ;
This function does absolutely nothing on Mac OS X.
Example :
KMiscTools::initMilliseconds() ; |
static long getYear(void);
|
Returns the current year.
Example :
long year = KMiscTools::getYear() ; |
static void launchURL( char *url , bool maximized) ;
|
Launch the default webbrowser to the specified website
Set maximized to true to launch the file in a maximized window ( windows only )
Example :
KMiscTools::launchURL( "http://www.phelios.com" ) ; |
static void launchFile( char *filename, bool maximized ) ;
|
Launch the specified file
Set maximized to true to launch the file in a maximized window ( windows only )
Example :
KMiscTools::launchFile( KMiscTools::makeFilePath( "data\\help.html" , true) ; |
static short flipShort( short value ) ;
|
flips the endians of the specified short.
This function does nothing on a window/linux machine.
Example :
short value2 = KMiscTools::flipShort( 10 ) ; |
static float flipFloat( float value ) ;
|
flips the endians of the specified float.
This function does nothing on a intel based machine.
Example :
float value2 = KMiscTools::flipFloat( 10 ) ; |
static void flipLong( long value ) ;
|
flips the endians of the specified long.
This function does nothing on a window/linux machine.
Example :
long value2 = KMiscTools::flipLong( 10 ) ; |
| static void enumerateFolder( char *folderpath , enumProc enumerationProcPtr ) |
You may return false if you want to END enumeration
isFolder==true if the returned path is a folder
typedef bool ( *enumProc ) ( char *filename , bool isFolder );
Example :
KMiscTools::enumerateFolder( "c:\\*.*" , displayResults ) ;
bool displayResults( char *f , bool isFolder )
{
//display only the folders
if ( isFolder == true )
{
if ( f ) KMiscTools::messageBox( 0 ,f ) ;
}
return true ;
}
|
static void setFileSource( bool inBundle ) ;
|
Mac os X only.
Call this function once at the beginning at your program to specify if the data of your program are located in the bundle of the application ( app/resources/ )
All the calls to KMiscTools::makeFilePath will then append the bundle path to the file.
Example :
KMiscTools::setFileSource( true );
Tip for Mac os X:
KMiscTools::setFileSource( true )
chdir( KMiscTools::makeFilePath( "" ) ;
will point to the current working directory.
|
|