Did somework on the generic dialogs,

Renamed wxBox -> wxBoxSizer
  Removed old dialog layout code,


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-08-11 11:53:40 +00:00
parent 9635832dbd
commit 92afa2b150
42 changed files with 267 additions and 2835 deletions

View File

@@ -36,154 +36,119 @@
#include "wx/intl.h"
#include "wx/settings.h"
#include "wx/stattext.h"
#include "wx/sizer.h"
#endif
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
//--------------------------------------------------------------------------
// wxDialogBase
//--------------------------------------------------------------------------
const long wxDialogBase::LAYOUT_X_MARGIN = 5;
const long wxDialogBase::LAYOUT_Y_MARGIN = 5;
const long wxDialogBase::MARGIN_BETWEEN_BUTTONS = 3*LAYOUT_X_MARGIN;
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// dialog layout functions
// ----------------------------------------------------------------------------
wxSize wxDialogBase::SplitTextMessage(const wxString& message,
wxArrayString *lines)
wxSizer *wxDialogBase::CreateTextSizer( const wxString &message )
{
wxClientDC dc(this);
dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
wxString curLine;
long height, width, heightTextMax = 0, widthTextMax = 0;
for ( const wxChar *pc = message; ; pc++ )
wxBoxSizer *box = new wxBoxSizer( wxVERTICAL );
wxString line;
for (size_t pos = 0; pos < message.Len(); pos++)
{
if ( *pc == _T('\n') || !*pc )
if (message[pos] == _T('\n'))
{
#if defined(__VISAGECPP__)
// have two versions of this in wxWindowDC tp avoid function hiding
// since there are two of these in wxDCBase, and in turn in wxDC.
// VA cannot resolve this so:
dc.GetTextExtent(curLine, &width, &height, NULL, NULL, NULL, FALSE);
#else
dc.GetTextExtent(curLine, &width, &height);
#endif
if ( width > widthTextMax )
widthTextMax = width;
if ( height > heightTextMax )
heightTextMax = height;
lines->Add(curLine);
if ( !*pc )
if (!line.IsEmpty())
{
// the end of string
break;
wxStaticText *s1 = new wxStaticText( this, -1, line );
box->Add( s1 );
line = _T("");
}
curLine.Empty();
}
else
{
curLine += *pc;
line += message[pos];
}
}
return wxSize(widthTextMax, heightTextMax);
// remaining text behind last '\n'
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( this, -1, line );
box->Add( s2 );
}
return box;
}
long wxDialogBase::CreateTextMessage(const wxArrayString& lines,
const wxPoint& posText,
const wxSize& sizeText)
wxSizer *wxDialogBase::CreateButtonSizer( long flags )
{
wxStaticText *text;
int y = posText.y;
size_t nLineCount = lines.GetCount();
for ( size_t nLine = 0; nLine < nLineCount; nLine++ )
{
text = new wxStaticText(this, -1, lines[nLine],
wxPoint(posText.x, y),
sizeText);
y += sizeText.GetHeight();
}
wxBoxSizer *box = new wxBoxSizer( wxHORIZONTAL );
return y;
}
wxSize wxDialogBase::GetStandardButtonSize(bool hasCancel)
{
#if 0
int wButton = 0;
GetTextExtent(_("OK"), &wButton, NULL);
if ( hasCancel )
{
int width;
GetTextExtent(_("Cancel"), &width, NULL);
if ( width > wButton )
wButton = width;
}
if ( wButton < 75 )
{
// the minimal acceptable width
wButton = 75;
}
else
{
// the width of the button is not just the width of the label...
wButton += 2*LAYOUT_X_MARGIN;
}
// a nice looking proportion
int hButton = (wButton * 23) / 75;
return wxSize(wButton, hButton);
#if defined(__WXMSW__) || defined(__WXMAC__)
int margin = 6;
#else
return wxButton::GetDefaultSize();
int margin = 10;
#endif
}
void wxDialogBase::CreateStandardButtons(long wDialog,
long y,
long wButton,
long hButton,
bool hasCancel)
{
// NB: create [Ok] first to get the right tab order
wxButton *ok = (wxButton *) NULL;
wxButton *cancel = (wxButton *) NULL;
long x = wDialog / 2;
if ( hasCancel )
x -= MARGIN_BETWEEN_BUTTONS / 2 + wButton;
else
x -= wButton / 2;
ok = new wxButton( this, wxID_OK, _("OK"),
wxPoint(x, y),
wxSize(wButton, hButton) );
if ( hasCancel )
wxButton *yes = (wxButton *) NULL;
wxButton *no = (wxButton *) NULL;
if (flags & wxYES_NO)
{
x += MARGIN_BETWEEN_BUTTONS + wButton;
cancel = new wxButton( this, wxID_CANCEL, _("Cancel"),
wxPoint(x, y),
wxSize(wButton, hButton) );
yes = new wxButton( this, wxID_YES, _("Yes") );
box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
no = new wxButton( this, wxID_NO, _("No") );
box->Add( no, 0, wxLEFT|wxRIGHT, margin );
} else
if (flags & wxYES)
{
yes = new wxButton( this, wxID_YES, _("Yes") );
box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
} else
if (flags & wxNO)
{
no = new wxButton( this, wxID_NO, _("No") );
box->Add( no, 0, wxLEFT|wxRIGHT, margin );
}
ok->SetDefault();
ok->SetFocus();
if (flags & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK") );
box->Add( ok, 0, wxLEFT|wxRIGHT, margin );
}
if (flags & wxFORWARD)
box->Add( new wxButton( this, wxID_FORWARD, _("Forward") ), 0, wxLEFT|wxRIGHT, margin );
if (flags & wxBACKWARD)
box->Add( new wxButton( this, wxID_BACKWARD, _("Backward") ), 0, wxLEFT|wxRIGHT, margin );
if (flags & wxSETUP)
box->Add( new wxButton( this, wxID_SETUP, _("Setup") ), 0, wxLEFT|wxRIGHT, margin );
if (flags & wxMORE)
box->Add( new wxButton( this, wxID_MORE, _("More...") ), 0, wxLEFT|wxRIGHT, margin );
if (flags & wxHELP)
box->Add( new wxButton( this, wxID_HELP, _("Help") ), 0, wxLEFT|wxRIGHT, margin );
if (flags & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
box->Add( cancel, 0, wxLEFT|wxRIGHT, margin );
}
if ((flags & wxNO_DEFAULT) == 0)
{
if (ok)
{
ok->SetDefault();
ok->SetFocus();
}
else if (yes)
{
yes->SetDefault();
yes->SetFocus();
}
}
return box;
}
long wxDialogBase::GetStandardTextHeight()
{
return (3*GetCharHeight()) / 2;
}

View File

