From eb6edfa6c3afcbd259a6211c123a66937f4720de Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Jan 2012 16:57:59 -0500 Subject: [PATCH] Added Menu Added Start of Menus, and main interface, fleshed out classes a little bi. --- src/databases/db_pdo.php | 17 ++++++- src/databases/odbc.php | 12 ++++- src/index.php | 16 +++++- src/windows/main.php | 107 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 147 insertions(+), 5 deletions(-) diff --git a/src/databases/db_pdo.php b/src/databases/db_pdo.php index 386bcda..3b57aa8 100644 --- a/src/databases/db_pdo.php +++ b/src/databases/db_pdo.php @@ -9,6 +9,21 @@ * @link https://github.com/aviat4ion/OpenSQLManager * @license http://philsturgeon.co.uk/code/dbad-license */ + +// -------------------------------------------------------------------------- + +/** + * Base Database class + * + * Extends PDO to simplify cross-database issues + */ class DB_PDO extends PDO { -} \ No newline at end of file + function __construct($dsn, $username=NULL, $password=NULL, $driver_options=array()) + { + parent::__construct($dsn, $username, $password, $driver_options); + } + +} + +// End of db_pdo.php \ No newline at end of file diff --git a/src/databases/odbc.php b/src/databases/odbc.php index cf17427..9e2975f 100644 --- a/src/databases/odbc.php +++ b/src/databases/odbc.php @@ -9,6 +9,16 @@ * @link https://github.com/aviat4ion/OpenSQLManager * @license http://philsturgeon.co.uk/code/dbad-license */ + + // -------------------------------------------------------------------------- + + /** + * ODBC Database Driver + * + * For general database access for databases not specified by the main drivers + */ class ODBC extends DB_PDO { -} \ No newline at end of file +} + +// End of odbc.php \ No newline at end of file diff --git a/src/index.php b/src/index.php index a6ad6d4..4e6c23d 100644 --- a/src/index.php +++ b/src/index.php @@ -9,6 +9,17 @@ * @link https://github.com/aviat4ion/OpenSQLManager * @license http://philsturgeon.co.uk/code/dbad-license */ + + // -------------------------------------------------------------------------- + + /** + * Bootstrap file + * + * Initializes parent window and starts the GTK event loop + */ + +// -------------------------------------------------------------------------- + if ( ! class_exists('gtk')) { die("Please load the php-gtk2 module in your php.ini\r\n"); @@ -30,7 +41,8 @@ $dir = dirname(__FILE__); // Create the main window $wnd = new Main(); -$wnd->show_all(); // Start the GTK event loop -GTK::main(); \ No newline at end of file +GTK::main(); + +// End of index.php \ No newline at end of file diff --git a/src/windows/main.php b/src/windows/main.php index 24c9f3a..07d5944 100644 --- a/src/windows/main.php +++ b/src/windows/main.php @@ -9,16 +9,121 @@ * @link https://github.com/aviat4ion/OpenSQLManager * @license http://philsturgeon.co.uk/code/dbad-license */ + +// -------------------------------------------------------------------------- + +/** + * Main Window Class + * + * Creates and displays the main interface window + */ class Main extends GtkWindow { + private $main_vbox, $main_hbox; + + /** + * Create and display the main window on startup + */ function __construct() { parent::__construct(); + //Layout the interface + $this->_main_layout(); + } + + /** + * Layout the main interface + * + * Create menus, hboxes, vboxs and other widgets + */ + private function _main_layout() + { $this->set_title('OpenSQLManager'); // Quit when this window is closed $this->connect_simple('destroy', array('gtk', 'main_quit')); + + // Main Vbox that everything is contained in + $main_vbox = new GTKVBox(); + + // Main Hbox for columns + $main_hbox = new GTKHBox(); + + // Add the menubar + $main_vbox->pack_start($this->_create_menu(), FALSE, FALSE); + + // Add the main interface area hbox + $main_vbox->pack_start($main_hbox, FALSE, FALSE); + + // Add the Vbox, and show the window + $this->add($main_vbox); + $this->show_all(); } -} \ No newline at end of file + /** + * Create the menu for the program + * + * @return GtkMenuBar + */ + private function _create_menu() + { + //Menu Bar + $menu_bar = new GtkMenuBar(); + + //Menu Bar Top Items + $top_file_menu = new GtkMenuItem('_File'); + $top_help_menu = new GtkMenuItem('_Help'); + + //Add sub Menus to top items + $file_menu = new GtkMenu(); + $top_file_menu->set_submenu($file_menu); + $help_menu = new GtkMenu(); + $top_help_menu->set_submenu($help_menu); + + + //File Menu + { + //Set up the quit item + $quit = new GtkImageMenuItem(GTK::STOCK_QUIT); + $quit->connect_simple('activate', array($this, 'quit')); + $file_menu->append($quit); + + // Add the top level menu to the menubar + $menu_bar->append($top_file_menu); + } + + //Help Menu + { + //Set up the about item + $about = new GtkImageMenuItem(GTK::STOCK_ABOUT); + $about->connect_simple('activate', array($this, 'about')); + $help_menu->append($about); + + // Add the top level menu to the menubar + $menu_bar->append($top_help_menu); + } + + + return $menu_bar; + } + + /** + * Display About menu with version information + */ + function about() + { + + } + + /** + * Quits the GTK loop + */ + function quit() + { + Gtk::main_quit(); + } + +} + +// End of main.php \ No newline at end of file