Update main entry to wxPHP

Well, at least there's a window...
This commit is contained in:
Timothy Warren 2012-05-29 06:21:30 -04:00
parent d4def2fc04
commit 49e531b591
2 changed files with 59 additions and 24 deletions

View File

@ -17,12 +17,12 @@
/**
* Bootstrap file
*
* Initializes parent window and starts the GTK event loop
* Initializes parent window and starts the wx event loop
*/
// --------------------------------------------------------------------------
namespace OpenSQLManager;
// Suppress errors that php-gtk puts out
// --------------------------------------------------------------------------
error_reporting(-1);
// Set the stupid timezone so PHP shuts up.
@ -51,13 +51,13 @@ function log_fatal()
$fatal = array(E_ERROR, E_PARSE, E_RECOVERABLE_ERROR);
// Log error.
if(in_array($error['type'], $fatal))
{
/*if(in_array($error['type'], $fatal))
{*/
file_put_contents('errors.txt', print_r($error, TRUE), FILE_APPEND);
}
//}
}
register_shutdown_function('log_fatal');
register_shutdown_function('OpenSQLManager\log_fatal');
// --------------------------------------------------------------------------
@ -88,12 +88,12 @@ if( ! class_exists('pdo'))
*/
function exception_error_handler($errno, $errstr, $errfile, $errline)
{
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
}
// Do this after the two compatibility checks for cleaner output
// Note that this will throw exceptions on notices
set_error_handler("exception_error_handler", E_ERROR | E_WARNING | E_NOTICE);
set_error_handler("OpenSQLManager\exception_error_handler", E_ERROR | E_WARNING | E_NOTICE);
// --------------------------------------------------------------------------
@ -121,7 +121,8 @@ if ( ! function_exists('do_include'))
*/
function osm_autoload($class)
{
$class = strtolower($class);
$class_spaces = explode('\\', $class);
$class = strtolower(end($class_spaces));
$widget_path = BASE_DIR . "/widgets/{$class}.php";
$window_path = BASE_DIR . "/windows/{$class}.php";
@ -139,7 +140,7 @@ function osm_autoload($class)
// Load everything so that we don't have to do requires later
require_once(BASE_DIR . '/common/functions.php');
spl_autoload_register('osm_autoload');
spl_autoload_register('OpenSQLManager\osm_autoload');
// --------------------------------------------------------------------------
@ -147,12 +148,45 @@ spl_autoload_register('osm_autoload');
require_once(BASE_DIR . "/db/autoload.php");
// --------------------------------------------------------------------------
// ! App Bootstrap class
// --------------------------------------------------------------------------
/**
* Class for the app itself
*
* @package OpenSQLManager
*/
class OpenSQLManager extends \wxApp {
/**
* Initialize the app
*
* @return int
*/
public function OnInit()
{
$main = new Main();
$main->show();
return 0;
}
/**
* Return exit code
*
* @return int
*/
public function OnExit()
{
return 0;
}
}
// Create the main window
$app = new Main();
$app = new OpenSQLManager();
// Start the wx event loop
wxApp::SetInstance($app);
wxEntry();
\wxApp::SetInstance($app);
\wxEntry();
// End of index.php
// End of OpenSQLManager.php

View File

@ -13,6 +13,8 @@
// --------------------------------------------------------------------------
namespace OpenSQLManager;
/**
* Main Window Class
*
@ -21,7 +23,7 @@
* @package OpenSQLManager
* @subpackage Windows
*/
class Main extends GtkWindow {
class Main extends \wxFrame {
/**
* Reference to settings instance
@ -42,12 +44,12 @@ class Main extends GtkWindow {
*/
public function __construct()
{
parent::__construct();
parent::__construct(NULL, NULL, PROGRAM_NAME, \wxDefaultPosition, new \wxSize(800, 600));
$this->settings =& Settings::get_instance();
$this->settings =& \Settings::get_instance();
if ( ! is_null($this->settings->width) && ! is_null($this->settings->height))
/*if ( ! is_null($this->settings->width) && ! is_null($this->settings->height))
{
// Resize to the last size
$this->set_size_request($this->settings->width, $this->settings->height);
@ -68,7 +70,7 @@ class Main extends GtkWindow {
}
// Layout the interface
$this->_main_layout();
$this->_main_layout();*/
}
// --------------------------------------------------------------------------
@ -81,7 +83,7 @@ class Main extends GtkWindow {
public function __destruct()
{
// Save the Window position
$this->settings->position = $this->get_position();
/*$this->settings->position = $this->get_position();
list($width, $height) = $this->get_size();
@ -89,8 +91,7 @@ class Main extends GtkWindow {
$this->settings->height = $height;
// Save the Window width
$this->settings->width = $width;
$this->settings->width = $width;*/
}
// --------------------------------------------------------------------------
@ -158,7 +159,7 @@ class Main extends GtkWindow {
private function _create_menu()
{
// Menu Bar
$menu_bar = new GtkMenuBar();
$menu_bar = new \wxMenuBar();
// Menu Bar Top Items
$top_file_menu = new GtkMenuItem('_File');