1//--------------------------------------------------------------------------- 2// This file is generated by wxPython's SIP generator. Do not edit by hand. 3// 4// Copyright: (c) 2018 by Total Control Software 5// License: wxWindows License 6// 7// This file will be included by _core.sip 8// 9//--------------------------------------------------------------------------- 10 11%ModuleHeaderCode 12#include <wx/cmdproc.h> 13%End 14 15 16//--------------------------------------------------------------------------- 17 18class wxCommand : wxObject 19{ 20 %Docstring 21 Command(canUndo=False, name=EmptyString) 22 23 wxCommand is a base class for modelling an application command, which 24 is an action usually performed by selecting a menu item, pressing a 25 toolbar button or any other means provided by the application to 26 change the data or view. 27 %End 28 %TypeHeaderCode 29 #include <wx/cmdproc.h> 30 %End 31 32public: 33 wxCommand( 34 bool canUndo = false, 35 const wxString & name = wxEmptyString 36 ); 37 38 virtual 39 ~wxCommand(); 40 41 virtual 42 bool CanUndo() const; 43 %Docstring 44 CanUndo() -> bool 45 46 Returns true if the command can be undone, false otherwise. 47 %End 48 49 virtual 50 bool Do() = 0; 51 %Docstring 52 Do() -> bool 53 54 Override this member function to execute the appropriate action when 55 called. 56 %End 57 58 virtual 59 wxString GetName() const; 60 %Docstring 61 GetName() -> String 62 63 Returns the command name. 64 %End 65 66 virtual 67 bool Undo() = 0; 68 %Docstring 69 Undo() -> bool 70 71 Override this member function to un-execute a previous Do. 72 %End 73 74 private: 75 wxCommand(const wxCommand&); 76 77 78 public: 79 80 81 %Property(name=Name, get=GetName) 82}; // end of class wxCommand 83 84 85class wxCommandProcessor : wxObject 86{ 87 %Docstring 88 CommandProcessor(maxCommands=-1) 89 90 wxCommandProcessor is a class that maintains a history of wxCommands, 91 with undo/redo functionality built-in. 92 %End 93 %TypeHeaderCode 94 #include <wx/cmdproc.h> 95 %End 96 97public: 98 wxCommandProcessor( 99 int maxCommands = -1 100 ); 101 102 virtual 103 ~wxCommandProcessor(); 104 105 virtual 106 bool CanUndo() const; 107 %Docstring 108 CanUndo() -> bool 109 110 Returns true if the currently-active command can be undone, false 111 otherwise. 112 %End 113 114 virtual 115 bool CanRedo() const; 116 %Docstring 117 CanRedo() -> bool 118 119 Returns true if the currently-active command can be redone, false 120 otherwise. 121 %End 122 123 virtual 124 void ClearCommands(); 125 %Docstring 126 ClearCommands() 127 128 Deletes all commands in the list and sets the current command pointer 129 to NULL. 130 %End 131 132 wxCommandList& GetCommands() /NoCopy/; 133 %Docstring 134 GetCommands() -> CommandList 135 136 Returns the list of commands. 137 %End 138 139 wxCommand * GetCurrentCommand() const; 140 %Docstring 141 GetCurrentCommand() -> Command 142 143 Returns the current command. 144 %End 145 146 wxMenu * GetEditMenu() const; 147 %Docstring 148 GetEditMenu() -> Menu 149 150 Returns the edit menu associated with the command processor. 151 %End 152 153 int GetMaxCommands() const; 154 %Docstring 155 GetMaxCommands() -> int 156 157 Returns the maximum number of commands that the command processor 158 stores. 159 %End 160 161 const wxString & GetRedoAccelerator() const; 162 %Docstring 163 GetRedoAccelerator() -> String 164 165 Returns the string that will be appended to the Redo menu item. 166 %End 167 168 wxString GetRedoMenuLabel() const; 169 %Docstring 170 GetRedoMenuLabel() -> String 171 172 Returns the string that will be shown for the redo menu item. 173 %End 174 175 const wxString & GetUndoAccelerator() const; 176 %Docstring 177 GetUndoAccelerator() -> String 178 179 Returns the string that will be appended to the Undo menu item. 180 %End 181 182 wxString GetUndoMenuLabel() const; 183 %Docstring 184 GetUndoMenuLabel() -> String 185 186 Returns the string that will be shown for the undo menu item. 187 %End 188 189 virtual 190 void Initialize(); 191 %Docstring 192 Initialize() 193 194 Initializes the command processor, setting the current command to the 195 last in the list (if any), and updating the edit menu (if one has been 196 specified). 197 %End 198 199 virtual 200 bool IsDirty() const; 201 %Docstring 202 IsDirty() -> bool 203 204 Returns a boolean value that indicates if changes have been made since 205 the last save operation. 206 %End 207 208 void MarkAsSaved(); 209 %Docstring 210 MarkAsSaved() 211 212 You must call this method whenever the project is saved if you plan to 213 use IsDirty(). 214 %End 215 216 virtual 217 bool Redo(); 218 %Docstring 219 Redo() -> bool 220 221 Executes (redoes) the current command (the command that has just been 222 undone if any). 223 %End 224 225 void SetEditMenu( 226 wxMenu * menu 227 ); 228 %Docstring 229 SetEditMenu(menu) 230 231 Tells the command processor to update the Undo and Redo items on this 232 menu as appropriate. 233 %End 234 235 virtual 236 void SetMenuStrings(); 237 %Docstring 238 SetMenuStrings() 239 240 Sets the menu labels according to the currently set menu and the 241 current command state. 242 %End 243 244 void SetRedoAccelerator( 245 const wxString & accel 246 ); 247 %Docstring 248 SetRedoAccelerator(accel) 249 250 Sets the string that will be appended to the Redo menu item. 251 %End 252 253 void SetUndoAccelerator( 254 const wxString & accel 255 ); 256 %Docstring 257 SetUndoAccelerator(accel) 258 259 Sets the string that will be appended to the Undo menu item. 260 %End 261 262 virtual 263 bool Submit( 264 wxCommand * command /Transfer/, 265 bool storeIt = true 266 ); 267 %Docstring 268 Submit(command, storeIt=True) -> bool 269 270 Submits a new command to the command processor. 271 %End 272 273 virtual 274 void Store( 275 wxCommand * command /Transfer/ 276 ); 277 %Docstring 278 Store(command) 279 280 Just store the command without executing it. 281 %End 282 283 virtual 284 bool Undo(); 285 %Docstring 286 Undo() -> bool 287 288 Undoes the last command executed. 289 %End 290 291 private: 292 wxCommandProcessor(const wxCommandProcessor&); 293 294 295 public: 296 297 298 %Property(name=Commands, get=GetCommands) 299 %Property(name=CurrentCommand, get=GetCurrentCommand) 300 %Property(name=EditMenu, get=GetEditMenu, set=SetEditMenu) 301 %Property(name=MaxCommands, get=GetMaxCommands) 302 %Property(name=RedoAccelerator, get=GetRedoAccelerator, set=SetRedoAccelerator) 303 %Property(name=RedoMenuLabel, get=GetRedoMenuLabel) 304 %Property(name=UndoAccelerator, get=GetUndoAccelerator, set=SetUndoAccelerator) 305 %Property(name=UndoMenuLabel, get=GetUndoMenuLabel) 306}; // end of class wxCommandProcessor 307 308 309class wxCommandList_iterator /Abstract/ 310{ 311 // the C++ implementation of this class 312 %TypeHeaderCode 313 typedef wxList wxCommandList; 314 class wxCommandList_iterator { 315 public: 316 wxCommandList_iterator(wxCommandList::compatibility_iterator start) 317 : m_node(start) {} 318 319 wxCommand* __next__() { 320 wxCommand* obj = NULL; 321 if (m_node) { 322 obj = (wxCommand*) m_node->GetData(); 323 m_node = m_node->GetNext(); 324 } 325 else { 326 PyErr_SetString(PyExc_StopIteration, ""); 327 } 328 return (wxCommand*)obj; 329 } 330 private: 331 wxCommandList::compatibility_iterator m_node; 332 }; 333 %End 334public: 335 wxCommand* __next__(); 336 %MethodCode 337 sipRes = sipCpp->__next__(); 338 if (PyErr_Occurred()) 339 return NULL; 340 %End 341}; 342 343class wxCommandList 344{ 345 %TypeHeaderCode 346 typedef wxList wxCommandList; 347 %End 348public: 349 SIP_SSIZE_T __len__(); 350 %MethodCode 351 sipRes = sipCpp->size(); 352 %End 353 354 wxCommand* __getitem__(long index); 355 %MethodCode 356 if (0 > index) 357 index += sipCpp->size(); 358 359 if (index < sipCpp->size() && (0 <= index)) { 360 wxCommandList::compatibility_iterator node = sipCpp->Item(index); 361 if (node) 362 sipRes = (wxCommand*)node->GetData(); 363 } 364 else { 365 wxPyErr_SetString(PyExc_IndexError, "sequence index out of range"); 366 sipError = sipErrorFail; 367 } 368 %End 369 370 int __contains__(const wxCommand* obj); 371 %MethodCode 372 wxCommandList::compatibility_iterator node; 373 node = sipCpp->Find((wxCommand*)obj); 374 sipRes = node != NULL; 375 %End 376 377 wxCommandList_iterator* __iter__() /Factory/; 378 %MethodCode 379 sipRes = new wxCommandList_iterator(sipCpp->GetFirst()); 380 %End 381 382 // TODO: add support for index(value, [start, [stop]]) 383 int index(wxCommand* obj); 384 %MethodCode 385 int idx = sipCpp->IndexOf((wxCommand*)obj); 386 if (idx == wxNOT_FOUND) { 387 sipError = sipErrorFail; 388 wxPyErr_SetString(PyExc_ValueError, 389 "sequence.index(x): x not in sequence"); 390 } 391 sipRes = idx; 392 %End 393 394 395}; 396 397%Extract(id=pycode_core) 398def _CommandList___repr__(self): 399 return "CommandList: " + repr(list(self)) 400CommandList.__repr__ = _CommandList___repr__ 401del _CommandList___repr__ 402%End 403 404 405 406//--------------------------------------------------------------------------- 407 408