A few cosmetic enhancements in dialog_edit_line_style

This commit is contained in:
jean-pierre charras 2017-11-15 20:28:17 +01:00
parent f68d829f54
commit df6d005fd3
5 changed files with 741 additions and 702 deletions

View File

@ -26,41 +26,37 @@
#include <widgets/color4Dpickerdlg.h>
#include <dialog_edit_line_style.h>
const int BUTT_SIZE_X = 32;
const int BUTT_SIZE_Y = 16;
const int BUTT_COLOR_MINSIZE_X = 32;
const int BUTT_COLOR_MINSIZE_Y = 20;
DIALOG_EDIT_LINE_STYLE::DIALOG_EDIT_LINE_STYLE( wxWindow* parent ) :
DIALOG_EDIT_LINE_STYLE_BASE( parent )
{
m_sdbSizer1Apply->SetLabel( _( "Default" ) );
m_sdbSizerApply->SetLabel( _( "Default" ) );
m_lineStyle->SetSelection( 0 );
m_lineWidth->SetFocus();
defaultStyle = 0;
defaultWidth = "";
m_defaultStyle = 0;
wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
wxBitmap bitmap( std::max( m_colorButton->GetSize().x, BUTT_COLOR_MINSIZE_X ),
std::max( m_colorButton->GetSize().y, BUTT_COLOR_MINSIZE_Y ) );
m_colorButton->SetBitmap( bitmap );
m_sdbSizer1OK->SetDefault();
m_sdbSizerOK->SetDefault();
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
// On some windows manager (Unity, XFCE), this dialog is
// not always raised, depending on this dialog is run.
// Force it to be raised
Raise();
}
void DIALOG_EDIT_LINE_STYLE::onColorButtonClicked( wxCommandEvent& event )
{
COLOR4D newColor = COLOR4D::UNSPECIFIED;
COLOR4D_PICKER_DLG dialog( this, selectedColor, false );
COLOR4D_PICKER_DLG dialog( this, m_selectedColor, false );
if( dialog.ShowModal() == wxID_OK )
newColor = dialog.GetColor();
if( newColor == COLOR4D::UNSPECIFIED || selectedColor == newColor )
if( newColor == COLOR4D::UNSPECIFIED || m_selectedColor == newColor )
return;
SetColor( newColor, true );
@ -75,12 +71,12 @@ void DIALOG_EDIT_LINE_STYLE::updateColorButton( COLOR4D& aColor )
iconDC.SelectObject( bitmap );
iconDC.SetPen( *wxBLACK_PEN );
wxBrush brush;
brush.SetColour( aColor.ToColour() );
brush.SetStyle( wxBRUSHSTYLE_SOLID );
wxBrush brush( aColor.ToColour() );
iconDC.SetBrush( brush );
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
// Paint the full bitmap in aColor:
iconDC.SetBackground( brush );
iconDC.Clear();
m_colorButton->SetBitmapLabel( bitmap );
m_colorButton->Refresh();
@ -91,41 +87,31 @@ void DIALOG_EDIT_LINE_STYLE::updateColorButton( COLOR4D& aColor )
void DIALOG_EDIT_LINE_STYLE::resetDefaults( wxCommandEvent& event )
{
SetStyle( defaultStyle );
SetWidth( defaultWidth );
SetColor( defaultColor, true );
SetStyle( m_defaultStyle );
SetWidth( m_defaultWidth );
SetColor( m_defaultColor, true );
Refresh();
}
void DIALOG_EDIT_LINE_STYLE::SetColor( const COLOR4D& aColor, bool aRefresh )
{
assert( aColor.r >= 0.0 && aColor.r <= 1.0 );
assert( aColor.g >= 0.0 && aColor.g <= 1.0 );
assert( aColor.b >= 0.0 && aColor.b <= 1.0 );
assert( aColor.a >= 0.0 && aColor.a <= 1.0 );
selectedColor = aColor;
m_selectedColor = aColor;
if( aRefresh )
updateColorButton( selectedColor );
updateColorButton( m_selectedColor );
}
void DIALOG_EDIT_LINE_STYLE::SetDefaultColor( const COLOR4D& aColor )
{
assert( aColor.r >= 0.0 && aColor.r <= 1.0 );
assert( aColor.g >= 0.0 && aColor.g <= 1.0 );
assert( aColor.b >= 0.0 && aColor.b <= 1.0 );
assert( aColor.a >= 0.0 && aColor.a <= 1.0 );
defaultColor = aColor;
m_defaultColor = aColor;
}
void DIALOG_EDIT_LINE_STYLE::SetStyle( const int aStyle )
{
assert( aStyle >= 0 && aStyle < 4 );
wxASSERT( aStyle >= 0 && aStyle < 4 );
m_lineStyle->SetSelection( aStyle );
}

View File

@ -27,8 +27,8 @@
/**
* @file
* Subclass of DIALOG_EDIT_LINE_STYLE_BASE, which is generated by wxFormBuilder.
* @file dialog_edit_line_style.h
* @brief Subclass of DIALOG_EDIT_LINE_STYLE_BASE, which is generated by wxFormBuilder.
*/
#include <dialog_edit_line_style_base.h>
@ -42,15 +42,15 @@ public:
DIALOG_EDIT_LINE_STYLE( wxWindow* parent );
void SetWidth( const wxString& aWidth ) { m_lineWidth->SetValue( aWidth ); }
void SetDefaultWidth( const wxString& aWidth ) { defaultWidth = aWidth; }
void SetDefaultWidth( const wxString& aWidth ) { m_defaultWidth = aWidth; }
wxString GetWidth() const { return m_lineWidth->GetValue(); }
COLOR4D GetColor() const { return selectedColor; }
COLOR4D GetColor() const { return m_selectedColor; }
void SetColor( const COLOR4D& aColor, bool aRefresh );
void SetDefaultColor( const COLOR4D& aColor );
void SetStyle( const int aStyle );
void SetDefaultStyle( const int aStyle ) { defaultStyle = aStyle; }
void SetDefaultStyle( const int aStyle ) { m_defaultStyle = aStyle; }
int GetStyle();
void SetLineWidthUnits(const wxString& aUnits)
@ -59,10 +59,10 @@ public:
}
private:
int defaultStyle;
wxString defaultWidth;
COLOR4D defaultColor;
COLOR4D selectedColor;
int m_defaultStyle;
wxString m_defaultWidth;
COLOR4D m_defaultColor;
COLOR4D m_selectedColor;
void resetDefaults( wxCommandEvent& event ) override;
void onColorButtonClicked( wxCommandEvent& aEvent ) override;

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 30 2017)
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_edit_line_style_base.h"
@ -19,78 +19,71 @@ DIALOG_EDIT_LINE_STYLE_BASE::DIALOG_EDIT_LINE_STYLE_BASE( wxWindow* parent, wxWi
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxHORIZONTAL );
mainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* dlgBorderSizer;
dlgBorderSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerUpper;
bSizerUpper = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* sbSizerGeneral;
sbSizerGeneral = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General") ), wxVERTICAL );
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General") ), wxVERTICAL );
wxFlexGridSizer* fgSizerGeneral;
fgSizerGeneral = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizerGeneral->AddGrowableCol( 1 );
fgSizerGeneral->SetFlexibleDirection( wxBOTH );
fgSizerGeneral->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxBoxSizer* bSizer31;
bSizer31 = new wxBoxSizer( wxHORIZONTAL );
m_staticTextWidth = new wxStaticText( sbSizerGeneral->GetStaticBox(), wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextWidth->Wrap( -1 );
fgSizerGeneral->Add( m_staticTextWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_staticWidth1 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticWidth1->Wrap( -1 );
bSizer31->Add( m_staticWidth1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_lineWidth = new wxTextCtrl( sbSizerGeneral->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );
m_lineWidth->SetMinSize( wxSize( 80,-1 ) );
m_lineWidth = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 2,-1 ), 0 );
bSizer31->Add( m_lineWidth, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
fgSizerGeneral->Add( m_lineWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_staticWidthUnits = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("millimeter"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticWidthUnits = new wxStaticText( sbSizerGeneral->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticWidthUnits->Wrap( -1 );
bSizer31->Add( m_staticWidthUnits, 1, wxALIGN_CENTER_VERTICAL|wxALL, 1 );
fgSizerGeneral->Add( m_staticWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1 );
sbSizer1->Add( bSizer31, 4, wxALL|wxEXPAND, 1 );
wxBoxSizer* bColorSizer;
bColorSizer = new wxBoxSizer( wxHORIZONTAL );
m_staticText5 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("C&olor:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5 = new wxStaticText( sbSizerGeneral->GetStaticBox(), wxID_ANY, _("Color:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5->Wrap( -1 );
bColorSizer->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
fgSizerGeneral->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_colorButton = new wxBitmapButton( sbSizer1->GetStaticBox(), idColorBtn, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
bColorSizer->Add( m_colorButton, 1, wxALL, 5 );
m_colorButton = new wxBitmapButton( sbSizerGeneral->GetStaticBox(), idColorBtn, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
fgSizerGeneral->Add( m_colorButton, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
bColorSizer->Add( 0, 0, 1, 0, 1 );
sbSizerGeneral->Add( fgSizerGeneral, 3, wxEXPAND, 5 );
sbSizer1->Add( bColorSizer, 3, wxEXPAND|wxALL, 1 );
bSizer7->Add( sbSizer1, 2, wxALL, 5 );
bSizerUpper->Add( sbSizerGeneral, 3, wxALL|wxEXPAND, 5 );
wxString m_lineStyleChoices[] = { _("Solid"), _("Dashed"), _("Dotted"), _("Dash-Dot") };
int m_lineStyleNChoices = sizeof( m_lineStyleChoices ) / sizeof( wxString );
m_lineStyle = new wxRadioBox( this, wxID_ANY, _("&Pen Style"), wxDefaultPosition, wxDefaultSize, m_lineStyleNChoices, m_lineStyleChoices, 4, wxRA_SPECIFY_ROWS );
m_lineStyle->SetSelection( 0 );
bSizer7->Add( m_lineStyle, 1, wxALL, 5 );
m_lineStyle = new wxRadioBox( this, wxID_ANY, _("Line Style"), wxDefaultPosition, wxDefaultSize, m_lineStyleNChoices, m_lineStyleChoices, 4, wxRA_SPECIFY_ROWS );
m_lineStyle->SetSelection( 1 );
bSizerUpper->Add( m_lineStyle, 2, wxALL|wxEXPAND, 5 );
dlgBorderSizer->Add( bSizer7, 0, wxEXPAND, 5 );
mainSizer->Add( bSizerUpper, 0, wxEXPAND, 5 );
dlgBorderSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 1 );
mainSizer->Add( 0, 0, 1, wxALL|wxEXPAND, 1 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Apply = new wxButton( this, wxID_APPLY );
m_sdbSizer1->AddButton( m_sdbSizer1Apply );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
mainSizer->Add( m_staticline, 0, wxEXPAND | wxALL, 5 );
dlgBorderSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerApply = new wxButton( this, wxID_APPLY );
m_sdbSizer->AddButton( m_sdbSizerApply );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
mainSizer->Add( dlgBorderSizer, 1, wxALL|wxEXPAND, 12 );
mainSizer->Add( m_sdbSizer, 0, wxALL|wxALIGN_RIGHT, 5 );
this->SetSizer( mainSizer );

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 30 2017)
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EDIT_LINE_STYLE_BASE_H__
@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
@ -19,14 +21,15 @@
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -50,16 +53,17 @@ class DIALOG_EDIT_LINE_STYLE_BASE : public DIALOG_SHIM
idColorBtn = 1000
};
wxStaticText* m_staticWidth1;
wxStaticText* m_staticTextWidth;
wxTextCtrl* m_lineWidth;
wxStaticText* m_staticWidthUnits;
wxStaticText* m_staticText5;
wxBitmapButton* m_colorButton;
wxRadioBox* m_lineStyle;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Apply;
wxButton* m_sdbSizer1Cancel;
wxStaticLine* m_staticline;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerApply;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void onColorButtonClicked( wxCommandEvent& event ) { event.Skip(); }
@ -69,7 +73,7 @@ class DIALOG_EDIT_LINE_STYLE_BASE : public DIALOG_SHIM
public:
bool m_isValid;
DIALOG_EDIT_LINE_STYLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Line Style"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 410,230 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_EDIT_LINE_STYLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Line Style"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 417,204 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EDIT_LINE_STYLE_BASE();
};