eelayer.h 8.79 KB
Newer Older
1 2 3 4 5 6 7 8
/*************/
/* eelayer.h */
/*************/

#ifndef _EELAYER_H_
#define _EELAYER_H_

#if defined(__GNUG__) && !defined(__APPLE__)
9
#pragma interface "eelayer.cpp"
10 11 12 13 14 15
#endif

#include "wx/statline.h"

class wxBoxSizer;
class wxStaticLine;
16
class wxStdDialogButtonSizer;
17 18 19


// Specify how many elements are contained within laytool_list[]
20
const int NB_BUTT = 24; // Includes an element associated with the grid
21 22 23 24 25 26 27 28 29 30 31 32 33 34

// Specify how many elements are contained within laytool_index[]
const int BUTTON_GROUPS = 5;

// Specify the numbers associated with assorted controls
enum col_sel_id {
    ID_DIALOG = 1800,
    ID_CHECKBOX_SHOW_GRID,
    ID_RADIOBOX_BACKGROUND_COLOR,
    ID_COLOR_SETUP
};

// #define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER
#define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
35
#define SYMBOL_WINEDA_SETCOLORSFRAME_TITLE _("EESchema Colors")
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#define SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME ID_DIALOG
// #define SYMBOL_WINEDA_SETCOLORSFRAME_SIZE wxSize(400, 300)
// #define SYMBOL_WINEDA_SETCOLORSFRAME_POSITION wxDefaultPosition

#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif

// Specify the width and height of every (color-displaying / bitmap) button
const int BUTT_SIZE_X = 30;
const int BUTT_SIZE_Y = 20;

// Macro utile :
#define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer])


52 53 54
/********************/
/* Layer menu list. */
/********************/
55 56 57 58 59 60 61

struct ColorButton
{
    wxString        m_Name;
    int*            m_Color;
    int             m_Id;
    wxBitmapButton* m_Button;
62
};
63 64 65

struct ButtonIndex
{
66 67
    wxString m_Name;            // Title
    int      m_Index;           // Index to last bitmap button in group
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
};


static ColorButton Layer_Wire_Item =
{
    _( "Wire" ),                    // Title
    ADR( LAYER_WIRE )               // Adr of optional parameter
};

static ColorButton Layer_Bus_Item =
{
    _( "Bus" ),                     // Title
    ADR( LAYER_BUS )                // Adr of optional parameter
};

static ColorButton Layer_Junction_Item =
{
    _( "Junction" ),                // Title
    ADR( LAYER_JUNCTION )           // Adr of optional parameter
};

static ColorButton Layer_LocalLabel_Item =
{
    _( "Label" ),                   // Title
    ADR( LAYER_LOCLABEL )           // Adr of optional parameter
};

static ColorButton Layer_GlobLabel_Item =
{
    _( "GlobLabel" ),               // Title
    ADR( LAYER_GLOBLABEL )          // Adr of optional parameter
};

static ColorButton Layer_NetNam_Item =
{
    _( "Netname" ),                 // Title
    ADR( LAYER_NETNAM )             // Adr of optional parameter
};

static ColorButton Layer_Notes_Item =
{
    _( "Notes" ),                   // Title
    ADR( LAYER_NOTES )              // Adr of optional parameter
};

static ColorButton Layer_NoConnect_Item =
{
    _( "NoConn" ),                  // Title
    ADR( LAYER_NOCONNECT )          // Adr of optional parameter
};


static ColorButton Layer_BodyDevice_Item =
{
    _( "Body" ),                    // Title
    ADR( LAYER_DEVICE )             // Adr of optional parameter
};

static ColorButton Layer_BodyBackgroundDevice_Item =
{
    _( "Body Bg" ),                 // Title
    ADR( LAYER_DEVICE_BACKGROUND )  // Adr of optional parameter
};

static ColorButton Layer_Pin_Item =
{
    _( "Pin" ),                     // Title
    ADR( LAYER_PIN )                // Adr of optional parameter
};

static ColorButton Layer_PinNum_Item =
{
    _( "PinNum" ),                  // Title
    ADR( LAYER_PINNUM )             // Adr of optional parameter
};

static ColorButton Layer_PinNam_Item =
{
    _( "PinNam" ),                  // Title
    ADR( LAYER_PINNAM )             // Adr of optional parameter
};

static ColorButton Layer_Reference_Item =
{
    _( "Reference" ),               // Title
    ADR( LAYER_REFERENCEPART )      // Adr of optional parameter
};

static ColorButton Layer_Value_Item =
{
    _( "Value" ),                   // Title
    ADR( LAYER_VALUEPART )          // Adr of optional parameter
};

static ColorButton Layer_Fields_Item =
{
    _( "Fields" ),                  // Title
    ADR( LAYER_FIELDS )             // Adr of optional parameter
};


static ColorButton Layer_Sheet_Item =
{
    _( "Sheet" ),                   // Title
    ADR( LAYER_SHEET )              // Adr of optional parameter
};

static ColorButton Layer_SheetFileName_Item =
{
    _( "Sheetfile" ),               // Title
    ADR( LAYER_SHEETFILENAME )      // Adr of optional parameter
};

