list = new \wxListCtrl($parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_LIST|wxLC_SINGLE_SEL); $this->settings =& Settings::get_instance(); // Create a button for adding new connections $new_conn = new \wxButton($this, self::BUTTON_ADD, 'New Connection'); $new_conn->Connect(wxEVT_COMMAND_BUTTON_CLICKED, array($this, 'add_conn')); // Add a sizer $sizer = new \wxBoxSizer(wxVERTICAL); $sizer->add($this->list, 1, wxALL|wxEXPAND); $sizer->add($new_conn, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM|wxEXPAND); $this->SetSizer($sizer); $this->Layout(); $this->Centre(wxBOTH); } // -------------------------------------------------------------------------- /** * Right-click event to create context menu * * @param wxEvent * @return void */ public function menu($event) { if ($this->list->GetCount() > 0 && $this->list->GetSelection() >= 0) { // Create the menu items $menu = new \wxMenu(); $menu->Append(self::MENU_EDIT_CONNECT, "Edit Connection", "Edit Connection Settings for the selected Database"); $menu->Append(self::MENU_DELETE_CONNECT, "Delete Connection", "Remove the selected connection"); // Wire up the event handler $menu->Connect(wxEVT_COMMAND_MENU_SELECTED, array($this, 'menu_event')); // Tell the object to show the menu $this->list->PopupMenu($menu); } } // -------------------------------------------------------------------------- /** * Handler for context menu options * * @param wxEvent * @return void */ public function menu_event($event) { } // -------------------------------------------------------------------------- /** * Handles an event for adding a connection * * @param wxEvent * @return void */ public function add_conn($event) { $win = new Connection_Manager($this); $win->show(); } } // End of connection_sidebar.php