Differences

Jefferson González edited this page Mar 26, 2014 · 13 revisions

Version Scheme

The wxPHP version consist of 4 numbers instead of 3 like wxWidgets does. This version number looks as follows:

3.0.0.0

The first 3 numbers reflect the wxWidgets version being used by wxPHP while the last number is used to identify the wxPHP revision. If changes or fixes are added to wxPHP the last number will be increased. For example:

3.0.0.1

Application Initialization

Initializing a wxPHP application can be done by extending the wxApp class and calling wxApp::SetInstance($mycustomapp) followed by wxEntry();

Example Code

<?php 
class SomeWindow extends wxFrame 
{
    function __construct( $parent=null ){
        parent::__construct( $parent, wxID_ANY);
        //Your code here...
    }
}

//Application initialization start point
class MyApp extends wxApp 
{
    function OnInit()
    {
        $this->frame = new SomeWindow();
        $this->frame->Show();
		
        return true;
    }
	
    function OnExit()
    {
        return 0;
    }
}

$customapp = new MyApp();
wxApp::SetInstance($customapp);
wxEntry();

Also, as of version 3.0.0.1 you can initialize a wxphp application without the need to instantiate a wxApp object which reduces the amount of code needed as follows:

<?php 
class SomeWindow extends wxFrame 
{
    function __construct( $parent=null ){
        parent::__construct( $parent, wxID_ANY);
        //Your code here...
    }
}

$frame = new SomeWindow();
$frame->Show();

wxEntry();

Data Types

Some classes of wxWidgets where replaced with php native data types to make the library more integrated into PHP. You should always check the wxPHP reference pages since they will tell you which data types are accepted on each methods and functions. Basically these classes are:

  • wxArrayString - PHP array, for example:

    <?php
    $aboutdialog = new wxAboutDialogInfo();
    $aboutdialog->SetDevelopers(array("John", "Peter"));
  • wxDateTime - Timestamp integer, for exampe:

    <?php
    $datepicker = new wxDatePickerCtrl();
    $datepicker->SetValue(time());
  • wxString - PHP string, for example:

    <?php
    $aboutdialog = new wxAboutDialogInfo();
    $aboutdialog->AddArtist("Peter");

Global Objects

Objects which are declared globally on the wxWidgets library are binded on wxPHP as global constants. This is to be able to call them without adding the dollar sign. One example of this would be wxNORMAL_FONT which in wxWidgets is an object of the type wxFont. In PHP there isn't official support for constants of objects since it doesn't make sense after all. So doing something like this will fail:

<?php
$pointsize = wxNORMAL_FONT->GetPointSize(); //Wrong!

Instead, you would need to use a custom function we added to the library which is called wxC2D. This function converts constants into dynamic objects. So the previous code would look like this:

<?php
$pointsize = wxC2D(wxNORMAL_FONT)->GetPointSize();

Conflicting Method Names

Some wxWidgets method names conflict with PHP reserved keywords, so they were renamed by appending the word "Method" to them as follows:

  • Clone -> CloneMethod
  • Exit -> ExitMethod
  • Print -> PrintMethod
  • Break -> BreakMethod
  • New -> NewMethod
  • Xor -> XorMethod
  • Yield -> YieldMethod
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.