146 lines
3.0 KiB
PHP
146 lines
3.0 KiB
PHP
<?php
|
|
/**
|
|
* OpenSQLManager
|
|
*
|
|
* Free Database manager for Open Source Databases
|
|
*
|
|
* @package OpenSQLManager
|
|
* @author Timothy J. Warren
|
|
* @copyright Copyright (c) 2012
|
|
* @link https://github.com/aviat4ion/OpenSQLManager
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
*/
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
namespace OpenSQLManager;
|
|
|
|
/**
|
|
* Main Window Class
|
|
*
|
|
* Creates and displays the main interface window
|
|
*
|
|
* @package OpenSQLManager
|
|
* @subpackage Windows
|
|
*/
|
|
class Main extends \wxFrame {
|
|
|
|
/**
|
|
* Reference to settings instance
|
|
*
|
|
* @var Settings
|
|
*/
|
|
private $settings;
|
|
|
|
/**
|
|
* Reference to connection sidebar instance
|
|
*
|
|
* @var Connection_Sidebar
|
|
*/
|
|
private $connection_sidebar;
|
|
|
|
/**
|
|
* Create and display the main window on startup
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct(NULL, NULL, PROGRAM_NAME, \wxDefaultPosition, new \wxSize(800, 600));
|
|
|
|
$this->SetSizeHints(\wxDefaultSize, \wxDefaultSize);
|
|
|
|
$this->_create_menu();
|
|
|
|
$sbar = $this->CreateStatusBar(2);
|
|
$sbar->SetStatusText("OpenSQLManager");
|
|
|
|
$this->settings =& \Settings::get_instance();
|
|
|
|
// Layout the interface
|
|
$this->_main_layout();
|
|
}
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
/**
|
|
* Some cleanup for when the main window is closed
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __destruct()
|
|
{
|
|
$this->Destroy();
|
|
}
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
/**
|
|
* Exits the wx loop
|
|
*
|
|
* @return void
|
|
*/
|
|
public function quit()
|
|
{
|
|
$this->Destroy();
|
|
}
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
/**
|
|
* Layout the main interface
|
|
* Create menus, hboxes, vboxs and other widgets
|
|
*
|
|
* @return void
|
|
*/
|
|
private function _main_layout()
|
|
{
|
|
// Set up the main menu
|
|
$this->_create_menu();
|
|
|
|
$win = new \wxSplitterWindow($this);
|
|
$win->setSplitMode(wxSPLIT_HORIZONTAL);
|
|
|
|
// Add the connection sidebar
|
|
$this->connection_sidebar =& Connection_Sidebar::get_instance();
|
|
}
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
/**
|
|
* Create the menu for the program
|
|
*
|
|
* @return GtkMenuBar
|
|
*/
|
|
private function _create_menu()
|
|
{
|
|
// Menu Bar
|
|
$menu_bar = new \wxMenuBar();
|
|
|
|
// Menu Bar Top Items
|
|
$top_file_menu = new \wxMenu();
|
|
$top_help_menu = new \wxMenu();
|
|
|
|
// File Menu
|
|
{
|
|
// Set up the quit item
|
|
$top_file_menu->Append(2, "&Quit", "Exit the program");
|
|
$this->Connect(2, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit"));
|
|
|
|
// Add the top level menu to the menubar
|
|
$menu_bar->Append($top_file_menu, "&File");
|
|
}
|
|
|
|
// Help Menu
|
|
{
|
|
// Set up the about item
|
|
//$top_help_menu->Append(4, "&About", "About this program");
|
|
//$this->Connect(4, wxEVT_COMMAND_MENU_SELECTED, "about");
|
|
|
|
// Add the top level menu to the menubar
|
|
$menu_bar->Append($top_help_menu, "&Help");
|
|
}
|
|
|
|
|
|
$this->SetMenuBar($menu_bar);
|
|
}
|
|
}
|
|
// End of main.php
|