~ubuntu-branches/ubuntu/lucid/codelite/lucid

« back to all changes in this revision

Viewing changes to Plugin/macrosdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-01-12 15:46:55 UTC
  • Revision ID: james.westby@ubuntu.com-20090112154655-sdynrljcb6u167yw
Tags: upstream-1.0.2674+dfsg
ImportĀ upstreamĀ versionĀ 1.0.2674+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////////
 
2
//////////////////////////////////////////////////////////////////////////////
 
3
//
 
4
// copyright            : (C) 2008 by Eran Ifrah                            
 
5
// file name            : macrosdlg.cpp              
 
6
//                                                                          
 
7
// -------------------------------------------------------------------------
 
8
// A                                                                        
 
9
//              _____           _      _     _ _                            
 
10
//             /  __ \         | |    | |   (_) |                           
 
11
//             | /  \/ ___   __| | ___| |    _| |_ ___                      
 
12
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )                     
 
13
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/                     
 
14
//              \____/\___/ \__,_|\___\_____/_|\__\___|                     
 
15
//                                                                          
 
16
//                                                  F i l e                 
 
17
//                                                                          
 
18
//    This program is free software; you can redistribute it and/or modify  
 
19
//    it under the terms of the GNU General Public License as published by  
 
20
//    the Free Software Foundation; either version 2 of the License, or     
 
21
//    (at your option) any later version.                                   
 
22
//                                                                          
 
23
//////////////////////////////////////////////////////////////////////////////
 
24
//////////////////////////////////////////////////////////////////////////////
 
25
 
 
26
#include <wx/dataobj.h>
 
27
#include <wx/app.h>
 
28
#include <wx/clipbrd.h>
 
29
#include <wx/menu.h>
 
30
#include <wx/xrc/xmlres.h>
 
31
#include "macrosdlg.h"
 
32
#include "globals.h"
 
33
 
 
34
BEGIN_EVENT_TABLE(MacrosDlg, MacrosBaseDlg)
 
35
        EVT_MENU(XRCID("copy_macro"), MacrosDlg::OnCopy)
 
36
END_EVENT_TABLE()
 
37
 
 
38
MacrosDlg::MacrosDlg( wxWindow* parent, int content )
 
39
                : MacrosBaseDlg( parent )
 
40
                , m_item(wxNOT_FOUND)
 
41
                , m_content(content)
 
42
{
 
43
        Initialize();
 
44
        m_buttonOk->SetFocus();
 
45
        GetSizer()->SetMinSize(500, 400);
 
46
        GetSizer()->Fit(this);
 
47
}
 
48
 
 
49
void MacrosDlg::OnItemRightClick( wxListEvent& event )
 
50
{
 
51
        m_item = event.m_itemIndex;
 
52
        wxMenu menu;
 
53
        menu.Append(XRCID("copy_macro"), wxT("Copy"), false);
 
54
        PopupMenu(&menu);
 
55
}
 
56
 
 
57
void MacrosDlg::Initialize()
 
