1 2 #ifndef _UNDO_LIST_HEADER_ 3 #define _UNDO_LIST_HEADER_ 4 5 6 #define MAX_UNDO_ENTRIES 40 7 8 enum undo_types { 9 UNDO_TYPE_NONE = 0, 10 UNDO_TYPE_POSITION, 11 UNDO_TYPE_SIZE, 12 UNDO_TYPE_STYLE, 13 UNDO_TYPE_SLIDER_INFO, 14 UNDO_TYPE_PROGRESS_BAR_INFO, 15 UNDO_TYPE_RADIAL_PROGRES_BAR_INFO, 16 UNDO_TYPE_LIST_ROWS, 17 UNDO_TYPE_OPEN_HEIGHT, 18 UNDO_TYPE_DYNAMIC_TEXT_BUFFER, 19 UNDO_TYPE_TEXT_VIEW_LINE_SPACE, 20 UNDO_TYPE_TEXT_VIEW_WHITESPACE, 21 UNDO_TYPE_TEXT_BUFFER_SIZE, 22 UNDO_TYPE_SCROLL_APPEARANCE, 23 UNDO_TYPE_SCROLL_STYLE, 24 UNDO_TYPE_INSERT_WIDGET, 25 UNDO_TYPE_DELETE_WIDGET, 26 UNDO_TYPE_COLOR, 27 UNDO_TYPE_FONT, 28 UNDO_TYPE_PIXELMAP, 29 UNDO_TYPE_STRING, 30 UNDO_TYPE_NAMES, 31 UNDO_TYPE_USER_DATA, 32 UNDO_TYPE_ALLOCATION, 33 UNDO_TYPE_FOCUS, 34 UNDO_TYPE_CIRCULAR_GAUGE_INFO, 35 UNDO_TYPE_CHART_INFO, 36 UNDO_TYPE_SCROLL_WHEEL_INFO, 37 UNDO_TYPE_TEXT_SCROLL_WHEEL_INFO, 38 UNDO_TYPE_STRING_SCROLL_WHEEL_INFO, 39 UNDO_TYPE_NUMRIC_SCROLL_WHEEL_INFO, 40 UNDO_TYPE_TEMPLATE, 41 UNDO_TYPE_NUMERIC_PROMPT_INFO, 42 UNDO_TYPE_MENU_INFO, 43 UNDO_TYPE_TREE_VIEW_INFO, 44 UNDO_TYPE_VISIBLE_AT_STARTUP, 45 UNDO_TYPE_INSERT_FOLDER, 46 UNDO_TYPE_DELETE_FOLDER, 47 UNDO_TYPE_INSERT_TOP_LEVEL_WIDGETS, 48 UNDO_TYPE_RADIAL_SLIDER_INFO 49 }; 50 51 52 class undo_widget 53 { 54 public: undo_widget()55 undo_widget() { 56 parent_info = NULL; 57 copy_info = NULL; 58 res_index = 0; 59 project_info = NULL; 60 folder = NULL; 61 } 62 63 // pointer to the parent widget_info structure in project: 64 widget_info *parent_info; 65 66 // a copy of the widget information, so that we can revert changes 67 widget_info *copy_info; 68 69 // pointer to widget_info structure in the open project 70 widget_info *project_info; 71 72 // pointer to folder_info structure (only used when folder is modified) 73 folder_info *folder; 74 CString folder_name; // folder belongs to 75 int res_index; 76 }; 77 78 79 typedef struct 80 { 81 int type; 82 CArray<undo_widget> widget_list; 83 } undo_record; 84 85 class undo_manager { 86 public: 87 undo_manager(); 88 ~undo_manager(); 89 void AddEntry(int type, folder_info *folder, int display); 90 void AddEntry(int type, widget_info *info, int res_index = 0, BOOL fold = FALSE); 91 void AddEntry(int type, CArray<WIDGET_SELECT_ENTRY> &widget_list, BOOL fold = FALSE); 92 void Undo(); 93 void Reset(); CountEntries()94 int CountEntries() {return entries;} 95 96 private: 97 void ClearUndoRecord(undo_record *entry); LockAddEntry()98 void LockAddEntry(){ is_add_entry_locked = TRUE; }; FreeAddEntry()99 void FreeAddEntry(){ is_add_entry_locked = FALSE; }; IsAddEntryLocked()100 BOOL IsAddEntryLocked(){ return is_add_entry_locked; }; 101 102 void UpdateUndoRecordInfoPointers(widget_info *new_info, widget_info *old_info); 103 void SearchAndReplaceInfoPointers(undo_record *search, widget_info **node_list, int node_list_size); 104 widget_info **BuildInfoNodeArray(widget_info **write, widget_info *new_tree, widget_info *old_tree); 105 int CountInfoNodes(widget_info *start, int count); 106 107 undo_record *tail; 108 undo_record *current; 109 undo_record undo_list[MAX_UNDO_ENTRIES]; 110 int entries; 111 BOOL is_add_entry_locked; 112 }; 113 114 #endif 115 116