dialog_options.cpp 13.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
/////////////////////////////////////////////////////////////////////////////
// Name:        dilaog_options.cpp
// Purpose:     
// Author:      jean-pierre Charras
// Modified by: 
// Created:     31/01/2006 13:27:33
// RCS-ID:      
// Copyright:   GNU Licence
// Licence:     GNU
/////////////////////////////////////////////////////////////////////////////

// Generated by DialogBlocks (unregistered), 31/01/2006 13:27:33

#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dilaog_options.h"
#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 "fctsys.h"
#include "gr_basic.h"

#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"

#include "id.h"

#include "protos.h"

////@begin includes
////@end includes

#include "dialog_options.h"

////@begin XPM images
////@end XPM images



/**************************************************************************/
void DisplayOptionFrame(WinEDA_DrawFrame * parent, const wxPoint & framepos)
/**************************************************************************/
{
	WinEDA_SetOptionsFrame * frame =
			new WinEDA_SetOptionsFrame(parent);
	frame->ShowModal(); frame->Destroy();
}


/*!
 * WinEDA_SetOptionsFrame type definition
 */

IMPLEMENT_DYNAMIC_CLASS( WinEDA_SetOptionsFrame, wxDialog )

/*!
 * WinEDA_SetOptionsFrame event table definition
 */

BEGIN_EVENT_TABLE( WinEDA_SetOptionsFrame, wxDialog )

////@begin WinEDA_SetOptionsFrame event table entries
    EVT_BUTTON( wxID_OK, WinEDA_SetOptionsFrame::OnOkClick )

    EVT_BUTTON( wxID_CANCEL, WinEDA_SetOptionsFrame::OnCancelClick )

////@end WinEDA_SetOptionsFrame event table entries

END_EVENT_TABLE()

/*!
 * WinEDA_SetOptionsFrame constructors
 */

WinEDA_SetOptionsFrame::WinEDA_SetOptionsFrame( )
{
}

WinEDA_SetOptionsFrame::WinEDA_SetOptionsFrame( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
	m_Parent = parent;
    Create(parent, id, caption, pos, size, style);
	
	/* Init options */
	if ( m_Parent->GetScreen() )
	{
		switch( m_Parent->GetScreen()->GetGrid().x )
		{
			case 50:
				m_SelGridSize->SetSelection(0);
				break;

			case 25:
				m_SelGridSize->SetSelection(1);
				break;

			case 10:
				m_SelGridSize->SetSelection(2);
				break;

			case 5:
				m_SelGridSize->SetSelection(3);
				break;

			case 2:
				m_SelGridSize->SetSelection(4);
				break;

			case 1:
				m_SelGridSize->SetSelection(5);
				break;

			default:
				DisplayError(this, wxT("WinEDA_SetOptionsFrame: Grid value not handle"));
				break;
		}
	}
	
	/* Adjust the current selections and options: */
	m_ShowGridOpt->SetValue(m_Parent->m_Draw_Grid);
	m_AutoPANOpt->SetValue(m_Parent->DrawPanel-> m_AutoPAN_Enable);
	m_SelShowPins->SetSelection( g_ShowAllPins ? TRUE : FALSE);
	m_Selunits->SetSelection( g_UnitMetric ? 0 : 1);
	m_SelDirWires->SetSelection( g_HVLines ? 0 : 1);
	m_Show_Page_Limits->SetSelection( g_ShowPageLimits ? 0 : 1);
wxString msg;
	msg = ReturnStringFromValue( g_UnitMetric,g_RepeatStep.x, m_Parent->m_InternalUnits);
	m_DeltaStepCtrl_X->SetValue( msg );
wxString title = _("Delta Step X") + ReturnUnitSymbol(g_UnitMetric);
    m_DeltaStepXTitle->SetLabel( title );

	msg = ReturnStringFromValue( g_UnitMetric,g_RepeatStep.y, m_Parent->m_InternalUnits);
	m_DeltaStepCtrl_Y->SetValue( msg );
	title = _("Delta Step Y") + ReturnUnitSymbol(g_UnitMetric);
    m_DeltaStepYTitle->SetLabel( title );

	m_DeltaLabelCtrl->SetValue( g_RepeatDeltaLabel );
	
}

/*!
 * WinEDA_SetOptionsFrame creator
 */

bool WinEDA_SetOptionsFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin WinEDA_SetOptionsFrame member initialisation
    m_DrawOptionsSizer = NULL;
    m_ShowGridOpt = NULL;
    m_SelGridSize = NULL;
    m_SelShowPins = NULL;
    m_AutoPANOpt = NULL;
    m_Selunits = NULL;
    m_LabelSizeCtrlSizer = NULL;
    m_SelDirWires = NULL;
    m_Show_Page_Limits = NULL;
    m_DeltaStepXTitle = NULL;
    m_DeltaStepCtrl_X = NULL;
    m_DeltaStepYTitle = NULL;
    m_DeltaStepCtrl_Y = NULL;
    m_DeltaIncTitle = NULL;
    m_DeltaLabelCtrl = NULL;
