This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
OpenSQLManager/sys/windows/main.php

189 lines
3.9 KiB
PHP
Raw Normal View History

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
*/
// --------------------------------------------------------------------------
namespace OpenSQLManager;
/**
* Main Window Class
*
* Creates and displays the main interface window
2012-04-20 13:30:27 -04:00
*
* @package OpenSQLManager
* @subpackage Windows
*/
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-05-30 16:41:33 -04:00
/**
* Reference to split window
*
* @var wxSplitterWindow
*/
protected $split;
/**
* 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
{
parent::__construct(NULL, NULL, PROGRAM_NAME, \wxDefaultPosition, new \wxSize(800, 600));
2012-05-29 14:29:20 -04:00
$this->_create_menu();
$sbar = $this->CreateStatusBar(2);
$sbar->SetStatusText("OpenSQLManager");
$this->settings =& \Settings::get_instance();
2012-03-28 11:23:08 -04:00
// Layout the interface
2012-05-29 14:29:20 -04:00
$this->_main_layout();
}
2012-01-30 13:15:44 -05:00
// --------------------------------------------------------------------------
/**
* Some cleanup for when the main window is closed
2012-04-11 14:57:38 -04:00
*
* @return void
*/
public function __destruct()
{
2012-05-29 14:29:20 -04:00
$this->Destroy();
}
// --------------------------------------------------------------------------
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-05-29 19:24:15 -04:00
/**
* Display About menu with version information
*
* @return void
*/
function about()
{
$dlg = new \wxAboutDialogInfo();
$dlg->SetName(PROGRAM_NAME);
$dlg->SetVersion(VERSION);
$dlg->SetCopyright("Copyright (c) ".date('Y')." Timothy J. Warren");
$dlg->SetWebSite('https://github.com/aviat4ion/OpenSQLManager','Fork on Github');
$dlg->SetLicense(file_get_contents(BASE_DIR . "/LICENSE"));
$dlg->SetDevelopers(array(
'Timothy J. Warren',
));
\wxAboutBox($dlg);
}
// --------------------------------------------------------------------------
/**
* Layout the main interface
* Create menus, hboxes, vboxs and other widgets
2012-03-28 11:23:08 -04:00
*
* @return void
*/
private function _main_layout()
{
2012-05-29 14:29:20 -04:00
// Set up the main menu
$this->_create_menu();
2012-05-30 16:41:33 -04:00
2012-05-29 19:24:15 -04:00
// Create a split window
$win = new \wxSplitterWindow($this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
2012-05-29 14:29:20 -04:00
$win->setSplitMode(wxSPLIT_HORIZONTAL);
2012-05-29 19:24:15 -04:00
2012-05-30 16:41:33 -04:00
// Add the connection sidebar
$this->connection_sidebar =& Connection_Sidebar::get_instance($win);
$win2 = new Data_Grid($win);
// Add the widgets to the split window
$win->SplitVertically($this->connection_sidebar, $win2);
$win->SetSashPosition(200, TRUE);
2012-05-29 19:24:15 -04:00
2012-05-30 16:41:33 -04:00
// Save a reference for later use
$this->split =& $win;
2012-01-26 16:09:05 -05:00
}
2012-01-30 13:15:44 -05:00
// --------------------------------------------------------------------------
/**
* Create the menu for the program
*
* @return GtkMenuBar
*/
private function _create_menu()
{
// Menu Bar
$menu_bar = new \wxMenuBar();
// 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
// File Menu
{
// 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"));
// Add the top level menu to the menubar
2012-05-29 14:29:20 -04:00
$menu_bar->Append($top_file_menu, "&File");
}
// Help Menu
{
// Set up the about item
2012-05-29 19:24:15 -04:00
$top_help_menu->Append(4, "&About", "About this program");
$this->Connect(4, wxEVT_COMMAND_MENU_SELECTED, array($this, "about"));
// Add the top level menu to the menubar
2012-05-29 14:29:20 -04:00
$menu_bar->Append($top_help_menu, "&Help");
}
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
}
}
// End of main.php