~ubuntu-branches/ubuntu/vivid/wxmaxima/vivid

« back to all changes in this revision

Viewing changes to src/GroupCell.cpp

  • Committer: Package Import Robot
  • Author(s): Frank S. Thomas
  • Date: 2013-06-19 18:16:46 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20130619181646-t3il62hqsjthfury
Tags: 13.04.2-1
* New upstream release.
* Upload to unstable. (closes: #711965)
* Updated debian/copyright for the new release.
* Bumped Standards-Version from 3.9.3 to 3.9.4, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
///
2
2
///  Copyright (C) 2008-2011 Andrej Vodopivec <andrej.vodopivec@gmail.com>
3
3
///            (C) 2008-2009 Ziga Lenarcic <zigalenarcic@users.sourceforge.net>
 
4
///            (C) 2012 Doug Ilijev <doug.ilijev@gmail.com>
4
5
///
5
6
///  This program is free software; you can redistribute it and/or modify
6
7
///  it under the terms of the GNU General Public License as published by
32
33
  m_input = NULL;
33
34
  m_output = NULL;
34
35
  m_hiddenTree = NULL;
 
36
  m_hiddenTreeParent = NULL;
35
37
  m_outputRect.x = -1;
36
38
  m_outputRect.y = -1;
37
39
  m_outputRect.width = 0;
58
60
  }
59
61
 
60
62
  bool match = true;
 
63
  bool insertAns = true;
61
64
  wxConfig::Get()->Read(wxT("matchParens"), &match);
 
65
  wxConfig::Get()->Read(wxT("insertAns"), &insertAns);
62
66
  EditorCell *editor = new EditorCell();
63
67
  editor->SetMatchParens(match);
 
68
  editor->SetInsertAns(insertAns);
64
69
 
65
70
  switch (groupType) {
66
71
    case GC_TYPE_CODE:
605
610
  str1.Replace(wxT("\\"), wxT("\\verb|\\|"));
606
611
  str1.Replace(wxT("_"), wxT("\\_"));
607
612
  str1.Replace(wxT("%"), wxT("\\%"));
 
613
  str1.Replace(wxT("$"), wxT("\\$"));
608
614
  str1.Replace(wxT("{"), wxT("\\{"));
609
615
  str1.Replace(wxT("}"), wxT("\\}"));
610
616
  str1.Replace(wxT("^"), wxT("\\verb|^|"));
1107
1113
  if (m_hiddenTree)
1108
1114
    return false;
1109
1115
  m_hiddenTree = tree;
 
1116
  m_hiddenTree->SetHiddenTreeParent(this);
1110
1117
  return true;
1111
 
 
1112
1118
}
1113
1119
 
1114
1120
GroupCell *GroupCell::UnhideTree()
1115
1121
{
1116
1122
  GroupCell *tree = m_hiddenTree;
 
1123
  m_hiddenTree->SetHiddenTreeParent(m_hiddenTreeParent);
1117
1124
  m_hiddenTree = NULL;
1118
1125
  return tree;
1119
1126
}
1120
1127
 
 
1128
/**
 
1129
 * Unfold a tree from the bottom up, when a hidden cell needs to be seen.
 
1130
 *
 
1131
 * @return true if any cells were unfolded.
 
1132
 */
 
1133
bool GroupCell::RevealHidden()
 
1134
{
 
1135
  if (!m_hiddenTreeParent)
 
1136
    return false;
 
1137
  m_hiddenTreeParent->RevealHidden();
 
1138
  m_hiddenTreeParent->Unfold();
 
1139
  return true;
 
1140
}
 
1141
 
 
1142
/**
 
1143
 * For every cell in this GroupCell, set m_hiddenTreeParent to parent.
 
1144
 * This way, the field can be used to traverse up the tree no matter which
 
1145
 * child we are on. In other words, every child knows its parent node.
 
1146
 */
 
1147
void GroupCell::SetHiddenTreeParent(GroupCell* parent) {
 
1148
  GroupCell* cell = this;
 
1149
  while (cell) {
 
1150
    cell->m_hiddenTreeParent = parent;
 
1151
    cell = dynamic_cast<GroupCell*>(cell->m_next);
 
1152
  }
 
1153
}
 
1154
 
1121
1155
GroupCell *GroupCell::Fold() {
1122
1156
  if (!IsFoldable() || m_hiddenTree) // already folded?? shouldn't happen
1123
1157
    return NULL;
1150
1184
  start->m_previous = start->m_previousToDraw = NULL;
1151
1185
  end->m_next = end->m_nextToDraw = NULL;
1152
1186
  m_hiddenTree = start; // save the torn out tree into m_hiddenTree
 
1187
  m_hiddenTree->SetHiddenTreeParent(this);
1153
1188
  return this;
1154
1189
}
1155
1190
 
1173
1208
  if (next)
1174
1209
    next->m_previous = next->m_previousToDraw = tmp;
1175
1210
 
 
1211
  m_hiddenTree->SetHiddenTreeParent(m_hiddenTreeParent);
1176
1212
  m_hiddenTree = NULL;
1177
1213
  return dynamic_cast<GroupCell*>(tmp);
1178
1214
}