Changeset c2a9854 in thomson
- Timestamp:
- Feb 4, 2012, 7:43:03 PM (12 years ago)
- Branches:
- main
- Children:
- 53c4be3
- Parents:
- 192e299
- Location:
- elec/CrO2/software
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
elec/CrO2/software/Makefile
r192e299 rc2a9854 14 14 15 15 CC = g++ 16 CPPFLAGS = $(USBFLAGS) -O -Wall -I/usr/include/IUP/ -I/local/include -g-std=c++0x -mthreads17 LIBS = $(USBLIBS) -L/usr/lib/ -mwindows -liup-lcomctl32 -lole32 -mthreads16 CPPFLAGS = $(USBFLAGS) -Os -Wall -I/usr/include/IUP/ -I/local/include -std=c++0x -mthreads 17 LIBS = $(USBLIBS) -Os -L/usr/lib/ -mwindows -liup -liupcontrols -liupcd -lcd -lfreetype -lz -lcomctl32 -lole32 -mthreads 18 18 19 19 PROJECT = CrO2 -
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 -
elec/CrO2/software/gui.h
r192e299 rc2a9854 20 20 int menu_exit(); 21 21 22 K5* file; 23 24 // Control 22 25 int setPlaying(int state); 23 26 24 K5* file; 27 // Explore 28 int selectBlock(int id, int what); 29 const char* matVal(int x, int y); 30 Ihandle* blocklist; 31 Ihandle* hexEd; 25 32 }; -
elec/CrO2/software/iupplusplus.h
r192e299 rc2a9854 7 7 #include <iup.h> 8 8 9 template<class Handler, typename ... Args> class Callback9 template<class Handler, typename ret = int, typename... Args> class Callback 10 10 { 11 typedef int(Handler::*T)(Args... args);11 typedef ret(Handler::*T)(Args... args); 12 12 13 13 public: … … 27 27 } 28 28 29 static int call(Ihandle* that, Args... args)29 static ret call(Ihandle* that, Args... args) 30 30 { 31 31 Callback* call = (Callback*)IupGetAttribute(that, "LCALLBACK");
Note:
See TracChangeset
for help on using the changeset viewer.