@@ -232,15 +232,15 @@ void wxSizer::SetDimension( int x, int y, int width, int height )
}
//---------------------------------------------------------------------------
// wxBox
// wxBoxSizer
//---------------------------------------------------------------------------
wxBox::wxBox( int orient )
wxBoxSizer::wxBoxSizer( int orient )
{
m_orient = orient;
}
void wxBox::RecalcSizes()
void wxBoxSizer::RecalcSizes()
{
if (m_children.GetCount() == 0)
{
@@ -328,7 +328,7 @@ void wxBox::RecalcSizes()
}
}
wxSize wxBox::CalcMin()
wxSize wxBoxSizer::CalcMin()
{
if (m_children.GetCount() == 0)
return wxSize(2,2);

View File

@@ -28,6 +28,7 @@
#include "wx/listbox.h"
#include "wx/stattext.h"
#include "wx/intl.h"
#include "wx/sizer.h"
#endif
#if wxUSE_STATLINE
@@ -164,9 +165,17 @@ END_EVENT_TABLE()
IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
#endif
#if defined(__WXMSW__) || defined(__WXMAC__)
#define wxCHOICEDLG_DIALOG_STYLE (wxDEFAULT_DIALOG_STYLE | \
wxDIALOG_MODAL | \
wxTAB_TRAVERSAL)
#else
#define wxCHOICEDLG_DIALOG_STYLE (wxDEFAULT_DIALOG_STYLE | \
wxDIALOG_MODAL | \
wxRESIZE_BORDER | \
wxTAB_TRAVERSAL)
#endif
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent,
const wxString& message,
@@ -225,119 +234,47 @@ bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent),
{
m_selection = 0;
m_clientData = NULL;
m_stringSelection = _T("");
// calc the message size
// ---------------------
m_dialogStyle = style;
wxArrayString lines;
wxSize sizeText = SplitTextMessage(message, &lines);
long heightTextMax = sizeText.GetHeight(),
widthTextMax = sizeText.GetWidth();
size_t nLineCount = lines.Count();
long hTotalMsg = heightTextMax*nLineCount;
wxBeginBusyCursor();
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
// calc the button size
// --------------------
// always create the OK button - the code below supposes we do have buttons
// and besides the user should have some way to close this dialog
wxASSERT_MSG( style & wxOK, _T("this dialog should have OK button") );
bool hasCancel = (style & wxCANCEL) != 0;
wxSize sizeButtons = GetStandardButtonSize(hasCancel);
long wButton = sizeButtons.GetWidth(),
hButton = sizeButtons.GetHeight();
long wTotalButtons = wButton;
if ( hasCancel )
{
wTotalButtons *= 2; // second button
wTotalButtons += MARGIN_BETWEEN_BUTTONS; // margin between the 2
}
// listbox and stat line
// ---------------------
// make the listbox at least as tall as the message - otherwise it looks
// ugly (the lower limit of 300 for the width is arbitrary OTOH)
//
// NB: we write "n + 2" because the horiz. scrollbar also takes some place
long hListbox = wxMax((n + 2) * heightTextMax, hTotalMsg),
wListbox = wxMax(300, wxMax(wTotalButtons, widthTextMax));
#if wxUSE_STATLINE
long hStatLine = wxStaticLine::GetDefaultSize();
#endif
// now the complete dialog size
// ----------------------------
long hDialog = 2*LAYOUT_Y_MARGIN + // top margin
hTotalMsg + // message
2*LAYOUT_Y_MARGIN + // margin between text and listbox
hListbox + // listbox
#if wxUSE_STATLINE
LAYOUT_Y_MARGIN + // margin
hStatLine + // separator line
#endif
2*LAYOUT_Y_MARGIN + // margin between listbox and buttons
hButton + // button(s)
LAYOUT_Y_MARGIN; // bottom margin
long wDialog = wxMax(wListbox, wxMax(wTotalButtons, widthTextMax)) +
4*LAYOUT_X_MARGIN; // 2 from each side
// create the controls
// -------------------
// message
wxStaticText *text;
int y = 2*LAYOUT_Y_MARGIN;
for ( size_t nLine = 0; nLine < nLineCount; nLine++ )
{
text = new wxStaticText(this, -1, lines[nLine],
wxPoint(2*LAYOUT_X_MARGIN, y),
wxSize(widthTextMax, heightTextMax));
y += heightTextMax;
}
y += 2*LAYOUT_X_MARGIN;
// listbox
m_listbox = new wxListBox( this, wxID_LISTBOX,
wxPoint(2*LAYOUT_X_MARGIN, y),
wxSize(wListbox, hListbox),
n, choices,
wxLB_HSCROLL);
y += hListbox;
if ( clientData )
// 1) text message
topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 );
// 2) list box
m_listbox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) ,
n, choices, wxLB_ALWAYS_SB );
m_listbox->SetSelection( m_selection );
if (clientData)
{
for (int i = 0; i < n; i++)
m_listbox->SetClientData(i, clientData[i]);
}
topsizer->Add( m_listbox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
// separator line
#if wxUSE_STATLINE
(void) new wxStaticLine( this, -1,
wxPoint(2*LAYOUT_X_MARGIN, y + LAYOUT_Y_MARGIN),
wxSize(wDialog - 4*LAYOUT_X_MARGIN, hStatLine) );
y += LAYOUT_Y_MARGIN + hStatLine;
// 3) static line
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
// buttons
// 4) buttons
topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 );
y += 2*LAYOUT_X_MARGIN;
CreateStandardButtons(wDialog, y, wButton, hButton, hasCancel);
SetClientSize( wDialog, hDialog );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
SetSizer( topsizer );
SetAutoLayout( TRUE );
Centre( wxBOTH );
m_listbox->SetFocus();
wxEndBusyCursor();
return TRUE;
}

View File

@@ -1,386 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: extdlgg.cpp
// Purpose: extended generic dialog
// Author: Robert Roebling
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "extdlgg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/intl.h"
#include "wx/dialog.h"
#include "wx/button.h"
#endif
#if wxUSE_STATLINE
#include "wx/statline.h"
#endif
#include "wx/generic/extdlgg.h"
//-----------------------------------------------------------------------------
// wxExtDialog
//-----------------------------------------------------------------------------
#define BUTTON_AREA_MARGIN 10
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxExtDialog, wxDialog)
BEGIN_EVENT_TABLE(wxExtDialog, wxDialog)
EVT_SIZE(wxExtDialog::OnSize)
EVT_BUTTON(wxID_YES, wxExtDialog::OnYes)
EVT_BUTTON(wxID_NO, wxExtDialog::OnNo)
EVT_BUTTON(wxID_CANCEL, wxExtDialog::OnCancel)
END_EVENT_TABLE()
#endif
wxExtDialog::wxExtDialog( wxWindow *parent, wxWindowID id,
const wxString& title, long extraStyle,
const wxPoint& pos, const wxSize& size,
long style, const wxString &name )
{
Create( parent, id, title, extraStyle, pos, size, style, name );
}
bool wxExtDialog::Create( wxWindow *parent, wxWindowID id,
const wxString& title, long extraStyle,
const wxPoint& pos, const wxSize& size,
long style, const wxString &name )
{
if (!wxDialog::Create( parent, id, title, pos, size, style, name ))
return FALSE;
m_extraStyle = extraStyle;
m_clientWindowMargin = 10;
if (m_windowStyle & wxED_BUTTONS_RIGHT)
{
m_spacePerButton.x = wxButton::GetDefaultSize().x + 18;
m_spacePerButton.y = wxButton::GetDefaultSize().y + 8;
}
else
{
m_spacePerButton.x = wxButton::GetDefaultSize().x + 8;
m_spacePerButton.y = wxButton::GetDefaultSize().y + 18;
}
#if defined(__WXGTK__) || defined(__WXMOTIF__)
// Under Motif and GTK, the default button has a big frame around
// it and to avoid overlapping buttons we make the margin bigger.
// We could give other platforms a bigger margin as well, but this
// wouldn't be standard L&F.
m_spacePerButton.x += 10;
m_spacePerButton.y += 10;
#endif
wxButton *ok = (wxButton *) NULL;
wxButton *cancel = (wxButton *) NULL;
wxButton *yes = (wxButton *) NULL;
wxButton *no = (wxButton *) NULL;
if (m_extraStyle & wxYES_NO)
{
yes = new wxButton( this, wxID_YES, _("Yes") );
m_buttons.Append( yes );
no = new wxButton( this, wxID_NO, _("No") );
m_buttons.Append( no );
}
if (m_extraStyle & wxYES)
{
yes = new wxButton( this, wxID_YES, _("Yes") );
m_buttons.Append( yes );
}
if (m_extraStyle & wxNO)
{
no = new wxButton( this, wxID_NO, _("No") );
m_buttons.Append( no );
}
if (m_extraStyle & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK") );
m_buttons.Append( ok );
}
if (m_extraStyle & wxFORWARD)
AddButton( new wxButton( this, wxID_FORWARD, _("Forward") ) );
if (m_extraStyle & wxBACKWARD)
AddButton( new wxButton( this, wxID_BACKWARD, _("Backward") ) );
if (m_extraStyle & wxSETUP)
AddButton( new wxButton( this, wxID_SETUP, _("Setup") ) );
if (m_extraStyle & wxMORE)
AddButton( new wxButton( this, wxID_MORE, _("More...") ) );
if (m_extraStyle & wxHELP)
AddButton( new wxButton( this, wxID_HELP, _("Help") ) );
if (m_extraStyle & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
m_buttons.Append( cancel );
}
if ((m_extraStyle & wxNO_DEFAULT) == 0)
{
if (ok)
{
ok->SetDefault();
ok->SetFocus();
}
else if (yes)
{
yes->SetDefault();
yes->SetFocus();
}
}
#if wxUSE_STATLINE
if (style & wxED_STATIC_LINE)
{
int line_style = wxLI_HORIZONTAL;
if (style & wxED_BUTTONS_RIGHT) line_style = wxLI_VERTICAL;
m_statLine = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, line_style );
}
else
m_statLine = (wxStaticLine*) NULL;
#endif
if (m_extraStyle & wxCENTRE)
Centre( wxBOTH );
return TRUE;
}
void wxExtDialog::AddButton( wxButton *button )
{
m_buttons.Append( button );
}
void wxExtDialog::SetDefaultButton( wxWindowID button )
{
wxNode *node = m_buttons.First();
while (node)
{
wxButton *but = (wxButton*) node->Data();
if (but->GetId() == button)
{
but->SetDefault();
but->SetFocus();
return;
}
}
}
void wxExtDialog::EnableButton( wxWindowID button, bool enable )
{
wxNode *node = m_buttons.First();
while (node)
{
wxButton *but = (wxButton*) node->Data();
if (but->GetId() == button)
{
but->Enable(enable);
return;
}
}
}
bool wxExtDialog::ButtonIsEnabled( wxWindowID button )
{
wxNode *node = m_buttons.First();
while (node)
{
wxButton *but = (wxButton*) node->Data();
if (but->GetId() == button)
return but->IsEnabled();
}
return FALSE;
}
void wxExtDialog::OnSize( wxSizeEvent &WXUNUSED(event) )
{
wxSize client_size( GetClientSize() );
wxSize button_area( LayoutButtons() );
if (HasFlag(wxED_BUTTONS_RIGHT))
client_size.x -= button_area.x;
else
client_size.y -= button_area.y;
if (m_clientWindow)
{
if (m_windowStyle & wxED_CLIENT_MARGIN)
m_clientWindow->SetSize( m_clientWindowMargin,
m_clientWindowMargin,
client_size.x - 2*m_clientWindowMargin,
client_size.y - 2*m_clientWindowMargin );
else
m_clientWindow->SetSize( 0, 0, client_size.x, client_size.y );
if (m_clientWindow->GetAutoLayout())
m_clientWindow->Layout();
}
}
void wxExtDialog::OnYes(wxCommandEvent& event)
{
EndModal( wxID_YES );
}
void wxExtDialog::OnNo(wxCommandEvent& event)
{
EndModal( wxID_NO );
}
void wxExtDialog::OnCancel(wxCommandEvent& event)
{
/* allow cancellation via ESC/Close button except if
only YES and NO are specified. */
if ((m_extraStyle & wxYES_NO) != wxYES_NO || (m_extraStyle & wxCANCEL))
{
EndModal( wxID_CANCEL );
}
}
wxSize wxExtDialog::GetButtonAreaSize()
{
if (m_buttons.GetCount() == 0) return wxSize(0,0);
wxSize ret(0,0);
if (m_windowStyle & wxED_BUTTONS_RIGHT)
{
ret.x = m_spacePerButton.x;
ret.y = m_buttons.GetCount()*m_spacePerButton.y + 2*BUTTON_AREA_MARGIN;
#if wxUSE_STATLINE
if (m_statLine)
ret.x += wxStaticLine::GetDefaultSize();
#endif
}
else
{
ret.x = m_buttons.GetCount()*m_spacePerButton.x + 2*BUTTON_AREA_MARGIN;
ret.y = m_spacePerButton.y;
#if wxUSE_STATLINE
if (m_statLine)
ret.y += wxStaticLine::GetDefaultSize();
#endif
}
return ret;
}
wxSize wxExtDialog::LayoutButtons()
{
if (m_buttons.GetCount() == 0) return wxSize(0,0);
wxSize area_used( GetButtonAreaSize() );
wxSize client_area( GetClientSize() );
if (m_windowStyle & wxED_BUTTONS_RIGHT)
{
area_used.y = client_area.y;
wxSize area_used_by_buttons( area_used );
#if wxUSE_STATLINE
if (m_statLine)
area_used_by_buttons.x -= wxStaticLine::GetDefaultSize();
#endif
int space_for_each_button = (client_area.y-2*BUTTON_AREA_MARGIN) / m_buttons.GetCount();
int n = 0;
wxNode *node = m_buttons.First();
while (node)
{
wxButton *button = (wxButton*)node->Data();
wxSize button_size( button->GetSize() );
if (button_size.x < wxButton::GetDefaultSize().x) button_size.x = wxButton::GetDefaultSize().x;
int center_of_button_y = n*space_for_each_button + space_for_each_button/2;
int button_y = BUTTON_AREA_MARGIN + center_of_button_y - button_size.y/2;
int center_of_button_x = client_area.x - area_used_by_buttons.x/2;
int button_x = center_of_button_x - button_size.x/2;
button->SetSize( button_x, button_y, button_size.x, button_size.y );
node = node->Next();
n++;
}
#if wxUSE_STATLINE
if (m_statLine)
m_statLine->SetSize( client_area.x - area_used_by_buttons.x - wxStaticLine::GetDefaultSize(),
0,
wxStaticLine::GetDefaultSize(),
client_area.y );
#endif
}
else
{
area_used.x = client_area.x;
wxSize area_used_by_buttons( area_used );
#if wxUSE_STATLINE
if (m_statLine)
area_used_by_buttons.y -= wxStaticLine::GetDefaultSize();
#endif
int space_for_each_button = (client_area.x-2*BUTTON_AREA_MARGIN) / m_buttons.GetCount();
int n = 0;
wxNode *node = m_buttons.First();
while (node)
{
wxButton *button = (wxButton*)node->Data();
wxSize button_size( button->GetSize() );
if (button_size.x < wxButton::GetDefaultSize().x) button_size.x = wxButton::GetDefaultSize().x;
int center_of_button_x = n*space_for_each_button + space_for_each_button/2;
int button_x = BUTTON_AREA_MARGIN + center_of_button_x - button_size.x/2;
int center_of_button_y = client_area.y - area_used_by_buttons.y/2;
int button_y = center_of_button_y - button_size.y/2;
button->SetSize( button_x, button_y, button_size.x, button_size.y );
node = node->Next();
n++;
}
#if wxUSE_STATLINE
if (m_statLine)
m_statLine->SetSize( 0,
client_area.y - area_used_by_buttons.y - wxStaticLine::GetDefaultSize(),
client_area.x,
wxStaticLine::GetDefaultSize() );
#endif
}
return area_used;
}

