Changeset c2a9854 in thomson for elec/CrO2/software/gui.cpp
- Timestamp:
- Feb 4, 2012, 7:43:03 PM (12 years ago)
- Branches:
- main
- Children:
- 53c4be3
- Parents:
- 192e299
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
elec/CrO2/software/gui.cpp
r192e299 rc2a9854 11 11 12 12 #include <stdint.h> 13 #include <string.h> 14 #include <sstream> 15 #include <iostream> 16 13 17 #include <iupcontrols.h> 14 18 … … 50 54 51 55 IupOpen(argc, argv); 52 //IupControlsOpen();56 IupControlsOpen(); 53 57 54 58 Ihandle* menu_open = IupItem("Open", NULL); … … 71 75 Ihandle* motoron = IupProgressBar(); 72 76 IupSetAttribute(motoron, "RASTERSIZE", "16x16"); 77 78 Ihandle* playToggle = IupToggle("play", NULL); 79 Callback<Gui, int, int>::create(playToggle, "ACTION", this, &Gui::setPlaying); 73 80 74 81 // EXPLORE … … 79 86 IupSetAttribute(platformlist, "VALUE", "1"); 80 87 81 Ihandle*blocklist = IupTree();88 blocklist = IupTree(); 82 89 IupSetAttribute(blocklist, "EXPAND", "VERTICAL"); 83 84 Ihandle* playToggle = IupToggle("play", NULL); 85 Callback<Gui, int>::create(playToggle, "ACTION", this, &Gui::setPlaying); 86 90 IupSetAttribute(blocklist, "ADDEXPANDED", "NO"); 91 IupSetAttribute(blocklist, "ADDROOT", "NO"); 92 IupSetAttribute(blocklist, "IMAGELEAF", "IMGBLANK"); 93 IupSetAttribute(blocklist, "RASTERSIZE", "140x200"); 94 Callback<Gui, int, int, int>::create(blocklist, "SELECTION_CB", this, &Gui::selectBlock); 95 96 Ihandle* hexEd = IupMatrix(NULL); 97 98 // Setup title cells 99 IupSetAttribute(hexEd, "NUMLIN", "16"); 100 IupSetAttribute(hexEd, "NUMCOL", "17"); 101 IupSetAttribute(hexEd, "WIDTHDEF", "12"); 102 IupSetAttribute(hexEd, "WIDTH17", "48"); 103 IupSetAttribute(hexEd, "USETITLESIZE", "YES"); 104 IupSetAttribute(hexEd, "FONT", "Courier, Bold 12"); 105 IupSetAttribute(hexEd, "EXPAND", "YES"); 106 Callback<Gui, const char*, int, int>::create(hexEd, "VALUE_CB", this, &Gui::matVal); 107 108 // WINDOW LAYOUT 87 109 Ihandle* tabs = IupTabs( 88 110 IupVbox( … … 108 130 blocklist, 109 131 IupVbox( 110 // IupMatrix(NULL),132 hexEd, 111 133 IupLabel("Checksum:"), 112 134 NULL … … 129 151 startPolling(motoron); 130 152 153 // TODO the IUP main loop is blocking - it may be wise to move it out of 154 // the constructor... 131 155 IupMainLoop(); 132 156 } 157 158 159 Gui::~Gui() 160 { 161 delete file; 162 163 IupControlsClose(); 133 164 IupClose(); 134 }135 136 137 Gui::~Gui()138 {139 delete file;140 165 } 141 166 … … 149 174 // Load file 150 175 file = new K5(name); 176 177 // Fill in EXPLORE tab 178 int count = file->getBlockCount(); 179 int lastfile = -1; 180 181 for (int i = 0; i < count; ++i) 182 { 183 const K5::Block& blk = file->getBlock(i); 184 switch(blk.type) 185 { 186 case 0: 187 //start block 188 char name[12]; 189 memcpy(name, blk.data, 11); 190 name[11] = 0; 191 192 IupSetAttributeId(blocklist, "INSERTBRANCH", lastfile, name); 193 lastfile = i; 194 break; 195 case 0xFF: 196 // end block 197 IupSetAttributeId(blocklist, "ADDLEAF", i-1, "EOF"); 198 IupSetAttributeId(blocklist, "IMAGE", i, "IMGLEAF"); 199 break; 200 default: 201 // regular block 202 IupSetAttributeId(blocklist, "ADDLEAF", i-1, "DATA"); 203 break; 204 } 205 } 151 206 } 152 207 return IUP_DEFAULT; … … 156 211 { 157 212 return IUP_CLOSE; 213 } 214 215 int Gui::selectBlock(int id, int what) 216 { 217 if (what) 218 { 219 IupSetAttribute(hexEd, "REDRAW", "ALL"); 220 } 221 222 return IUP_DEFAULT; 223 } 224 225 const char* Gui::matVal(int x, int y) 226 { 227 if (x == 0) 228 { 229 switch(y) 230 { 231 case 0: 232 return "0x"; 233 case 17: 234 return "ASCII"; 235 default: 236 { 237 std::ostringstream name; 238 name << std::hex; 239 name << (y-1); 240 return name.str().c_str(); 241 } 242 } 243 } 244 245 if (y == 0) 246 { 247 return "C"; 248 } 249 250 return "V"; 158 251 } 159 252
Note:
See TracChangeset
for help on using the changeset viewer.