From b597a7a741d47e29b7b2916195697da37412aab4 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 27 Nov 2012 22:32:45 -0500 Subject: [PATCH] Add c file for embedded php wrapper Add very biased makefile, and update some stuff --- .gitignore | 5 ++++- OpenSQLManager.c | 26 ++++++++++++++++++++++++ makefile | 8 ++++++++ sys/widgets/connection_sidebar.php | 32 +++++++++++++++++++++++++++++- sys/widgets/data_grid.php | 6 +++--- sys/widgets/db_tabs.php | 2 +- sys/windows/main.php | 15 ++++++++++---- 7 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 OpenSQLManager.c create mode 100644 makefile diff --git a/.gitignore b/.gitignore index 80e1afa..a424021 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,7 @@ settings.json errors.txt tests/db_files/* test_config.json -nbproject/* \ No newline at end of file +nbproject/* +*.o +*.app/* +OpenSQLManager \ No newline at end of file diff --git a/OpenSQLManager.c b/OpenSQLManager.c new file mode 100644 index 0000000..288e64a --- /dev/null +++ b/OpenSQLManager.c @@ -0,0 +1,26 @@ +/** + * 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 https://timshomepage.net/dbaj.txt + */ + +/** + * Wrapper program for embeded php + */ + +#include + +int main(int argc, char *argv[]) +{ + PHP_EMBED_START_BLOCK(argc,argv) + zend_eval_string("include ('./OpenSQLManager.php');", NULL, "TEST" TSRMLS_CC); + PHP_EMBED_END_BLOCK() + + return 0; +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..12b9bb1 --- /dev/null +++ b/makefile @@ -0,0 +1,8 @@ +CC = gcc +CFLAGS = -c `/opt/php-embed/bin/php-config --includes` -Wall -g + +LDFLAGS = -L/Library/Frameworks/Firebird.framework/Libraries -L/opt/php-embed/lib -lphp5 `/opt/php-embed/bin/php-config --libs` + +all: OpenSQLManager.c + ${CC} -o OpenSQLManager.o OpenSQLManager.c ${CFLAGS} + ${CC} -o OpenSQLManager OpenSQLManager.o ${LDFLAGS} \ No newline at end of file diff --git a/sys/widgets/connection_sidebar.php b/sys/widgets/connection_sidebar.php index 7aedab1..b777f7a 100644 --- a/sys/widgets/connection_sidebar.php +++ b/sys/widgets/connection_sidebar.php @@ -64,6 +64,13 @@ class Connection_Sidebar extends \wxPanel { */ private $list; + /** + * Reference to the image list control that holds connection images + * + * @var wxImageList + */ + private $img_list; + /** * Reference to the parent of the current object * @@ -174,6 +181,20 @@ class Connection_Sidebar extends \wxPanel { // -------------------------------------------------------------------------- + /** + * Connect to the database for data display/manipulation + * + * @param wxEvent + * @return void + */ + public function open_connection($event) + { + $id = $event->GetId(); + alert('Double click:' . $id); + } + + // -------------------------------------------------------------------------- + /** * Add the existing items to the connection sidebar * @@ -181,9 +202,18 @@ class Connection_Sidebar extends \wxPanel { */ public function _layout() { - $this->list = new \wxListCtrl($this->parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_LIST|wxLC_SINGLE_SEL); + $this->list = new \wxListCtrl($this->parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_SMALL_ICON | wxLC_SINGLE_SEL | wxLC_ALIGN_TOP); + $this->img_list = new \wxImageList(32, 32); $this->settings =& Settings::get_instance(); $this->list->Connect(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, array($this, 'menu')); + $this->list->Connect(wxEVT_LEFT_DCLICK, array($this, 'open_connection')); + + // Add Images to the Image list + foreach(glob(OSM_RESOURCE_DIR.'/images/*.xpm') as $path) + { + //$img = new \wxBitmap($path); + //$this->img_list->Add($img); + } // Create a button for adding new connections $new_conn = new \wxButton($this, self::BTN_ADD, 'New Connection'); diff --git a/sys/widgets/data_grid.php b/sys/widgets/data_grid.php index 00c0faf..db3fab8 100644 --- a/sys/widgets/data_grid.php +++ b/sys/widgets/data_grid.php @@ -33,9 +33,9 @@ class Data_Grid extends \wxGrid { if ( ! is_null($parent)) { parent::__construct($parent, wxID_ANY); - $this->CreateGrid(10,10); - $this->HideColLabels(); - $this->HideRowLabels(); + $this->CreateGrid(30,8); + //$this->HideColLabels(); + //$this->HideRowLabels(); } else { diff --git a/sys/widgets/db_tabs.php b/sys/widgets/db_tabs.php index 03393cf..9bd3ad9 100644 --- a/sys/widgets/db_tabs.php +++ b/sys/widgets/db_tabs.php @@ -66,7 +66,7 @@ class DB_tabs extends \wxAUINotebook { */ public function __construct($parent) { - parent::__construct($parent); + parent::__construct($parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_CLOSE_ON_ALL_TABS | wxAUI_NB_WINDOWLIST_BUTTON); $this->parent = $parent; $this->data = new \StdClass(); } diff --git a/sys/windows/main.php b/sys/windows/main.php index 23efa66..1940182 100644 --- a/sys/windows/main.php +++ b/sys/windows/main.php @@ -47,7 +47,14 @@ class Main extends \wxFrame { * * @var wxSplitterWindow */ - protected $split; + protected $split; + + /** + * Reference to tab control in split Window + * + * @var wxAUINotebook + */ + protected $tabs; /** * Create and display the main window on startup @@ -149,15 +156,15 @@ class Main extends \wxFrame { // Add the connection sidebar $this->connection_sidebar =& Connection_Sidebar::get_instance($win); - $win2 = new Db_tabs($win); - $win2->add_tab('Test'); + $win2 = new Db_tabs($win); // Add the widgets to the split window $win->SplitVertically($this->connection_sidebar, $win2); $win->SetSashPosition(200, TRUE); // Save a reference for later use - $this->split =& $win; + $this->split =& $win; + $this->tabs =& $win2; } // --------------------------------------------------------------------------