kicad.h 9.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/**
 * @file kicad/kicad.h
 * @brief KICAD_MANAGER_FRAME is the KiCad main frame.
 */

/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2013 CERN (www.cern.ch)
 * Copyright (C) 2013 KiCad Developers, see CHANGELOG.txt for contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */
plyatov's avatar
plyatov committed
29 30 31 32

#ifndef KICAD_H
#define KICAD_H

33
#include <vector>
34 35

#include <wx/treectrl.h>
36
#include <wx/dragimag.h>
37
#include <wx/filename.h>
38
#include <wx/process.h>
plyatov's avatar
plyatov committed
39

40 41
#include <id.h>
#include <wxstruct.h>
42
//#include <pgm_base.h>
43

44 45 46 47 48 49
// With a recent wxWidget, we can use the wxFileSystemWatcherEvent
// to monitor files add/remove/rename in tree project
#if wxCHECK_VERSION( 2, 9, 4  )
#define KICAD_USE_FILES_WATCHER
#endif

50
class LAUNCHER_PANEL;
51 52
class TREEPROJECTFILES;
class TREE_PROJECT_FRAME;
plyatov's avatar
plyatov committed
53

54 55 56 57 58 59 60 61 62
// Enum to identify the type of files handled by Kicad manager
//
// When changing this enum  please verify (and perhaps update)
// TREE_PROJECT_FRAME::GetFileExt(),
// TREE_PROJECT_FRAME::GetFileExt()
// s_AllowedExtensionsToList[]

enum TreeFileType {
    TREE_PROJECT = 1,
63 64 65 66 67 68 69
    TREE_SCHEMA,            // Schematic file (.sch)
    TREE_LEGACY_PCB,        // board file (.brd) legacy format
    TREE_SEXP_PCB,          // board file (.kicad_brd) new s expression format
    TREE_GERBER,            // Gerber  file (.pho, .g*)
    TREE_PDF,               // PDF file (.pdf)
    TREE_TXT,               // ascii text file (.txt)
    TREE_NET,               // netlist file (.net)
70 71
    TREE_UNKNOWN,
    TREE_DIRECTORY,
72 73 74 75 76 77
    TREE_CMP_LINK,          // cmp/footprint link file (.cmp)
    TREE_REPORT,            // report file (.rpt)
    TREE_FP_PLACE,          // fooprints position (place) file (.pos)
    TREE_DRILL,             // Excellon drill file (.drl)
    TREE_SVG,               // SVG file (.svg)
    TREE_PAGE_LAYOUT_DESCR, // Page layout and title block descr file (.kicad_wks)
78 79 80
    TREE_MAX
};

81

82
/**
83
 * Command IDs for KiCad.
84
 *
stambaughw's avatar
stambaughw committed
85
 * Please add IDs that are unique to Kicad  here and not in the global id.h
86
 * file.  This will prevent the entire project from being rebuilt when adding
87
 * new commands to KiCad.
88 89
 */

charras's avatar
charras committed
90
enum id_kicad_frm {
91 92 93 94 95 96 97 98 99 100 101 102
    ID_LEFT_FRAME = ID_END_LIST,
    ID_PROJECT_TREE,
    ID_PROJECT_TXTEDIT,
    ID_PROJECT_TREE_REFRESH,
    ID_PROJECT_NEWDIR,
    ID_PROJECT_DELETE,
    ID_PROJECT_RENAME,
    ID_PROJECT_OPEN_FILE_WITH_TEXT_EDITOR,

    ID_TO_EDITOR,
    ID_TO_EESCHEMA,
    ID_TO_GERBVIEW,
103
    ID_TO_BITMAP_CONVERTER,
104
    ID_TO_PCB_CALCULATOR,
105
    ID_TO_PL_EDITOR,
106 107 108 109 110 111
    ID_BROWSE_AN_SELECT_FILE,
    ID_SELECT_PREFERED_EDITOR,
    ID_SELECT_PREFERED_PDF_BROWSER_NAME,
    ID_SELECT_PREFERED_PDF_BROWSER,
    ID_SELECT_DEFAULT_PDF_BROWSER,
    ID_SAVE_AND_ZIP_FILES,
112 113
    ID_READ_ZIP_ARCHIVE,
    ID_INIT_WATCHED_PATHS
114 115
};

116

117 118 119
/**
 * Class KICAD_MANAGER_FRAME
 * is the main KiCad project manager frame.  It is not a KIWAY_PLAYER.
120
 */
121
class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME
plyatov's avatar
plyatov committed
122
{
123 124
public:
    KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
125
                             const wxPoint& pos, const wxSize& size );
126

127
    ~KICAD_MANAGER_FRAME();
128

129 130
    void OnCloseWindow( wxCloseEvent& Event );
    void OnSize( wxSizeEvent& event );
131 132 133 134 135

    /**
     * Function OnLoadProject
     * loads an exiting or creates a new project (.pro) file.
     */
136
    void OnLoadProject( wxCommandEvent& event );
137 138 139 140 141 142

    /**
     * Function OnSaveProject
     * is the command event hendler to Save the project (.pro) file containing the top level
     * configuration parameters.
     */
143
    void OnSaveProject( wxCommandEvent& event );
144

145 146 147 148 149 150 151
    void OnArchiveFiles( wxCommandEvent& event );
    void OnUnarchiveFiles( wxCommandEvent& event );
    void OnRunPcbNew( wxCommandEvent& event );
    void OnRunCvpcb( wxCommandEvent& event );
    void OnRunEeschema( wxCommandEvent& event );
    void OnRunGerbview( wxCommandEvent& event );
    void OnRunBitmapConverter( wxCommandEvent& event );