View File

@@ -29,7 +29,8 @@
#include "wx/layout.h"
#include "wx/intl.h"
#include "wx/icon.h"
# include "wx/app.h"
#include "wx/sizer.h"
#include "wx/app.h"
#endif
#include <stdio.h>
@@ -66,170 +67,37 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent,
wxBeginBusyCursor();
wxLayoutConstraints *c;
SetAutoLayout(TRUE);
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
wxStaticBitmap *icon = new wxStaticBitmap(this, -1,
wxTheApp->GetStdIcon(style & wxICON_MASK));
const int iconSize = icon->GetBitmap().GetWidth();
// split the message in lines
// --------------------------
wxArrayString lines;
wxSize sizeText = SplitTextMessage(message, &lines);
long widthTextMax = sizeText.GetWidth(),
heightTextMax = sizeText.GetHeight();
size_t nLineCount = lines.GetCount();
// calculate the total dialog size
enum
wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL );
// 1) icon
if (style & wxICON_MASK)
{
Btn_Ok,
Btn_Yes,
Btn_No,
Btn_Cancel,
Btn_Max
};
wxButton *buttons[Btn_Max] = { NULL, NULL, NULL, NULL };
int nDefaultBtn = -1;
// some checks are in order...
wxASSERT_MSG( !(style & wxOK) || !(style & wxYES_NO),
"don't create dialog with both Yes/No and Ok buttons!" );
wxASSERT_MSG( (style & wxOK ) || (style & wxYES_NO),
"don't create dialog with only the Cancel button!" );
if ( style & wxYES_NO ) {
buttons[Btn_Yes] = new wxButton(this, wxID_YES, _("Yes"));
buttons[Btn_No] = new wxButton(this, wxID_NO, _("No"));
if(style & wxNO_DEFAULT)
nDefaultBtn = Btn_No;
else
nDefaultBtn = Btn_Yes;
wxStaticBitmap *icon = new wxStaticBitmap(
this, -1, wxTheApp->GetStdIcon(style & wxICON_MASK));
icon_text->Add( icon, 0, wxCENTER );
}
// 2) text
icon_text->Add( CreateTextSizer( message ), 0, wxCENTER | wxLEFT, 10 );
topsizer->Add( icon_text, 0, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
#if wxUSE_STATLINE
// 3) static line
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
if (style & wxOK) {
buttons[Btn_Ok] = new wxButton(this, wxID_OK, _("OK"));
// 4) buttons
topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 );
if ( nDefaultBtn == -1 )
nDefaultBtn = Btn_Ok;
}
topsizer->SetSizeHints( this );
topsizer->Fit( this );
SetSizer( topsizer );
SetAutoLayout( TRUE );
if (style & wxCANCEL) {
buttons[Btn_Cancel] = new wxButton(this, wxID_CANCEL, _("Cancel"));
}
// get the longest caption and also calc the number of buttons
size_t nBtn, nButtons = 0;
int width, widthBtnMax = 0;
for ( nBtn = 0; nBtn < Btn_Max; nBtn++ ) {
if ( buttons[nBtn] ) {
nButtons++;
GetTextExtent(buttons[nBtn]->GetLabel(), &width, NULL);
if ( width > widthBtnMax )
widthBtnMax = width;
}
}
// now we can place the buttons
if ( widthBtnMax < 75 )
widthBtnMax = 75;
else
widthBtnMax += 10;
long heightButton = widthBtnMax*23/75;
// *1.2 baselineskip
heightTextMax *= 12;
heightTextMax /= 10;
long widthButtonsTotal = nButtons * (widthBtnMax + LAYOUT_X_MARGIN) -
LAYOUT_X_MARGIN;
// the size of the dialog
long widthDlg = wxMax(widthTextMax + iconSize + 4*LAYOUT_X_MARGIN,
wxMax(widthButtonsTotal, width)) +
2*LAYOUT_X_MARGIN,
heightDlg = 8*LAYOUT_Y_MARGIN + heightButton +
heightTextMax*(nLineCount + 1);
// create the controls
// -------------------
// the icon first
c = new wxLayoutConstraints;
c->width.Absolute(iconSize);
c->height.Absolute(iconSize);
c->top.SameAs(this, wxTop, 3*LAYOUT_Y_MARGIN);
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
icon->SetConstraints(c);
wxStaticText *text = NULL;
for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) {
c = new wxLayoutConstraints;
if ( text == NULL )
c->top.SameAs(this, wxTop, 3*LAYOUT_Y_MARGIN);
else
c->top.Below(text);
c->left.RightOf(icon, 2*LAYOUT_X_MARGIN);
c->width.Absolute(widthTextMax);
c->height.Absolute(heightTextMax);
text = new wxStaticText(this, -1, lines[nLine]);
text->SetConstraints(c);
}
// create the buttons
wxButton *btnPrevious = (wxButton *)NULL;
for ( nBtn = 0; nBtn < Btn_Max; nBtn++ ) {
if ( buttons[nBtn] ) {
c = new wxLayoutConstraints;
if ( btnPrevious ) {
c->left.RightOf(btnPrevious, LAYOUT_X_MARGIN);
}
else {
c->left.SameAs(this, wxLeft,
(widthDlg - widthButtonsTotal) / 2);
}
c->width.Absolute(widthBtnMax);
c->top.Below(text, 4*LAYOUT_Y_MARGIN);
c->height.Absolute(heightButton);
buttons[nBtn]->SetConstraints(c);
btnPrevious = buttons[nBtn];
}
}
// set default button
// ------------------
if ( nDefaultBtn != -1 ) {
buttons[nDefaultBtn]->SetDefault();
buttons[nDefaultBtn]->SetFocus();
}
else {
wxFAIL_MSG( "can't find default button for this dialog." );
}
// position the controls and the dialog itself
// -------------------------------------------
SetClientSize(widthDlg, heightDlg);
// SetSizeHints() wants the size of the whole dialog, not just client size
wxSize sizeTotal = GetSize(),
sizeClient = GetClientSize();
SetSizeHints(widthDlg + sizeTotal.GetWidth() - sizeClient.GetWidth(),
heightDlg + sizeTotal.GetHeight() - sizeClient.GetHeight());
Layout();
Centre(wxCENTER_FRAME | wxBOTH);
Centre( wxBOTH | wxCENTER_FRAME);
wxEndBusyCursor();
}