////@end WinEDA_SetOptionsFrame member initialisation

////@begin WinEDA_SetOptionsFrame creation
    SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
    wxDialog::Create( parent, id, caption, pos, size, style );

    CreateControls();
    if (GetSizer())
    {
        GetSizer()->SetSizeHints(this);
    }
    Centre();
////@end WinEDA_SetOptionsFrame creation
    return true;
}

/*!
 * Control creation for WinEDA_SetOptionsFrame
 */

void WinEDA_SetOptionsFrame::CreateControls()
{    
	SetFont(*g_DialogFont);
////@begin WinEDA_SetOptionsFrame content construction
    // Generated by DialogBlocks, 23/02/2007 10:59:46 (unregistered)

    WinEDA_SetOptionsFrame* itemDialog1 = this;

    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
    itemDialog1->SetSizer(itemBoxSizer2);

    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxStaticBox* itemStaticBoxSizer4Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Draw Options:"));
    m_DrawOptionsSizer = new wxStaticBoxSizer(itemStaticBoxSizer4Static, wxVERTICAL);
    itemBoxSizer3->Add(m_DrawOptionsSizer, 0, wxGROW|wxALL, 5);

    m_ShowGridOpt = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Show grid"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_ShowGridOpt->SetValue(false);
    m_DrawOptionsSizer->Add(m_ShowGridOpt, 0, wxALIGN_LEFT|wxALL, 5);

    wxString m_SelGridSizeStrings[] = {
        _("Normal (50 mils)"),
        _("Small (25 mils)"),
        _("Very small (10 mils)"),
        _("Special (5 mils)"),
        _("Special (2 mils)"),
        _("Special (1 mil)")
    };
    m_SelGridSize = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Grid Size"), wxDefaultPosition, wxDefaultSize, 6, m_SelGridSizeStrings, 1, wxRA_SPECIFY_COLS );
    m_SelGridSize->SetSelection(0);
    itemBoxSizer3->Add(m_SelGridSize, 0, wxGROW|wxALL, 5);

    wxString m_SelShowPinsStrings[] = {
        _("Normal"),
        _("Show alls")
    };
    m_SelShowPins = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Show pins"), wxDefaultPosition, wxDefaultSize, 2, m_SelShowPinsStrings, 1, wxRA_SPECIFY_COLS );
    m_SelShowPins->SetSelection(0);
    itemBoxSizer3->Add(m_SelShowPins, 0, wxGROW|wxALL, 5);

    wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    m_AutoPANOpt = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Auto PAN"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_AutoPANOpt->SetValue(false);
    m_AutoPANOpt->SetForegroundColour(wxColour(0, 0, 255));
    itemBoxSizer8->Add(m_AutoPANOpt, 0, wxGROW|wxALL, 5);

    wxString m_SelunitsStrings[] = {
        _("millimeter"),
        _("inches")
    };
    m_Selunits = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Units"), wxDefaultPosition, wxDefaultSize, 2, m_SelunitsStrings, 1, wxRA_SPECIFY_COLS );
    m_Selunits->SetSelection(0);
    itemBoxSizer8->Add(m_Selunits, 0, wxGROW|wxALL, 5);

    m_LabelSizeCtrlSizer = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer8->Add(m_LabelSizeCtrlSizer, 0, wxGROW|wxALL, 5);

    wxString m_SelDirWiresStrings[] = {
        _("Horiz/Vertical"),
        _("Any")
    };
    m_SelDirWires = new wxRadioBox( itemDialog1, ID_RADIOBOX3, _("Wires - Bus orient"), wxDefaultPosition, wxDefaultSize, 2, m_SelDirWiresStrings, 1, wxRA_SPECIFY_COLS );
    m_SelDirWires->SetSelection(0);
    itemBoxSizer8->Add(m_SelDirWires, 0, wxGROW|wxALL, 5);

    wxString m_Show_Page_LimitsStrings[] = {
        _("Yes"),
        _("No")
    };
    m_Show_Page_Limits = new wxRadioBox( itemDialog1, ID_RADIOBOX4, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 2, m_Show_Page_LimitsStrings, 1, wxRA_SPECIFY_COLS );
    m_Show_Page_Limits->SetSelection(0);
    itemBoxSizer8->Add(m_Show_Page_Limits, 0, wxGROW|wxALL, 5);

    wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxButton* itemButton15 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton15->SetForegroundColour(wxColour(202, 0, 0));
    itemBoxSizer14->Add(itemButton15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton16->SetForegroundColour(wxColour(0, 0, 255));
    itemBoxSizer14->Add(itemButton16, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    itemBoxSizer14->Add(5, 5, 0, wxGROW|wxALL, 5);

    wxStaticBox* itemStaticBoxSizer18Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Auto increment params"));
    wxStaticBoxSizer* itemStaticBoxSizer18 = new wxStaticBoxSizer(itemStaticBoxSizer18Static, wxVERTICAL);
    itemBoxSizer14->Add(itemStaticBoxSizer18, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    m_DeltaStepXTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Delta Step X"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer18->Add(m_DeltaStepXTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_DeltaStepCtrl_X = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer18->Add(m_DeltaStepCtrl_X, 0, wxGROW|wxALL, 5);

    m_DeltaStepYTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Delta Step Y"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer18->Add(m_DeltaStepYTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_DeltaStepCtrl_Y = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer18->Add(m_DeltaStepCtrl_Y, 0, wxGROW|wxALL, 5);

    m_DeltaIncTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Delta Label:"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer18->Add(m_DeltaIncTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_DeltaLabelCtrl = new wxSpinCtrl( itemDialog1, ID_SPINCTRL, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -16, 16, 0 );
    itemStaticBoxSizer18->Add(m_DeltaLabelCtrl, 0, wxGROW|wxALL, 5);

////@end WinEDA_SetOptionsFrame content construction

	m_DefaultDrawLineWidthCtrl = new WinEDA_ValueCtrl(this, _("Default Line Width"),g_DrawMinimunLineWidth,
			g_UnitMetric, m_DrawOptionsSizer, EESCHEMA_INTERNAL_UNIT);

	m_DefaultLabelSizeCtrl = new WinEDA_ValueCtrl(this, _("Default Label Size"),g_DefaultTextLabelSize,
			g_UnitMetric, m_LabelSizeCtrlSizer, EESCHEMA_INTERNAL_UNIT);

}

/*!
 * Should we show tooltips?
 */

bool WinEDA_SetOptionsFrame::ShowToolTips()
{
    return true;
}

/*!
 * Get bitmap resources
 */

wxBitmap WinEDA_SetOptionsFrame::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin WinEDA_SetOptionsFrame bitmap retrieval
    wxUnusedVar(name);
    return wxNullBitmap;
////@end WinEDA_SetOptionsFrame bitmap retrieval
}

/*!
 * Get icon resources
 */

wxIcon WinEDA_SetOptionsFrame::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin WinEDA_SetOptionsFrame icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end WinEDA_SetOptionsFrame icon retrieval
}
/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
 */

void WinEDA_SetOptionsFrame::OnOkClick( wxCommandEvent& event )
{
	Accept(event);
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_SetOptionsFrame.
    // Before editing this code, remove the block markers.
    event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK in WinEDA_SetOptionsFrame. 
}


/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
 */

void WinEDA_SetOptionsFrame::OnCancelClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_SetOptionsFrame.
    // Before editing this code, remove the block markers.
    event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_SetOptionsFrame. 
}


