/////////////////////////////////////////////////////////////////////////////
// Name:        No names yet.
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     2000/02/08
// RCS-ID:      $Id: labeleditdlg.cpp,v 1.5 2001/04/04 12:42:37 aleksandras Exp $
// Copyright:   (c) Aleksandras Gluchovas (alex@soften.ktu.lt)
// Licence:   	GPL (version 2.0 or later)
/////////////////////////////////////////////////////////////////////////////

#ifdef __GNUG__
    #pragma implementation "minimal.cpp"
    #pragma interface "minimal.cpp"
#endif

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

#include "labeleditdlg.h"
#include "wx/sizer.h"

/***** Implementation for class LabelEditDlg *****/

LabelEditDlg::LabelEditDlg( wxWindow* parent, 
						    const wxString& dialogTitle,
						    const wxString& labelTitle,
						    const wxString& labelValue,
						    const wxString& nameTitle,
						    const wxString& nameValue,
							bool showLabel,
						    bool selectAll )
	: wxDialog( parent, -1, dialogTitle, wxDefaultPosition, wxDefaultSize,
				wxDEFAULT_DIALOG_STYLE )
{
	wxGridSizer* grid = new wxGridSizer( 2, 2 );

	wxBoxSizer* box = new wxBoxSizer( wxVERTICAL );

	wxBoxSizer* box1 = new wxBoxSizer( wxHORIZONTAL );

	box->Add( grid, 1, wxEXPAND | wxALL, 10 );
	box->Add( box1, 0, wxCENTER | wxALL, 10 );

	wxButton* bOk = new wxButton( this, wxID_OK, "&Apply", wxDefaultPosition );
	wxButton* bCn = new wxButton( this, wxID_CANCEL, "Cancel", wxDefaultPosition );
	bOk->SetDefault();

	box1->Add( bOk, 0, wxALL, 10 );
	box1->Add( bCn, 0, wxALL, 10 );

	// fillint-out the grid

	grid->Add( new wxStaticText( this, -1, labelTitle, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ) );
	
	mpLabel = new wxTextCtrl( this, -1, labelValue, wxDefaultPosition, wxDefaultSize );
	grid->Add( mpLabel );

	grid->Add( new wxStaticText( this, -1, nameTitle, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ) );
	
	mpName = new wxTextCtrl( this, -1, nameValue, wxDefaultPosition, wxDefaultSize );
	grid->Add( mpName );

	if ( !showLabel )
	{
		mpLabel->Enable( FALSE );
		mpName->SetFocus();

		if ( selectAll ) 
			
			mpName->SetSelection( 0, 1000 );
	}
	else
	{
		mpLabel->SetFocus();

		if ( selectAll ) 
			
			mpLabel->SetSelection( 0, 1000 );
	}

	this->SetAutoLayout( TRUE );
	SetSizer( box );
	box->Fit( this );
	box->SetSizeHints( this );
	this->Layout();
	this->Center( wxBOTH );
}

wxString LabelEditDlg::GetItemName()
{
	return mpName->GetValue();
}

wxString LabelEditDlg::GetItemLabel()
{
	return mpLabel->GetValue();
}