View File

@@ -48,35 +48,6 @@
// this is where wxGetNumberFromUser() is declared
#include "wx/generic/textdlgg.h"
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
{
wxString line;
for (size_t pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
{
if (!line.IsEmpty())
{
wxStaticText *s1 = new wxStaticText( parent, -1, line );
sizer->Add( s1 );
line = _T("");
}
}
else
{
line += message[pos];
}
}
// remaining text behind last '\n'
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( parent, -1, line );
sizer->Add( s2 );
}
}
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
@@ -137,15 +108,13 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
wxBeginBusyCursor();
wxBox *topsizer = new wxBox( wxVERTICAL );
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
// 1) text message
wxBox *textsizer = new wxBox( wxVERTICAL );
wxSplitMessage2( message, this, textsizer );
topsizer->Add( textsizer, 0, wxALL, 10 );
topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 );
// 2) prompt and text ctrl
wxBox *inputsizer = new wxBox( wxHORIZONTAL );
wxBoxSizer *inputsizer = new wxBoxSizer( wxHORIZONTAL );
// prompt if any
if (!prompt.IsEmpty())
inputsizer->Add( new wxStaticText( this, -1, prompt ), 0, wxCENTER | wxLEFT, 10 );
@@ -162,26 +131,9 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
// 4) buttons
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
wxButton *ok = (wxButton *) NULL;
// if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK") );
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
}
wxButton *cancel = (wxButton *) NULL;
// if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
}
topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 );
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
SetSizer( topsizer );
SetAutoLayout( TRUE );
@@ -190,9 +142,6 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
Centre( wxBOTH );
if (ok)
ok->SetDefault();
m_spinctrl->SetFocus();
wxEndBusyCursor();

View File

@@ -37,6 +37,7 @@
#include "wx/stattext.h"
#include "wx/textctrl.h"
#include "wx/intl.h"
#include "wx/sizer.h"
#endif
#if wxUSE_STATLINE
@@ -77,55 +78,38 @@ wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent,
wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL),
m_value(value)
{
// calculate the sizes
// -------------------
m_dialogStyle = style;
m_value = value;
wxArrayString lines;
wxSize sizeText = SplitTextMessage(message, &lines);
wxBeginBusyCursor();
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
wxSize sizeBtn = GetStandardButtonSize();
// 1) text message
topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 );
// 2) text ctrl
m_textctrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1));
topsizer->Add( m_textctrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
long wText = wxMax(4*sizeBtn.GetWidth(), sizeText.GetWidth());
long hText = GetStandardTextHeight();
#if wxUSE_STATLINE
// 3) static line
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
long wDialog = 4*LAYOUT_X_MARGIN + wText;
long hDialog = 2*LAYOUT_Y_MARGIN +
sizeText.GetHeight() * lines.GetCount() +
2*LAYOUT_Y_MARGIN +
hText +
2*LAYOUT_Y_MARGIN +
sizeBtn.GetHeight() +
2*LAYOUT_Y_MARGIN;
// 4) buttons
topsizer->Add( CreateButtonSizer( style ), 0, wxCENTRE | wxALL, 10 );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
SetSizer( topsizer );
SetAutoLayout( TRUE );
// create the controls
// -------------------
// message
long x = 2*LAYOUT_X_MARGIN;
long y = CreateTextMessage(lines,
wxPoint(x, 2*LAYOUT_Y_MARGIN),
sizeText);
y += 2*LAYOUT_X_MARGIN;
// text ctrl
m_textctrl = new wxTextCtrl(this, wxID_TEXT, m_value,
wxPoint(x, y),
wxSize(wText, hText));
y += hText + 2*LAYOUT_X_MARGIN;
// and buttons
CreateStandardButtons(wDialog, y, sizeBtn.GetWidth(), sizeBtn.GetHeight());
// set the dialog size and position
SetClientSize(wDialog, hDialog);
if ( pos == wxDefaultPosition )
{
// centre the dialog if no explicit position given
Centre(wxBOTH | wxCENTER_FRAME);
}
Centre( wxBOTH );
m_textctrl->SetFocus();
wxEndBusyCursor();
}
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )

View File

