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

« back to all changes in this revision

Viewing changes to LiteEditor/addoptioncheckdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-08-15 17:42:43 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090815174243-nlb9ikgigbiybz12
Tags: 1.0.2893+dfsg-0ubuntu1
* debian/rules:
  + Tidy up get-orig-source rule
* debian/control:
  + Bump Standards-Version
  + Change Maintainer email address to @ubuntu.com
  + Drop cdbs build-dependency
* debian/copyright:
  + Update to DEP-5 format
* debian/patches/00_add-fPIC.patch:
  + Dropped, fix upstream
* Closes LP: #413992

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
        for ( ; itOption != m_cmpOptions.end(); ++itOption)
18
18
        {
19
19
                const Compiler::CmpCmdLineOption& cmpOption = itOption->second;
20
 
                m_checkListOptions->Append(cmpOption.name);
 
20
                m_checkListOptions->Append(cmpOption.help + wxT(" [") + cmpOption.name + wxT("]"));
21
21
        }
22
22
        
23
23
        // Update controls
24
24
        SetValue(value);
25
 
        UpdateCheckOptions();
26
25
}
27
26
 
28
27
AddOptionCheckDlg::~AddOptionCheckDlg()
32
31
 
33
32
void AddOptionCheckDlg::SetValue(const wxString& value)
34
33
{
35
 
        wxString text;
36
 
        wxStringTokenizer tkz(value, wxT(";"));
37
 
        while(tkz.HasMoreTokens())
38
 
        {
39
 
                wxString token = tkz.GetNextToken();
40
 
                token = token.Trim().Trim(false);
41
 
                if (!token.empty())
42
 
                {
43
 
                        text << token << wxT('\n');
44
 
                }
45
 
        }
46
 
        m_textOptions->ChangeValue(text);
 
34
        m_textCmdLn->SetValue(value);
 
35
        
 
36
        UpdateOptions();
 
37
        UpdateCmdLine();
47
38
}
48
39
 
49
40
wxString AddOptionCheckDlg::GetValue() const
50
41
{
51
 
        wxStringInputStream input(m_textOptions->GetValue());
52
 
        wxTextInputStream text(input);
53
 
 
54
 
        wxString value;
55
 
        while( !input.Eof() ) {
56
 
                // Read the next line
57
 
                wxString line = text.ReadLine().Trim().Trim(false);
58
 
                if (!line.empty())
59
 
                {
60
 
                        value << line << wxT(';');
61
 
                }
62
 
        }
63
 
        return value.BeforeLast(wxT(';'));
 
42
        return m_textCmdLn->GetValue();
64
43
}
65
44
 
66
45
void AddOptionCheckDlg::OnOptionToggled( wxCommandEvent& event )
67
46
{
68
 
        UpdateTextOptions();
 
47
        UpdateCmdLine();
 
48
        UpdateOptions();
69
49
}
70
50
 
71
51
void AddOptionCheckDlg::OnOptionsText( wxCommandEvent& event )
72
52
{
73
 
        UpdateCheckOptions();
74
 
}
75
 
 
76
 
void AddOptionCheckDlg::OnOptionSelected( wxCommandEvent& event )
77
 
{
78
 
        wxString sOption = m_checkListOptions->GetString(event.GetInt());
79
 
        Compiler::CmpCmdLineOptions::const_iterator itOption = m_cmpOptions.find(sOption);
80
 
        if (itOption != m_cmpOptions.end())
81
 
        {
82
 
                wxString sHelp;
83
 
                sHelp << sOption << wxT(":\n") << itOption->second.help;
84
 
                m_textHelp->ChangeValue(sHelp);
85
 
        }
86
 
}
87
 
 
88
 
void AddOptionCheckDlg::UpdateCheckOptions()
 
53
        UpdateCmdLine();
 
54
}
 
