Commit add4d5eb authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

re-work the LSET(int,...) constructor

parent 0a1665d5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ bool LAYER_SELECTOR::SetLayersHotkeys( bool value )
}


void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_ID aLayer )
void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
{
    wxMemoryDC bmpDC;
    wxBrush    brush;
@@ -120,7 +120,7 @@ void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
    for( LAYER_NUM i = 0; i < elements; ++i )
    {
        wxBitmap layerbmp( 14, 14 );
        SetBitmapLayer( layerbmp, ToLAYER_ID( i ) );
        SetBitmapLayer( layerbmp, i );
    }
}
+27 −11
Original line number Diff line number Diff line
@@ -37,13 +37,22 @@ LSET::LSET( const LAYER_ID* aArray, unsigned aCount )
}


LSET::LSET( size_t aIdCount, ... )
LSET::LSET( unsigned aIdCount, LAYER_ID aFirst, ... )
{
    // The constructor, without the mandatory aFirst argument, could have been confused
    // by the compiler with the LSET( LAYER_ID ).  With aFirst, that ambiguity is not
    // present.  Therefore aIdCount must always be >=1.
    wxASSERT_MSG( aIdCount > 0, wxT( "aIdCount must be >= 1" ) );

    set( aFirst );

    if( --aIdCount )
    {
        va_list ap;

    va_start( ap, aIdCount );
        va_start( ap, aFirst );

    for( size_t i=0;  i<aIdCount;  ++i )
        for( unsigned i=0;  i<aIdCount;  ++i )
        {
            LAYER_ID id = (LAYER_ID) va_arg( ap, int );

@@ -56,6 +65,7 @@ LSET::LSET( size_t aIdCount, ... )

        va_end( ap );
    }
}


const wxChar* LSET::Name( LAYER_ID aLayerId )
@@ -633,4 +643,10 @@ LSEQ LSET::UIOrder() const
    return Seq( order, DIM( order ) );
}

LAYER_ID ToLAYER_ID( int aLayer );

LAYER_ID ToLAYER_ID( int aLayer )
{
    wxASSERT( unsigned( aLayer ) < LAYER_ID_COUNT );
    return LAYER_ID( aLayer );
}
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
            continue;

        // Prepare Bitmap
        SetBitmapLayer( layerbmp, ToLAYER_ID( layerid ) );
        SetBitmapLayer( layerbmp, layerid );

        layername = GetLayerName( layerid );

+3 −3
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public:

protected:
   // Fills the layer bitmap aLayerbmp with the layer color
    void SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_ID aLayer );
    void SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer );
};


+27 −9
Original line number Diff line number Diff line
@@ -149,7 +149,11 @@ typedef std::vector<LAYER_ID> BASE_SEQ;
 * <code>
 *
 *      for( LSEQ cu_stack = aSet.CuStack();  cu_stack;  ++cu_stack )
 *      {
 *          layer_id = *cu_stack;
 *          :
 *          things to do with layer_id;
 *      }
 *
 * </code>
 */
@@ -198,13 +202,24 @@ class LSET : public BASE_SET
{
public:

    // The constructor flavors are carefully chosen to prevent LSET( int ) from compiling.
    // That excludes  "LSET s = 0;" and excludes "LSET s = -1;", etc.
    // LSET s = 0;  needs to be removed from the code, this accomplishes that.
    // Remember LSET( LAYER_ID(0) ) sets bit 0, so "LSET s = 0;" is illegal
    // to prevent that surprize.  Therefore LSET's constructor suite is significantly
    // different than the base class from which it is derived.

    // Other member functions (non-constructor functions) are identical to the base
    // class's and therefore are re-used from the base class.

    /**
     * Constructor LSET()
     * creates an empty (cleared) set.
     */
    LSET() :
        BASE_SET()
    {}
        BASE_SET()  // all bits are set to zero in BASE_SET()
    {
    }

    LSET( const BASE_SET& aOther ) :
        BASE_SET( aOther )
@@ -214,12 +229,11 @@ public:
    /**
     * Constructor LSET( LAYER_ID )
     * takes a LAYER_ID and sets that bit.  This makes the following code into
     * a bug typically:
     * a bug:
     *
     * <code>   LSET s = 0;  </code>
     *
     * since that will call this constructor and set bit zero, probably not what was
     * intended. Use
     * Instead use:
     *
     * <code>
     *    LSET s;
@@ -239,12 +253,16 @@ public:
    LSET( const LAYER_ID* aArray, unsigned aCount );

    /**
     * Constructor LSET( int, ...)
     * takes a variable number of LAYER_IDs in the argument list to construct
     * the set.  Typically used only in static construction.
     * Constructor LSET( unsigned, LAYER_ID, ...)
     * takes one or more LAYER_IDs in the argument list to construct
     * the set.  Typically only used in static construction.
     *
     * @param aIdCount is the number of LAYER_IDs which follow.
     * @param aFirst is the first included in @a aIdCount and must always be present, and can
     *  be followed by any number of additional LAYER_IDs so long as @a aIdCount accurately
     *  reflects the count.
     */
    LSET( size_t aIdCount, ... );
    LSET( unsigned aIdCount, LAYER_ID aFirst, ... );  // args chosen to prevent LSET( int ) from compiling

    /**
     * Function Name
Loading