diff --git a/CHANGELOG b/CHANGELOG index 73a4d58..ce5b5c9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,22 @@ Ideas for future versions: Solaris (and possibly other platforms) - Perhaps change to SVG for objects +Version 1.9: +- Fixed bug with exporting beziers to SVG +- Added support for text cursor movement when editting text +- Added emacs keys for text edits (ctrl-u, ctrl-k, ctrl-a) +- Added export to PNG format +- Export to PNG/BMP now no longer include gridlines/statusbar/scrollbars +- Fixed crash when changing to zero gridsize +- now re-calcing scrollbar size whenever diagram is modified +- can no longer accidentally change maps while scrolling vertically +- fixed graphical glitch when editting text while scrolled +- clicking mouse while entering text is now the same as pressing enter +- findnext now works again +- when searching, the found object is more obviously highlighted + + +======= Version 1.8d: - Fixed bug with Ellipse objects when exporting to SVG - Fixed slowdown when creating new links @@ -16,6 +32,7 @@ Version 1.8c: - when searching, the found object is more obviously highlighted +>>>>>>> .r60 Version 1.8b: - Fixed placement of text fields in dialog screens diff --git a/constants.h b/constants.h index f537318..5bab3ff 100644 --- a/constants.h +++ b/constants.h @@ -1,4 +1,4 @@ -#define VERSION "1.8d" +#define VERSION "1.9" /* variable sizes */ #define SMALLBUFLEN 64 /* small text buffer */ diff --git a/dist.sh b/dist.sh index e2eaef6..9297111 100755 --- a/dist.sh +++ b/dist.sh @@ -15,7 +15,8 @@ rm -rf ${FULLNAME} mkdir ${FULLNAME} -cp README.txt INSTALL.txt objects.dat buttons.dat netmapr.exe netmapr.c netmapr.h constants.h convert.c convert.h verdana.ttf example.map icon.bmp windows_files/*.dll ${FULLNAME}/ +#cp README.txt INSTALL.txt objects.dat buttons.dat netmapr.exe netmapr.c netmapr.h constants.h convert.c convert.h verdana.ttf example.map icon.bmp windows_files/*.dll ${FULLNAME}/ +cp README.txt INSTALL.txt objects.dat buttons.dat netmapr.exe netmapr.c netmapr.h constants.h convert.c convert.h verdana.ttf example.map icon.bmp dlls/*.dll ${FULLNAME}/ cp -R doc ${FULLNAME}/ rm -rf ${FULLNAME}/doc/CVS rm -rf ${FULLNAME}/doc/.svn diff --git a/netmapr.c b/netmapr.c index fe45753..8554777 100644 --- a/netmapr.c +++ b/netmapr.c @@ -13,6 +13,7 @@ #include #include +#include "savepng.h" #include "netmapr.h" #include "constants.h" @@ -154,6 +155,7 @@ int textanchor; char text[BUFLEN]; int startobj,endobj; int updateheight; +char * textpos; // new char progdir[BUFLEN]; @@ -303,7 +305,8 @@ int main (int argc, char **argv) { /* set screen size */ screen = SDL_SetVideoMode(event.resize.w > MINSCREENX ? event.resize.w : MINSCREENX, event.resize.h > MINSCREENY ? event.resize.h : MINSCREENY, - map[curmap].bpp, SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE); + //map[curmap].bpp, SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE); + map[curmap].bpp, SDL_SWSURFACE|SDL_RESIZABLE); SDL_FreeSurface(buffer); buffer = SDL_CreateRGBSurface(SDL_SWSURFACE,screen->w - SIDEBARW,screen->h - STATUSH, screen->format->BitsPerPixel, screen->format->Rmask, @@ -340,7 +343,7 @@ int main (int argc, char **argv) { screenx = event.button.x - ((screen->w - SIDEBARW)/2); screeny = event.button.y - ((screen->h - STATUSH)/2); validatescreenpos(); - drawmap(); + drawmap(TRUE); } else if ((event.button.button == SDL_BUTTON_LEFT) && ((mod & KMOD_CTRL) == 0)) { /* is there a selected link? if so check for it first */ if ((map[curmap].selecteditemtype == T_LINK) && (map[curmap].selecteditem != -1) && @@ -476,7 +479,7 @@ int main (int argc, char **argv) { if ((state == S_XSCROLL) || (state == S_YSCROLL)) { changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if (state == S_EDITTEXT) { endtextedit(); } else if (state == S_TYPETEXT) { @@ -501,7 +504,7 @@ int main (int argc, char **argv) { sprintf(statustext, "Cannot drill down - object has no children (use drill tool to create one)."); map[curmap].selecteditem = -1; changestate(S_NONE); - drawmap(); + drawmap(TRUE); } } else { o = textat(event.button.x, event.button.y); @@ -516,7 +519,7 @@ int main (int argc, char **argv) { map[curmap].selecteditem = -1; map[curmap].selecteditemtype = T_EMPTY; sprintf(statustext,"Objects/lines deselected.\n"); - drawmap(); + drawmap(TRUE); } } else if (state == S_DRAWFLOW) { int clickedtype = -1; @@ -537,7 +540,7 @@ int main (int argc, char **argv) { if (clickedtype == -1) { /* reset to old showflows value */ changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else { toggleflow(o, clickedtype); if (isflow(o, clickedtype)) { @@ -547,7 +550,7 @@ int main (int argc, char **argv) { setinfo(255); sprintf(statustext, "%s #%d traffic flow status = FALSE.", typedesc[clickedtype], o); } - drawmap(); + drawmap(TRUE); } } else if (state == S_REALLYQUIT) { o = getyn(event.button.x-screenx, event.button.y-screeny); @@ -555,7 +558,7 @@ int main (int argc, char **argv) { done = TRUE; } else { changestate(S_NONE); - drawmap(); + drawmap(TRUE); } } else if (state == S_MATCHSIZE) { if (matchtype == T_OBJECT) { @@ -582,7 +585,7 @@ int main (int argc, char **argv) { } changestate(S_NONE); sprintf(statustext, "Object #%d resized to match object #%d.",map[curmap].selecteditem,o); - drawmap(); + drawmap(TRUE); } } else if (matchtype == T_TEXT) { o = textat(event.button.x, event.button.y); @@ -599,7 +602,7 @@ int main (int argc, char **argv) { /* adjust offsets on all links to/from object */ changestate(S_NONE); sprintf(statustext, "Text #%d resized to match text #%d.",map[curmap].selecteditem,o); - drawmap(); + drawmap(TRUE); } } } else if (state == S_MATCHX) { @@ -618,7 +621,7 @@ int main (int argc, char **argv) { (map[curmap].obj[map[curmap].selecteditem].w/2); changestate(S_NONE); sprintf(statustext, "Object #%d X relocated to match object #%d.",map[curmap].selecteditem,o); - drawmap(); + drawmap(TRUE); } } else if (matchtype == T_TEXT) { o = textat(event.button.x, event.button.y); @@ -639,7 +642,7 @@ int main (int argc, char **argv) { changestate(S_NONE); sprintf(statustext, "Text #%d X relocated to match text #%d.",map[curmap].selecteditem,o); - drawmap(); + drawmap(TRUE); } } } else if (state == S_MATCHY) { @@ -657,7 +660,7 @@ int main (int argc, char **argv) { map[curmap].obj[map[curmap].selecteditem].h/2; changestate(S_NONE); sprintf(statustext, "Object #%d Y relocated to match object #%d.",map[curmap].selecteditem,o); - drawmap(); + drawmap(TRUE); } } else if (matchtype == T_TEXT) { o = textat(event.button.x, event.button.y); @@ -684,7 +687,7 @@ int main (int argc, char **argv) { /* match middle of text */ changestate(S_NONE); sprintf(statustext, "Text #%d Y relocated to match text #%d.",map[curmap].selecteditem,o); - drawmap(); + drawmap(TRUE); } } } else if (state == S_OBJMOVING) { @@ -695,14 +698,14 @@ int main (int argc, char **argv) { map[curmap].selecteditemtype = T_OBJECT; changestate(S_NONE); sprintf(statustext, "Object #%d (%s) selected.\n",map[curmap].selecteditem, objtype[map[curmap].obj[map[curmap].selecteditem].type].name); - drawmap(); + drawmap(TRUE); } else { // actually move the object if (!endobjmove(event.button.x, event.button.y)) { sprintf(statustext, "Object #%d moved to (%d,%d).\n",map[curmap].curobj,event.button.x, event.button.y); } changestate(S_NONE); - drawmap(); + drawmap(TRUE); } } else if (state == S_LINKMOVING) { @@ -713,13 +716,13 @@ int main (int argc, char **argv) { map[curmap].selecteditemtype = T_LINK; changestate(S_NONE); sprintf(statustext,"Link #%d selected.\n",map[curmap].selecteditem); - drawmap(); + drawmap(TRUE); } else { // actually move the link endlinkmove(event.button.x, event.button.y); changestate(S_NONE); sprintf(statustext,"Link #%d moved to (%d,%d).\n",map[curmap].curlink,event.button.x, event.button.y); - drawmap(); + drawmap(TRUE); } } else if (state == S_LINKPOINTMOVE) { /* has mouse actually moved? */ @@ -730,12 +733,12 @@ int main (int argc, char **argv) { map[curmap].selectedlinkpoint = map[curmap].curlinkpoint; changestate(S_NONE); sprintf(statustext,"Link #%d point #%d selected.\n",map[curmap].selecteditem,map[curmap].selectedlinkpoint); - drawmap(); + drawmap(TRUE); } else { // actually move the link endlinkpointmove(event.button.x, event.button.y); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } } else if (state == S_TEXTMOVING) { /* has mouse actually moved? */ @@ -745,30 +748,30 @@ int main (int argc, char **argv) { map[curmap].selecteditemtype = T_TEXT; changestate(S_NONE); sprintf(statustext,"Text item #%d selected.\n",map[curmap].selecteditem); - drawmap(); + drawmap(TRUE); } else { // actually move the text if (!endtextmove(event.button.x, event.button.y)) { sprintf(statustext,"Text item #%d moved to (%d,%d).\n",map[curmap].curtext,event.button.x, event.button.y); } changestate(S_NONE); - drawmap(); + drawmap(TRUE); } } else if (state == S_LINKSRCMOVE) { // actually move the link src endpoint endlinksrcmove(event.button.x, event.button.y); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if (state == S_LINKDSTMOVE) { // actually move the link dst endpoint endlinkdstmove(event.button.x, event.button.y); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if (state == S_ADDOBJ) { /* create a new object */ createobject(map[curmap].selectedtype, event.button.x, event.button.y); - drawmap(); + drawmap(TRUE); changestate(S_NONE); } else if (state == S_ADDTEXT) { /* start listening for text input */ @@ -782,6 +785,7 @@ int main (int argc, char **argv) { updateheight = DEFTEXTH; strcpy(text, ""); + textpos = text; bg = NULL; updatetextcursor(); @@ -802,7 +806,7 @@ int main (int argc, char **argv) { sprintf(statustext, "Fill colour selected: R=%d,G=%d,B=%d",objfillcol.r,objfillcol.g,objfillcol.b); } changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if (state == S_FGCOL) { getcolor(screen, event.button.x, event.button.y, &fgcol); if (map[curmap].selecteditem != -1) { @@ -826,7 +830,7 @@ int main (int argc, char **argv) { sprintf(statustext, "Foreground colour selected: R=%d,G=%d,B=%d",fgcol.r,fgcol.g,fgcol.b); } changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if (state == S_CREATETELE) { int pos; @@ -839,7 +843,7 @@ int main (int argc, char **argv) { strcpy(oldstatustext, statustext); setmod(TRUE); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if ((pos+maplistpos) <= (nummaps-1)) { if ((map[curmap].selecteditem != -1) && (map[curmap].selecteditemtype == T_OBJECT)) { if ((pos+maplistpos) != curmap) { @@ -848,7 +852,7 @@ int main (int argc, char **argv) { strcpy(oldstatustext, statustext); setmod(TRUE); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else { seterror(255); sprintf(statustext, "ERROR: Cannot link to current map!"); @@ -858,12 +862,12 @@ int main (int argc, char **argv) { } else { /* mouse is not over a map name */ sprintf(statustext, "Map link creation cancelled."); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } } else { sprintf(statustext, "Map link creation cancelled."); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } } @@ -889,7 +893,7 @@ int main (int argc, char **argv) { map[curmap].obj[map[curmap].selecteditem].type = seltype; state = S_NONE; drawtoolbox(); - drawmap(); + drawmap(TRUE); } } else { map[curmap].selectedtype = tempy*obox.gridrowlen + tempx + (obox.pos*3); @@ -909,7 +913,7 @@ int main (int argc, char **argv) { bg = NULL; strcpy(text, map[curmap].name); changestate(S_MAPNAMING); - drawmap(); + drawmap(TRUE); break; } else if (isonmapboxchildren(event.button.x, event.button.y)) { if ((state != S_XSCROLL) && (state != S_YSCROLL)) { @@ -946,7 +950,7 @@ int main (int argc, char **argv) { fgcol = black; sprintf(statustext, "Foreground colour selected: R=0,G=0,B=0"); changestate(S_NONE); - drawmap(); + drawmap(TRUE); break; } else if (state == S_FILLCOL) { /* set bgcol to 'nothing' */ @@ -964,7 +968,7 @@ int main (int argc, char **argv) { sprintf(statustext, "Fill colour removed."); } changestate(S_NONE); - drawmap(); + drawmap(TRUE); break; } @@ -998,11 +1002,11 @@ int main (int argc, char **argv) { showflows = TRUE; } drawtoolbox(); - drawmap(); + drawmap(TRUE); break; case TB_GRID: togglegrid(); - drawmap(); + drawmap(TRUE); break; case TB_NEW: if (readonly) { @@ -1025,7 +1029,7 @@ int main (int argc, char **argv) { sprintf(statustext, "All maps cleared."); sprintf(oldstatustext, statustext); - drawmap(); + drawmap(TRUE); break; case TB_LINESTYLE: if (map[curmap].selecteditemtype == T_LINK) { @@ -1050,7 +1054,7 @@ int main (int argc, char **argv) { map[curmap].olink[si].style |= (defarrow << 16); } setmod(TRUE); - drawmap(); + drawmap(TRUE); } else { seterror(255); sprintf(statustext, "No link selected!"); @@ -1068,7 +1072,7 @@ int main (int argc, char **argv) { case T_TEXT: matchtype = map[curmap].selecteditemtype; changestate(S_MATCHSIZE); - drawmap(); + drawmap(TRUE); break; } } @@ -1080,7 +1084,7 @@ int main (int argc, char **argv) { case T_TEXT: matchtype = map[curmap].selecteditemtype; changestate(S_MATCHX); - drawmap(); + drawmap(TRUE); break; } } @@ -1116,7 +1120,7 @@ int main (int argc, char **argv) { seterror(255); sprintf(statustext, "No object selected! (use RMB to select new foreground colour)"); } - drawmap(); + drawmap(TRUE); break; case TB_FILLCOL: if (map[curmap].selecteditem != -1) { @@ -1137,7 +1141,7 @@ int main (int argc, char **argv) { seterror(255); sprintf(statustext, "No object selected! (use RMB to select new fill colour)"); } - drawmap(); + drawmap(TRUE); break; case TB_DELETEMAP: /* safety - must hold down SHIFT to delete maps */ @@ -1218,14 +1222,14 @@ int main (int argc, char **argv) { history[n]--; } } - drawmap(); + drawmap(TRUE); break; case TB_CREATETELE: if ((map[curmap].selecteditemtype == T_OBJECT) && (map[curmap].selecteditem != -1)) { setinfo(255); sprintf(statustext,"Select destination map to link to..."); changestate(S_CREATETELE); - drawmap(); + drawmap(TRUE); } else { seterror(255); sprintf(statustext,"Cannot create map link - no object selected!"); @@ -1248,7 +1252,7 @@ int main (int argc, char **argv) { bg = NULL; strcpy(text, currentfilename); changestate(S_SAVING); - drawmap(); + drawmap(TRUE); break; case TB_LOAD: startx = 1; @@ -1256,7 +1260,7 @@ int main (int argc, char **argv) { bg = NULL; strcpy(text, currentfilename); changestate(S_LOADING); - drawmap(); + drawmap(TRUE); break; } @@ -1271,7 +1275,7 @@ int main (int argc, char **argv) { endobj = o; endlink(event.button.x,event.button.y); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else { pasteline(screen,linebg); sprintf(statustext,"Aborting link #%d.\n", map[curmap].numlinks); @@ -1286,7 +1290,7 @@ int main (int argc, char **argv) { /* select the link */ map[curmap].selecteditemtype = T_LINK; map[curmap].selecteditem = o; - drawmap(); + drawmap(TRUE); } } @@ -1297,7 +1301,7 @@ int main (int argc, char **argv) { // end resize endresize(event.button.x, event.button.y); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if (state == S_TEXTRESIZING) { // end text resize endtextresize(event.button.x, event.button.y); @@ -1339,22 +1343,22 @@ int main (int argc, char **argv) { break; case TB_GRID: changegridsize(); - drawmap(); + drawmap(TRUE); break; case TB_FLOW: oldshowflows = showflows; showflows = TRUE; drawtoolbox(); changestate(S_DRAWFLOW); - drawmap(); + drawmap(TRUE); break; case TB_FGCOL: changestate(S_FGCOL); - drawmap(); + drawmap(TRUE); break; case TB_FILLCOL: changestate(S_FILLCOL); - drawmap(); + drawmap(TRUE); break; case TB_MATCHPOS: /* match y */ if (map[curmap].selecteditem != -1) { @@ -1363,7 +1367,7 @@ int main (int argc, char **argv) { case T_TEXT: matchtype = map[curmap].selecteditemtype; changestate(S_MATCHY); - drawmap(); + drawmap(TRUE); break; } } @@ -1566,7 +1570,7 @@ int main (int argc, char **argv) { drawstatusbar(); break; case TB_SAVE: - sprintf(statustext, "LMB = Save the current map to disk (will automatically export based on extensions of BMP or SVG)"); + sprintf(statustext, "LMB = Save the current map to disk (will automatically export based on extensions of BMP/PNG/SVG)"); drawstatusbar(); break; default: @@ -1627,7 +1631,7 @@ int main (int argc, char **argv) { if (modified) { strcpy(text, "Changes not saved - really quit?"); changestate(S_REALLYQUIT); - drawmap(); + drawmap(TRUE); } else { done = TRUE; } @@ -1684,20 +1688,77 @@ int main (int argc, char **argv) { } /* state dependant */ if ((state == S_TYPETEXT) || (state == S_SAVING) || (state == S_LOADING) || (state == S_MAPNAMING) || (state == S_EDITTEXT) || (state == S_SEARCH)) { - if ((c >= FIRSTLET) && (c <= LASTLET)) { +// ooooooooooooooo + if ((c2 == 'u') && (mod & KMOD_CTRL)) { + // delete from start to text pos + strcpy(text, textpos); + //text[0] = '\0'; + textpos = text; + updatetextcursor(); + } else if ((c2 == 'k') && (mod & KMOD_CTRL)) { + // delete from here to end + *textpos = '\0'; + updatetextcursor(); + } else if ((c2 == 'a') && (mod & KMOD_CTRL)) { + // go to start of text + textpos = text; + updatetextcursor(); + } else if ((c >= FIRSTLET) && (c <= LASTLET)) { + // add onto end of text char temptext[2]; + char endbit[BUFLEN]; + // remember from here until end + if (textpos) { + strcpy(endbit, textpos); + } else { + endbit[0] = '\0'; + } + // end here + *textpos = '\0'; + // append char sprintf(temptext, "%c", c); strcat(text, temptext); + // move cursor to end of appended bit + textpos = &text[strlen(text)]; + // append end bit + if (strlen(endbit) > 0) { + strcat(text, endbit); + } + // updatetextcursor(); + } else if (c2 == SDLK_LEFT) { + // move cursor + if (textpos != text) textpos--; + updatetextcursor(); + } else if (c2 == SDLK_RIGHT) { + if (textpos != &text[strlen(text)]) textpos++; + updatetextcursor(); +//oooooooooo } else if (c2 == SDLK_ESCAPE) { sprintf(statustext, "Aborted."); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if (c == ' ') { + // add onto end of text + char endbit[BUFLEN]; + // remember from here until end + strcpy(endbit, textpos); + // end here + *textpos = '\0'; + // append char strcat(text, " "); + // move cursor to end of appended bit + textpos = &text[strlen(text)]; + // append end bit + strcat(text, endbit); updatetextcursor(); } else if (c2 == SDLK_BACKSPACE) { - text[strlen(text)-1] = '\0'; + // remove last charater + if (textpos != text) { + strcpy(textpos-1, textpos); + } + //text[strlen(text)-1] = '\0'; + textpos--; updatetextcursor(); } else if (c == 13) { /* enter */ if (state == S_TYPETEXT) { @@ -1707,11 +1768,11 @@ int main (int argc, char **argv) { } else if (state == S_SAVING) { savemap(); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if (state == S_LOADING) { loadmap(); changestate(S_NONE); - drawmap(); + drawmap(TRUE); } else if (state == S_SEARCH) { changestate(S_NONE); if (dosearch()) { @@ -1723,26 +1784,26 @@ int main (int argc, char **argv) { sprintf(statustext, "Found '%s' in text object #%d (map '%s')",searchtext, map[curmap].selecteditem, map[curmap].name); setsearchflash(255); } - drawmap(); + drawmap(TRUE); } else if (state == S_MAPNAMING) { /* rename map */ strcpy(map[curmap].name,text); changestate(S_NONE); setinfo(255); sprintf(statustext, "Map #%d renamed to '%s'.",curmap,map[curmap].name); - drawmap(); + drawmap(TRUE); } } } else { if (c2 == SDLK_HOME) { screenx = 0; screeny = 0; - drawmap(); + drawmap(TRUE); } if (c2 == SDLK_END) { screenx = map[curmap].width - (screen->w-SIDEBARW); screeny = map[curmap].height - (screen->h-STATUSH); - drawmap(); + drawmap(TRUE); } if (c == 'a') { /* add map[curmap].object */ if (state == S_NONE) { @@ -1756,7 +1817,7 @@ int main (int argc, char **argv) { bg = NULL; strcpy(text, ""); changestate(S_SEARCH); - drawmap(); + drawmap(TRUE); } } if (c == 'n') { /* find next */ @@ -1770,7 +1831,7 @@ int main (int argc, char **argv) { sprintf(statustext, "Foundnext %s'%s' in text object #%d (map '%s')",searchwrap ? "(wrapped) " : "",searchtext, map[curmap].selecteditem, map[curmap].name); setsearchflash(255); } - drawmap(); + drawmap(TRUE); } if (c == 'm') { /* modify object type */ if (state == S_NONE) { @@ -1799,16 +1860,18 @@ int main (int argc, char **argv) { starty = ((screen->h-STATUSH)/2)-2; bg = NULL; strcpy(text, currentfilename); + textpos = &text[strlen(text)]; changestate(S_SAVING); - drawmap(); + drawmap(TRUE); } if ((c == 'l') || (c == 'o')) { /* load, open */ startx = 1; starty = ((screen->h-STATUSH)/2)-2; bg = NULL; strcpy(text, currentfilename); + textpos = &text[strlen(text)]; changestate(S_LOADING); - drawmap(); + drawmap(TRUE); } if ((c == ',') || (c == 'q')) { /* scroll object box up */ if (state == S_CREATETELE) { @@ -1845,7 +1908,7 @@ int main (int argc, char **argv) { case T_TEXT: matchtype = map[curmap].selecteditemtype; changestate(S_MATCHX); - drawmap(); + drawmap(TRUE); break; } } @@ -1857,7 +1920,7 @@ int main (int argc, char **argv) { case T_TEXT: matchtype = map[curmap].selecteditemtype; changestate(S_MATCHY); - drawmap(); + drawmap(TRUE); break; } } @@ -1869,7 +1932,7 @@ int main (int argc, char **argv) { case T_TEXT: matchtype = map[curmap].selecteditemtype; changestate(S_MATCHSIZE); - drawmap(); + drawmap(TRUE); break; } } @@ -1880,7 +1943,7 @@ int main (int argc, char **argv) { } if (c == ';') { /* change gridsize */ changegridsize(); - drawmap(); + drawmap(TRUE); } if (c == 'c') { /* copy */ copy(); @@ -1911,7 +1974,7 @@ int main (int argc, char **argv) { showflows = TRUE; } drawtoolbox(); - drawmap(); + drawmap(TRUE); } if ((c == 'p') || (c == 'v')) { /* paste */ paste(); @@ -1993,7 +2056,7 @@ int main (int argc, char **argv) { } sprintf(statustext, "Deleted link #%d point #%d.",map[curmap].selecteditem,map[curmap].selectedlinkpoint); - drawmap(); + drawmap(TRUE); } else { deletething(map[curmap].selecteditem,map[curmap].selecteditemtype); } @@ -2171,6 +2234,19 @@ void calcmapdimensions(void) { } +int setgridsize(int size) { + int n; + for (n = 0; n < gridsizenum; n++) { + if (gridsizelist[n] == size) { + gridsizeindex = n; + gridsize = gridsizelist[n]; + return FALSE; + } + } + + return TRUE; +} + void changegridsize(void) { if (++gridsizeindex >= gridsizenum) { gridsizeindex = 0; @@ -2197,7 +2273,7 @@ void changelinearrow(int changeby) { map[curmap].olink[map[curmap].selecteditem].style &= 0x00ffff; map[curmap].olink[map[curmap].selecteditem].style |= (defarrow << 16); setmod(TRUE); - drawmap(); + drawmap(TRUE); } } @@ -2220,7 +2296,7 @@ void changelinestyle(int changeby) { map[curmap].olink[map[curmap].selecteditem].style &= 0xff00ff; map[curmap].olink[map[curmap].selecteditem].style |= (defstyle << 8); setmod(TRUE); - drawmap(); + drawmap(TRUE); } } @@ -2240,7 +2316,7 @@ void changelinethickness(int changeby) { map[curmap].olink[map[curmap].selecteditem].style &= 0xffff00; map[curmap].olink[map[curmap].selecteditem].style |= defthickness; setmod(TRUE); - drawmap(); + drawmap(TRUE); } } @@ -2284,12 +2360,12 @@ void changestate(int newstate) { state = newstate; if (oldstate == S_DRAWFLOW) { - drawmap(); + drawmap(TRUE); } drawtoolbox(); switch (state) { case S_NONE: - //sprintf(statustext,"Selection mode enabled.\n"); fflush(stdout); + //sprintf(statustext,"Selection mode enabled.\n"); fflush(STDOUT); if (oldstate == S_DRAWFLOW) { sprintf(statustext,"Traffic flow definition complete."); } @@ -2555,7 +2631,7 @@ void deletething(int id, int type) { setmod(TRUE); map[curmap].selecteditem = -1; map[curmap].selecteditemtype = -1; - drawmap(); + drawmap(TRUE); } void deletelink(int linkid) { @@ -3706,7 +3782,7 @@ void drawobject(SDL_Surface *dest, mapobject_t *o, int doublebuffer, int adjust) /* create temp surface */ if (testing) { printf("About to create surface..."); - fflush(stdout); + fflush(STDOUT); } if (doublebuffer) { temps = SDL_CreateRGBSurface(SDL_SWSURFACE,o->w+3, o->h+3, @@ -3723,7 +3799,7 @@ void drawobject(SDL_Surface *dest, mapobject_t *o, int doublebuffer, int adjust) /* draw onto temp surface */ if (testing) { printf("About to drawvector ..."); - fflush(stdout); + fflush(STDOUT); } if (o->fillcol.unused & USECOLOUR) { drawvector(temps, &objtype[o->type].vimg, 0, 0, o->w, o->h, NULL, &o->fillcol); @@ -3734,7 +3810,7 @@ void drawobject(SDL_Surface *dest, mapobject_t *o, int doublebuffer, int adjust) /* set transparent colour on temp surface */ if (testing) { printf("About to setcolour ..."); - fflush(stdout); + fflush(STDOUT); } SDL_SetColorKey(temps, SDL_SRCCOLORKEY|SDL_RLEACCEL, bgcol); @@ -3750,7 +3826,7 @@ void drawobject(SDL_Surface *dest, mapobject_t *o, int doublebuffer, int adjust) area.h = o->h; if (testing) { printf("About to blitsurface ..."); - fflush(stdout); + fflush(STDOUT); } SDL_BlitSurface(temps, 0, dest, &area); SDL_FreeSurface(temps); @@ -3761,7 +3837,7 @@ void drawobject(SDL_Surface *dest, mapobject_t *o, int doublebuffer, int adjust) if (testing) { printf("About to return ..."); - fflush(stdout); + fflush(STDOUT); } } @@ -3846,7 +3922,7 @@ void drawpixel(SDL_Surface *screen, int x, int y, SDL_Color c) { //SDL_UpdateRect(screen, x, y, 1, 1); } -void drawmap(void) { +void drawmap(int wantdecs) { int i; int testing = 0; SDL_Rect area; @@ -3881,50 +3957,52 @@ void drawmap(void) { } if (testing) { - printf("START DRAWMAP\n"); fflush(stdout); + printf("START DRAWMAP\n"); fflush(STDOUT); } /* clear map */ fillcol = SDL_MapRGB(buffer->format, map[curmap].bgcol.r,map[curmap].bgcol.g,map[curmap].bgcol.b); SDL_FillRect(buffer, NULL, fillcol); - /* always draw grid */ - for (x = 0; x < screen->w - SIDEBARW; x += (gridsize*2)) { - drawline(buffer,x,0,x,(screen->h - STATUSH), gridcol, (LS_BIGDASH << 8) | 1); - if ((x+gridsize) < screen->w - SIDEBARW) { - drawline(buffer,x+gridsize,0,x+gridsize,(screen->h - DEFTEXTH-2), gridcol, (LS_DOTTED << 8) | 1); + /* draw grid */ + if (gridsize != 0) { + for (x = 0; x < screen->w - SIDEBARW; x += (gridsize*2)) { + drawline(buffer,x,0,x,(screen->h - STATUSH), gridcol, (LS_BIGDASH << 8) | 1); + if ((x+gridsize) < screen->w - SIDEBARW) { + drawline(buffer,x+gridsize,0,x+gridsize,(screen->h - DEFTEXTH-2), gridcol, (LS_DOTTED << 8) | 1); + } } - } - for (y = 0; y < screen->h - STATUSH; y += (gridsize*2)) { - drawline(buffer,0,y,screen->w - SIDEBARW, y,gridcol, (LS_BIGDASH << 8) | 1); - if ((y+gridsize) < (screen->h - STATUSH)) { - drawline(buffer,0,y+gridsize,screen->w - SIDEBARW, y+gridsize,gridcol, (LS_DOTTED << 8) | 1); + for (y = 0; y < screen->h - STATUSH; y += (gridsize*2)) { + drawline(buffer,0,y,screen->w - SIDEBARW, y,gridcol, (LS_BIGDASH << 8) | 1); + if ((y+gridsize) < (screen->h - STATUSH)) { + drawline(buffer,0,y+gridsize,screen->w - SIDEBARW, y+gridsize,gridcol, (LS_DOTTED << 8) | 1); + } } } if (testing) { - printf("DRAWING THINGS \n"); fflush(stdout); + printf("DRAWING THINGS \n"); fflush(STDOUT); } /* draw all map[curmap].objects links etc*/ for (i = 0; i < map[curmap].numthings; i++) { if (map[curmap].thing[i].type == T_OBJECT) { - if (testing) { printf("Drawing thing #%d (%d, %s)\n",i,map[curmap].thing[i].id,objtype[map[curmap].obj[map[curmap].thing[i].id].type].name); fflush(stdout); } + if (testing) { printf("Drawing thing #%d (%d, %s)\n",i,map[curmap].thing[i].id,objtype[map[curmap].obj[map[curmap].thing[i].id].type].name); fflush(STDOUT); } if (!isflow(map[curmap].thing[i].id, T_OBJECT)) { drawobject(buffer, &map[curmap].obj[map[curmap].thing[i].id], TRUE, TRUE); thingdrawn[i] = TRUE; } } else if (map[curmap].thing[i].type == T_LINK) { - if (testing) { printf ("Drawing thing #%d (%d, link)\n",i,map[curmap].thing[i].id); fflush(stdout); } + if (testing) { printf ("Drawing thing #%d (%d, link)\n",i,map[curmap].thing[i].id); fflush(STDOUT); } if (!isflow(map[curmap].thing[i].id, T_LINK)) { drawlink(buffer, &map[curmap].olink[map[curmap].thing[i].id]); thingdrawn[i] = TRUE; } } else if (map[curmap].thing[i].type == T_TEXT) { - if (testing) { printf ("Drawing thing #%d (%d, text)\n",i,map[curmap].thing[i].id); fflush(stdout); } + if (testing) { printf ("Drawing thing #%d (%d, text)\n",i,map[curmap].thing[i].id); fflush(STDOUT); } if (!isflow(map[curmap].thing[i].id, T_TEXT)) { drawtext(buffer, &map[curmap].textob[map[curmap].thing[i].id], TRUE); thingdrawn[i] = TRUE; @@ -3961,11 +4039,11 @@ void drawmap(void) { } if (testing) { - printf("FINISHED THINGS \n"); fflush(stdout); + printf("FINISHED THINGS \n"); fflush(STDOUT); } if (testing) { - printf("DRAWING HIGHLIGHT\n"); fflush(stdout); + printf("DRAWING HIGHLIGHT\n"); fflush(STDOUT); } /* highlight the selected map[curmap].object */ @@ -4167,26 +4245,30 @@ void drawmap(void) { SDL_BlitSurface(buffer, 0, screen,0); if (testing) { - printf("START MAPBOX\n"); fflush(stdout); + printf("START MAPBOX\n"); fflush(STDOUT); } drawmapbox(); /* draw status bar */ - if (testing) { - printf("START STATUSBAR\n"); fflush(stdout); - } - drawstatusbar(); - - if (testing) { - printf("FLIP\n"); fflush(stdout); + if (wantdecs) { + if (testing) { + printf("START STATUSBAR\n"); fflush(STDOUT); + } + drawstatusbar(); } - /* draw scrollbars, if required */ - if (map[curmap].width > (screen->w - SIDEBARW)) { - drawxscrollbar(); + if (testing) { + printf("FLIP\n"); fflush(STDOUT); } - if (map[curmap].height > (screen->h - STATUSH)) { - drawyscrollbar(); + + if (wantdecs) { + /* draw scrollbars, if required */ + if (map[curmap].width > (screen->w - SIDEBARW)) { + drawxscrollbar(); + } + if (map[curmap].height > (screen->h - STATUSH)) { + drawyscrollbar(); + } } /* calculate mapdimensions if diagram has been modified */ @@ -4798,7 +4880,7 @@ void drawobox(void) { } void drawscreen(void){ - drawmap(); + drawmap(TRUE); drawtoolbox(); drawobox(); SDL_Flip(screen); @@ -4846,6 +4928,7 @@ void drawtext(SDL_Surface *dest, text_t *t, int adjust) { } + /* x or y == -1 means to centre */ void drawtextat(SDL_Surface *dest, int x, int y, char *text, int size, SDL_Color c) { int tw,th; @@ -5345,11 +5428,10 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove polycol.unused = 0; +printf("** called drawvector()\n"); + for (i = 0; i < vimg->vnum; i++) { - - - // select colour if (overridefg == NULL) { if (vimg->vector[i].c.unused == 255) { @@ -5450,8 +5532,6 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove break; case VT_ENDPOLY: - inbez = 0; - if (subobjfill.unused & USECOLOUR) { fillcol = subobjfill; subobjfill.r = 0; @@ -5459,7 +5539,7 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove subobjfill.b = 0; subobjfill.unused = 0; } - if (inpoly) { + if (inpoly || inbez) { sprintf(temp, "\" style=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);stroke-width:1\"/>\n", fillcol.r, fillcol.g, fillcol.b, polycol.r, polycol.g, polycol.b); strcat(svgbuf, temp); fprintf(svgfile, svgbuf); @@ -5471,6 +5551,7 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove //sprintf(svgbuf, "\n", gnum, + inbez = FALSE; insubobj = FALSE; inpoly = FALSE; break; @@ -5503,7 +5584,7 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove realx4, realy4 ); */ - sprintf(svgbuf,"C%d %d %d %d %d %d", + sprintf(svgbuf," C%d %d %d %d %d %d", realx2, realy2, realx3, realy3, realx4, realy4 @@ -5533,6 +5614,7 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove polycol.b = linecol.b; } } else { + sprintf(svgbuf,"vector[i].type == VT_BEZIER) { + if (insubobj) { + /* use colour from subobj */ + sprintf(svgbuf,"\" style=\"fill:rgb(%d,%d,%d);stroke-width:1;stroke:rgb(%d,%d,%d)\"/>\n", subobjfill.r, subobjfill.g, subobjfill.b, linecol.r,linecol.g,linecol.b); + } else { + sprintf(svgbuf,"\" style=\"stroke-width:1;stroke:rgb(%d,%d,%d)\"/>\n", linecol.r,linecol.g,linecol.b); + } + } + return; } @@ -5577,7 +5671,7 @@ int endtext(void) { if (strlen(text) == 0) { sprintf(statustext,"Text entry aborted."); changestate(S_NONE); - drawmap(); + drawmap(TRUE); return TRUE; } @@ -5629,7 +5723,7 @@ int endtext(void) { changestate(S_NONE); - drawmap(); + drawmap(TRUE); return FALSE; } @@ -5676,7 +5770,7 @@ int endtextedit(void) { changestate(S_NONE); - drawmap(); + drawmap(TRUE); return FALSE; } @@ -5828,7 +5922,7 @@ int getcolor(SDL_Surface *dest, int x, int y, SDL_Color *col) { if (bpp != 2) { printf("bpp isnt 2!!!\n"); - fflush(stdout); + fflush(STDOUT); } //pixel = (Uint32 *) (dest->pixels + (y * dest->w) + x) ; @@ -5888,7 +5982,7 @@ void goback(void) { changemap(history[numhistory-1]); numhistory--; sprintf(statustext, "Drilled back to #%d (%s) - current depth is %d.",curmap,map[curmap].name, numhistory); - drawmap(); + drawmap(TRUE); } else { seterror(255); sprintf(statustext, "Already at top level!"); @@ -6128,7 +6222,7 @@ int loadmap(void) { updatewm(); - drawmap(); + drawmap(TRUE); return FALSE; } @@ -6163,7 +6257,7 @@ void lowerselected(int amt) { setmod(TRUE); sprintf(statustext, "Selected item position lowered by %d (now %d of %d).", n, target+1, map[curmap].numthings); /* redraw map */ - drawmap(); + drawmap(TRUE); } int objat(int x, int y) { @@ -6215,7 +6309,7 @@ void paste(void) { sprintf(statustext,"Map %d ('%s') copied to map %d.", copymap, map[copymap].name, curmap); copytype = -1; copymap = -1; - drawmap(); + drawmap(TRUE); } } else if (copytype == T_TEXT) { @@ -6261,7 +6355,7 @@ void paste(void) { copytype = -1; copymap = -1; - drawmap(); + drawmap(TRUE); } else if (copytype == T_OBJECT) { int newtype, newx, newy, n; int newnum; @@ -6307,7 +6401,7 @@ void paste(void) { map[curmap].selecteditem = newnum; sprintf(statustext,"Object pasted at %d,%d.",newx,newy); - drawmap(); + drawmap(TRUE); } else { seterror(255); sprintf(statustext,"Error: No copy source selected!"); @@ -6454,20 +6548,21 @@ int initgraphics(void) { } /* open window */ - screen = SDL_SetVideoMode(DEFSCREENW, DEFSCREENH, 16, (SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE)); + //screen = SDL_SetVideoMode(DEFSCREENW, DEFSCREENH, 16, (SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE)); + screen = SDL_SetVideoMode(DEFSCREENW, DEFSCREENH, 16, (SDL_SWSURFACE|SDL_RESIZABLE)); if(!screen) { printf("SDL_SetVideoMode: %s\n", SDL_GetError()); return -1; } if (screen->flags & SDL_SWSURFACE) { - printf("SWSurface set ok.\n"); fflush(stdout); + printf("SWSurface set ok.\n"); fflush(STDOUT); } if (screen->flags & SDL_SWSURFACE) { - printf("HWSurface set ok.\n"); fflush(stdout); + printf("HWSurface set ok.\n"); fflush(STDOUT); } if (screen->flags & SDL_DOUBLEBUF) { - printf("Doublebuf set ok.\n"); fflush(stdout); + printf("Doublebuf set ok.\n"); fflush(STDOUT); } @@ -6497,7 +6592,7 @@ int initgraphics(void) { /* load fonts */ TTF_Init(); - sprintf(file, "verdana.ttf"); + sprintf(file, "/usr/local/share/netmapr/verdana.ttf"); for (i = 1; i < MAXLETTERHEIGHT; i++) { font[i] = TTF_OpenFont(file,i); if (!font[i]) { @@ -7608,7 +7703,7 @@ void raiseselected(int amt) { setmod(TRUE); sprintf(statustext, "Selected item position raised by %d (now %d of %d).", n, target+1, map[curmap].numthings); /* redraw map */ - drawmap(); + drawmap(TRUE); } void seterror (int errnum) { @@ -7682,6 +7777,7 @@ int savemap(void) { char filename[BUFLEN]; FILE *f; int namelen; + int prevgrid; int i; int eoff; SDL_Surface *exportmap; @@ -7706,17 +7802,20 @@ int savemap(void) { ((filename[eoff+2] == 'm') || (filename[eoff+2] == 'M')) && ((filename[eoff+3] == 'p') || (filename[eoff+3] == 'P')) ) { - exportmap = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].width, map[curmap].height, + exportmap = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].width, screen->h - STATUSH, buffer->format->BitsPerPixel, buffer->format->Rmask, buffer->format->Gmask,buffer->format->Bmask, buffer->format->Amask); state = S_NONE; - drawmap(); + prevgrid = gridsize; + setgridsize(0); + drawmap(FALSE); + gridsize = prevgrid; area.x = 0; area.y = 0; area.w = map[curmap].width; - area.h = map[curmap].height; + area.h = screen->h - STATUSH; SDL_BlitSurface(screen,&area,exportmap, 0); if (SDL_SaveBMP(exportmap, filename)) { seterror(255); @@ -7730,6 +7829,38 @@ int savemap(void) { drawstatusbar(); return FALSE; } + if ((filename[eoff] == '.') && + ((filename[eoff+1] == 'p') || (filename[eoff+1] == 'P')) && + ((filename[eoff+2] == 'n') || (filename[eoff+2] == 'N')) && + ((filename[eoff+3] == 'g') || (filename[eoff+3] == 'G')) + ) { + exportmap = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].width, screen->h - STATUSH, + buffer->format->BitsPerPixel, buffer->format->Rmask, + buffer->format->Gmask,buffer->format->Bmask, + buffer->format->Amask); + + state = S_NONE; + prevgrid = gridsize; + setgridsize(0); + drawmap(FALSE); + gridsize = prevgrid; + area.x = 0; + area.y = 0; + area.w = map[curmap].width; + area.h = screen->h - STATUSH; + SDL_BlitSurface(screen,&area,exportmap, 0); + if (SavePNG(filename, exportmap, TRUE)) { + seterror(255); + sprintf(statustext,"ERROR: Could not export to PNG file '%s'.\n",filename); + drawstatusbar(); + return TRUE; + } + setinfo(255); + sprintf(statustext,"Successfully exported map to PNG file '%s'.\n",filename); + drawtoolbox(); + drawstatusbar(); + return FALSE; + } /* export to SVG format */ if ((filename[eoff] == '.') && ((filename[eoff+1] == 's') || (filename[eoff+1] == 'S')) && @@ -7758,6 +7889,7 @@ int savemap(void) { return TRUE; } + /* dump version, 8 bytes, right padded with 0s */ sprintf(vers, "V%-7s", VERSION); fwrite(vers, 8, 1, f); @@ -7959,6 +8091,7 @@ void startedittext(int o) { textanchor = map[curmap].textob[o].anchor; strcpy(text, map[curmap].textob[o].text); + textpos = &text[strlen(text)]; updateheight = map[curmap].textob[o].h; @@ -8037,7 +8170,7 @@ int startlinkdstmove(int x, int y) { copyline(screen, linex1,liney1,linex2,liney2, linebg ); - sprintf(statustext,"Starting dst endpoint move for link #%d...\n", map[curmap].curlink); fflush(stdout); + sprintf(statustext,"Starting dst endpoint move for link #%d...\n", map[curmap].curlink); fflush(STDOUT); drawstatusbar(); return 0; @@ -8100,18 +8233,18 @@ int startlinksrcmove(int x, int y) { len = linelen(linex1,liney1,linex2,liney2); if (len <= 0) { printf("ERROR: length is zero or negative - %d\n",len); - fflush(stdout); + fflush(STDOUT); exit(1); } linebg = malloc((len + 4) * sizeof(int)); if (linebg == NULL) { - printf("ERROR: cannot malloc()\n"); fflush(stdout); + printf("ERROR: cannot malloc()\n"); fflush(STDOUT); } copyline(screen, linex1,liney1,linex2,liney2, linebg); - sprintf(statustext,"Starting src endpoint move for link #%d...\n", map[curmap].curlink); fflush(stdout); + sprintf(statustext,"Starting src endpoint move for link #%d...\n", map[curmap].curlink); fflush(STDOUT); drawstatusbar(); return 0; @@ -8134,17 +8267,17 @@ int startlinkmove (int x, int y) { len = linelen(linex1,liney1,linex2,liney2); if (len <= 0) { printf("ERROR: length is zero or negative - %d\n",len); - fflush(stdout); + fflush(STDOUT); exit(1); } linebg = malloc((len+4) * sizeof(int)); if (linebg == NULL) { - printf("ERROR: cannot malloc()\n"); fflush(stdout); + printf("ERROR: cannot malloc()\n"); fflush(STDOUT); } copyline(screen, linex1,liney1,linex2,liney2, linebg); - sprintf(statustext,"Starting move of link #%d...\n", map[curmap].curlink); fflush(stdout); + sprintf(statustext,"Starting move of link #%d...\n", map[curmap].curlink); fflush(STDOUT); drawstatusbar(); @@ -8854,6 +8987,11 @@ int updatetextcursor(void) { SDL_Rect area; SDL_Color ccol = blue; int tw,th; + int len; + //int lenpix; + int sw,sh; + int cwid, dummy; + char tempbuf[BUFLEN]; if ((state == S_SAVING) || (state == S_LOADING) || (state == S_MAPNAMING) || (state == S_SEARCH)) { showfiledialog(); @@ -8898,15 +9036,43 @@ int updatetextcursor(void) { bgx = sarea.x; bgy = sarea.y; - /* draw text */ - drawtextat(screen, startx - screenx, starty - screeny, text, updateheight, fgcol); + // xxxxxxxxxx + + // figure out where to draw cursor + len = textpos - text; + + sprintf(tempbuf, text); + tempbuf[len] = '\0'; + printf("len is %d, tempbuf is [%s]\n",len, tempbuf); + TTF_SizeText(font[updateheight], tempbuf, &sw, &sh); + + // find width of next char + if (*textpos == '\0') { + cwid = CURSORWIDTH; + } else { + tempbuf[0] = *textpos; + tempbuf[1] = '\0'; + TTF_SizeText(font[updateheight], tempbuf, &cwid, &dummy); + } + // oooooooooooooooooooooo + /* draw cursor (a solid block) */ - for (y = starty ; y < (starty + th); y++ ) { - drawline(screen, startx + tw+1 - screenx, y - screeny, startx + tw + CURSORWIDTH - screenx,y - screeny,ccol,1); + for (y = starty ; y < (starty + sh); y++ ) { + drawline(screen, startx - screenx + sw+1, y - screeny, + startx - screenx + sw + cwid,y - screeny,ccol,1); + } - SDL_UpdateRect(screen, startx - screenx, starty - screeny, tw + CURSORWIDTH + 3 , th); + /* draw text */ + drawtextat(screen, startx - screenx, starty - screeny, text, updateheight, fgcol); + + + // update screen + SDL_UpdateRect(screen, startx - screenx, starty - screeny, + startx - screenx + tw + cwid + 3 , th); + + //SDL_Flip(screen); return FALSE; @@ -9101,7 +9267,7 @@ int endlinksrcmove(int x, int y) { int endlinkmove(int x, int y) { /* free variable */ - //printf("about to free linebg (0x%x)\n",linebg); fflush(stdout); + //printf("about to free linebg (0x%x)\n",linebg); fflush(STDOUT); if (linebg) free(linebg); @@ -9137,7 +9303,7 @@ void drillto(int mapnum) { strcpy(text, map[curmap].name); changestate(S_MAPNAMING); - drawmap(); + drawmap(TRUE); } else { seterror(255); sprintf(statustext, "ERROR: Maximum number of maps reached."); @@ -9172,7 +9338,7 @@ void drillto(int mapnum) { } else { sprintf(statustext,"Drilled down into map #%d (%s) - current depth is %d.",curmap,map[curmap].name, numhistory); } - drawmap(); + drawmap(TRUE); } } @@ -9297,7 +9463,7 @@ int endresize(int x, int y) { } setmod(TRUE); - drawmap(); + drawmap(TRUE); return 0; } @@ -9347,7 +9513,7 @@ int endtextresize(int x, int y) { setmod(TRUE); sprintf(statustext, "Text item #%d resized to %d points (%dx%d).",map[curmap].curtext,map[curmap].textob[map[curmap].curtext].h, tw, th); - drawmap(); + drawmap(TRUE); return 0; } diff --git a/netmapr.h b/netmapr.h index 16fa449..407ed8b 100644 --- a/netmapr.h +++ b/netmapr.h @@ -1,5 +1,14 @@ #include "constants.h" +#ifndef __CONSTANTS_H +#define __CONSTANTS_H +#ifdef WINDOWS +#define STDOUT (FILE *)1 +#else +#define STDOUT stdout +#endif +#endif + typedef struct { int x; int y; @@ -206,7 +215,7 @@ void drawlinkSVG(link_t *l); void drawobject(SDL_Surface *dest, mapobject_t *o, int doublebuffer, int adjust); void drawobjectSVG(SDL_Surface *dest, mapobject_t *o, int doublebuffer); void drawpixel(SDL_Surface *screen, int x, int y, SDL_Color c); -void drawmap(void); +void drawmap(int wantdecs); void drawmapbox(void); void drawobox(void); void drawscreen(void); diff --git a/windows_files/SDL.dll b/windows_files/SDL.dll index 00822b7..3ce97a5 100755 Binary files a/windows_files/SDL.dll and b/windows_files/SDL.dll differ diff --git a/windows_files/SDL_ttf.dll b/windows_files/SDL_ttf.dll index f74f0b8..d860530 100755 Binary files a/windows_files/SDL_ttf.dll and b/windows_files/SDL_ttf.dll differ diff --git a/windows_files/libfreetype-6.dll b/windows_files/libfreetype-6.dll new file mode 100755 index 0000000..fed8bca Binary files /dev/null and b/windows_files/libfreetype-6.dll differ diff --git a/windows_files/libpng12-0.dll b/windows_files/libpng12-0.dll new file mode 100755 index 0000000..23a6d30 Binary files /dev/null and b/windows_files/libpng12-0.dll differ diff --git a/windows_files/zlib1.dll b/windows_files/zlib1.dll new file mode 100755 index 0000000..007afc4 Binary files /dev/null and b/windows_files/zlib1.dll differ