add more public API functions to LAYER_WIDGET
This commit is contained in:
parent
cf7ad0f503
commit
07c35ed356
|
@ -301,9 +301,34 @@ int LAYER_WIDGET::findLayerRow( int aLayer )
|
|||
for( int row=0; row<count; ++row )
|
||||
{
|
||||
// column 0 in the layer scroll window has a wxStaticBitmap, get its ID.
|
||||
wxStaticBitmap* bm = (wxStaticBitmap*) getLayerComp( row * LYR_COLUMN_COUNT );
|
||||
wxWindow* w = getLayerComp( row * LYR_COLUMN_COUNT );
|
||||
wxASSERT( w );
|
||||
|
||||
if( aLayer == getDecodedId( bm->GetId() ))
|
||||
if( aLayer == getDecodedId( w->GetId() ))
|
||||
return row;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
wxWindow* LAYER_WIDGET::getRenderComp( int aSizerNdx )
|
||||
{
|
||||
if( (unsigned) aSizerNdx < m_RenderFlexGridSizer->GetChildren().GetCount() )
|
||||
return m_RenderFlexGridSizer->GetChildren()[aSizerNdx]->GetWindow();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int LAYER_WIDGET::findRenderRow( int aId )
|
||||
{
|
||||
int count = GetRenderRowCount();
|
||||
for( int row=0; row<count; ++row )
|
||||
{
|
||||
// column 0 in the layer scroll window has a wxStaticBitmap, get its ID.
|
||||
wxWindow* w = getRenderComp( row * RND_COLUMN_COUNT );
|
||||
wxASSERT( w );
|
||||
|
||||
if( aId == getDecodedId( w->GetId() ))
|
||||
return row;
|
||||
}
|
||||
return -1;
|
||||
|
@ -675,6 +700,82 @@ void LAYER_WIDGET::SetLayerVisible( int aLayer, bool isVisible )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool LAYER_WIDGET::IsLayerVisible( int aLayer )
|
||||
{
|
||||
int row = findLayerRow( aLayer );
|
||||
if( row >= 0 )
|
||||
{
|
||||
wxCheckBox* cb = (wxCheckBox*) getLayerComp( row * LYR_COLUMN_COUNT + 3 );
|
||||
wxASSERT( cb );
|
||||
return cb->GetValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void LAYER_WIDGET::SetLayerColor( int aLayer, int aColor )
|
||||
{
|
||||
int row = findLayerRow( aLayer );
|
||||
if( row >= 0 )
|
||||
{
|
||||
int col = 1; // bitmap button is column 1
|
||||
wxBitmapButton* bmb = (wxBitmapButton*) getLayerComp( row * LYR_COLUMN_COUNT + col );
|
||||
wxASSERT( bmb );
|
||||
|
||||
wxBitmap bm = makeBitmap( aColor );
|
||||
|
||||
bmb->SetBitmapLabel( bm );
|
||||
bmb->SetName( makeColorTxt( aColor ) ); // save color value in name as string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int LAYER_WIDGET::GetLayerColor( int aLayer )
|
||||
{
|
||||
int row = findLayerRow( aLayer );
|
||||
if( row >= 0 )
|
||||
{
|
||||
int col = 1; // bitmap button is column 1
|
||||
wxBitmapButton* bmb = (wxBitmapButton*) getLayerComp( row * LYR_COLUMN_COUNT + col );
|
||||
wxASSERT( bmb );
|
||||
|
||||
wxString colorTxt = bmb->GetName();
|
||||
int color = strtoul( CONV_TO_UTF8(colorTxt), NULL, 0 );
|
||||
return color;
|
||||
}
|
||||
|
||||
return 0; // it's caller fault, gave me a bad layer
|
||||
}
|
||||
|
||||
|
||||
void LAYER_WIDGET::SetRenderState( int aId, bool isSet )
|
||||
{
|
||||
int row = findRenderRow( aId );
|
||||
if( row >= 0 )
|
||||
{
|
||||
int col = 1; // checkbox is column 1
|
||||
wxCheckBox* cb = (wxCheckBox*) getRenderComp( row * RND_COLUMN_COUNT + col );
|
||||
wxASSERT( cb );
|
||||
cb->SetValue( isSet ); // does not fire an event
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool LAYER_WIDGET::GetRenderState( int aId )
|
||||
{
|
||||
int row = findRenderRow( aId );
|
||||
if( row >= 0 )
|
||||
{
|
||||
int col = 1; // checkbox is column 1
|
||||
wxCheckBox* cb = (wxCheckBox*) getRenderComp( row * RND_COLUMN_COUNT + col );
|
||||
wxASSERT( cb );
|
||||
return cb->GetValue();
|
||||
}
|
||||
return false; // the value of a non-existent row
|
||||
}
|
||||
|
||||
|
||||
void LAYER_WIDGET::UpdateLayouts()
|
||||
{
|
||||
m_LayersFlexGridSizer->Layout();
|
||||
|
|
|
@ -162,12 +162,14 @@ protected:
|
|||
* been added to the m_LayersFlexGridSizer.
|
||||
*/
|
||||
wxWindow* getLayerComp( int aSizerNdx );
|
||||
wxWindow* getRenderComp( int aSizerNdx );
|
||||
|
||||
/**
|
||||
* Function findLayerRow
|
||||
* returns the row index that \a aLayer resides in, or -1 if not found.
|
||||
*/
|
||||
int findLayerRow( int aLayer );
|
||||
int findRenderRow( int aId );
|
||||
|
||||
/**
|
||||
* Function insertLayerRow
|
||||
|
@ -288,6 +290,42 @@ public:
|
|||
*/
|
||||
void SetLayerVisible( int aLayer, bool isVisible );
|
||||
|
||||
/**
|
||||
* Function IsLayerVisible
|
||||
* returns the visible state of the layer ROW associated with \a aLayer id.
|
||||
*/
|
||||
bool IsLayerVisible( int aLayer );
|
||||
|
||||
/**
|
||||
* Function SetLayerColor
|
||||
* changes the color of \a aLayer
|
||||
*/
|
||||
void SetLayerColor( int aLayer, int aColor );
|
||||
|
||||
/**
|
||||
* Function GetLayerColor
|
||||
* returns the color of the layer ROW associated with \a aLayer id.
|
||||
*/
|
||||
int GetLayerColor( int aLayer );
|
||||
|
||||
/**
|
||||
* Function SetRenderState
|
||||
* sets the state of the checkbox associated with \a aId within the
|
||||
* Render tab group of the widget. Does not fire an event, i.e. does
|
||||
* not invoke OnRenderEnable().
|
||||
* @param aId is the same unique id used when adding a ROW to the
|
||||
* Render tab.
|
||||
*/
|
||||
void SetRenderState( int aId, bool isSet );
|
||||
|
||||
/**
|
||||
* Function GetRenderState
|
||||
* returns the state of the checkbox associated with \a aId.
|
||||
* @return bool - true if checked, else false.
|
||||
*/
|
||||
bool GetRenderState( int aId );
|
||||
|
||||
|
||||
void UpdateLayouts();
|
||||
|
||||
/* did not help:
|
||||
|
|
Loading…
Reference in New Issue