58
{
 
59
        m_listCtrlMacros->InsertColumn(0, wxT("Macro"));
 
60
        m_listCtrlMacros->InsertColumn(1, wxT("Description"));
 
61
 
 
62
        switch ( m_content ) {
 
63
        case MacrosProject:
 
64
                AddMacro(wxT("$(ProjectPath)"), wxT("Expands to project's path"));
 
65
                AddMacro(wxT("$(WorkspacePath)"), wxT("Expands to workspace's path"));
 
66
                AddMacro(wxT("$(ProjectName)"), wxT("Expands to the current project name as appears in the 'File View'"));
 
67
                AddMacro(wxT("$(IntermediateDirectory)"), wxT("Expands to the current project intermediate directory path, as set in the project settings"));
 
68
                AddMacro(wxT("$(ConfigurationName)"), wxT("Expands to the current project selected configuration"));
 
69
                AddMacro(wxT("$(OutDir)"), wxT("An alias to $(IntermediateDirectory)"));
 
70
                AddMacro(wxT("$(CurrentFileName)"), wxT("Expands to current file name (without extension and path)"));
 
71
                AddMacro(wxT("$(CurrentFilePath)"), wxT("Expands to current file path"));
 
72
                AddMacro(wxT("$(CurrentFileFullPath)"), wxT("Expands to current file full path (path and full name)"));
 
73
                AddMacro(wxT("$(User)"), wxT("Expands to logged-in user as defined by the OS"));
 
74
                AddMacro(wxT("$(Date)"), wxT("Expands to current date"));
 
75
                AddMacro(wxT("$(CodeLitePath)"), wxT("Expands to CodeLite's startup directory on (e.g. on Unix it exapnds to ~/.codelite/"));
 
76
                AddMacro(wxT("`expression`"), wxT("backticks: evaluates the expression inside the backticks into a string"));
 
77
                break;
 
78
        case MacrosCompiler:
 
79
                AddMacro(wxT("$(CompilerName)"), wxT("Expands to the compiler name as set in the Tools tab"));
 
80
                AddMacro(wxT("$(SourceSwitch)"), wxT("Expands to the source switch (usually, -c)"));
 
81
                AddMacro(wxT("$(FileFullPath)"), wxT("The file full path (includes path+name+extnesion)"));
 
82
                AddMacro(wxT("$(FileFullName)"), wxT("The file full name (includes name+extnesion)"));
 
83
                AddMacro(wxT("$(FileName)"), wxT("The file name (includes name only)"));
 
84
                AddMacro(wxT("$(CmpOptions)"), wxT("Expands to the compiler options as set in the project settings"));
 
85
                AddMacro(wxT("$(RcCompilerName)"), wxT("Expands to the resource compiler name"));
 
86
                AddMacro(wxT("$(IntermediateDirectory)"), wxT("Expands to the current project intermediate directory path, as set in the project settings"));
 
87
                AddMacro(wxT("$(ConfigurationName)"), wxT("Expands to the current project selected configuration"));
 
88
                AddMacro(wxT("$(OutDir)"), wxT("An alias to $(IntermediateDirectory)"));
 
89
                AddMacro(wxT("$(LinkerName)"), wxT("Expands to the linker name as set in the Tools tab"));
 
90
                AddMacro(wxT("$(ArchiveTool)"), wxT("Expands to the archive tool (e.g. ar) name as set in the Tools tab"));
 
91
                AddMacro(wxT("$(SharedObjectLinkerName)"), wxT("Expands to the shared object linker name as set in the Tools tab"));
 
92
                AddMacro(wxT("$(ObjectSuffix)"), wxT("Objects suffix (usually set to .o)"));
 
93
                AddMacro(wxT("$(DependSuffix)"), wxT("Objects suffix (usually set to .o.d)"));
 
94
                AddMacro(wxT("$(PreprocessSuffix)"), wxT("Objects suffix (usually set to .o.i)"));
 
95
                AddMacro(wxT("$(IncludeSwitch)"), wxT("The compiler include switch"));
 
96
                AddMacro(wxT("$(LibrarySwitch)"), wxT("The library switch (e.g. -l)"));
 
97
                AddMacro(wxT("$(OutputSwitch)"), wxT("The output switch (e.g. -o)"));
 
98
                AddMacro(wxT("$(LibraryPathSwitch)"), wxT("Library switch (e.g. -L)"));
 
99
                AddMacro(wxT("$(PreprocessorSwitch)"), wxT("Preprocessor switch (e.g. -D)"));
 
100
                AddMacro(wxT("$(Preprocessors)"), wxT("Expands to all preprocessors set in the project setting where each entry is prefixed with $(PreprocessorSwitch)"));
 
101
                AddMacro(wxT("$(ArchiveOutputSwitch)"), wxT("Archive switch, usually not needed (VC compiler sets it to /OUT:"));
 
102
        AddMacro(wxT("$(PreprocessOnlySwitch)"), wxT("The compiler preprocess-only switch (e.g. -E)"));
 
103
                AddMacro(wxT("$(LinkOptions)"), wxT("The linker options as set in the project settings"));
 
104
                AddMacro(wxT("$(IncludePath)"), wxT("All include paths prefixed with $(IncludeSwitch)"));
 
105
                AddMacro(wxT("$(RcIncludePath)"), wxT("Resource compiler include path as set in the project settings"));
 
106
                AddMacro(wxT("$(Libs)"), wxT("List of libraries to link with. each library is prefixed with $(LibrarySwitch)"));
 
107
                AddMacro(wxT("$(LibPath)"), wxT("List of library paths to link with. each library is prefixed with $(LibraryPathSwitch)"));
 
108
                AddMacro(wxT("$(OutputFile)"), wxT("The output file"));
 
109
                break;
 
110
        }
 
111
 
 
112
        // resize columns
 
113
        m_listCtrlMacros->SetColumnWidth(0, wxLIST_AUTOSIZE);
 
114
        m_listCtrlMacros->SetColumnWidth(1, wxLIST_AUTOSIZE);
 
115
}
 
116
 
 
117
void MacrosDlg::AddMacro(const wxString& name, const wxString& desc)
 
118
{
 
119
        long row = AppendListCtrlRow(m_listCtrlMacros);
 
120
        SetColumnText(m_listCtrlMacros, row, 0, name);
 
121
        SetColumnText(m_listCtrlMacros, row, 1, desc);
 
122
}
 
123
 
 
124
MacrosDlg::~MacrosDlg()
 
125
{
 
126
}
 
127
 
 
128
void MacrosDlg::OnCopy(wxCommandEvent& e)
 
129
{
 
130
        if (m_item != wxNOT_FOUND) {
 
131
                wxString value = GetColumnText(m_listCtrlMacros, m_item,  0);
 
132
#if wxUSE_CLIPBOARD
 
133
                if (wxTheClipboard->Open()) {
 
134
                        wxTheClipboard->UsePrimarySelection(false);
 
135
                        if (!wxTheClipboard->SetData(new wxTextDataObject(value))) {
 
136
                                //wxPrintf(wxT("Failed to insert data %s to clipboard"), textToCopy.GetData());
 
137
                        }
 
138
                        wxTheClipboard->Close();
 
139
                } else {
 
140
                        wxPrintf(wxT("Failed to open the clipboard"));
 
141
                }
 
142
#endif
 
143
        }
 
144
        m_item = wxNOT_FOUND;
 
145
}