Code cleaning and coding style fix.
This commit is contained in:
parent
5d6f8d1edc
commit
c1f0ab91a2
|
@ -438,8 +438,9 @@ void PAGE_LAYOUT_READER_PARSER::readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem )
|
||||||
tmp += "EndData";
|
tmp += "EndData";
|
||||||
|
|
||||||
wxString msg;
|
wxString msg;
|
||||||
STRING_LINE_READER reader( tmp, wxT("Png kicad_wks data") );
|
STRING_LINE_READER str_reader( tmp, wxT("Png kicad_wks data") );
|
||||||
if( ! aItem->m_ImageBitmap->LoadData( reader, msg ) )
|
|
||||||
|
if( ! aItem->m_ImageBitmap->LoadData( str_reader, msg ) )
|
||||||
{
|
{
|
||||||
wxLogMessage(msg);
|
wxLogMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,146 +34,84 @@
|
||||||
|
|
||||||
|
|
||||||
enum colors_id {
|
enum colors_id {
|
||||||
ID_COLOR_BLACK = 2000 // ID_COLOR_ = ID_COLOR_BLACK a ID_COLOR_BLACK + 31
|
ID_COLOR_BLACK = 2000 // colors_id = ID_COLOR_BLACK a ID_COLOR_BLACK + NBCOLORS-1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class WinEDA_SelColorFrame : public wxDialog
|
class CHOOSE_COLOR_DLG : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WinEDA_SelColorFrame( wxWindow* parent,
|
CHOOSE_COLOR_DLG( wxWindow* aParent, EDA_COLOR_T aOldColor );
|
||||||
const wxPoint& framepos, int OldColor );
|
~CHOOSE_COLOR_DLG() {};
|
||||||
~WinEDA_SelColorFrame() {};
|
|
||||||
|
EDA_COLOR_T GetSelectedColor() { return m_color; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init_Dialog( int aOldColor );
|
void init_Dialog();
|
||||||
void OnCancel( wxCommandEvent& event );
|
void selColor( wxCommandEvent& event );
|
||||||
void SelColor( wxCommandEvent& event );
|
|
||||||
|
EDA_COLOR_T m_color;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE( WinEDA_SelColorFrame, wxDialog )
|
BEGIN_EVENT_TABLE( CHOOSE_COLOR_DLG, wxDialog )
|
||||||
EVT_BUTTON( wxID_CANCEL, WinEDA_SelColorFrame::OnCancel )
|
EVT_COMMAND_RANGE( ID_COLOR_BLACK, ID_COLOR_BLACK + NBCOLORS,
|
||||||
EVT_COMMAND_RANGE( ID_COLOR_BLACK, ID_COLOR_BLACK + 31,
|
|
||||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||||
WinEDA_SelColorFrame::SelColor )
|
CHOOSE_COLOR_DLG::selColor )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
EDA_COLOR_T DisplayColorFrame( wxWindow* parent, int OldColor )
|
EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor )
|
||||||
{
|
{
|
||||||
wxPoint framepos;
|
CHOOSE_COLOR_DLG dlg( aParent, aOldColor );
|
||||||
EDA_COLOR_T color;
|
|
||||||
|
|
||||||
wxGetMousePosition( &framepos.x, &framepos.y );
|
if( dlg.ShowModal() == wxID_OK )
|
||||||
|
{
|
||||||
|
return dlg.GetSelectedColor();
|
||||||
|
}
|
||||||
|
|
||||||
WinEDA_SelColorFrame* frame = new WinEDA_SelColorFrame( parent,
|
return UNSPECIFIED_COLOR;
|
||||||
framepos, OldColor );
|
|
||||||
color = static_cast<EDA_COLOR_T>( frame->ShowModal() );
|
|
||||||
frame->Destroy();
|
|
||||||
if( color > NBCOLORS )
|
|
||||||
color = UNSPECIFIED_COLOR;
|
|
||||||
return color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WinEDA_SelColorFrame::WinEDA_SelColorFrame( wxWindow* parent,
|
CHOOSE_COLOR_DLG::CHOOSE_COLOR_DLG( wxWindow* aParent, EDA_COLOR_T aOldColor ) :
|
||||||
const wxPoint& framepos,
|
wxDialog( aParent, -1, _( "Colors" ), wxDefaultPosition, wxDefaultSize,
|
||||||
int OldColor ) :
|
|
||||||
wxDialog( parent, -1, _( "Colors" ), framepos, wxDefaultSize,
|
|
||||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
|
||||||
{
|
{
|
||||||
|
m_color = aOldColor;
|
||||||
|
|
||||||
Init_Dialog( OldColor );
|
init_Dialog();
|
||||||
// Resize the dialog
|
// Resize the dialog
|
||||||
GetSizer()->SetSizeHints( this );
|
GetSizer()->SetSizeHints( this );
|
||||||
|
|
||||||
// Ensure the whole frame is visible, whenever the asked position.
|
|
||||||
// Moreover with a work station having dual monitors, the asked position can be relative to a monitor
|
|
||||||
// and this frame can be displayed on the other monitor, with an "out of screen" position.
|
|
||||||
// Give also a small margin.
|
|
||||||
int margin = 10;
|
|
||||||
wxPoint windowPosition = GetPosition();
|
|
||||||
if( framepos != wxDefaultPosition )
|
|
||||||
{
|
|
||||||
if( windowPosition.x < margin )
|
|
||||||
windowPosition.x = margin;
|
|
||||||
// Under MACOS, a vertical margin >= 20 is needed by the system menubar
|
|
||||||
int v_margin = std::max(20, margin);
|
|
||||||
if( windowPosition.y < v_margin )
|
|
||||||
windowPosition.y = v_margin;
|
|
||||||
if( windowPosition != framepos )
|
|
||||||
SetPosition(windowPosition);
|
|
||||||
}
|
|
||||||
wxPoint endCornerPosition = GetPosition();
|
|
||||||
endCornerPosition.x += GetSize().x + margin;
|
|
||||||
endCornerPosition.y += GetSize().y + margin;
|
|
||||||
|
|
||||||
windowPosition = GetPosition();
|
|
||||||
wxRect freeScreenArea( wxGetClientDisplayRect( ) );
|
|
||||||
|
|
||||||
if( freeScreenArea.GetRight() < endCornerPosition.x )
|
|
||||||
{
|
|
||||||
windowPosition.x += freeScreenArea.GetRight() - endCornerPosition.x;
|
|
||||||
|
|
||||||
if( windowPosition.x < freeScreenArea.x )
|
|
||||||
windowPosition.x = freeScreenArea.x;
|
|
||||||
|
|
||||||
// Sligly modify the vertical position to avoid the mouse to be
|
|
||||||
// exactly on the upper side of the window
|
|
||||||
windowPosition.y +=5;
|
|
||||||
endCornerPosition.y += 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( freeScreenArea.GetBottom() < endCornerPosition.y )
|
|
||||||
{
|
|
||||||
windowPosition.y += freeScreenArea.GetBottom() - endCornerPosition.y;
|
|
||||||
|
|
||||||
if( windowPosition.y < freeScreenArea.y )
|
|
||||||
windowPosition.y = freeScreenArea.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetPosition(windowPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
|
void CHOOSE_COLOR_DLG::init_Dialog()
|
||||||
{
|
{
|
||||||
wxBoxSizer* OuterBoxSizer = NULL;
|
|
||||||
wxBoxSizer* MainBoxSizer = NULL;
|
|
||||||
wxFlexGridSizer* FlexColumnBoxSizer = NULL;
|
wxFlexGridSizer* FlexColumnBoxSizer = NULL;
|
||||||
wxBitmapButton* BitmapButton = NULL;
|
wxBitmapButton* focusedButton = NULL;
|
||||||
wxStaticText* Label = NULL;
|
const int w = 20, h = 20;
|
||||||
wxStaticLine* Line = NULL;
|
|
||||||
wxStdDialogButtonSizer* StdDialogButtonSizer = NULL;
|
|
||||||
wxButton* Button = NULL;
|
|
||||||
|
|
||||||
int ii, butt_ID;
|
wxBoxSizer* OuterBoxSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
int w = 20, h = 20;
|
|
||||||
bool ColorFound = false;
|
|
||||||
|
|
||||||
SetReturnCode( -1 );
|
|
||||||
|
|
||||||
OuterBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
||||||
SetSizer( OuterBoxSizer );
|
SetSizer( OuterBoxSizer );
|
||||||
|
|
||||||
MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
wxBoxSizer*MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||||
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
||||||
|
|
||||||
for( ii = 0; ii < NBCOLORS; ++ii )
|
for( int ii = 0; ii < NBCOLORS; ++ii )
|
||||||
{
|
{
|
||||||
// Provide a separate column for every six buttons (and their
|
// Provide a separate column for every six buttons (and their
|
||||||
// associated text strings), so provide a FlexGrid Sizer with
|
// associated text strings), so provide a FlexGrid Sizer with
|
||||||
// eight rows and two columns.
|
// six rows and two columns.
|
||||||
if( ii % 6 == 0 )
|
if( ii % 6 == 0 )
|
||||||
{
|
{
|
||||||
FlexColumnBoxSizer = new wxFlexGridSizer( 6, 2, 0, 0 );
|
FlexColumnBoxSizer = new wxFlexGridSizer( 6, 2, 0, 0 );
|
||||||
|
|
||||||
// Specify that all of the rows can be expanded.
|
// Specify that all of the rows can be expanded.
|
||||||
for( int ii = 0; ii < 6; ii++ )
|
for( int kk = 0; kk < 6; kk++ )
|
||||||
{
|
{
|
||||||
FlexColumnBoxSizer->AddGrowableRow( ii );
|
FlexColumnBoxSizer->AddGrowableRow( kk );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specify that the second column can also be expanded.
|
// Specify that the second column can also be expanded.
|
||||||
|
@ -182,7 +120,7 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
|
||||||
MainBoxSizer->Add( FlexColumnBoxSizer, 1, wxGROW | wxTOP, 5 );
|
MainBoxSizer->Add( FlexColumnBoxSizer, 1, wxGROW | wxTOP, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
butt_ID = ID_COLOR_BLACK + ii;
|
int butt_ID = ID_COLOR_BLACK + ii;
|
||||||
wxMemoryDC iconDC;
|
wxMemoryDC iconDC;
|
||||||
wxBitmap ButtBitmap( w, h );
|
wxBitmap ButtBitmap( w, h );
|
||||||
wxBrush brush;
|
wxBrush brush;
|
||||||
|
@ -200,24 +138,21 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
|
||||||
iconDC.Clear();
|
iconDC.Clear();
|
||||||
iconDC.DrawRoundedRectangle( 0, 0, w, h, (double) h / 3 );
|
iconDC.DrawRoundedRectangle( 0, 0, w, h, (double) h / 3 );
|
||||||
|
|
||||||
BitmapButton = new wxBitmapButton( this, butt_ID, ButtBitmap,
|
wxBitmapButton* bitmapButton = new wxBitmapButton( this, butt_ID, ButtBitmap,
|
||||||
wxDefaultPosition, wxSize( w+8, h+6 ) );
|
wxDefaultPosition, wxSize( w+8, h+6 ) );
|
||||||
FlexColumnBoxSizer->Add( BitmapButton, 0,
|
FlexColumnBoxSizer->Add( bitmapButton, 0,
|
||||||
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
||||||
wxLEFT | wxBOTTOM, 5 );
|
wxLEFT | wxBOTTOM, 5 );
|
||||||
|
|
||||||
// Set focus to this button if its color matches the
|
// Set focus to this button if its color matches the
|
||||||
// color which had been selected previously (for
|
// color which had been selected previously (for
|
||||||
// whichever layer's color is currently being edited).
|
// whichever layer's color is currently being edited).
|
||||||
if( aOldColor == buttcolor )
|
if( m_color == buttcolor )
|
||||||
{
|
focusedButton = bitmapButton;
|
||||||
ColorFound = true;
|
|
||||||
BitmapButton->SetFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
Label = new wxStaticText( this, -1, ColorGetName( buttcolor ),
|
wxStaticText* label = new wxStaticText( this, -1, ColorGetName( buttcolor ),
|
||||||
wxDefaultPosition, wxDefaultSize, 0 );
|
wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
FlexColumnBoxSizer->Add( Label, 1,
|
FlexColumnBoxSizer->Add( label, 1,
|
||||||
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
||||||
wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
||||||
}
|
}
|
||||||
|
@ -227,38 +162,35 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
|
||||||
// (and also provide a horizontal static line to separate
|
// (and also provide a horizontal static line to separate
|
||||||
// that button from all of the other buttons).
|
// that button from all of the other buttons).
|
||||||
|
|
||||||
Line = new wxStaticLine( this, -1, wxDefaultPosition,
|
wxStaticLine* sline = new wxStaticLine( this, -1, wxDefaultPosition,
|
||||||
wxDefaultSize, wxLI_HORIZONTAL );
|
wxDefaultSize, wxLI_HORIZONTAL );
|
||||||
OuterBoxSizer->Add( Line, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
OuterBoxSizer->Add( sline, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
||||||
|
|
||||||
StdDialogButtonSizer = new wxStdDialogButtonSizer;
|
wxStdDialogButtonSizer* stdDialogButtonSizer = new wxStdDialogButtonSizer;
|
||||||
OuterBoxSizer->Add( StdDialogButtonSizer, 0, wxGROW | wxALL, 10 );
|
OuterBoxSizer->Add( stdDialogButtonSizer, 0, wxGROW | wxALL, 10 );
|
||||||
|
|
||||||
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition,
|
wxButton* cancelButton = new wxButton( this, wxID_CANCEL, _( "Cancel" ),
|
||||||
wxDefaultSize, 0 );
|
wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
StdDialogButtonSizer->AddButton( Button );
|
stdDialogButtonSizer->AddButton( cancelButton );
|
||||||
|
|
||||||
StdDialogButtonSizer->Realize();
|
stdDialogButtonSizer->Realize();
|
||||||
|
|
||||||
// Set focus to the Cancel button if the currently selected color
|
// Set focus to the Cancel button if the currently selected color
|
||||||
// does not match any of the colors provided by this dialog box.
|
// does not match any of the colors provided by this dialog box.
|
||||||
// (That shouldn't ever happen in practice though.)
|
// (That shouldn't ever happen in practice though.)
|
||||||
if( !ColorFound )
|
if( focusedButton )
|
||||||
Button->SetFocus();
|
focusedButton->SetFocus();
|
||||||
}
|
else
|
||||||
|
cancelButton->SetFocus();
|
||||||
void WinEDA_SelColorFrame::OnCancel( wxCommandEvent& WXUNUSED( event ) )
|
|
||||||
{
|
|
||||||
// Setting the return value to -1 indicates that the
|
|
||||||
// dialog box has been canceled (and thus that the
|
|
||||||
// previously selected color is to be retained).
|
|
||||||
EndModal( -1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WinEDA_SelColorFrame::SelColor( wxCommandEvent& event )
|
void CHOOSE_COLOR_DLG::selColor( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
int id = event.GetId();
|
int id = event.GetId();
|
||||||
|
m_color = EDA_COLOR_T( id - ID_COLOR_BLACK );
|
||||||
|
|
||||||
EndModal( id - ID_COLOR_BLACK );
|
// Close the dialog by calling the default dialog handler for a wxID_OK event
|
||||||
|
event.SetId( wxID_OK );
|
||||||
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,9 +437,9 @@ void WIDGET_HOTKEY_LIST::OnSize( wxSizeEvent& aEvent )
|
||||||
|
|
||||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||||
{
|
{
|
||||||
wxWindow* view = GetView();
|
wxWindow* win_view = GetView();
|
||||||
view->Refresh();
|
win_view->Refresh();
|
||||||
view->Update();
|
win_view->Update();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -429,9 +429,9 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
||||||
sheet->SetName( tmp );
|
sheet->SetName( tmp );
|
||||||
|
|
||||||
sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ), (long) newtimestamp ) );
|
sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ), (long) newtimestamp ) );
|
||||||
SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
|
SCH_SCREEN* new_screen = new SCH_SCREEN( &Kiway() );
|
||||||
screen->SetMaxUndoItems( m_UndoRedoCountMax );
|
new_screen->SetMaxUndoItems( m_UndoRedoCountMax );
|
||||||
sheet->SetScreen( screen );
|
sheet->SetScreen( new_screen );
|
||||||
sheet->GetScreen()->SetFileName( sheet->GetFileName() );
|
sheet->GetScreen()->SetFileName( sheet->GetFileName() );
|
||||||
}
|
}
|
||||||
// clear annotation and init new time stamp for the new components
|
// clear annotation and init new time stamp for the new components
|
||||||
|
@ -447,7 +447,7 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
||||||
bs = nextbs;
|
bs = nextbs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OnModify();
|
OnModify();
|
||||||
|
|
||||||
// redraw base screen (ROOT) if necessary
|
// redraw base screen (ROOT) if necessary
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
|
|
||||||
#include "widget_eeschema_color_config.h"
|
#include "widget_eeschema_color_config.h"
|
||||||
|
|
||||||
|
// See selcolor.cpp:
|
||||||
|
extern EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor );
|
||||||
|
|
||||||
// Specify the width and height of every (color-displaying / bitmap) button
|
// Specify the width and height of every (color-displaying / bitmap) button
|
||||||
const int BUTT_SIZE_X = 16;
|
const int BUTT_SIZE_X = 16;
|
||||||
const int BUTT_SIZE_Y = 16;
|
const int BUTT_SIZE_Y = 16;
|
||||||
|
@ -215,7 +218,7 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::SetColor( wxCommandEvent& event )
|
||||||
|
|
||||||
wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) );
|
wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) );
|
||||||
|
|
||||||
EDA_COLOR_T color = DisplayColorFrame( this, colorButton->m_Layer );
|
EDA_COLOR_T color = DisplayColorFrame( this, currentColors[colorButton->m_Layer] );
|
||||||
|
|
||||||
if( color < 0 || currentColors[ colorButton->m_Layer ] == color )
|
if( color < 0 || currentColors[ colorButton->m_Layer ] == color )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -295,7 +295,6 @@ int ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC,
|
||||||
*/
|
*/
|
||||||
time_t GetNewTimeStamp();
|
time_t GetNewTimeStamp();
|
||||||
|
|
||||||
EDA_COLOR_T DisplayColorFrame( wxWindow* parent, int OldColor );
|
|
||||||
int GetCommandOptions( const int argc, const char** argv,
|
int GetCommandOptions( const int argc, const char** argv,
|
||||||
const char* stringtst, const char** optarg,
|
const char* stringtst, const char** optarg,
|
||||||
int* optind );
|
int* optind );
|
||||||
|
|
|
@ -44,6 +44,9 @@
|
||||||
#define BUTT_SIZE_Y 18
|
#define BUTT_SIZE_Y 18
|
||||||
#define BUTT_VOID 4
|
#define BUTT_VOID 4
|
||||||
|
|
||||||
|
// See selcolor.cpp:
|
||||||
|
extern EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor );
|
||||||
|
|
||||||
const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType();
|
const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType();
|
||||||
|
|
||||||
/* XPM
|
/* XPM
|
||||||
|
|
Loading…
Reference in New Issue