Commit 0e6dd578 authored by dickelbeck's avatar dickelbeck

more layer widget work

parent 465a82a2
......@@ -20,45 +20,33 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi
m_LayerPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_LayerPanel->SetToolTip( _("Layer selection and visibility control") );
wxStaticBoxSizer* sbSizer3;
sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_LayerPanel, wxID_ANY, _("Layers") ), wxVERTICAL );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxVERTICAL );
m_LayerScrolledWindow = new wxScrolledWindow( m_LayerPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL );
m_LayerScrolledWindow->SetScrollRate( 5, 5 );
m_LayersFlexGridSizer = new wxFlexGridSizer( 0, 3, 3, 3 );
m_LayersFlexGridSizer = new wxFlexGridSizer( 0, 4, 3, 3 );
m_LayersFlexGridSizer->SetFlexibleDirection( wxHORIZONTAL );
m_LayersFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_LayerScrolledWindow->SetSizer( m_LayersFlexGridSizer );
m_LayerScrolledWindow->Layout();
m_LayersFlexGridSizer->Fit( m_LayerScrolledWindow );
sbSizer3->Add( m_LayerScrolledWindow, 1, wxEXPAND | wxALL, 5 );
bSizer3->Add( m_LayerScrolledWindow, 1, wxBOTTOM|wxEXPAND|wxTOP, 5 );
m_LayerPanel->SetSizer( sbSizer3 );
m_LayerPanel->SetSizer( bSizer3 );
m_LayerPanel->Layout();
sbSizer3->Fit( m_LayerPanel );
bSizer3->Fit( m_LayerPanel );
m_notebook->AddPage( m_LayerPanel, _("Layers"), true );
m_Page1Panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Page1Panel->SetToolTip( _("Part depiction and visibility") );
wxStaticBoxSizer* sbSizer4;
sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_Page1Panel, wxID_ANY, _("Rendering") ), wxVERTICAL );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
m_scrolledWindow2 = new wxScrolledWindow( m_Page1Panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL );
m_scrolledWindow2->SetScrollRate( 5, 5 );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer2->SetFlexibleDirection( wxBOTH );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_scrolledWindow2->SetSizer( fgSizer2 );
m_scrolledWindow2->Layout();
fgSizer2->Fit( m_scrolledWindow2 );
sbSizer4->Add( m_scrolledWindow2, 1, wxEXPAND | wxALL, 5 );
m_Page1Panel->SetSizer( sbSizer4 );
m_Page1Panel->SetSizer( bSizer4 );
m_Page1Panel->Layout();
sbSizer4->Fit( m_Page1Panel );
bSizer4->Fit( m_Page1Panel );
m_notebook->AddPage( m_Page1Panel, _("Rendering"), false );
boxSizer->Add( m_notebook, 1, wxEXPAND | wxALL, 5 );
......@@ -68,6 +56,7 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi
boxSizer->Fit( this );
// Connect Events
m_LayerScrolledWindow->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDblClickLayers ), NULL, this );
m_LayerScrolledWindow->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDownLayers ), NULL, this );
m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnRightDownLayers ), NULL, this );
}
......@@ -75,6 +64,7 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi
LAYER_PANEL_BASE::~LAYER_PANEL_BASE()
{
// Disconnect Events
m_LayerScrolledWindow->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDblClickLayers ), NULL, this );
m_LayerScrolledWindow->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDownLayers ), NULL, this );
m_LayerScrolledWindow->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnRightDownLayers ), NULL, this );
}
......@@ -17,7 +17,6 @@
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/statbox.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
......@@ -40,9 +39,9 @@ class LAYER_PANEL_BASE : public wxPanel
wxScrolledWindow* m_LayerScrolledWindow;
wxFlexGridSizer* m_LayersFlexGridSizer;
wxPanel* m_Page1Panel;
wxScrolledWindow* m_scrolledWindow2;
// Virtual event handlers, overide them in your derived class
virtual void OnLeftDblClickLayers( wxMouseEvent& event ){ event.Skip(); }
virtual void OnLeftDownLayers( wxMouseEvent& event ){ event.Skip(); }
virtual void OnRightDownLayers( wxMouseEvent& event ){ event.Skip(); }
......
......@@ -38,8 +38,56 @@
#include "layer_panel_base.h"
#include "colors.h"
#include <wx/wx.h>
#include <wx/statbmp.h>
#include <wx/aui/aui.h>
//#include "rightarrow.xpm"
/* XPM */
static const char * clear_xpm[] = {
"32 14 1 1",
" c None",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};
/* XPM */
static const char * rightarrow_xpm[] = {
"32 14 5 1",
" c None",
". c white",
"X c #8080ff",
"o c BLUE",
"O c gray56",
" . .. ",
" .XX ",
" .XXX ",
" .XXXX ",
" ....................XXXXX ",
" .XXXXXXXXXXXXXXXXXXXXXXXX ",
" .XXXXXXXXXXXXXXXXXXXXXXXXX ",
" .oooooooooooooooooooooooooO ",
" .ooooooooooooooooooooooooO ",
" OOOOOOOOOOOOOOOOOoooooO ",
" ooooO ",
" oooO ",
" ooO ",
" oO "};
/**
* Struct LAYER_SPEC
......@@ -70,26 +118,36 @@ class BOARD;
*/
class LAYER_PANEL : public LAYER_PANEL_BASE
{
BOARD* m_Board;
BOARD* m_Board;
wxBitmap* m_BlankBitmap;
wxBitmap* m_RightArrowBitmap;
wxSize m_BitmapSize;
wxStaticBitmap* m_Bitmaps[32];
int m_CurrentRow;
#define LAYER_COLUMN_COUNT 4
#define LAYER_COLUMN_COUNT 3
class MYSTATICTEXT : public wxStaticText
{
public:
MYSTATICTEXT( wxWindow *parent, wxWindowID id, const wxString &label,
MYSTATICTEXT( LAYER_PANEL* aLayerPanel, wxWindowID id, const wxString &label,
const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize,
long style=0, const wxString &name=wxStaticTextNameStr) :
wxStaticText( parent, id, label, pos, size, style, name )
wxStaticText( aLayerPanel->m_LayerScrolledWindow, id, label, pos, size, style, name )
{
//Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnLeftDownLayers ), NULL, parent );
//Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnRightDownLayers ), NULL, parent );
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnLeftDownLayers ), NULL, aLayerPanel );
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnRightDownLayers ), NULL, aLayerPanel );
}
~MYSTATICTEXT()
{
//Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnLeftDownLayers ), NULL, GetParent() );
//Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnRightDownLayers ), NULL, GetParent() );
Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnLeftDownLayers ), NULL, NULL );
Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnRightDownLayers ), NULL, NULL );
}
};
......@@ -113,10 +171,11 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
}
*/
static wxBitmapButton* makeColorButton( int aColorIndex, int aID, wxWindow* aParent )
{
const int BUTT_SIZE_X = 25;
const int BUTT_SIZE_Y = 20;
const int BUTT_SIZE_X = 32;
const int BUTT_SIZE_Y = 22;
// dynamically make a wxBitMap and brush it with the appropriate color,
// then create a wxBitmapButton from it.
......@@ -126,16 +185,18 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
wxMemoryDC iconDC;
iconDC.SelectObject( bitmap );
iconDC.SetPen( *wxBLACK_PEN );
brush.SetColour( MakeColour( aColorIndex ) );
brush.SetStyle( wxSOLID );
iconDC.SetBrush( brush );
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
return new wxBitmapButton( aParent, aID, bitmap,
wxDefaultPosition, wxSize(BUTT_SIZE_X, BUTT_SIZE_Y) );
wxBitmapButton* ret = new wxBitmapButton( aParent, aID, bitmap,
wxDefaultPosition, wxSize(BUTT_SIZE_X, BUTT_SIZE_Y), wxBORDER_RAISED );
return ret;
}
void insertLayerRow( int aRow, const LAYER_SPEC& aSpec )
......@@ -149,19 +210,32 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
flags.Align(wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL);
// column 0
#if 1
m_Bitmaps[aRow] = new wxStaticBitmap( m_LayerScrolledWindow, -1, *m_BlankBitmap,
wxDefaultPosition, m_BitmapSize );
m_LayersFlexGridSizer->Insert( index+0, m_Bitmaps[aRow], wxSizerFlags().Align( wxALIGN_CENTER_VERTICAL ) );
#else
m_LayersFlexGridSizer->Insert( index+0,
makeColorButton( aSpec.colorIndex, 0, m_LayerScrolledWindow ),
flags );
#endif
// column 1
m_LayersFlexGridSizer->Insert( index+1,
new wxCheckBox( m_LayerScrolledWindow, aSpec.checkBoxId, wxEmptyString ),
flags );
wxBitmapButton* bb = makeColorButton( aSpec.colorIndex, 0, m_LayerScrolledWindow );
bb->SetToolTip( _("Double click to change layer color" ) );
m_LayersFlexGridSizer->Insert( index+1, bb, flags );
// column 2
m_LayersFlexGridSizer->Insert( index+2,
new MYSTATICTEXT( m_LayerScrolledWindow, -1, aSpec.layerName ),
wxSizerFlags() );
MYSTATICTEXT* st = new MYSTATICTEXT( this, -1, aSpec.layerName );
st->SetToolTip( _( "Click here to select this layer" ) );
m_LayersFlexGridSizer->Insert( index+2, st,
wxSizerFlags().Align( wxALIGN_CENTER_VERTICAL ) );
// column 3
wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow, aSpec.checkBoxId, wxEmptyString );
cb->SetToolTip( _( "Enable this for visibility" ) );
m_LayersFlexGridSizer->Insert( index+3, cb, flags );
}
......@@ -173,21 +247,70 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
{
printf("OnRightDownLayers\n");
}
void OnLeftDClickLayers( wxMouseEvent& event )
{
printf("OnLeftDblClickLayers\n");
}
/**
* Function getLayerComp
* returns the component within the m_LayersFlexGridSizer at aSizerNdx.
*/
wxWindow* getLayerComp( int aSizerNdx )
{
return m_LayersFlexGridSizer->GetChildren()[aSizerNdx]->GetWindow();
}
public:
/**
* Function GetLayerRowCount
* returns the number of rows in the layer tab.
*/
int GetLayerRowCount()
{
int controlCount = m_LayersFlexGridSizer->GetChildren().GetCount();
return controlCount / LAYER_COLUMN_COUNT;
}
void SelectLayerRow( int aRow )
{
int newNdx = LAYER_COLUMN_COUNT * aRow;
int oldNdx = LAYER_COLUMN_COUNT * m_CurrentRow;
wxStaticBitmap* oldbm = (wxStaticBitmap*) getLayerComp( oldNdx );
wxStaticBitmap* newbm = (wxStaticBitmap*) getLayerComp( newNdx );
oldbm->SetBitmap( *m_BlankBitmap );
newbm->SetBitmap( *m_RightArrowBitmap );
}
/** Constructor */
LAYER_PANEL( wxWindow* parent, BOARD* aBoard ) :
LAYER_PANEL_BASE( parent )
{
m_Board = aBoard;
insertLayerRow( 0, LAYER_SPEC( wxT("layer 1"), RED ) );
m_CurrentRow = 0;
m_RightArrowBitmap = new wxBitmap( rightarrow_xpm );
m_BlankBitmap = new wxBitmap( clear_xpm ); // translucent
m_BitmapSize = wxSize(m_BlankBitmap->GetWidth(), m_BlankBitmap->GetHeight());
insertLayerRow( 0, LAYER_SPEC( wxT("layer 1"), RED ) );
insertLayerRow( 1, LAYER_SPEC( wxT("layer 2"), GREEN ) );
insertLayerRow( 2, LAYER_SPEC( wxT("layer_3_you"), BLUE ) );
insertLayerRow( 3, LAYER_SPEC( wxT("brown_layer"), BROWN ) );
SelectLayerRow( 1 );
}
};
......
......@@ -161,17 +161,14 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Layers</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">sbSizer3</property>
<property name="name">bSizer3</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxTOP</property>
<property name="proportion">1</property>
<object class="wxScrolledWindow" expanded="1">
<property name="bg"></property>
......@@ -201,7 +198,7 @@
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDClick">OnLeftDblClickLayers</event>
<event name="OnLeftDown">OnLeftDownLayers</event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
......@@ -218,7 +215,7 @@
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">3</property>
<property name="cols">4</property>
<property name="flexible_direction">wxHORIZONTAL</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
......@@ -281,77 +278,11 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Rendering</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">sbSizer4</property>
<property name="name">bSizer4</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">1</property>
<object class="wxScrolledWindow" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_scrolledWindow2</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="scroll_rate_x">5</property>
<property name="scroll_rate_y">5</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxVSCROLL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer2</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
</object>
</object>
</object>
</object>
</object>
</object>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment