Florian G. Pflug wrote:
> Andreas Pflug wrote:
>
>> The inner notebook should be half the height of the outer notebook,
>> but this isn't so. Please use the attached dlgServer.xrc and
>> dlgServer.cpp and post the resulting image as well as the info debug
>> output it creates (three lines "Mac debug").
>
> Hm... seems you forgot to actually attach those files... - or they
> went to the bitbucket somewhere along the way.. ;-)
Oops, try these...
Regards,
Andreas
<?xml version="1.0" ?>
<resource>
<object class="wxDialog" name="dlgServer">
<title></title>
<object class="wxNotebook" name="nbNotebook">
<object class="notebookpage">
<label>Properties</label>
<object class="wxPanel" name="pnlProperties">
<object class="wxStaticText" name="stName">
<label>Address</label>
<pos>1005,7d</pos>
</object>
<object class="wxTextCtrl" name="txtName">
<pos>1005,5d</pos>
<size>100,-1d</size>
</object>
<object class="wxTextCtrl" name="txtSomething">
<value>some decent text</value>
<pos>5,5d</pos>
<size>100,-1d</size>
</object>
<object class="wxTextCtrl" name="txtSomething2">
<value>some decent text</value>
<pos>5,20d</pos>
<size>100,-1d</size>
</object>
<object class="wxStaticText" name="stDescription">
<label>Description</label>
<pos>1005,22d</pos>
</object>
<object class="wxTextCtrl" name="txtDescription">
<pos>1070,20d</pos>
<size>135,-1d</size>
</object>
<object class="wxStaticText" name="stService">
<label>Service</label>
<pos>1005,37d</pos>
</object>
<object class="wxTextCtrl" name="txtService">
<pos>1070,35d</pos>
<size>135,-1d</size>
</object>
<object class="wxStaticText" name="stPort">
<label>Port</label>
<pos>1005,52d</pos>
</object>
<object class="wxTextCtrl" name="txtPort">
<pos>1070,50d</pos>
<size>26,-1d</size>
</object>
<object class="wxStaticText" name="stSSL">
<label>SSL</label>
<pos>1000,52d</pos>
</object>
<object class="wxComboBox" name="cbSSL">
<pos>1120,50d</pos>
<size>85,12d</size>
<style>wxCB_READONLY|wxCB_DROPDOWN</style>
<content/>
</object>
<object class="wxStaticText" name="stDatabase">
<label>Initial DB</label>
<pos>1005,67d</pos>
</object>
<object class="wxComboBox" name="cbDatabase">
<pos>1070,65d</pos>
<size>135,12d</size>
<content/>
<style>wxCB_DROPDOWN</style>
</object>
<object class="wxStaticText" name="stUsername">
<label>Username</label>
<pos>1005,82d</pos>
</object>
<object class="wxTextCtrl" name="txtUsername">
<pos>1070,80d</pos>
<size>135,-1d</size>
</object>
<object class="wxStaticText" name="stNeedPwd">
<label>need password</label>
<pos>1005,97d</pos>
</object>
<object class="wxCheckBox" name="chkNeedPwd">
<label></label>
<checked>1</checked>
<pos>1070,95d</pos>
<size>12,12d</size>
</object>
<object class="wxStaticText" name="stPassword">
<label>Password</label>
<pos>1005,112d</pos>
</object>
<object class="wxTextCtrl" name="txtPassword">
<pos>1070,110d</pos>
<style>wxTE_PASSWORD</style>
<size>135,-1d</size>
</object>
<object class="wxNotebook" name="testNotebook">
<object class="notebookpage">
<label>testpanel</label>
<object class="wxPanel" name="pnlX">
<object class="wxTextCtrl" name="txt">
<value>some decent text</value>
<pos>5,5d</pos>
<size>80,-1d</size>
</object>
</object>
</object>
<pos>5,35d</pos>
<size>100,75d</size>
</object>
</object>
<selected>1</selected>
</object>
<pos>5,5d</pos>
<size>200,150d</size>
</object>
<object class="wxButton" name="wxID_HELP">
<label>Help</label>
<pos>2,190d</pos>
</object>
<object class="wxTextCtrl" name="txt2">
<value>some decent text</value>
<pos>5,160d</pos>
<size>80,-1d</size>
</object>
<object class="wxButton" name="wxID_OK">
<label>OK</label>
<default>1</default>
<pos>113,190d</pos>
</object>
<object class="wxButton" name="wxID_CANCEL">
<label>Cancel</label>
<pos>166,190d</pos>
</object>
<size>218,200d</size>
<style></style>
</object>
</resource>//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
// RCS-ID: $Id: dlgServer.cpp,v 1.16 2005/01/10 15:26:30 dpage Exp $
// Copyright (C) 2002 - 2005, The pgAdmin Development Team
// This software is released under the Artistic Licence
//
// dlgServer.cpp - PostgreSQL Database Property
//
//////////////////////////////////////////////////////////////////////////
// wxWindows headers
#include <wx/wx.h>
// App headers
#include "pgAdmin3.h"
#include "misc.h"
#include "frmMain.h"
#include "dlgServer.h"
#include "pgDatabase.h"
// Images
#include "images/server.xpm"
// pointer to controls
#define txtDescription CTRL_TEXT("txtDescription")
#define txtService CTRL_TEXT("txtService")
#define cbDatabase CTRL_COMBOBOX("cbDatabase")
#define txtPort CTRL_TEXT("txtPort")
#define cbSSL CTRL_COMBOBOX("cbSSL")
#define txtUsername CTRL_TEXT("txtUsername")
#define chkNeedPwd CTRL_CHECKBOX("chkNeedPwd")
#define stPassword CTRL_STATIC("stPassword")
#define txtPassword CTRL_TEXT("txtPassword")
extern double libpqVersion;
BEGIN_EVENT_TABLE(dlgServer, dlgProperty)
EVT_NOTEBOOK_PAGE_CHANGED(XRCID("nbNotebook"), dlgServer::OnPageSelect)
EVT_TEXT(XRCID("txtDescription"), dlgProperty::OnChange)
EVT_TEXT(XRCID("txtService"), dlgProperty::OnChange)
EVT_TEXT(XRCID("cbDatabase"), dlgProperty::OnChange)
EVT_COMBOBOX(XRCID("cbDatabase"), dlgProperty::OnChange)
EVT_TEXT(XRCID("txtPort") , dlgProperty::OnChange)
EVT_TEXT(XRCID("txtUsername"), dlgProperty::OnChange)
EVT_COMBOBOX(XRCID("cbSSL"), dlgProperty::OnChange)
EVT_CHECKBOX(XRCID("chkNeedPwd"), dlgServer::OnChangeNeedPwd)
EVT_BUTTON(wxID_OK, dlgServer::OnOK)
END_EVENT_TABLE();
dlgServer::dlgServer(frmMain *frame, pgServer *node)
: dlgProperty(frame, wxT("dlgServer"))
{
SetIcon(wxIcon(server_xpm));
server=node;
objectType = PG_SERVER;
cbDatabase->Append(settings->GetLastDatabase());
cbDatabase->SetSelection(0);
txtPort->SetValue(NumToStr((long)settings->GetLastPort()));
cbSSL->SetSelection(settings->GetLastSSL());
txtUsername->SetValue(settings->GetLastUsername());
chkNeedPwd->SetValue(true);
wxLogInfo(wxT("MAC debug: Dialog: %s %d %d"), GetFont().GetNativeFontInfoDesc().c_str(), GetCharWidth(),
GetCharHeight());
wxWindow *w;
w=CTRL_NOTEBOOK("nbNotebook");
wxLogInfo(wxT("MAC debug: outer notebook: %s %d %d"), w->GetFont().GetNativeFontInfoDesc().c_str(),
w->GetCharWidth(),w->GetCharHeight());
w=CTRL_NOTEBOOK("testNotebook");
wxLogInfo(wxT("MAC debug: inner notebook: %s %d %d"), w->GetFont().GetNativeFontInfoDesc().c_str(),
w->GetCharWidth(),w->GetCharHeight());
}
dlgServer::~dlgServer()
{
if (!server)
{
settings->SetLastDatabase(cbDatabase->GetValue());
settings->SetLastPort(StrToLong(txtPort->GetValue()));
settings->SetLastSSL(cbSSL->GetSelection());
settings->SetLastUsername(txtUsername->GetValue());
}
}
pgObject *dlgServer::GetObject()
{
return server;
}
void dlgServer::OnOK(wxCommandEvent &ev)
{
// notice: changes active after reconnect
EnableOK(false);
if (server)
{
server->iSetName(GetName());
server->iSetDescription(txtDescription->GetValue());
if (txtService->GetValue() != server->GetServiceID())
{
mainForm->StartMsg(_("Checking server status"));
server->iSetServiceID(txtService->GetValue());
mainForm->EndMsg();
}
server->iSetPort(StrToLong(txtPort->GetValue()));
server->iSetSSL(cbSSL->GetSelection());
server->iSetLastDatabase(cbDatabase->GetValue());
server->iSetUsername(txtUsername->GetValue());
server->iSetNeedPwd(chkNeedPwd->GetValue());
mainForm->execSelChange(server->GetId(), true);
mainForm->GetBrowser()->SetItemText(item, server->GetFullName());
}
if (IsModal())
{
EndModal(wxID_OK);
return;
}
else
Destroy();
}
void dlgServer::OnPageSelect(wxNotebookEvent &event)
{
// to prevent dlgProperty from catching it
}
wxString dlgServer::GetHelpPage() const
{
return wxT("pgadmin/connect");
}
int dlgServer::GoNew()
{
if (cbSSL->IsEmpty())
return Go(true);
else
{
CheckChange();
return ShowModal();
}
}
int dlgServer::Go(bool modal)
{
cbSSL->Append(wxT(" "));
#ifdef SSL
cbSSL->Append(_("require"));
cbSSL->Append(_("prefer"));
if (libpqVersion > 7.3)
{
cbSSL->Append(_("allow"));
cbSSL->Append(_("disable"));
}
#endif
if (server)
{
cbDatabase->Append(server->GetDatabaseName());
txtDescription->SetValue(server->GetDescription());
txtService->SetValue(server->GetServiceID());
txtPort->SetValue(NumToStr((long)server->GetPort()));
cbSSL->SetSelection(server->GetSSL());
cbDatabase->SetValue(server->GetDatabaseName());
txtUsername->SetValue(server->GetUsername());
chkNeedPwd->SetValue(server->GetNeedPwd());
stPassword->Disable();
txtPassword->Disable();
if (connection)
{
txtName->Disable();
cbDatabase->Disable();
txtPort->Disable();
cbSSL->Disable();
txtUsername->Disable();
chkNeedPwd->Disable();
}
}
else
{
SetTitle(_("Add server"));
}
int rc=dlgProperty::Go(modal);
CheckChange();
return rc;
}
wxString dlgServer::GetPassword()
{
if (chkNeedPwd->GetValue())
return txtPassword->GetValue();
return wxEmptyString;
}
pgObject *dlgServer::CreateObject(pgCollection *collection)
{
wxString name=GetName();
pgObject *obj=new pgServer(GetName(), txtDescription->GetValue(), cbDatabase->GetValue(),
txtUsername->GetValue(), StrToLong(txtPort->GetValue()), !chkNeedPwd->GetValue(), cbSSL->GetSelection());
return obj;
}
void dlgServer::OnChangeNeedPwd(wxCommandEvent &ev)
{
if (!server)
txtPassword->Enable(chkNeedPwd->GetValue());
OnChange(ev);
}
void dlgServer::CheckChange()
{
wxString name=GetName();
bool enable=true;
if (server)
{
enable = name != server->GetName()
|| txtDescription->GetValue() != server->GetDescription()
|| txtService->GetValue() != server->GetServiceID()
|| StrToLong(txtPort->GetValue()) != server->GetPort()
|| cbDatabase->GetValue() != server->GetDatabaseName()
|| txtUsername->GetValue() != server->GetUsername()
|| cbSSL->GetSelection() != server->GetSSL()
|| chkNeedPwd->GetValue() != server->GetNeedPwd();
}
CheckValid(enable, !name.IsEmpty(), _("Please specify address."));
CheckValid(enable, !txtDescription->GetValue().IsEmpty(), _("Please specify description."));
CheckValid(enable, StrToLong(txtPort->GetValue()) > 0, _("Please specify port."));
CheckValid(enable, !txtUsername->GetValue().IsEmpty(), _("Please specify user name"));
EnableOK(enable);
}
wxString dlgServer::GetSql()
{
return wxEmptyString;
}