@@ -37,10 +37,10 @@
#include "wx/dialog.h"
#include "wx/icon.h"
#include "wx/intl.h"
#include "wx/layout.h"
#include "wx/settings.h"
#include "wx/textctrl.h"
#include "wx/statbmp.h"
#include "wx/sizer.h"
#endif // WX_PRECOMP
#include "wx/statline.h"
@@ -164,12 +164,13 @@ wxTipDialog::wxTipDialog(wxWindow *parent,
{
m_tipProvider = tipProvider;
wxSize sizeBtn = GetStandardButtonSize();
wxLayoutConstraints *c;
// create the controls in the right order, then set the constraints
// 1) create all controls in tab order
wxButton *btnClose = new wxButton(this, wxID_CANCEL, _("&Close"));
m_checkbox = new wxCheckBox(this, -1, _("&Show tips at startup"));
m_checkbox->SetValue(showAtStartup);
wxButton *btnNext = new wxButton(this, wxID_NEXT_TIP, _("&Next"));
wxTextCtrl *text = new wxTextCtrl(this, -1, _("Did you know..."),
@@ -179,7 +180,7 @@ wxTipDialog::wxTipDialog(wxWindow *parent,
text->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNFACE));
m_text = new wxTextCtrl(this, -1, _T(""),
wxDefaultPosition, wxDefaultSize,
wxDefaultPosition, wxSize(200, 160),
wxTE_MULTILINE | wxTE_READONLY | wxSUNKEN_BORDER);
m_text->SetFont(wxFont(14, wxROMAN, wxNORMAL, wxNORMAL));
@@ -189,63 +190,35 @@ wxTipDialog::wxTipDialog(wxWindow *parent,
#include "wx/generic/tip.xpm"
wxIcon icon(tipIcon);
#endif
wxStaticBitmap *bmp = new wxStaticBitmap(this, -1, icon);
const int iconSize = icon.GetWidth();
// 2) put them in boxes
c = new wxLayoutConstraints;
c->top.SameAs(this, wxTop, 2*LAYOUT_Y_MARGIN);
c->left.RightOf(bmp, 2*LAYOUT_X_MARGIN);
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
c->height.Absolute(2*text->GetSize().GetHeight());
text->SetConstraints(c);
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL );
icon_text->Add( bmp, 0, wxCENTER );
icon_text->Add( text, 1, wxCENTER | wxLEFT, 10 );
topsizer->Add( icon_text, 0, wxEXPAND | wxALL, 10 );
topsizer->Add( m_text, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 );
c = new wxLayoutConstraints;
c->centreY.SameAs(text, wxCentreY);
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
c->width.Absolute(iconSize);
c->height.Absolute(iconSize);
bmp->SetConstraints(c);
c = new wxLayoutConstraints;
c->bottom.SameAs(this, wxBottom, 2*LAYOUT_X_MARGIN);
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
c->width.Absolute(sizeBtn.GetWidth());
c->height.Absolute(sizeBtn.GetHeight());
btnClose->SetConstraints(c);
c = new wxLayoutConstraints;
c->bottom.SameAs(this, wxBottom, 2*LAYOUT_X_MARGIN);
c->right.LeftOf(btnClose, 2*LAYOUT_X_MARGIN);
c->width.Absolute(sizeBtn.GetWidth());
c->height.Absolute(sizeBtn.GetHeight());
btnNext->SetConstraints(c);
c = new wxLayoutConstraints;
c->bottom.SameAs(this, wxBottom, 2*LAYOUT_X_MARGIN);
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
c->width.AsIs();
c->height.AsIs();
m_checkbox->SetConstraints(c);
m_checkbox->SetValue(showAtStartup);
c = new wxLayoutConstraints;
c->top.Below(text);
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
c->bottom.Above(btnClose, -2*LAYOUT_Y_MARGIN);
m_text->SetConstraints(c);
wxBoxSizer *bottom = new wxBoxSizer( wxHORIZONTAL );
bottom->Add( m_checkbox, 0, wxCENTER );
bottom->Add( btnNext, 0, wxCENTER | wxLEFT, 10 );
bottom->Add( btnClose, 0, wxCENTER | wxLEFT, 10 );
topsizer->Add( bottom, 0, wxALIGN_RIGHT | wxALL, 10 );
SetTipText();
SetAutoLayout(TRUE);
SetSizer( topsizer );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
Centre(wxBOTH | wxCENTER_FRAME);
wxSize size(5*sizeBtn.GetWidth(), 10*sizeBtn.GetHeight());
SetSize(size);
SetSizeHints(size.x, size.y);
SetAutoLayout(TRUE);
}
// ----------------------------------------------------------------------------

View File

@@ -117,10 +117,10 @@ libwx_gtk_la_SOURCES = \
\
busyinfo.cpp \
caret.cpp \
choicdgg.cpp \
colrdlgg.cpp \
dcpsg.cpp \
dirdlgg.cpp \
extdlgg.cpp \
fontdlgg.cpp \
gridg.cpp \
helpext.cpp \
@@ -129,6 +129,7 @@ libwx_gtk_la_SOURCES = \
imaglist.cpp \
laywin.cpp \
listctrl.cpp \
msgdlgg.cpp \
numdlgg.cpp \
panelg.cpp \
printps.cpp \
@@ -142,6 +143,7 @@ libwx_gtk_la_SOURCES = \
splitter.cpp \
statusbr.cpp \
tabg.cpp \
textdlgg.cpp \
tipdlg.cpp \
treectrl.cpp \
\
@@ -157,7 +159,6 @@ libwx_gtk_la_SOURCES = \
checkbox.cpp \
checklst.cpp \
choice.cpp \
choicdlg.cpp \
clipbrd.cpp \
colour.cpp \
combobox.cpp \
@@ -182,7 +183,6 @@ libwx_gtk_la_SOURCES = \
mdi.cpp \
menu.cpp \
minifram.cpp \
msgdlg.cpp \
notebook.cpp \
palette.cpp \
pen.cpp \
@@ -199,7 +199,6 @@ libwx_gtk_la_SOURCES = \
stattext.cpp \
tbargtk.cpp \
textctrl.cpp \
textdlg.cpp \
timer.cpp \
tooltip.cpp \
utilsgtk.cpp \

View File

@@ -97,8 +97,17 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font );
wxSize newSize = size;
if (newSize.x == -1) newSize.x = 12+x;
if (newSize.y == -1) newSize.y = 11+y;
if (newSize.x == -1)
{
newSize.x = 12+x;
if (newSize.x < 80) newSize.x = 80;
}
if (newSize.y == -1)
{
newSize.y = 11+y;
if (newSize.x < 26) newSize.x = 26;
}
SetSize( newSize.x, newSize.y );
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",

View File

@@ -1,332 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: choicdgg.cpp
// Purpose: Choice dialogs
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "choicdgg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/button.h"
#include "wx/listbox.h"
#include "wx/stattext.h"
#include "wx/intl.h"
#include "wx/sizer.h"
#endif
#if wxUSE_STATLINE
#include "wx/statline.h"
#endif
#include "wx/gtk/choicdlg.h"
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
{
wxString line;
for (size_t pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
{
if (!line.IsEmpty())
{
wxStaticText *s1 = new wxStaticText( parent, -1, line );
sizer->Add( s1 );
line = _T("");
}
}
else
{
line += message[pos];
}
}
// remaining text behind last '\n'
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( parent, -1, line );
sizer->Add( s2 );
}
}
wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n,
const wxString *choices, wxWindow *parent,
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
int WXUNUSED(width), int WXUNUSED(height) )
{
wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
if ( dialog.ShowModal() == wxID_OK )
return dialog.GetStringSelection();
else
return _T("");
}
// Overloaded for backward compatibility
wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n,
char *choices[], wxWindow *parent,
int x, int y, bool centre,
int width, int height )
{
wxString *strings = new wxString[n];
int i;
for ( i = 0; i < n; i++)
{
strings[i] = choices[i];
}
wxString ans(wxGetSingleChoice(message, caption, n, (const wxString *)strings, parent,
x, y, centre, width, height));
delete[] strings;
return ans;
}
int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n,
const wxString *choices, wxWindow *parent,
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
int WXUNUSED(width), int WXUNUSED(height) )
{
wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
if ( dialog.ShowModal() == wxID_OK )
return dialog.GetSelection();
else
return -1;
}
// Overloaded for backward compatibility
int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n,
wxChar *choices[], wxWindow *parent,
int x, int y, bool centre,
int width, int height )
{
wxString *strings = new wxString[n];
for ( int i = 0; i < n; i++)
strings[i] = choices[i];
int ans = wxGetSingleChoiceIndex(message, caption, n, (const wxString *)strings, parent,
x, y, centre, width, height);
delete[] strings;
return ans;
}
wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n,
const wxString *choices, char **client_data, wxWindow *parent,
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
int WXUNUSED(width), int WXUNUSED(height) )
{
wxSingleChoiceDialog dialog(parent, message, caption, n, choices, client_data);
if ( dialog.ShowModal() == wxID_OK )
return (wxChar *)dialog.GetSelectionClientData();
else
return NULL;
}
// Overloaded for backward compatibility
wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n,
wxChar *choices[], char **client_data, wxWindow *parent,
int x, int y, bool centre,
int width, int height )
{
wxString *strings = new wxString[n];
int i;
for ( i = 0; i < n; i++)
{
strings[i] = choices[i];
}
wxChar *data = wxGetSingleChoiceData(message, caption, n, (const wxString *)strings, client_data, parent,
x, y, centre, width, height);
delete[] strings;
return data;
}
/* Multiple choice dialog contributed by Robert Cowell
*
The new data passed are in the "int nsel" and "int * selection"
The idea is to make a multiple selection from list of strings.
The returned value is the total number selected. initialily there
are nsel selected, with indices stored in
selection[0],...,selection[nsel-1] which appear highlighted to
begin with. On exit with value i
selection[0..i-1] contains the indices of the selected items.
(Some prior selectecions might be deselected.)
Thus selection must be as big as choices, in case all items are
selected.
*/
/*
int wxGetMultipleChoice(const wxString& message, const wxString& caption,
int n, const wxString *choices,
int nsel, int * selection,
wxWindow *parent , int x , int y, bool centre,
int width, int height)
{
return -1;
}
*/
// wxSingleChoiceDialog
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK)
EVT_LISTBOX_DCLICK(wxID_LISTBOX, wxSingleChoiceDialog::OnListBoxDClick)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
#endif
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
int n, const wxString *choices, char **clientData, long style, const wxPoint& pos):
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
{
Create(parent, message, caption, n, choices, clientData, style);
}
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
const wxStringList& choices, char **clientData, long style, const wxPoint& pos):
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
{
Create(parent, message, caption, choices, clientData, style);
}
bool wxSingleChoiceDialog::Create(wxWindow *parent, const wxString& message, const wxString& caption,
const wxStringList& choices, char **clientData, long style, const wxPoint& pos)
{
wxString *strings = new wxString[choices.Number()];
int i;
for ( i = 0; i < choices.Number(); i++)
{
strings[i] = (char *)choices.Nth(i)->Data();
}
bool ans = Create(parent, message, caption, choices.Number(), strings, clientData, style, pos);
delete[] strings;
return ans;
}
bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& message,
const wxString& WXUNUSED(caption), int n,
const wxString *choices, char **clientData, long style,
const wxPoint& WXUNUSED(pos) )
{
m_dialogStyle = style;
m_selection = 0;
m_stringSelection = _T("");
m_clientData = NULL;
wxBeginBusyCursor();
wxBox *topsizer = new wxBox( wxVERTICAL );
// 1) text message
wxBox *textsizer = new wxBox( wxVERTICAL );
wxSplitMessage2( message, this, textsizer );
topsizer->Add( textsizer, 0, wxALL, 10 );
// 2) list box
wxListBox *listBox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) ,
n, choices, wxLB_ALWAYS_SB );
listBox->SetSelection( m_selection );
if (clientData)
{
for (int i = 0; i < n; i++)
listBox->SetClientData(i, clientData[i]);
}
topsizer->Add( listBox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
#if wxUSE_STATLINE
// 3) static line
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
// 4) buttons
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
wxButton *ok = (wxButton *) NULL;
if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK") );
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
}
wxButton *cancel = (wxButton *) NULL;
if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
}
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
SetSizer( topsizer );
SetAutoLayout( TRUE );
Centre( wxBOTH );
if (ok)
ok->SetDefault();
listBox->SetFocus();
wxEndBusyCursor();
return TRUE;
}
// Set the selection
void wxSingleChoiceDialog::SetSelection(int sel)
{
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
if (listBox)
{
listBox->SetSelection(sel);
}
m_selection = sel;
}
void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
if ( listBox )
{
m_selection = listBox->GetSelection();
m_stringSelection = listBox->GetStringSelection();
m_clientData = listBox->GetClientData(m_selection);
}
EndModal(wxID_OK);
}
void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event))
{
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
if ( listBox )
{
m_selection = listBox->GetSelection();
m_stringSelection = listBox->GetStringSelection();
m_clientData = listBox->GetClientData(m_selection);
}
EndModal(wxID_OK);
}