152
    void OnRunPcbCalculator( wxCommandEvent& event );
153
    void OnRunPageLayoutEditor( wxCommandEvent& event );
154 155 156 157 158 159 160 161 162 163

    void OnOpenTextEditor( wxCommandEvent& event );
    void OnOpenFileInTextEditor( wxCommandEvent& event );
    void OnOpenFileInEditor( wxCommandEvent& event );

    void OnFileHistory( wxCommandEvent& event );
    void OnExit( wxCommandEvent& event );
    void Process_Preferences( wxCommandEvent& event );
    void ReCreateMenuBar();
    void RecreateBaseHToolbar();
164 165 166 167 168 169 170 171 172

    /**
     * Function PrintMsg
     * displays \a aText in the text panel.
     *
     * @param aText The text to display.
     */
    void PrintMsg( const wxString& aText );

173 174 175 176 177 178 179 180 181 182
    /**
     * a minor helper function:
     * Prints the Current Working Dir name and the projet name on the text panel.
     */
    void PrintPrjInfo();

    /**
     * a minor helper function:
     * Erase the text panel.
     */
183
    void ClearMsg();
184

185 186 187 188 189 190 191
    void OnRefresh( wxCommandEvent& event );
    void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
    void OnSelectPreferredPdfBrowser( wxCommandEvent& event );

    void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
    void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );

192
    void CreateNewProject( const wxString& aPrjFullFileName, bool aTemplateSelector );
193

194
    void LoadSettings( wxConfigBase* aCfg );
195

196
    void SaveSettings( wxConfigBase* aCfg );
197

198 199 200 201 202 203 204 205
    /**
     * Function Execute
     * opens another KiCad application and logs a message.
     * @param frame = owner frame.
     * @param execFile = name of the executable file.
     * @param param = parameters to be passed to the executable.
     */
    void Execute( wxWindow* frame, const wxString& execFile,
Dick Hollenbeck's avatar
Dick Hollenbeck committed
206
                  wxString param = wxEmptyString );
207

208
    class TERMINATE_HANDLER : public wxProcess
209 210 211 212 213
    {
    private:
        wxString appName;

    public:
214
        TERMINATE_HANDLER( const wxString& appName ) :
215 216 217 218 219 220 221
            appName(appName)
        {
        }

        void OnTerminate( int pid, int status );
    };

222 223 224 225 226 227 228 229
#ifdef KICAD_USE_FILES_WATCHER
    /**
     * Called by sending a event with id = ID_INIT_WATCHED_PATHS
     * rebuild the list of wahtched paths
     */
    void OnChangeWatchedPaths(wxCommandEvent& aEvent );
#endif

230 231 232 233 234 235
    void SetProjectFileName( const wxString& aFullProjectProFileName );
    const wxString GetProjectFileName();

    // read only accessors
    const wxString SchFileName();
    const wxString PcbFileName();
Dick Hollenbeck's avatar
Dick Hollenbeck committed
236 237 238 239 240 241 242 243 244 245 246
    const wxString PcbLegacyFileName();

    void ReCreateTreePrj();

    /// Call this only for a PCB associated with the current project.  That is,
    /// it must have the same path and name as the project *.pro file.
    void RunPcbNew( const wxString& aProjectBoardFileName );

    /// Call this only for a SCH associated with the current project.  That is,
    /// it must have the same path and name as the project *.pro file.
    void RunEeschema( const wxString& aProjectSchematicFileName );
247

248
    DECLARE_EVENT_TABLE()
249 250 251 252 253 254 255 256 257 258 259 260 261

private:

    wxConfigBase*       config();       // override EDA_BASE_FRAME virtual

    const SEARCH_STACK& sys_search();   // override EDA_BASE_FRAME virtual

    wxString help_name();               // override EDA_BASE_FRAME virtual

    TREE_PROJECT_FRAME* m_LeftWin;
    LAUNCHER_PANEL*     m_Launcher;
    wxTextCtrl*         m_MessagesBox;
    wxAuiToolBar*       m_VToolBar;             // Vertical toolbar (not used)
Dick Hollenbeck's avatar
Dick Hollenbeck committed
262
    wxString            m_project_file_name;
263 264 265 266

    int m_leftWinWidth;

    void language_change( wxCommandEvent& event );
plyatov's avatar
plyatov committed
267 268
};

269

270
/** class LAUNCHER_PANEL
271
 */
272
class LAUNCHER_PANEL : public wxPanel
273
{
charras's avatar
charras committed
274
private:
275 276
    int     m_buttonSeparation;             // button distance in pixels
    wxPoint m_buttonsListPosition;          /* position of the left bottom corner
277 278
                                             *  of the first bitmap button
                                             */
279
    wxPoint m_buttonLastPosition;           // position of the last button in the window
280 281 282
    int     m_bitmapButtons_maxHeigth;      // height of bigger bitmap buttons
                                            // Used to calculate the height of the panel.

283 284 285 286
public: LAUNCHER_PANEL( wxWindow* parent );
    ~LAUNCHER_PANEL() { };

    int GetPanelHeight() const;
287

288
private:
289

290 291 292 293
    /**
     * Function CreateCommandToolbar
     * creates the main tool bar buttons (fast launch buttons)
     */
294
    void            CreateCommandToolbar( void );
295

296
    wxBitmapButton* AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap );
297 298
};

299 300 301 302
// The C++ project manager includes a single PROJECT in its link image.
class PROJECT;
extern PROJECT& Prj();

plyatov's avatar
plyatov committed
303
#endif