Move resources into their own folder, mac menu improvements

This commit is contained in:
Timothy Warren 2012-06-06 16:26:06 -04:00
parent 19e02e1349
commit 152a10d6b3
13 changed files with 126 additions and 117 deletions

View File

@ -1,4 +1,3 @@
#!/usr/bin/env php
<?php
/**
* OpenSQLManager
@ -33,6 +32,7 @@ ini_set('memory_limit', -1);
// Set the current directory as the base for included files
define('BASE_DIR', __DIR__.'/sys');
define('RESOURCE_DIR', __DIR__.'/resources');
define('SETTINGS_DIR', __DIR__);
define('PROGRAM_NAME', 'OpenSQLManager');
define('VERSION', '0.2.0pre');
@ -190,6 +190,9 @@ $app = new OpenSQLManager();
// Create platform information object
$platform = new \wxPlatformInfo();
// Define the platform for later use
define('PLATFORM', $platform->GetOperatingSystemId());
// Start the wx event loop
\wxApp::SetInstance($app);
\wxEntry();

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 946 B

After

Width:  |  Height:  |  Size: 946 B

View File

@ -124,7 +124,7 @@ class Connection_Sidebar extends \wxPanel {
*/
public function menu($event)
{
if ($this->list->GetSelectedItemCount() === 1)
if ($this->list->GetSelectedItemCount() > 0)
{
// Create the menu items
$menu = new \wxMenu();

View File

@ -39,13 +39,13 @@ class Connection_Manager extends \wxFrame {
*
* @var array
*/
protected $fields = array();
/**
* Array of labels for Connection Information manipulation
*
* @var array
*/
protected $fields = array();
/**
* Array of labels for Connection Information manipulation
*
* @var array
*/
protected $labels = array();
/**
@ -56,7 +56,7 @@ class Connection_Manager extends \wxFrame {
*/
public function __construct($parent, $params = array())
{
parent::__construct($parent, 32, "Connection Manager", wxDefaultPosition);
parent::__construct($parent, 32, "Connection Manager", wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxSTAY_ON_TOP | wxRESIZE_BORDER);
// Save a reference to the settings class
$this->settings =& Settings::get_instance();
@ -105,16 +105,16 @@ class Connection_Manager extends \wxFrame {
'Password' => new \wxTextCtrl($this, self::TXT_DB_PASS)
);
$choice->Create($this, self::COMBO_DB_TYPE, wxDefaultPosition, wxDefaultSize, $db_types);
// Enable hiding/showing of controls based on choice
$choice->Create($this, self::COMBO_DB_TYPE, wxDefaultPosition, wxDefaultSize, $db_types);
// Enable hiding/showing of controls based on choice
$choice->Connect(wxEVT_COMMAND_CHOICE_SELECTED, array($this, 'change_db'));
// Add the controls to the sizer
$i = 1;
foreach ($this->fields as $lbl => $ctrl)
{
// Add the label to the labels array for later manipulation
{
// Add the label to the labels array for later manipulation
$this->labels[$lbl] = new \wxStaticText($this, $i, $lbl);
$sizer->Add($this->labels[$lbl], 0, wxALIGN_LEFT);
@ -168,7 +168,7 @@ class Connection_Manager extends \wxFrame {
continue;
}
// Use the ibase_functions over PDO::Firebird, at least for now
// Use the ibase_functions over PDO::Firebird
if ($d === 'firebird')
{
continue;
@ -198,7 +198,7 @@ class Connection_Manager extends \wxFrame {
/**
* Adds a connection to the connection manager
*
*
* @param wxCommandEvent
* @return void
*/
@ -219,66 +219,71 @@ class Connection_Manager extends \wxFrame {
/**
* Set defaults for new database type
*
*
* @param wxCommandEvent
* @return void
*/
public function change_db($event)
{
$db = strtolower($event->GetString());
$sizer = $this->GetSizer();
$fields =& $this->fields;
// Set defaults
$this->_show(array(
'Host',
'Database Name',
'Port',
'User',
'Password'
));
$this->_hide(array('Database File'));
$fields['Password']->SetValue('');
$fields['Database Name']->SetValue('');
$fields['Host']->SetValue('127.0.0.1');
// Set db-specific defaults
switch($db)
{
case "mysql":
$fields['User']->SetValue('root');
$fields['Port']->SetValue('3306');
break;
case "postgresql":
$fields['User']->SetValue('postgres');
$fields['Port']->SetValue('5432');
break;
case "firebird":
$fields['User']->SetValue('sysdba');
$fields['Password']->SetValue('masterkey');
$fields['Port']->SetValue('');
$this->_show(array('Database File'));
$this->_hide(array('Database Name'));
break;
case "sqlite":
$this->_show(array('Database File'));
$this->_hide(array(
'Database Name',
'Port',
'Host',
'User',
'Password'
));
break;
}
// Resize the window to fit the controls
$db = strtolower($event->GetString());
$sizer = $this->GetSizer();
$fields =& $this->fields;
// Set defaults
$this->_show(array(
'Host',
'Database Name',
'Port',
'User',
'Password'
));
$this->_hide(array('Database File'));
$fields['User']->SetValue('');
$fields['Port']->SetValue('');
$fields['Password']->SetValue('');
$fields['Database Name']->SetValue('');
$fields['Host']->SetValue('127.0.0.1');
// Set db-specific defaults
switch($db)
{
case "mysql":
$fields['User']->SetValue('root');
$fields['Port']->SetValue('3306');
break;
case "postgresql":
$fields['User']->SetValue('postgres');
$fields['Port']->SetValue('5432');
break;
case "firebird":
$fields['User']->SetValue('sysdba');
$fields['Password']->SetValue('masterkey');
$fields['Port']->SetValue('');
$this->_show(array('Database File'));
$this->_hide(array(
'Database Name',
'Port'
));
break;
case "sqlite":
$this->_show(array('Database File'));
$this->_hide(array(
'Database Name',
'Port',
'Host',
'User',
'Password'
));
break;
}
// Resize the window to fit the controls
$sizer->Fit($this);
}
@ -294,7 +299,7 @@ class Connection_Manager extends \wxFrame {
// Get the connection parameters
$params = $this->_get_vals();
// Smart alek error for smart alek behavior
// Smart aleck error for smart aleck behavior
if (empty($params->type))
{
error("You need to select the correct database type");
@ -348,44 +353,44 @@ class Connection_Manager extends \wxFrame {
$params->pass = $fields['Password']->GetValue();
return $params;
}
// --------------------------------------------------------------------------
/**
* Hides a list of elements
*
* @param array
*/
private function _hide($ctrls)
{
$f =& $this->fields;
$l =& $this->labels;
foreach($ctrls as $c)
{
$f[$c]->Hide();
$l[$c]->Hide();
}
}
// --------------------------------------------------------------------------
/**
* Shows a list of elements
*
* @param array
*/
private function _show($ctrls)
{
$f =& $this->fields;
$l =& $this->labels;
foreach($ctrls as $c)
{
$f[$c]->Show();
$l[$c]->Show();
}
}
// --------------------------------------------------------------------------
/**
* Hides a list of elements
*
* @param array
*/
private function _hide($ctrls)
{
$f =& $this->fields;
$l =& $this->labels;
foreach($ctrls as $c)
{
$f[$c]->Hide();
$l[$c]->Hide();
}
}
// --------------------------------------------------------------------------
/**
* Shows a list of elements
*
* @param array
*/
private function _show($ctrls)
{
$f =& $this->fields;
$l =& $this->labels;
foreach($ctrls as $c)
{
$f[$c]->Show();
$l[$c]->Show();
}
}
}

View File

@ -106,7 +106,7 @@ class Main extends \wxFrame {
$dlg->SetWebSite('https://github.com/aviat4ion/OpenSQLManager','Fork on Github');
$dlg->SetLicense(file_get_contents(BASE_DIR . "/LICENSE"));
$dlg->SetLicense(file_get_contents(RESOURCE_DIR . "/LICENSE"));
$dlg->SetDevelopers(array(
'Timothy J. Warren',
@ -163,8 +163,8 @@ class Main extends \wxFrame {
// 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"));
$top_file_menu->Append(wxID_EXIT, "&Quit\tCtrl+Q", "Exit the program");
$this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, array($this, "quit"));
// Add the top level menu to the menubar
$menu_bar->Append($top_file_menu, "&File");
@ -173,11 +173,12 @@ class Main extends \wxFrame {
// Help Menu
{
// Set up the about item
$top_help_menu->Append(4, "&About", "About this program");
$this->Connect(4, wxEVT_COMMAND_MENU_SELECTED, array($this, "about"));
$top_help_menu->Append(wxID_ABOUT, "&About", "About this program");
$this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, array($this, "about"));
// Add the top level menu to the menubar
$menu_bar->Append($top_help_menu, "&Help");
}