View File

@@ -11,7 +11,7 @@
#
#
#
# This file was automatically generated by tmake at 19:48, 1999/08/10
# This file was automatically generated by tmake at 09:46, 1999/08/11
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
#
@@ -103,9 +103,9 @@ DOCDIR = $(WXDIR)/docs
GTK_GENERICOBJS = \
../generic/busyinfo.o \
../generic/caret.o \
../generic/choicdgg.o \
../generic/colrdlgg.o \
../generic/dirdlgg.o \
../generic/extdlgg.o \
../generic/fontdlgg.o \
../generic/gridg.o \
../generic/imaglist.o \
@@ -123,6 +123,7 @@ GTK_GENERICOBJS = \
../generic/scrolwin.o \
../generic/splitter.o \
../generic/statusbr.o \
../generic/textdlgg.o \
../generic/tipdlg.o \
../generic/treectrl.o
@@ -216,7 +217,6 @@ GTK_GUIOBJS = \
../gtk/button.o \
../gtk/checkbox.o \
../gtk/checklst.o \
../gtk/choicdlg.o \
../gtk/choice.o \
../gtk/clipbrd.o \
../gtk/colour.o \
@@ -260,7 +260,6 @@ GTK_GUIOBJS = \
../gtk/stattext.o \
../gtk/tbargtk.o \
../gtk/textctrl.o \
../gtk/textdlg.o \
../gtk/timer.o \
../gtk/tooltip.o \
../gtk/utilsgtk.o \
@@ -275,7 +274,6 @@ MOTIF_GENERICOBJS = \
../generic/choicdgg.o \
../generic/colrdlgg.o \
../generic/dirdlgg.o \
../generic/extdlgg.o \
../generic/fontdlgg.o \
../generic/gridg.o \
../generic/helpxlp.o \

View File

@@ -1,197 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlgg.cpp
// Purpose: wxGenericMessageDialog
// Author: Julian Smart, Robert Roebling
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Markus Holzem, Robert Roebling
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "msgdlgg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/listbox.h"
#include "wx/button.h"
#include "wx/statbmp.h"
#include "wx/stattext.h"
#include "wx/layout.h"
#include "wx/intl.h"
#include "wx/bitmap.h"
#include "wx/app.h"
#endif
#include <stdio.h>
#include <string.h>
#include "wx/gtk/msgdlg.h"
#include "wx/statline.h"
///////////////////////////////////////////////////////////////////
// New dialog box implementations
// Split message, using constraints to position controls
wxSize wxSplitMessage2( const wxString &message, wxWindow *parent, int text_pos_x )
{
int y = 15;
int w = 50;
wxString line( _T("") );
for (uint pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
{
if (!line.IsEmpty())
{
wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) );
wxSize size1( s1->GetSize() );
if (size1.x > w) w = size1.x;
line = _T("");
}
y += 18;
}
else
{
line += message[pos];
}
}
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) );
wxSize size2( s2->GetSize() );
if (size2.x > w) w = size2.x;
}
y += 18;
return wxSize(w+15+text_pos_x,y);
}
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog)
EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes)
EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo)
EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog)
#endif
wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString& message,
const wxString& caption, long style, const wxPoint& pos) :
wxDialog( parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE )
{
m_dialogStyle = style;
int text_pos_x = 15;
if (m_dialogStyle & wxICON_MASK)
text_pos_x += 80;
wxSize message_size( wxSplitMessage2( message, this, text_pos_x ) );
if (m_dialogStyle & wxICON_MASK)
{
if (message_size.y < 50) message_size.y = 50;
(void) new wxStaticBitmap( this, -1,
wxTheApp->GetStdIcon(m_dialogStyle
& wxICON_MASK),
wxPoint(15,message_size.y/2-16) );
}
wxButton *ok = (wxButton *) NULL;
wxButton *cancel = (wxButton *) NULL;
wxButton *yes = (wxButton *) NULL;
wxButton *no = (wxButton *) NULL;
int y = message_size.y + 30;
if (style & wxYES_NO)
{
yes = new wxButton( this, wxID_YES, _("Yes"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( yes );
no = new wxButton( this, wxID_NO, _("No"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( no );
}
if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( ok );
}
if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( cancel );
}
if (ok)
{
ok->SetDefault();
ok->SetFocus();
}
else if (yes)
{
yes->SetDefault();
yes->SetFocus();
}
int w = m_buttons.GetCount() * 100;
if (message_size.x > w) w = message_size.x;
int space = w / (m_buttons.GetCount()*2);
int n = 0;
wxNode *node = m_buttons.First();
while (node)
{
wxWindow *win = (wxWindow*)node->Data();
int x = (n*2+1)*space - 40 + 15;
win->Move( x, -1 );
node = node->Next();
n++;
}
#ifdef __WXGTK__
int edge_margin = 7;
(void) new wxStaticLine( this, -1, wxPoint(edge_margin,y-20), wxSize(w+30-2*edge_margin, 5) );
#endif
SetSize( w+30, y+40 );
Centre( wxBOTH );
}
void wxGenericMessageDialog::OnYes(wxCommandEvent& WXUNUSED(event))
{
EndModal( wxID_YES );
}
void wxGenericMessageDialog::OnNo(wxCommandEvent& WXUNUSED(event))
{
EndModal( wxID_NO );
}
void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
{
/* Allow cancellation via ESC/Close button except if
only YES and NO are specified. */
if ( (m_dialogStyle & wxYES_NO) != wxYES_NO || (m_dialogStyle & wxCANCEL) )
{
EndModal( wxID_CANCEL );
}
}

View File

@@ -1,146 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: textdlgg.cpp
// Purpose: wxTextEntryDialog
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "textdlgg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/button.h"
#include "wx/stattext.h"
#include "wx/textctrl.h"
#include "wx/intl.h"
#include "wx/sizer.h"
#endif
#if wxUSE_STATLINE
#include "wx/statline.h"
#endif
#include "wx/gtk/textdlg.h"
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
{
wxString line;
for (size_t pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
{
if (!line.IsEmpty())
{
wxStaticText *s1 = new wxStaticText( parent, -1, line );
sizer->Add( s1 );
line = _T("");
}
}
else
{
line += message[pos];
}
}
// remaining text behind last '\n'
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( parent, -1, line );
sizer->Add( s2 );
}
}
// wxTextEntryDialog
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog)
#endif
wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption,
const wxString& value, long style, const wxPoint& pos):
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
{
m_dialogStyle = style;
m_value = value;
wxBeginBusyCursor();
wxBox *topsizer = new wxBox( wxVERTICAL );
// 1) text message
wxBox *textsizer = new wxBox( wxVERTICAL );
wxSplitMessage2( message, this, textsizer );
topsizer->Add( textsizer, 0, wxALL, 10 );
// 2) text ctrl
wxTextCtrl *textCtrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1));
topsizer->Add( textCtrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
#if wxUSE_STATLINE
// 3) static line
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
// 4) buttons
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
wxButton *ok = (wxButton *) NULL;
if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK") );
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
}
wxButton *cancel = (wxButton *) NULL;
if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
}
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
SetSizer( topsizer );
SetAutoLayout( TRUE );
Centre( wxBOTH );
if (ok)
ok->SetDefault();
textCtrl->SetFocus();
wxEndBusyCursor();
}
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
{
wxTextCtrl *textCtrl = (wxTextCtrl *)FindWindow(wxID_TEXT);
if ( textCtrl )
m_value = textCtrl->GetValue();
EndModal(wxID_OK);
}

View File