static ColorButton Layer_SheetName_Item =
{
    _( "SheetName" ),               // Title
    ADR( LAYER_SHEETNAME )          // Adr of optional parameter
};

static ColorButton Layer_SheetLabel_Item =
{
189
    _( "SheetLabel (Pin Sheet)" ),  // Title
190 191 192
    ADR( LAYER_SHEETLABEL )         // Adr of optional parameter
};

193 194 195 196 197
static ColorButton Layer_HierarchicalLabel_Item =
{
    _( "Hierarchical Label" ),       // Title
    ADR( LAYER_HIERLABEL )           // Adr of optional parameter
};
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241

static ColorButton Layer_Erc_Warning_Item =
{
    _( "Erc Warning" ),             // Title
    ADR( LAYER_ERC_WARN )           // Adr of optional parameter
};

static ColorButton Layer_Erc_Error_Item =
{
    _( "Erc Error" ),               // Title
    ADR( LAYER_ERC_ERR )            // Adr of optional parameter
};


static ColorButton Layer_Grid_Item =
{
    _( "Grid" ),                    // Title
    &g_GridColor                    // Adr of optional parameter
};


static ColorButton* laytool_list[NB_BUTT] = {
    &Layer_Wire_Item,
    &Layer_Bus_Item,
    &Layer_Junction_Item,
    &Layer_LocalLabel_Item,
    &Layer_GlobLabel_Item,
    &Layer_NetNam_Item,
    &Layer_Notes_Item,
    &Layer_NoConnect_Item,

    &Layer_BodyDevice_Item,
    &Layer_BodyBackgroundDevice_Item,
    &Layer_Pin_Item,
    &Layer_PinNum_Item,
    &Layer_PinNam_Item,
    &Layer_Reference_Item,
    &Layer_Value_Item,
    &Layer_Fields_Item,

    &Layer_Sheet_Item,
    &Layer_SheetFileName_Item,
    &Layer_SheetName_Item,
    &Layer_SheetLabel_Item,
242
    &Layer_HierarchicalLabel_Item,
243 244 245 246 247 248 249 250 251 252 253

    &Layer_Erc_Warning_Item,
    &Layer_Erc_Error_Item,

    &Layer_Grid_Item
};


static ButtonIndex Msg_General =
{
    _( "General" ),                 // Title
254
    7                               // Index to first bitmap button in group
255 256 257 258 259
};

static ButtonIndex MsgDevice_Item =
{
    _( "Device" ),                  // Title
260
    15                              // Index to first bitmap button in group
261 262 263 264 265
};

static ButtonIndex Msg_Sheets =
{
    _( "Sheets" ),                  // Title
266
    20                              // Index to first bitmap button in group
267 268 269 270 271
};

static ButtonIndex Msg_ErcMarck =
{
    _( "Erc Mark" ),                // Title
272
    22                              // Index to first bitmap button in group
273 274 275 276 277
};

static ButtonIndex Msg_Other =
{
    _( "Other" ),                   // Title
278
    23                              // Index to first bitmap button in group
279 280 281 282 283 284 285 286 287 288 289 290
};


static ButtonIndex* laytool_index[BUTTON_GROUPS] = {
    &Msg_General,
    &MsgDevice_Item,
    &Msg_Sheets,
    &Msg_ErcMarck,
    &Msg_Other
};


291 292 293
/***********************************************/
/* Derived class for the frame color settings. */
/***********************************************/
294 295 296 297 298 299 300

class WinEDA_SetColorsFrame: public wxDialog
{
private:
    DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame )
    DECLARE_EVENT_TABLE()

301 302 303 304 305 306 307 308 309 310 311 312
    WinEDA_DrawFrame*       m_Parent;
    wxBoxSizer*             OuterBoxSizer;
    wxBoxSizer*             MainBoxSizer;
    wxBoxSizer*             ColumnBoxSizer;
    wxBoxSizer*             RowBoxSizer;
    wxStaticText*           Label;
    wxBitmapButton*         BitmapButton;
    wxCheckBox*             m_ShowGrid;
    wxRadioBox*             m_SelBgColor;
    wxStaticLine*           Line;
    wxStdDialogButtonSizer* StdDialogButtonSizer;
    wxButton*               Button;
313 314 315 316 317 318 319 320 321

    // Creation
    bool Create( wxWindow* parent,
                 wxWindowID id = SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME,
                 const wxString& caption = SYMBOL_WINEDA_SETCOLORSFRAME_TITLE,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
                 long style = SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );

322
    // Initializes member variables
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
    void Init();

    // Creates the controls and sizers
    void CreateControls();

    wxBitmap GetBitmapResource( const wxString& name );
    wxIcon GetIconResource( const wxString& name );
    static bool ShowToolTips();

    void    UpdateLayerSettings();
    void    SetColor( wxCommandEvent& event );
    void    OnOkClick( wxCommandEvent& event );
    void    OnCancelClick( wxCommandEvent& event );
    void    OnApplyClick( wxCommandEvent& event );

public:
    // Constructors and destructor
    WinEDA_SetColorsFrame();
    WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent, const wxPoint& framepos );
    ~WinEDA_SetColorsFrame();
};

345
#endif    // _EELAYER_H_