Some tab tests

Renamed Constants to have a consistent prefix
This commit is contained in:
Timothy Warren 2012-11-27 13:31:55 -05:00
parent 471925bc72
commit 0f02d9a423
6 changed files with 74 additions and 37 deletions

View File

@ -31,11 +31,11 @@ date_default_timezone_set('GMT');
ini_set('memory_limit', -1); ini_set('memory_limit', -1);
// Set the current directory as the base for included files // Set the current directory as the base for included files
define('BASE_DIR', __DIR__.'/sys'); define('OSM_BASE_DIR', __DIR__.'/sys');
define('RESOURCE_DIR', __DIR__.'/resources'); define('OSM_RESOURCE_DIR', __DIR__.'/resources');
define('SETTINGS_DIR', __DIR__); define('OSM_SETTINGS_DIR', __DIR__);
define('PROGRAM_NAME', 'OpenSQLManager'); define('OSM_PROGRAM_NAME', 'OpenSQLManager');
define('VERSION', '0.2.0pre'); define('OSM_VERSION', '0.2.0pre');
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -132,8 +132,8 @@ function osm_autoload($class)
{ {
$class_spaces = explode('\\', $class); $class_spaces = explode('\\', $class);
$class = strtolower(end($class_spaces)); $class = strtolower(end($class_spaces));
$widget_path = BASE_DIR . "/widgets/{$class}.php"; $widget_path = OSM_BASE_DIR . "/widgets/{$class}.php";
$window_path = BASE_DIR . "/windows/{$class}.php"; $window_path = OSM_BASE_DIR . "/windows/{$class}.php";
if (is_file($widget_path)) if (is_file($widget_path))
{ {
@ -148,13 +148,13 @@ function osm_autoload($class)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Load all the common classes, and register the autoloader // Load all the common classes, and register the autoloader
array_map('OpenSQLManager\do_include', glob(BASE_DIR.'/common/*.php')); array_map('OpenSQLManager\do_include', glob(OSM_BASE_DIR.'/common/*.php'));
spl_autoload_register('OpenSQLManager\osm_autoload'); spl_autoload_register('OpenSQLManager\osm_autoload');
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Auto-load db drivers // Auto-load db drivers
require_once(BASE_DIR . "/db/autoload.php"); require_once(OSM_BASE_DIR . "/db/autoload.php");
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! App Bootstrap class // ! App Bootstrap class

View File

@ -18,6 +18,7 @@ I've put together this package from the latest wxPHP windows package. It's avail
* php5-postgresql * php5-postgresql
* php5-sqlite * php5-sqlite
* php5-ssh2 * php5-ssh2
* Firebird support has to be manually compiled
* Compile wxPHP extension * Compile wxPHP extension
* Run via terminal in the OpenSQLManager folder using `php OpenSQLManager.php` * Run via terminal in the OpenSQLManager folder using `php OpenSQLManager.php`

View File

@ -57,13 +57,13 @@ class Settings {
private function __construct() private function __construct()
{ {
// For testing and use outside of OpenSQLManager, // For testing and use outside of OpenSQLManager,
// define a different SETTINGS_DIR // define a different settings directory
if ( ! defined('SETTINGS_DIR')) if ( ! defined('OSM_SETTINGS_DIR'))
{ {
define('SETTINGS_DIR', '.'); define('OSM_SETTINGS_DIR', '.');
} }
$path = SETTINGS_DIR.'/settings.json'; $path = OSM_SETTINGS_DIR.'/settings.json';
if( ! is_file($path)) if( ! is_file($path))
{ {
@ -102,7 +102,7 @@ class Settings {
? json_encode($this->current, JSON_PRETTY_PRINT) ? json_encode($this->current, JSON_PRETTY_PRINT)
: json_encode($this->current); : json_encode($this->current);
file_put_contents(SETTINGS_DIR . '/settings.json', $file_string); file_put_contents(OSM_SETTINGS_DIR . '/settings.json', $file_string);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

View File

@ -33,7 +33,7 @@ class Data_Grid extends \wxGrid {
if ( ! is_null($parent)) if ( ! is_null($parent))
{ {
parent::__construct($parent, wxID_ANY); parent::__construct($parent, wxID_ANY);
$this->CreateGrid(0,0); $this->CreateGrid(10,10);
$this->HideColLabels(); $this->HideColLabels();
$this->HideRowLabels(); $this->HideRowLabels();
} }

View File

@ -21,7 +21,7 @@ namespace OpenSQLManager;
* @package OpenSQLManager * @package OpenSQLManager
* @subpackage Widgets * @subpackage Widgets
*/ */
class DB_tabs extends \wxNotebook { class DB_tabs extends \wxAUINotebook {
/** /**
* Current Tab Widget object * Current Tab Widget object
@ -36,17 +36,24 @@ class DB_tabs extends \wxNotebook {
* @var array * @var array
*/ */
private $data; private $data;
/**
* Reference to parent
*
* @var wxWindow
*/
private $parent;
/** /**
* Return the db tabs object if it exists, or create and return * Return the db tabs object if it exists, or create and return
* *
* @return DB_tabs * @return DB_tabs
*/ */
public static function &get_instance() public static function &get_instance($parent)
{ {
if (empty(self::$instance)) if (empty(self::$instance))
{ {
self::$instance = new DB_tabs(); self::$instance = new DB_tabs($parent);
} }
return self::$instance; return self::$instance;
@ -57,10 +64,11 @@ class DB_tabs extends \wxNotebook {
/** /**
* Create the object * Create the object
*/ */
public function __construct() public function __construct($parent)
{ {
parent::__construct(); parent::__construct($parent);
$this->data = new StdClass(); $this->parent = $parent;
$this->data = new \StdClass();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -76,10 +84,11 @@ class DB_tabs extends \wxNotebook {
{ {
if (is_null($widget)) if (is_null($widget))
{ {
$widget = new Data_Grid(); $widget = new Data_Grid($this);
} }
//$this->append_page($widget, new GtkLabel($label)); $this->AddPage($widget, $label);
} }
} }
// End of db_tabs.php // End of db_tabs.php

View File

@ -23,7 +23,10 @@ namespace OpenSQLManager;
* @package OpenSQLManager * @package OpenSQLManager
* @subpackage Windows * @subpackage Windows
*/ */
class Main extends \wxFrame { class Main extends \wxFrame {
const MAC_EXIT_ITEM = 100;
const MAC_ABOUT_ITEM = 101;
/** /**
* Reference to settings instance * Reference to settings instance
@ -51,7 +54,7 @@ class Main extends \wxFrame {
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(NULL, NULL, PROGRAM_NAME, \wxDefaultPosition,new \wxSize(800, 480)); parent::__construct(NULL, NULL, OSM_PROGRAM_NAME, \wxDefaultPosition, new \wxSize(800, 480));
$this->_create_menu(); $this->_create_menu();
$sbar = $this->CreateStatusBar(2); $sbar = $this->CreateStatusBar(2);
@ -99,14 +102,14 @@ class Main extends \wxFrame {
{ {
$dlg = new \wxAboutDialogInfo(); $dlg = new \wxAboutDialogInfo();
$dlg->SetName(PROGRAM_NAME); $dlg->SetName(OSM_PROGRAM_NAME);
$dlg->SetVersion(VERSION); $dlg->SetVersion(OSM_VERSION);
$dlg->SetCopyright("Copyright (c) ".date('Y')." Timothy J. Warren"); $dlg->SetCopyright("Copyright (c) ".date('Y')." Timothy J. Warren");
$dlg->SetWebSite('https://github.com/aviat4ion/OpenSQLManager','Fork on Github'); $dlg->SetWebSite('https://github.com/aviat4ion/OpenSQLManager','Fork on Github');
$dlg->SetLicense(file_get_contents(RESOURCE_DIR . "/LICENSE")); $dlg->SetLicense(file_get_contents(OSM_RESOURCE_DIR . "/LICENSE"));
$dlg->SetDevelopers(array( $dlg->SetDevelopers(array(
'Timothy J. Warren', 'Timothy J. Warren',
@ -118,13 +121,15 @@ class Main extends \wxFrame {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Layout tabs for databases, tables, &c; * Loads data tabs for the selected database
*
* @param string $dbname
*/ */
public function load_tabs() public function load_tabs($dbname)
{ {
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -144,7 +149,8 @@ class Main extends \wxFrame {
// Add the connection sidebar // Add the connection sidebar
$this->connection_sidebar =& Connection_Sidebar::get_instance($win); $this->connection_sidebar =& Connection_Sidebar::get_instance($win);
$win2 = new Data_Grid($win); $win2 = new Db_tabs($win);
$win2->add_tab('Test');
// Add the widgets to the split window // Add the widgets to the split window
$win->SplitVertically($this->connection_sidebar, $win2); $win->SplitVertically($this->connection_sidebar, $win2);
@ -162,23 +168,32 @@ class Main extends \wxFrame {
* @return void * @return void
*/ */
private function _create_menu() private function _create_menu()
{ {
// Menu Bar // Menu Bar
$menu_bar = new \wxMenuBar(); $menu_bar = new \wxMenuBar();
// Menu Bar Top Items // Menu Bar Top Items
$top_file_menu = new \wxMenu(); $top_file_menu = new \wxMenu();
$top_export_menu = new \wxMenu();
$top_help_menu = new \wxMenu(); $top_help_menu = new \wxMenu();
// File Menu // File Menu
{ {
// Set up the quit item // Set up the quit item
$top_file_menu->Append(wxID_EXIT, "&Quit\tCtrl+Q", "Exit the program"); $top_file_menu->Append(wxID_EXIT, "&Quit\tCtrl+Q", "Exit the program");
$this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit")); $this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit"));
// Add the top level menu to the menubar // Add the top level menu to the menubar
$menu_bar->Append($top_file_menu, "&File"); $menu_bar->Append($top_file_menu, "&File");
} }
// Export Menu
{
// Add the top level menu to the menubar
$menu_bar->Append($top_export_menu, "E&xport");
}
// Help Menu // Help Menu
{ {
@ -189,6 +204,18 @@ class Main extends \wxFrame {
// Add the top level menu to the menubar // Add the top level menu to the menubar
$menu_bar->Append($top_help_menu, "&Help"); $menu_bar->Append($top_help_menu, "&Help");
}
// For OS X, duplicate the Quit and About menu items
if (PLATFORM == wxOS_MAC_OSX_DARWIN)
{
// Quit
$top_file_menu->Append(self::MAC_EXIT_ITEM, "&Quit\tCtrl+Q", "Exit the program");
$this->Connect(self::MAC_EXIT_ITEM, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit"));
// About
$top_help_menu->Append(self::MAC_ABOUT_ITEM, "&About", "About this program");
$this->Connect(self::MAC_ABOUT_ITEM, wxEVT_COMMAND_MENU_SELECTED, array($this, "about"));
} }
$this->SetMenuBar($menu_bar); $this->SetMenuBar($menu_bar);