@@ -117,10 +117,10 @@ libwx_gtk_la_SOURCES = \
\
busyinfo.cpp \
caret.cpp \
choicdgg.cpp \
colrdlgg.cpp \
dcpsg.cpp \
dirdlgg.cpp \
extdlgg.cpp \
fontdlgg.cpp \
gridg.cpp \
helpext.cpp \
@@ -129,6 +129,7 @@ libwx_gtk_la_SOURCES = \
imaglist.cpp \
laywin.cpp \
listctrl.cpp \
msgdlgg.cpp \
numdlgg.cpp \
panelg.cpp \
printps.cpp \
@@ -142,6 +143,7 @@ libwx_gtk_la_SOURCES = \
splitter.cpp \
statusbr.cpp \
tabg.cpp \
textdlgg.cpp \
tipdlg.cpp \
treectrl.cpp \
\
@@ -157,7 +159,6 @@ libwx_gtk_la_SOURCES = \
checkbox.cpp \
checklst.cpp \
choice.cpp \
choicdlg.cpp \
clipbrd.cpp \
colour.cpp \
combobox.cpp \
@@ -182,7 +183,6 @@ libwx_gtk_la_SOURCES = \
mdi.cpp \
menu.cpp \
minifram.cpp \
msgdlg.cpp \
notebook.cpp \
palette.cpp \
pen.cpp \
@@ -199,7 +199,6 @@ libwx_gtk_la_SOURCES = \
stattext.cpp \
tbargtk.cpp \
textctrl.cpp \
textdlg.cpp \
timer.cpp \
tooltip.cpp \
utilsgtk.cpp \

View File

@@ -97,8 +97,17 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font );
wxSize newSize = size;
if (newSize.x == -1) newSize.x = 12+x;
if (newSize.y == -1) newSize.y = 11+y;
if (newSize.x == -1)
{
newSize.x = 12+x;
if (newSize.x < 80) newSize.x = 80;
}
if (newSize.y == -1)
{
newSize.y = 11+y;
if (newSize.x < 26) newSize.x = 26;
}
SetSize( newSize.x, newSize.y );
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",

View File

@@ -1,332 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: choicdgg.cpp
// Purpose: Choice dialogs
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "choicdgg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/button.h"
#include "wx/listbox.h"
#include "wx/stattext.h"
#include "wx/intl.h"
#include "wx/sizer.h"
#endif
#if wxUSE_STATLINE
#include "wx/statline.h"
#endif
#include "wx/gtk/choicdlg.h"
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
{
wxString line;
for (size_t pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
{
if (!line.IsEmpty())
{
wxStaticText *s1 = new wxStaticText( parent, -1, line );
sizer->Add( s1 );
line = _T("");
}
}
else
{
line += message[pos];
}
}
// remaining text behind last '\n'
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( parent, -1, line );
sizer->Add( s2 );
}
}
wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n,
const wxString *choices, wxWindow *parent,
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
int WXUNUSED(width), int WXUNUSED(height) )
{
wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
if ( dialog.ShowModal() == wxID_OK )
return dialog.GetStringSelection();
else
return _T("");
}
// Overloaded for backward compatibility
wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n,
char *choices[], wxWindow *parent,
int x, int y, bool centre,
int width, int height )
{
wxString *strings = new wxString[n];
int i;
for ( i = 0; i < n; i++)
{
strings[i] = choices[i];
}
wxString ans(wxGetSingleChoice(message, caption, n, (const wxString *)strings, parent,
x, y, centre, width, height));
delete[] strings;
return ans;
}
int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n,
const wxString *choices, wxWindow *parent,
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
int WXUNUSED(width), int WXUNUSED(height) )
{
wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
if ( dialog.ShowModal() == wxID_OK )
return dialog.GetSelection();
else
return -1;
}
// Overloaded for backward compatibility
int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n,
wxChar *choices[], wxWindow *parent,
int x, int y, bool centre,
int width, int height )
{
wxString *strings = new wxString[n];
for ( int i = 0; i < n; i++)
strings[i] = choices[i];
int ans = wxGetSingleChoiceIndex(message, caption, n, (const wxString *)strings, parent,
x, y, centre, width, height);
delete[] strings;
return ans;
}
wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n,
const wxString *choices, char **client_data, wxWindow *parent,
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
int WXUNUSED(width), int WXUNUSED(height) )
{
wxSingleChoiceDialog dialog(parent, message, caption, n, choices, client_data);
if ( dialog.ShowModal() == wxID_OK )
return (wxChar *)dialog.GetSelectionClientData();
else
return NULL;
}
// Overloaded for backward compatibility
wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n,
wxChar *choices[], char **client_data, wxWindow *parent,
int x, int y, bool centre,
int width, int height )
{
wxString *strings = new wxString[n];
int i;
for ( i = 0; i < n; i++)
{
strings[i] = choices[i];
}
wxChar *data = wxGetSingleChoiceData(message, caption, n, (const wxString *)strings, client_data, parent,
x, y, centre, width, height);
delete[] strings;
return data;
}
/* Multiple choice dialog contributed by Robert Cowell
*
The new data passed are in the "int nsel" and "int * selection"
The idea is to make a multiple selection from list of strings.
The returned value is the total number selected. initialily there
are nsel selected, with indices stored in
selection[0],...,selection[nsel-1] which appear highlighted to
begin with. On exit with value i
selection[0..i-1] contains the indices of the selected items.
(Some prior selectecions might be deselected.)
Thus selection must be as big as choices, in case all items are
selected.
*/
/*
int wxGetMultipleChoice(const wxString& message, const wxString& caption,
int n, const wxString *choices,
int nsel, int * selection,
wxWindow *parent , int x , int y, bool centre,
int width, int height)
{
return -1;
}
*/
// wxSingleChoiceDialog
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK)
EVT_LISTBOX_DCLICK(wxID_LISTBOX, wxSingleChoiceDialog::OnListBoxDClick)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
#endif
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
int n, const wxString *choices, char **clientData, long style, const wxPoint& pos):
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
{
Create(parent, message, caption, n, choices, clientData, style);
}
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
const wxStringList& choices, char **clientData, long style, const wxPoint& pos):
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
{
Create(parent, message, caption, choices, clientData, style);
}
bool wxSingleChoiceDialog::Create(wxWindow *parent, const wxString& message, const wxString& caption,
const wxStringList& choices, char **clientData, long style, const wxPoint& pos)
{
wxString *strings = new wxString[choices.Number()];
int i;
for ( i = 0; i < choices.Number(); i++)
{
strings[i] = (char *)choices.Nth(i)->Data();
}
bool ans = Create(parent, message, caption, choices.Number(), strings, clientData, style, pos);
delete[] strings;
return ans;
}
bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& message,
const wxString& WXUNUSED(caption), int n,
const wxString *choices, char **clientData, long style,
const wxPoint& WXUNUSED(pos) )
{
m_dialogStyle = style;
m_selection = 0;
m_stringSelection = _T("");
m_clientData = NULL;
wxBeginBusyCursor();
wxBox *topsizer = new wxBox( wxVERTICAL );
// 1) text message
wxBox *textsizer = new wxBox( wxVERTICAL );
wxSplitMessage2( message, this, textsizer );
topsizer->Add( textsizer, 0, wxALL, 10 );
// 2) list box
wxListBox *listBox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) ,
n, choices, wxLB_ALWAYS_SB );
listBox->SetSelection( m_selection );
if (clientData)
{
for (int i = 0; i < n; i++)
listBox->SetClientData(i, clientData[i]);
}
topsizer->Add( listBox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
#if wxUSE_STATLINE
// 3) static line
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
// 4) buttons
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
wxButton *ok = (wxButton *) NULL;
if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK") );
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
}
wxButton *cancel = (wxButton *) NULL;
if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
}
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
SetSizer( topsizer );
SetAutoLayout( TRUE );
Centre( wxBOTH );
if (ok)
ok->SetDefault();
listBox->SetFocus();
wxEndBusyCursor();
return TRUE;
}
// Set the selection
void wxSingleChoiceDialog::SetSelection(int sel)
{
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
if (listBox)
{
listBox->SetSelection(sel);
}
m_selection = sel;
}
void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
if ( listBox )
{
m_selection = listBox->GetSelection();
m_stringSelection = listBox->GetStringSelection();
m_clientData = listBox->GetClientData(m_selection);
}
EndModal(wxID_OK);
}
void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event))
{
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
if ( listBox )
{
m_selection = listBox->GetSelection();
m_stringSelection = listBox->GetStringSelection();
m_clientData = listBox->GetClientData(m_selection);
}
EndModal(wxID_OK);
}

View File