/**************************************************************************/
void WinEDA_SetOptionsFrame::Accept(wxCommandEvent& event)
/**************************************************************************/
{
wxSize grid;
bool setgrid = TRUE;
wxString msg;
	
	g_DrawMinimunLineWidth = m_DefaultDrawLineWidthCtrl->GetValue();
	if ( g_DrawMinimunLineWidth < 0 ) g_DrawMinimunLineWidth = 0;
	if ( g_DrawMinimunLineWidth > 100 ) g_DrawMinimunLineWidth = 100;
		
	g_DefaultTextLabelSize = m_DefaultLabelSizeCtrl->GetValue();
	if ( g_DefaultTextLabelSize < 0 ) g_DefaultTextLabelSize = 0;
	if ( g_DefaultTextLabelSize > 1000 ) g_DefaultTextLabelSize = 1000;

	msg = m_DeltaStepCtrl_X->GetValue();
	g_RepeatStep.x = 
		ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits);
	msg = m_DeltaStepCtrl_Y->GetValue();
	g_RepeatStep.y =
		ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits);

	g_RepeatDeltaLabel = m_DeltaLabelCtrl->GetValue();

	if ( m_Show_Page_Limits->GetSelection() == 0 ) g_ShowPageLimits = TRUE;
	else g_ShowPageLimits = FALSE;

	if ( m_SelDirWires->GetSelection() == 0 ) g_HVLines = 1;
	else g_HVLines = 0;

	if ( m_Selunits->GetSelection() == 0 ) g_UnitMetric = 1;
	else  g_UnitMetric = 0;

	if ( m_SelShowPins->GetSelection() == 0 ) g_ShowAllPins = FALSE;
	else g_ShowAllPins = TRUE;

	g_ShowGrid = m_Parent->m_Draw_Grid = m_ShowGridOpt->GetValue();
	m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue();

	m_Parent->m_Draw_Grid = m_ShowGridOpt->GetValue();
	switch( m_SelGridSize->GetSelection() )
		{
		default:
			setgrid = FALSE;
			break;
		
		case 0:
			grid = wxSize(50,50);
			break;
		case 1:
			grid = wxSize(25,25);
			break;

		case 2:
			grid = wxSize(10,10);
			break;
		}

	if ( m_Parent->m_CurrentScreen )
	{
		if ( setgrid ) m_Parent->m_CurrentScreen->SetGrid(grid);
		m_Parent->m_CurrentScreen->SetRefreshReq();
	}
}