55
 
 
56
void AddOptionCheckDlg::UpdateOptions()
89
57
{
90
58
        // Remove all check boxes
91
59
        m_checkListOptions->Freeze();
 
60
        
92
61
        for (unsigned int idx = 0; idx < m_checkListOptions->GetCount(); ++idx)
93
62
        {
94
63
                m_checkListOptions->Check(idx, false);
95
64
        }
96
65
        
97
66
        // Check all options entered 
98
 
        wxStringInputStream input(m_textOptions->GetValue());
99
 
        wxTextInputStream text(input);
100
 
        while( !input.Eof() )
 
67
        wxString customOptions;
 
68
        wxStringTokenizer tkz(m_textCmdLn->GetValue(), wxT(";"));
 
69
        while(tkz.HasMoreTokens())
101
70
        {
102
 
                // Read the next line
103
 
                wxString value = text.ReadLine().Trim().Trim(false);
104
 
                if (m_cmpOptions.find(value) != m_cmpOptions.end())
 
71
                wxString token = tkz.GetNextToken();
 
72
                token = token.Trim().Trim(false);
 
73
                if (!token.empty())
105
74
                {
106
 
                        m_checkListOptions->Check(m_checkListOptions->FindString(value));                       
 
75
                        Compiler::CmpCmdLineOptions::const_iterator itOption = m_cmpOptions.find(token);
 
76
                        if(itOption != m_cmpOptions.end())
 
77
                        {
 
78
                                const Compiler::CmpCmdLineOption& cmpOption = itOption->second;
 
79
                                m_checkListOptions->Check(m_checkListOptions->FindString(cmpOption.help + wxT(" [") + cmpOption.name + wxT("]")));                      
 
80
                        }
 
81
                        else
 
82
                        {
 
83
                                if(!customOptions.empty()) customOptions << wxT(";");
 
84
                                customOptions << token;
 
85
                        }
107
86
                }
108
87
        }
 
88
        m_textOptions->ChangeValue(customOptions);
 
89
        
109
90
        m_checkListOptions->Thaw();
110
91
}
111
92
 
112
 
void AddOptionCheckDlg::UpdateTextOptions()
 
93
void AddOptionCheckDlg::UpdateCmdLine()
113
94
{
114
95
        // Store all actual options
115
96
        std::list<wxString> options;
126
107
        // Read check box options
127
108
        for (unsigned int idx = 0; idx < m_checkListOptions->GetCount(); ++idx)
128
109
        {
129
 
                wxString value = m_checkListOptions->GetString(idx);
 
110
                wxString value = m_checkListOptions->GetString(idx).AfterLast(wxT('[')).BeforeLast(wxT(']'));
130
111
                if (m_checkListOptions->IsChecked(idx))
131
112
                {
132
113
                        // If the option doesn't exist actually, add it
133
114
                        if (std::find(options.begin(), options.end(), value) == options.end())
134
115
                        {
135
 
                                options.push_back(value);
 
116
                                //options.push_back(value.AfterLast(wxT('[')).BeforeLast(wxT(']')));
 
117
                                options.insert(options.begin(), value);
136
118
                        }
137
 
                }
138
 
                else
139
 
                {
140
 
                        // Remove the unchecked option
141
 
                        options.remove(value);
 
119
                        else
 
120
                                // uncheck the option if already defined manualy
 
121
                                m_checkListOptions->Check(idx, false);
142
122
                }
143
123
        }
144
124
        
147
127
        std::list<wxString>::const_iterator itOption = options.begin();
148
128
        for ( ; itOption != options.end(); ++itOption)
149
129
        {
150
 
                value << *itOption << wxT('\n');
 
130
                if(!value.Contains(*itOption))
 
131
                {
 
132
                        if(!value.empty()) value << wxT(";");
 
133
                        value << *itOption;
 
134
                }
151
135
        }
152
 
        m_textOptions->ChangeValue(value);
 
136
        m_textCmdLn->SetValue(value);
153
137
}
 
138