@@ -11,7 +11,7 @@
#
#
#
# This file was automatically generated by tmake at 19:48, 1999/08/10
# This file was automatically generated by tmake at 09:46, 1999/08/11
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
#
@@ -103,9 +103,9 @@ DOCDIR = $(WXDIR)/docs
GTK_GENERICOBJS = \
../generic/busyinfo.o \
../generic/caret.o \
../generic/choicdgg.o \
../generic/colrdlgg.o \
../generic/dirdlgg.o \
../generic/extdlgg.o \
../generic/fontdlgg.o \
../generic/gridg.o \
../generic/imaglist.o \
@@ -123,6 +123,7 @@ GTK_GENERICOBJS = \
../generic/scrolwin.o \
../generic/splitter.o \
../generic/statusbr.o \
../generic/textdlgg.o \
../generic/tipdlg.o \
../generic/treectrl.o
@@ -216,7 +217,6 @@ GTK_GUIOBJS = \
../gtk/button.o \
../gtk/checkbox.o \
../gtk/checklst.o \
../gtk/choicdlg.o \
../gtk/choice.o \
../gtk/clipbrd.o \
../gtk/colour.o \
@@ -260,7 +260,6 @@ GTK_GUIOBJS = \
../gtk/stattext.o \
../gtk/tbargtk.o \
../gtk/textctrl.o \
../gtk/textdlg.o \
../gtk/timer.o \
../gtk/tooltip.o \
../gtk/utilsgtk.o \
@@ -275,7 +274,6 @@ MOTIF_GENERICOBJS = \
../generic/choicdgg.o \
../generic/colrdlgg.o \
../generic/dirdlgg.o \
../generic/extdlgg.o \
../generic/fontdlgg.o \
../generic/gridg.o \
../generic/helpxlp.o \

View File

@@ -1,197 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlgg.cpp
// Purpose: wxGenericMessageDialog
// Author: Julian Smart, Robert Roebling
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Markus Holzem, Robert Roebling
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "msgdlgg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/listbox.h"
#include "wx/button.h"
#include "wx/statbmp.h"
#include "wx/stattext.h"
#include "wx/layout.h"
#include "wx/intl.h"
#include "wx/bitmap.h"
#include "wx/app.h"
#endif
#include <stdio.h>
#include <string.h>
#include "wx/gtk/msgdlg.h"
#include "wx/statline.h"
///////////////////////////////////////////////////////////////////
// New dialog box implementations
// Split message, using constraints to position controls
wxSize wxSplitMessage2( const wxString &message, wxWindow *parent, int text_pos_x )
{
int y = 15;
int w = 50;
wxString line( _T("") );
for (uint pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
{
if (!line.IsEmpty())
{
wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) );
wxSize size1( s1->GetSize() );
if (size1.x > w) w = size1.x;
line = _T("");
}
y += 18;
}
else
{
line += message[pos];
}
}
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) );
wxSize size2( s2->GetSize() );
if (size2.x > w) w = size2.x;
}
y += 18;
return wxSize(w+15+text_pos_x,y);
}
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog)
EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes)
EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo)
EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog)
#endif
wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString& message,
const wxString& caption, long style, const wxPoint& pos) :
wxDialog( parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE )
{
m_dialogStyle = style;
int text_pos_x = 15;
if (m_dialogStyle & wxICON_MASK)
text_pos_x += 80;
wxSize message_size( wxSplitMessage2( message, this, text_pos_x ) );
if (m_dialogStyle & wxICON_MASK)
{
if (message_size.y < 50) message_size.y = 50;
(void) new wxStaticBitmap( this, -1,
wxTheApp->GetStdIcon(m_dialogStyle
& wxICON_MASK),
wxPoint(15,message_size.y/2-16) );
}
wxButton *ok = (wxButton *) NULL;
wxButton *cancel = (wxButton *) NULL;
wxButton *yes = (wxButton *) NULL;
wxButton *no = (wxButton *) NULL;
int y = message_size.y + 30;
if (style & wxYES_NO)
{
yes = new wxButton( this, wxID_YES, _("Yes"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( yes );
no = new wxButton( this, wxID_NO, _("No"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( no );
}
if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( ok );
}
if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxPoint(-1,y), wxSize(80,-1) );
m_buttons.Append( cancel );
}
if (ok)
{
ok->SetDefault();
ok->SetFocus();
}
else if (yes)
{
yes->SetDefault();
yes->SetFocus();
}
int w = m_buttons.GetCount() * 100;
if (message_size.x > w) w = message_size.x;
int space = w / (m_buttons.GetCount()*2);
int n = 0;
wxNode *node = m_buttons.First();
while (node)
{
wxWindow *win = (wxWindow*)node->Data();
int x = (n*2+1)*space - 40 + 15;
win->Move( x, -1 );
node = node->Next();
n++;
}
#ifdef __WXGTK__
int edge_margin = 7;
(void) new wxStaticLine( this, -1, wxPoint(edge_margin,y-20), wxSize(w+30-2*edge_margin, 5) );
#endif
SetSize( w+30, y+40 );
Centre( wxBOTH );
}
void wxGenericMessageDialog::OnYes(wxCommandEvent& WXUNUSED(event))
{
EndModal( wxID_YES );
}
void wxGenericMessageDialog::OnNo(wxCommandEvent& WXUNUSED(event))
{
EndModal( wxID_NO );
}
void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
{
/* Allow cancellation via ESC/Close button except if
only YES and NO are specified. */
if ( (m_dialogStyle & wxYES_NO) != wxYES_NO || (m_dialogStyle & wxCANCEL) )
{
EndModal( wxID_CANCEL );
}
}

View File

@@ -1,146 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: textdlgg.cpp
// Purpose: wxTextEntryDialog
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "textdlgg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/button.h"
#include "wx/stattext.h"
#include "wx/textctrl.h"
#include "wx/intl.h"
#include "wx/sizer.h"
#endif
#if wxUSE_STATLINE
#include "wx/statline.h"
#endif
#include "wx/gtk/textdlg.h"
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
{
wxString line;
for (size_t pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
{
if (!line.IsEmpty())
{
wxStaticText *s1 = new wxStaticText( parent, -1, line );
sizer->Add( s1 );
line = _T("");
}
}
else
{
line += message[pos];
}
}
// remaining text behind last '\n'
if (!line.IsEmpty())
{
wxStaticText *s2 = new wxStaticText( parent, -1, line );
sizer->Add( s2 );
}
}
// wxTextEntryDialog
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog)
#endif
wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption,
const wxString& value, long style, const wxPoint& pos):
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
{
m_dialogStyle = style;
m_value = value;
wxBeginBusyCursor();
wxBox *topsizer = new wxBox( wxVERTICAL );
// 1) text message
wxBox *textsizer = new wxBox( wxVERTICAL );
wxSplitMessage2( message, this, textsizer );
topsizer->Add( textsizer, 0, wxALL, 10 );
// 2) text ctrl
wxTextCtrl *textCtrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1));
topsizer->Add( textCtrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
#if wxUSE_STATLINE
// 3) static line
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
// 4) buttons
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
wxButton *ok = (wxButton *) NULL;
if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK") );
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
}
wxButton *cancel = (wxButton *) NULL;
if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
}
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
topsizer->SetSizeHints( this );
topsizer->Fit( this );
SetSizer( topsizer );
SetAutoLayout( TRUE );
Centre( wxBOTH );
if (ok)
ok->SetDefault();
textCtrl->SetFocus();
wxEndBusyCursor();
}
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
{
wxTextCtrl *textCtrl = (wxTextCtrl *)FindWindow(wxID_TEXT);
if ( textCtrl )
m_value = textCtrl->GetValue();
EndModal(wxID_OK);
}

View File

@@ -11,7 +11,7 @@
#
#
#
# This file was automatically generated by tmake at 19:48, 1999/08/10
# This file was automatically generated by tmake at 09:46, 1999/08/11
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
#
@@ -103,9 +103,9 @@ DOCDIR = $(WXDIR)/docs
GTK_GENERICOBJS = \
../generic/busyinfo.o \
../generic/caret.o \
../generic/choicdgg.o \
../generic/colrdlgg.o \
../generic/dirdlgg.o \
../generic/extdlgg.o \
../generic/fontdlgg.o \
../generic/gridg.o \
../generic/imaglist.o \
@@ -123,6 +123,7 @@ GTK_GENERICOBJS = \
../generic/scrolwin.o \
../generic/splitter.o \
../generic/statusbr.o \
../generic/textdlgg.o \
../generic/tipdlg.o \
../generic/treectrl.o
@@ -216,7 +217,6 @@ GTK_GUIOBJS = \
../gtk/button.o \
../gtk/checkbox.o \
../gtk/checklst.o \
../gtk/choicdlg.o \
../gtk/choice.o \
../gtk/clipbrd.o \
../gtk/colour.o \
@@ -260,7 +260,6 @@ GTK_GUIOBJS = \
../gtk/stattext.o \
../gtk/tbargtk.o \
../gtk/textctrl.o \
../gtk/textdlg.o \
../gtk/timer.o \
../gtk/tooltip.o \
../gtk/utilsgtk.o \
@@ -275,7 +274,6 @@ MOTIF_GENERICOBJS = \
../generic/choicdgg.o \
../generic/colrdlgg.o \
../generic/dirdlgg.o \
../generic/extdlgg.o \
../generic/fontdlgg.o \
../generic/gridg.o \
../generic/helpxlp.o \