Contents

wxWidgets helper types

wxWidgets consists of a large group of helper types, that help programmers to do their job. Here we will show only a tiny drop of the whole lake.

Utility functions

wxWidgets has several handy utility functions for executing a process, getting a home user directory or getting the OS name.

In the following example, we execute the ls command. For this, we have the wxShell() function. Linux/MacOS only.

shell.bmx <- Open source
SuperStrict Framework wx.wxApp Import wx.wxProcess New MyApp.Run() Type MyApp Extends wxApp Method OnInit:Int() wxShell("ls -l") Return False End Method End Type
Output
total 40 -rwxr-xr-x 1 vronskij vronskij 9028 2007-09-06 22:10 basic -rw-r--r-- 1 vronskij vronskij 95 2007-09-06 22:09 basic.cpp -rw-r--r-- 1 vronskij vronskij 430 2007-09-06 00:07 basic.cpp~ -rwxr-xr-x 1 vronskij vronskij 11080 2007-09-05 23:17 console -rw-r--r-- 1 vronskij vronskij 500 2007-09-05 23:17 console.cpp -rw-r--r-- 1 vronskij vronskij 485 2007-09-05 23:16 console.cpp~

Next we will we will get the home user directory, os name, user name, host name and total free memory.


SuperStrict
 
Framework wx.wxApp
Import BRL.StandardIO
 
New MyApp.Run()
 
Type MyApp Extends wxApp

	Method OnInit:Int()
	
		Print wxGetHomeDir()
		Print wxGetOsDescription()
		Print wxGetUserName()
		Print wxGetFullHostName()
 
		Print "Memory: " + wxGetFreeMemory()
 
		Return False
	End Method

End Type
Output
/home/vronskij Linux 2.6.20-16-generic i686 jan bodnar spartan Memory: 741244928

Time & date

In wxWidgets, we have several types for working with date & time.

The example shows current date or time in various formats.


SuperStrict
 
Framework wx.wxApp
Import wx.wxDateTime
Import BRL.StandardIO
 
New MyApp.Run()
 
Type MyApp Extends wxApp

	Method OnInit:Int()
	
		Local now:wxDateTime = wxDateTime.Now()

		Print now.Format()
		Print now.Format("%X")
		Print now.Format("%x")
 
		Return False
	End Method

End Type
Output
Fri Sep 7 21:28:38 2007 21:28:38 09/07/07

Next we will show current time in different cities.


SuperStrict
 
Framework wx.wxApp
Import wx.wxDateTime
Import BRL.StandardIO
 
New MyApp.Run()
 
Type MyApp Extends wxApp

	Method OnInit:Int()
	
		Local now:wxDateTime = wxDateTime.Now()
 
		Print "   Tokyo: " + now.Format("%a %T", wxDateTime.GMT9)
		Print "  Moscow: " + now.Format("%a %T", wxDateTime.MSD)
		Print "Budapest: " + now.Format("%a %T", wxDateTime.CEST)
		Print "  London: " + now.Format("%a %T", wxDateTime.WEST)
		Print "New York: " + now.Format("%a %T", wxDateTime.EDT)
 
		Return False
	End Method

End Type
Output
Tokyo: Sat 05:42:24 Moscow: Sat 00:42:24 Budapest: Fri 22:42:24 London: Fri 22:42:24 New York: Fri 16:42:24

The following example shows, how we can add date spans to our date/time. We add one month to the current time.


SuperStrict
 
Framework wx.wxApp
Import wx.wxDateTime
Import BRL.StandardIO
 
New MyApp.Run()
 
Type MyApp Extends wxApp

	Method OnInit:Int()
	
		Local now:wxDateTime = wxDateTime.Now()
		Print now.Format("%B %d %Y")
 
		Local span:wxDateSpan = New wxDateSpan.Create(0, 1)
		Local later:wxDateTime = now.AddDS(span)
 
		Print later.Format("%B %d %Y")
 
		Return False
	End Method

End Type
Output
September 07 2007 October 07 2007