2012-01-26 16:09:05 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* OpenSQLManager
|
|
|
|
*
|
|
|
|
* Free Database manager for Open Source Databases
|
|
|
|
*
|
2012-04-20 13:30:27 -04:00
|
|
|
* @package OpenSQLManager
|
2012-01-26 16:09:05 -05:00
|
|
|
* @author Timothy J. Warren
|
|
|
|
* @copyright Copyright (c) 2012
|
|
|
|
* @link https://github.com/aviat4ion/OpenSQLManager
|
2012-03-28 11:23:08 -04:00
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
2012-01-26 16:09:05 -05:00
|
|
|
*/
|
2012-01-27 16:57:59 -05:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-05-29 06:21:30 -04:00
|
|
|
namespace OpenSQLManager;
|
|
|
|
|
2012-01-27 16:57:59 -05:00
|
|
|
/**
|
|
|
|
* Main Window Class
|
|
|
|
*
|
|
|
|
* Creates and displays the main interface window
|
2012-04-20 13:30:27 -04:00
|
|
|
*
|
|
|
|
* @package OpenSQLManager
|
|
|
|
* @subpackage Windows
|
2012-01-27 16:57:59 -05:00
|
|
|
*/
|
2012-05-29 06:21:30 -04:00
|
|
|
class Main extends \wxFrame {
|
2012-01-26 16:09:05 -05:00
|
|
|
|
2012-04-19 12:29:47 -04:00
|
|
|
/**
|
|
|
|
* Reference to settings instance
|
2012-04-19 21:55:44 -04:00
|
|
|
*
|
|
|
|
* @var Settings
|
2012-04-19 12:29:47 -04:00
|
|
|
*/
|
|
|
|
private $settings;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reference to connection sidebar instance
|
2012-04-19 21:55:44 -04:00
|
|
|
*
|
|
|
|
* @var Connection_Sidebar
|
2012-04-19 12:29:47 -04:00
|
|
|
*/
|
|
|
|
private $connection_sidebar;
|
2012-01-27 16:57:59 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and display the main window on startup
|
|
|
|
*/
|
2012-02-21 11:45:42 -05:00
|
|
|
public function __construct()
|
2012-01-26 16:09:05 -05:00
|
|
|
{
|
2012-05-29 06:21:30 -04:00
|
|
|
parent::__construct(NULL, NULL, PROGRAM_NAME, \wxDefaultPosition, new \wxSize(800, 600));
|
2012-05-29 14:29:20 -04:00
|
|
|
|
|
|
|
$this->SetSizeHints(\wxDefaultSize, \wxDefaultSize);
|
|
|
|
|
|
|
|
$this->_create_menu();
|
|
|
|
|
|
|
|
$sbar = $this->CreateStatusBar(2);
|
|
|
|
$sbar->SetStatusText("OpenSQLManager");
|
|
|
|
|
2012-05-29 06:21:30 -04:00
|
|
|
$this->settings =& \Settings::get_instance();
|
2012-03-28 11:23:08 -04:00
|
|
|
|
2012-03-28 16:10:39 -04:00
|
|
|
// Layout the interface
|
2012-05-29 14:29:20 -04:00
|
|
|
$this->_main_layout();
|
2012-01-27 16:57:59 -05:00
|
|
|
}
|
|
|
|
|
2012-01-30 13:15:44 -05:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-03-27 09:37:04 -04:00
|
|
|
/**
|
|
|
|
* Some cleanup for when the main window is closed
|
2012-04-11 14:57:38 -04:00
|
|
|
*
|
|
|
|
* @return void
|
2012-03-27 09:37:04 -04:00
|
|
|
*/
|
|
|
|
public function __destruct()
|
|
|
|
{
|
2012-05-29 14:29:20 -04:00
|
|
|
$this->Destroy();
|
2012-03-27 09:37:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-03-28 11:23:08 -04:00
|
|
|
/**
|
2012-05-29 14:29:20 -04:00
|
|
|
* Exits the wx loop
|
2012-04-11 14:57:38 -04:00
|
|
|
*
|
|
|
|
* @return void
|
2012-01-30 13:15:44 -05:00
|
|
|
*/
|
2012-02-21 11:45:42 -05:00
|
|
|
public function quit()
|
2012-01-30 13:15:44 -05:00
|
|
|
{
|
2012-05-29 14:29:20 -04:00
|
|
|
$this->Destroy();
|
2012-01-30 13:15:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-01-27 16:57:59 -05:00
|
|
|
/**
|
|
|
|
* Layout the main interface
|
|
|
|
* Create menus, hboxes, vboxs and other widgets
|
2012-03-28 11:23:08 -04:00
|
|
|
*
|
|
|
|
* @return void
|
2012-01-27 16:57:59 -05:00
|
|
|
*/
|
|
|
|
private function _main_layout()
|
|
|
|
{
|
2012-05-29 14:29:20 -04:00
|
|
|
// Set up the main menu
|
|
|
|
$this->_create_menu();
|
|
|
|
|
|
|
|
$win = new \wxSplitterWindow($this);
|
|
|
|
$win->setSplitMode(wxSPLIT_HORIZONTAL);
|
2012-02-07 10:31:54 -05:00
|
|
|
|
2012-02-24 17:53:16 -05:00
|
|
|
// Add the connection sidebar
|
2012-02-28 10:38:13 -05:00
|
|
|
$this->connection_sidebar =& Connection_Sidebar::get_instance();
|
2012-01-26 16:09:05 -05:00
|
|
|
}
|
|
|
|
|
2012-01-30 13:15:44 -05:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-01-27 16:57:59 -05:00
|
|
|
/**
|
|
|
|
* Create the menu for the program
|
|
|
|
*
|
|
|
|
* @return GtkMenuBar
|
|
|
|
*/
|
|
|
|
private function _create_menu()
|
|
|
|
{
|
2012-03-28 16:10:39 -04:00
|
|
|
// Menu Bar
|
2012-05-29 06:21:30 -04:00
|
|
|
$menu_bar = new \wxMenuBar();
|
2012-01-27 16:57:59 -05:00
|
|
|
|
2012-03-28 16:10:39 -04:00
|
|
|
// Menu Bar Top Items
|
2012-05-29 14:29:20 -04:00
|
|
|
$top_file_menu = new \wxMenu();
|
|
|
|
$top_help_menu = new \wxMenu();
|
2012-03-28 11:23:08 -04:00
|
|
|
|
2012-03-28 16:10:39 -04:00
|
|
|
// File Menu
|
2012-01-31 11:39:30 -05:00
|
|
|
{
|
2012-03-28 16:10:39 -04:00
|
|
|
// Set up the quit item
|
2012-05-29 14:29:20 -04:00
|
|
|
$top_file_menu->Append(2, "&Quit", "Exit the program");
|
|
|
|
$this->Connect(2, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit"));
|
2012-01-27 16:57:59 -05:00
|
|
|
|
|
|
|
// Add the top level menu to the menubar
|
2012-05-29 14:29:20 -04:00
|
|
|
$menu_bar->Append($top_file_menu, "&File");
|
2012-01-31 11:39:30 -05:00
|
|
|
}
|
2012-01-27 16:57:59 -05:00
|
|
|
|
2012-03-28 16:10:39 -04:00
|
|
|
// Help Menu
|
2012-01-31 11:39:30 -05:00
|
|
|
{
|
2012-03-28 16:10:39 -04:00
|
|
|
// Set up the about item
|
2012-05-29 14:29:20 -04:00
|
|
|
//$top_help_menu->Append(4, "&About", "About this program");
|
|
|
|
//$this->Connect(4, wxEVT_COMMAND_MENU_SELECTED, "about");
|
2012-01-27 16:57:59 -05:00
|
|
|
|
|
|
|
// Add the top level menu to the menubar
|
2012-05-29 14:29:20 -04:00
|
|
|
$menu_bar->Append($top_help_menu, "&Help");
|
2012-01-31 11:39:30 -05:00
|
|
|
}
|
2012-01-27 16:57:59 -05:00
|
|
|
|
2012-03-28 11:23:08 -04:00
|
|
|
|
2012-05-29 14:29:20 -04:00
|
|
|
$this->SetMenuBar($menu_bar);
|
2012-03-28 11:23:08 -04:00
|
|
|
}
|
2012-01-27 16:57:59 -05:00
|
|
|
}
|
|
|
|
// End of main.php
|