From 5d2c2b27a6323e2666378b986129b2a7c2c39e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 6 Feb 2022 16:04:24 +0100 Subject: New upstream version 5.2.2GA --- app/bin/trknote.c | 131 +++++++++++++++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 65 deletions(-) (limited to 'app/bin/trknote.c') diff --git a/app/bin/trknote.c b/app/bin/trknote.c index f27cf2e..f2462ba 100644 --- a/app/bin/trknote.c +++ b/app/bin/trknote.c @@ -20,31 +20,26 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include - +#include "common.h" #include "cundo.h" #include "custom.h" #include "dynstring.h" #include "fileio.h" -#include "i18n.h" #include "misc.h" #include "note.h" #include "param.h" #include "track.h" #include "include/utf8convert.h" -#include "utility.h" extern BOOL_T inDescribeCmd; extern descData_t noteDesc[]; -static TRKTYP_T T_NOTE = -1; +EXPORT TRKTYP_T T_NOTE = -1; static wDrawBitMap_p note_bm, link_bm, document_bm; typedef struct { - char **xpm; + char ***xpm; int OP; char * shortName; char * cmdName; @@ -52,14 +47,14 @@ typedef struct { long acclKey; } trknoteData_t; -#include "bitmaps/sticky-note-text.xpm" -#include "bitmaps/sticky-note-chain.xpm" -#include "bitmaps/sticky-note-clip.xpm" +#include "bitmaps/sticky-note.xpm" +#include "bitmaps/sticky-link.xpm" +#include "bitmaps/sticky-doc.xpm" static trknoteData_t noteTypes[] = { - { sticky_note_text_bits, OP_NOTETEXT, N_("Note"), N_("Comment"), "cmdTextNote", 0L }, - { sticky_note_chain_bits, OP_NOTELINK, N_("Link"), N_("Weblink"), "cmdLinkNote", 0L }, - { sticky_note_clip_bits, OP_NOTEFILE, N_("Document"), N_("Document"), "cmdFileNote", 0L }, + { sticky_note_xpm, OP_NOTETEXT, N_("Note"), N_("Comment"), "cmdTextNote", 0L }, + { sticky_link_xpm, OP_NOTELINK, N_("Link"), N_("Weblink"), "cmdLinkNote", 0L }, + { sticky_doc_xpm, OP_NOTEFILE, N_("Document"), N_("Document"), "cmdFileNote", 0L }, }; static long curNoteType; @@ -67,7 +62,7 @@ static long curNoteType; static unsigned layerSave; static coOrd posSave; -#define NOTETYPESCOUNT (sizeof(noteTypes)/sizeof(trknoteData_t)) +#define NOTETYPESCOUNT COUNT(noteTypes) /***************************************************************************** @@ -77,9 +72,9 @@ static coOrd posSave; static track_p NewNote(wIndex_t index, coOrd p, enum noteCommands command ) { track_p t; - struct extraDataNote * xx; + struct extraDataNote_t * xx; t = NewTrack(index, T_NOTE, 0, sizeof *xx); - xx = (struct extraDataNote *)GetTrkExtraData(t); + xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); xx->pos = p; xx->op = command; SetBoundingBox(t, p, p); @@ -96,26 +91,29 @@ static track_p NewNote(wIndex_t index, coOrd p, enum noteCommands command ) static void DrawNote(track_p t, drawCmd_p d, wDrawColor color) { - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(t); - coOrd p[4]; + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + coOrd p[5]; + int type[5]; - if (d->scale >= 16) { - return; - } - if ((d->options & DC_SIMPLE)) { - //while the icon is moved, draw a square + + if ((d->options & DC_SIMPLE) || mainD.scale >= 16) { + //while the icon is moved, draw a square with a lopped off corner //because CmdMove draws all selected object into tempSeg and //tempSegDrawFuncs doesn't have a BitMap drawing func DIST_T dist; - dist = 0.1*mainD.scale; + dist = 0.8 + 0.1*(mainD.scale-16)/4; p[0].x = p[1].x = xx->pos.x - dist; - p[2].x = p[3].x = xx->pos.x + dist; + p[2].x = p[3].x = p[4].x = xx->pos.x + dist; p[1].y = p[2].y = xx->pos.y - dist; - p[3].y = p[0].y = xx->pos.y + dist; - DrawLine(d, p[0], p[1], 0, color); - DrawLine(d, p[1], p[2], 0, color); - DrawLine(d, p[2], p[3], 0, color); - DrawLine(d, p[3], p[0], 0, color); + p[3].y = p[4].y = p[0].y = xx->pos.y + dist; + p[3].y = p[3].y - (dist/2); + p[4].x = p[4].x - (dist/2); + + for (int i=0;i<5;i++) { + type[i] = 0; + } + DrawPoly(d, 5, p, type, color, 0, DRAW_CLOSED); + DrawPoly(d, 5, p, type, drawColorGold, 0, DRAW_FILL); } else { // draw a bitmap for static object wDrawBitMap_p bm; @@ -135,7 +133,7 @@ static void DrawNote(track_p t, drawCmd_p d, wDrawColor color) static DIST_T DistanceNote(track_p t, coOrd * p) { - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(t); + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); DIST_T d; d = FindDistance(*p, xx->pos); @@ -143,12 +141,12 @@ static DIST_T DistanceNote(track_p t, coOrd * p) return d; } - return 100000.0; + return DIST_INF; } static void DeleteNote(track_p t) { - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(t); + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); switch (xx->op) { case OP_NOTETEXT: @@ -180,7 +178,7 @@ static void DeleteNote(track_p t) void NoteStateSave(track_p trk) { - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(trk); + struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); layerSave = GetTrkLayer(trk); posSave = xx->pos; } @@ -193,7 +191,7 @@ void CommonCancelNote(track_p trk) { if (inDescribeCmd) { - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(trk); + struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); xx->layer = layerSave; xx->pos = posSave; SetBoundingBox(trk, xx->pos, xx->pos); @@ -201,9 +199,9 @@ CommonCancelNote(track_p trk) } static void -CommonUpdateNote(track_p trk, int inx, struct extraDataNote *noteData ) +CommonUpdateNote(track_p trk, int inx, struct extraDataNote_t *noteData ) { - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(trk); + struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); switch (inx) { case OR_NOTE: @@ -220,10 +218,10 @@ CommonUpdateNote(track_p trk, int inx, struct extraDataNote *noteData ) } -void UpdateFile(struct extraDataNote *noteUIData, int inx, BOOL_T needUndoStart) +void UpdateFile(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart) { track_p trk = noteUIData->trk; - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(trk); + struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); switch (inx) { case OR_NOTE: @@ -253,10 +251,10 @@ void UpdateFile(struct extraDataNote *noteUIData, int inx, BOOL_T needUndoStart } } -void UpdateLink(struct extraDataNote *noteUIData, int inx, BOOL_T needUndoStart) +void UpdateLink(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart) { track_p trk = noteUIData->trk; - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(trk); + struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); switch (inx) { case OR_NOTE: @@ -275,10 +273,10 @@ void UpdateLink(struct extraDataNote *noteUIData, int inx, BOOL_T needUndoStart) } } -void UpdateText(struct extraDataNote *noteUIData, int inx, BOOL_T needUndoStart) +void UpdateText(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart) { track_p trk = noteUIData->trk; - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(trk); + struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); switch (inx) { case OR_NOTE: @@ -334,8 +332,9 @@ GetNoteMarker(enum noteCommands command ) static BOOL_T WriteNote(track_p t, FILE * f) { - struct extraDataNote *xx = (struct extraDataNote *)GetTrkExtraData(t); + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); BOOL_T rc = TRUE; + unsigned strings2convert = 1; rc &= fprintf(f, "NOTE %d %u 0 0 %0.6f %0.6f 0 %d", GetTrkIndex(t), GetTrkLayer(t), @@ -349,16 +348,18 @@ static BOOL_T WriteNote(track_p t, FILE * f) case OP_NOTELINK: s[0]=ConvertToEscapedText( xx->noteData.linkData.url ); s[1]=ConvertToEscapedText( xx->noteData.linkData.title ); + strings2convert = 2; break; case OP_NOTEFILE: s[0]=ConvertToEscapedText( xx->noteData.fileData.path ); s[1]=ConvertToEscapedText( xx->noteData.fileData.title ); + strings2convert = 2; break; default: AbortProg( "WriteNote: %d", xx->op ); } -#ifdef WINDOWS - for ( int inx = 0; inx < 2; inx++ ) { +#ifdef UTFCONVERT + for ( unsigned int inx = 0; inx < strings2convert; inx++ ) { if ( RequiresConvToUTF8( s[inx] ) ) { wSystemToUTF8 ( s[inx], message, sizeof message ); MyFree( s[inx] ); @@ -389,7 +390,7 @@ ReadTrackNote(char *line) track_p t; int size; char * cp; - struct extraDataNote *xx; + struct extraDataNote_t *xx; wIndex_t index; wIndex_t layer; coOrd pos; @@ -404,17 +405,17 @@ ReadTrackNote(char *line) return FALSE; } - if ( paramVersion >= 12 ) { + if ( paramVersion >= VERSION_INLINENOTE ) { noteType = size; t = NewNote(index, pos, noteType); SetTrkLayer(t, layer); - xx = (struct extraDataNote *)GetTrkExtraData(t); + xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); switch (noteType) { case OP_NOTETEXT: if ( !GetArgs( cp, "qc", &sText, &cp ) ) return FALSE; -#ifdef WINDOWS +#ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.text = sText; @@ -422,13 +423,13 @@ ReadTrackNote(char *line) case OP_NOTELINK: if ( !GetArgs( cp, "qc", &sText, &cp ) ) return FALSE; -#ifdef WINDOWS +#ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.linkData.url = sText; if ( !GetArgs( cp, "qc", &sText, &cp ) ) return FALSE; -#ifdef WINDOWS +#ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.linkData.title = sText; @@ -436,13 +437,13 @@ ReadTrackNote(char *line) case OP_NOTEFILE: if ( !GetArgs( cp, "qc", &sText, &cp ) ) return FALSE; -#ifdef WINDOWS +#ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.fileData.path = sText; if ( !GetArgs( cp, "qc", &sText, &cp ) ) return FALSE; -#ifdef WINDOWS +#ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.fileData.title = sText; @@ -467,7 +468,7 @@ ReadTrackNote(char *line) t = NewNote(index, pos, noteType); SetTrkLayer(t, layer); - xx = (struct extraDataNote *)GetTrkExtraData(t); + xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); switch (noteType) { case OP_NOTETEXT: @@ -515,7 +516,7 @@ ReadNote(char * line) static void MoveNote(track_p trk, coOrd orig) { - struct extraDataNote * xx = (struct extraDataNote *)GetTrkExtraData(trk); + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); xx->pos.x += orig.x; xx->pos.y += orig.y; SetBoundingBox(trk, xx->pos, xx->pos); @@ -524,14 +525,14 @@ static void MoveNote(track_p trk, coOrd orig) static void RotateNote(track_p trk, coOrd orig, ANGLE_T angle) { - struct extraDataNote * xx = (struct extraDataNote *)GetTrkExtraData(trk); + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); Rotate(&xx->pos, orig, angle); SetBoundingBox(trk, xx->pos, xx->pos); } static void RescaleNote(track_p trk, FLOAT_T ratio) { - struct extraDataNote * xx = (struct extraDataNote *)GetTrkExtraData(trk); + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); xx->pos.x *= ratio; xx->pos.y *= ratio; } @@ -574,8 +575,8 @@ static BOOL_T QueryNote( track_p trk, int query ) static wBool_t CompareNote( track_cp trk1, track_cp trk2 ) { - struct extraDataNote *xx1 = (struct extraDataNote *)GetTrkExtraData( trk1 ); - struct extraDataNote *xx2 = (struct extraDataNote *)GetTrkExtraData( trk2 ); + struct extraDataNote_t *xx1 = GET_EXTRA_DATA( trk1, T_NOTE, extraDataNote_t ); + struct extraDataNote_t *xx2 = GET_EXTRA_DATA( trk2, T_NOTE, extraDataNote_t ); char * cp = message + strlen(message); REGRESS_CHECK_POS( "Pos", xx1, xx2, pos ) REGRESS_CHECK_INT( "Layer", xx1, xx2, layer ) @@ -636,7 +637,7 @@ static STATUS_T CmdNote(wAction_t action, coOrd pos) switch (action) { case C_START: InfoMessage(_("Place a note on the layout")); - curNoteType = (long)commandContext; + curNoteType = VP2L(commandContext); return C_CONTINUE; case C_DOWN: @@ -697,7 +698,7 @@ static STATUS_T CmdNote(wAction_t action, coOrd pos) #include "bitmaps/note.xbm" #include "bitmaps/link.xbm" #include "bitmaps/clip.xbm" -#include "bitmaps/cnote.xpm" +// RWS not used #include "bitmaps/note.xpm" void InitTrkNote(wMenu_p menu) { @@ -711,8 +712,8 @@ void InitTrkNote(wMenu_p menu) wIcon_p icon; nt = noteTypes + i; - icon = wIconCreatePixMap(nt->xpm); - AddMenuButton(menu, CmdNote, nt->helpKey, _(nt->cmdName), icon, LEVEL0_50, IC_STICKY | IC_POPUP2, nt->acclKey, (void *)(intptr_t)nt->OP); + icon = wIconCreatePixMap(nt->xpm[iconSize]); + AddMenuButton(menu, CmdNote, nt->helpKey, _(nt->cmdName), icon, LEVEL0_50, IC_STICKY | IC_POPUP2, nt->acclKey, I2VP(nt->OP)); } ButtonGroupEnd(); -- cgit v1.2.3 From a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 3 Jul 2024 10:19:30 +0200 Subject: New upstream version 5.3.0GA --- app/bin/trknote.c | 478 +++++++++++++++++++++--------------------------------- 1 file changed, 182 insertions(+), 296 deletions(-) (limited to 'app/bin/trknote.c') diff --git a/app/bin/trknote.c b/app/bin/trknote.c index f2462ba..a62c22d 100644 --- a/app/bin/trknote.c +++ b/app/bin/trknote.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common.h" @@ -31,9 +31,6 @@ #include "track.h" #include "include/utf8convert.h" -extern BOOL_T inDescribeCmd; -extern descData_t noteDesc[]; - EXPORT TRKTYP_T T_NOTE = -1; static wDrawBitMap_p note_bm, link_bm, document_bm; @@ -47,14 +44,14 @@ typedef struct { long acclKey; } trknoteData_t; -#include "bitmaps/sticky-note.xpm" -#include "bitmaps/sticky-link.xpm" -#include "bitmaps/sticky-doc.xpm" +#include "bitmaps/sticky-note.xpm3" +#include "bitmaps/sticky-link.xpm3" +#include "bitmaps/sticky-doc.xpm3" static trknoteData_t noteTypes[] = { - { sticky_note_xpm, OP_NOTETEXT, N_("Note"), N_("Comment"), "cmdTextNote", 0L }, - { sticky_link_xpm, OP_NOTELINK, N_("Link"), N_("Weblink"), "cmdLinkNote", 0L }, - { sticky_doc_xpm, OP_NOTEFILE, N_("Document"), N_("Document"), "cmdFileNote", 0L }, + { sticky_note_xpm3, OP_NOTETEXT, N_("Note"), N_("Text Note"), "cmdTextNote", ACCL_NOTE }, + { sticky_link_xpm3, OP_NOTELINK, N_("Link"), N_("Weblink"), "cmdLinkNote", 0L }, + { sticky_doc_xpm3, OP_NOTEFILE, N_("Document"), N_("Document"), "cmdFileNote", 0L }, }; static long curNoteType; @@ -69,16 +66,16 @@ static coOrd posSave; * NOTE OBJECT */ -static track_p NewNote(wIndex_t index, coOrd p, enum noteCommands command ) +EXPORT track_p NewNote(wIndex_t index, coOrd p, enum noteCommands command ) { - track_p t; - struct extraDataNote_t * xx; - t = NewTrack(index, T_NOTE, 0, sizeof *xx); - xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); - xx->pos = p; + track_p t; + struct extraDataNote_t * xx; + t = NewTrack(index, T_NOTE, 0, sizeof *xx); + xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + xx->pos = p; xx->op = command; - SetBoundingBox(t, p, p); - return t; + SetBoundingBox(t, p, p); + return t; } /** @@ -91,9 +88,9 @@ static track_p NewNote(wIndex_t index, coOrd p, enum noteCommands command ) static void DrawNote(track_p t, drawCmd_p d, wDrawColor color) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); - coOrd p[5]; - int type[5]; + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + coOrd p[5]; + int type[5]; if ((d->options & DC_SIMPLE) || mainD.scale >= 16) { @@ -109,7 +106,7 @@ static void DrawNote(track_p t, drawCmd_p d, wDrawColor color) p[3].y = p[3].y - (dist/2); p[4].x = p[4].x - (dist/2); - for (int i=0;i<5;i++) { + for (int i=0; i<5; i++) { type[i] = 0; } DrawPoly(d, 5, p, type, color, 0, DRAW_CLOSED); @@ -127,21 +124,21 @@ static void DrawNote(track_p t, drawCmd_p d, wDrawColor color) bm = note_bm; } } - DrawBitMap(d, xx->pos, bm, color); - } + DrawBitMap(d, xx->pos, bm, color); + } } static DIST_T DistanceNote(track_p t, coOrd * p) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); - DIST_T d; - d = FindDistance(*p, xx->pos); + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + DIST_T d; + d = FindDistance(*p, xx->pos); - if (d < 3.0*(mainD.scale/12.0)) { - return d; - } + if (d < 3.0*(mainD.scale/12.0)) { + return d; + } - return DIST_INF; + return DIST_INF; } static void DeleteNote(track_p t) @@ -175,126 +172,8 @@ static void DeleteNote(track_p t) } } -void -NoteStateSave(track_p trk) -{ - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - layerSave = GetTrkLayer(trk); - posSave = xx->pos; -} - -/** -* Handle Cancel button: restore old values for layer and position -*/ - -void -CommonCancelNote(track_p trk) -{ - if (inDescribeCmd) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - xx->layer = layerSave; - xx->pos = posSave; - SetBoundingBox(trk, xx->pos, xx->pos); - } -} - -static void -CommonUpdateNote(track_p trk, int inx, struct extraDataNote_t *noteData ) -{ - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - - switch (inx) { - case OR_NOTE: - xx->pos = noteData->pos; - SetBoundingBox(trk, xx->pos, xx->pos); - break; - case LY_NOTE: - SetTrkLayer(trk, noteData->layer); - break; - case CANCEL_NOTE: - CommonCancelNote(trk); - break; - } -} - - -void UpdateFile(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart) -{ - track_p trk = noteUIData->trk; - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - - switch (inx) { - case OR_NOTE: - case LY_NOTE: - case CANCEL_NOTE: - CommonUpdateNote(trk, inx, noteUIData); - break; - case OK_FILE: - { - DeleteNote(trk); - xx->noteData.fileData.path = MyStrdup(noteUIData->noteData.fileData.path); - xx->noteData.fileData.title = MyStrdup(noteUIData->noteData.fileData.title); - //result = malloc( maximumSize ); - //resultSize = File2URI(noteFileData->path, maximumSize, result); - //xx->text = (char*)MyMalloc(resultSize + strlen(noteFileData->title) + 2); - //sprintf(xx->text, "%s %s", result, noteFileData->title); - //if (noteFileData->inArchive) { - // CopyFile(noteFileData->path, archiveDirectory); - - //} - //free(result); - } - break; - - default: - break; - } -} - -void UpdateLink(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart) -{ - track_p trk = noteUIData->trk; - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - - switch (inx) { - case OR_NOTE: - case LY_NOTE: - case CANCEL_NOTE: - CommonUpdateNote(trk, inx, noteUIData); - break; - - case OK_LINK: - DeleteNote(trk); - xx->noteData.linkData.title = MyStrdup(noteUIData->noteData.linkData.title); - xx->noteData.linkData.url = MyStrdup(noteUIData->noteData.linkData.url); - break; - default: - break; - } -} - -void UpdateText(struct extraDataNote_t *noteUIData, int inx, BOOL_T needUndoStart) -{ - track_p trk = noteUIData->trk; - struct extraDataNote_t *xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - - switch (inx) { - case OR_NOTE: - case LY_NOTE: - case CANCEL_NOTE: - CommonUpdateNote(trk, inx, noteUIData); - break; - - case OK_TEXT: - DeleteNote(trk); - xx->noteData.text = MyStrdup(noteUIData->noteData.text); - break; - default: - break; - } - changed++; -} +#if 0 /** * Get the delimited marker for the current note. Markers start and end with * a delimiter. The marker itself is a single digit number. For plain text notes @@ -321,6 +200,7 @@ GetNoteMarker(enum noteCommands command ) } return(marker); } +#endif /** * Write the note to file. Handles the complete syntax for a note statement @@ -332,13 +212,15 @@ GetNoteMarker(enum noteCommands command ) static BOOL_T WriteNote(track_p t, FILE * f) { - struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); - BOOL_T rc = TRUE; + struct extraDataNote_t *xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + BOOL_T rc = TRUE; +#ifdef UTFCONVERT unsigned strings2convert = 1; +#endif rc &= fprintf(f, "NOTE %d %u 0 0 %0.6f %0.6f 0 %d", GetTrkIndex(t), - GetTrkLayer(t), - xx->pos.x, xx->pos.y, xx->op )>0; + GetTrkLayer(t), + xx->pos.x, xx->pos.y, xx->op )>0; char *s[2] = { NULL, NULL }; switch (xx->op) { @@ -348,15 +230,19 @@ static BOOL_T WriteNote(track_p t, FILE * f) case OP_NOTELINK: s[0]=ConvertToEscapedText( xx->noteData.linkData.url ); s[1]=ConvertToEscapedText( xx->noteData.linkData.title ); +#ifdef UTFCONVERT strings2convert = 2; +#endif break; case OP_NOTEFILE: s[0]=ConvertToEscapedText( xx->noteData.fileData.path ); s[1]=ConvertToEscapedText( xx->noteData.fileData.title ); +#ifdef UTFCONVERT strings2convert = 2; +#endif break; default: - AbortProg( "WriteNote: %d", xx->op ); + CHECKMSG( FALSE, ( "WriteNote: %d", xx->op ) ); } #ifdef UTFCONVERT for ( unsigned int inx = 0; inx < strings2convert; inx++ ) { @@ -374,7 +260,7 @@ static BOOL_T WriteNote(track_p t, FILE * f) MyFree( s[1] ); } rc &= fprintf( f, "\n" )>0; - + return rc; } @@ -387,62 +273,67 @@ static BOOL_T WriteNote(track_p t, FILE * f) static BOOL_T ReadTrackNote(char *line) { - track_p t; - int size; - char * cp; - struct extraDataNote_t *xx; - wIndex_t index; - wIndex_t layer; - coOrd pos; - DIST_T elev; + track_p t; + int size; + char * cp; + struct extraDataNote_t *xx; + wIndex_t index; + wIndex_t layer; + coOrd pos; + DIST_T elev; char *noteText; enum noteCommands noteType; char * sText; - if (!GetArgs(line + 5, paramVersion < 3 ? "XXpYdc" : paramVersion < 9 ? - "dL00pYdc" : "dL00pfdc", - &index, &layer, &pos, &elev, &size, &cp)) { - return FALSE; - } + if (!GetArgs(line + 5, paramVersion < 3 ? "XXpYdc" : paramVersion < 9 ? + "dL00pYdc" : "dL00pfdc", + &index, &layer, &pos, &elev, &size, &cp)) { + return FALSE; + } if ( paramVersion >= VERSION_INLINENOTE ) { noteType = size; t = NewNote(index, pos, noteType); - SetTrkLayer(t, layer); - - xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + SetTrkLayer(t, layer); + + xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); switch (noteType) { case OP_NOTETEXT: - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.text = sText; break; case OP_NOTELINK: - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.linkData.url = sText; - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.linkData.title = sText; break; case OP_NOTEFILE: - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif xx->noteData.fileData.path = sText; - if ( !GetArgs( cp, "qc", &sText, &cp ) ) + if ( !GetArgs( cp, "qc", &sText, &cp ) ) { return FALSE; + } #ifdef UTFCONVERT ConvertUTF8ToSystem( sText ); #endif @@ -450,51 +341,48 @@ ReadTrackNote(char *line) xx->noteData.fileData.inArchive = FALSE; break; default: - AbortProg( "ReadNote: %d", noteType ); + CHECKMSG( FALSE, ( "ReadNote: %d", noteType ) ); } } else { - noteText = ReadMultilineText(); + noteText = ReadMultilineText(); - noteType = OP_NOTETEXT; + noteType = OP_NOTETEXT; - if( !strncmp(noteText, DELIMITER, strlen( DELIMITER )) && - !strncmp(noteText + strlen(DELIMITER) + 1, DELIMITER, strlen(DELIMITER)) && - noteText[strlen(DELIMITER)] - '0' > 0 && - noteText[strlen(DELIMITER)] - '0' <= OP_NOTEFILE) - { - noteType = noteText[strlen(DELIMITER)] - '0'; - } + if( !strncmp(noteText, DELIMITER, strlen( DELIMITER )) && + !strncmp(noteText + strlen(DELIMITER) + 1, DELIMITER, strlen(DELIMITER)) && + noteText[strlen(DELIMITER)] - '0' > 0 && + noteText[strlen(DELIMITER)] - '0' <= OP_NOTEFILE) { + noteType = noteText[strlen(DELIMITER)] - '0'; + } - t = NewNote(index, pos, noteType); - SetTrkLayer(t, layer); - - xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + t = NewNote(index, pos, noteType); + SetTrkLayer(t, layer); - switch (noteType) { - case OP_NOTETEXT: - xx->noteData.text = MyStrdup(noteText); - break; - case OP_NOTELINK: - { - char *ptr; - ptr = strtok(noteText, " "); - xx->noteData.linkData.url = MyStrdup(ptr + 2 * strlen(DELIMITER) + 1); - xx->noteData.linkData.title = MyStrdup(noteText + strlen(ptr) + 1); - break; - } - case OP_NOTEFILE: - { - char *ptr; - ptr = strtok(noteText + 2 * strlen(DELIMITER) + 1, "\""); - xx->noteData.fileData.path = MyStrdup(ptr); - xx->noteData.fileData.title = MyStrdup(ptr + strlen(ptr) + 2 ); - xx->noteData.fileData.inArchive = FALSE; - break; - } + xx = GET_EXTRA_DATA( t, T_NOTE, extraDataNote_t ); + switch (noteType) { + case OP_NOTETEXT: + xx->noteData.text = MyStrdup(noteText); + break; + case OP_NOTELINK: { + char *ptr; + ptr = strtok(noteText, " "); + xx->noteData.linkData.url = MyStrdup(ptr + 2 * strlen(DELIMITER) + 1); + xx->noteData.linkData.title = MyStrdup(noteText + strlen(ptr) + 1); + break; + } + case OP_NOTEFILE: { + char *ptr; + ptr = strtok(noteText + 2 * strlen(DELIMITER) + 1, "\""); + xx->noteData.fileData.path = MyStrdup(ptr); + xx->noteData.fileData.title = MyStrdup(ptr + strlen(ptr) + 2 ); + xx->noteData.fileData.inArchive = FALSE; + break; + } + + } + MyFree(noteText); } - MyFree(noteText); - } return TRUE; } @@ -507,42 +395,41 @@ ReadTrackNote(char *line) static BOOL_T ReadNote(char * line) { - if (strncmp(line, "NOTE MAIN", 9) == 0) { - return ReadMainNote(line); - } else { - return ReadTrackNote(line); - } + if (strncmp(line, "NOTE MAIN", 9) == 0) { + return ReadMainNote(line); + } else { + return ReadTrackNote(line); + } } static void MoveNote(track_p trk, coOrd orig) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - xx->pos.x += orig.x; - xx->pos.y += orig.y; - SetBoundingBox(trk, xx->pos, xx->pos); + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + xx->pos.x += orig.x; + xx->pos.y += orig.y; + SetBoundingBox(trk, xx->pos, xx->pos); } static void RotateNote(track_p trk, coOrd orig, ANGLE_T angle) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - Rotate(&xx->pos, orig, angle); - SetBoundingBox(trk, xx->pos, xx->pos); + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + Rotate(&xx->pos, orig, angle); + SetBoundingBox(trk, xx->pos, xx->pos); } static void RescaleNote(track_p trk, FLOAT_T ratio) { - struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); - xx->pos.x *= ratio; - xx->pos.y *= ratio; + struct extraDataNote_t * xx = GET_EXTRA_DATA( trk, T_NOTE, extraDataNote_t ); + xx->pos.x *= ratio; + xx->pos.y *= ratio; } static void DescribeNote(track_p trk, char * str, CSIZE_T len) { if (IsLinkNote(trk)) { DescribeLinkNote(trk, str, len); - } - else { + } else { if (IsFileNote(trk)) { DescribeFileNote(trk, str, len); } else { @@ -551,7 +438,8 @@ static void DescribeNote(track_p trk, char * str, CSIZE_T len) } } -static void ActivateNote(track_p trk) { +static void ActivateNote(track_p trk) +{ if (IsLinkNote(trk) ) { ActivateLinkNote(trk); } @@ -564,8 +452,8 @@ static BOOL_T QueryNote( track_p trk, int query ) { switch ( query ) { case Q_IS_ACTIVATEABLE:; - if (IsFileNote(trk)) return TRUE; - if (IsLinkNote(trk)) return TRUE; + if (IsFileNote(trk)) { return TRUE; } + if (IsLinkNote(trk)) { return TRUE; } break; default: return FALSE; @@ -579,28 +467,27 @@ static wBool_t CompareNote( track_cp trk1, track_cp trk2 ) struct extraDataNote_t *xx2 = GET_EXTRA_DATA( trk2, T_NOTE, extraDataNote_t ); char * cp = message + strlen(message); REGRESS_CHECK_POS( "Pos", xx1, xx2, pos ) - REGRESS_CHECK_INT( "Layer", xx1, xx2, layer ) REGRESS_CHECK_INT( "Op", xx1, xx2, op ) return TRUE; } static trackCmd_t noteCmds = { - "NOTE", - DrawNote, - DistanceNote, - DescribeNote, - DeleteNote, - WriteNote, - ReadNote, - MoveNote, - RotateNote, - RescaleNote, - NULL, /* audit */ - NULL, /* getAngle */ - NULL, /* split */ - NULL, /* traverse */ - NULL, /* enumerate */ - NULL, /* redraw */ + "NOTE", + DrawNote, + DistanceNote, + DescribeNote, + DeleteNote, + WriteNote, + ReadNote, + MoveNote, + RotateNote, + RescaleNote, + NULL, /* audit */ + NULL, /* getAngle */ + NULL, /* split */ + NULL, /* traverse */ + NULL, /* enumerate */ + NULL, /* redraw */ NULL, /*trim*/ NULL, /*merge*/ NULL, /*modify*/ @@ -630,51 +517,45 @@ static trackCmd_t noteCmds = { static STATUS_T CmdNote(wAction_t action, coOrd pos) { - static coOrd oldPos; - static int state_on = FALSE; - track_p trk; + static coOrd oldPos; + static int state_on = FALSE; + track_p trk; - switch (action) { - case C_START: - InfoMessage(_("Place a note on the layout")); + switch (action) { + case C_START: + InfoMessage(_("Place a note on the layout")); curNoteType = VP2L(commandContext); - return C_CONTINUE; - - case C_DOWN: - state_on = TRUE; - oldPos = pos; - return C_CONTINUE; - - case C_MOVE: - oldPos = pos; - return C_CONTINUE; - - case C_UP: - UndoStart(_("New Note"), "New Note"); - state_on = FALSE; - trk = NewNote(-1, pos, curNoteType ); - inDescribeCmd = TRUE; - DrawNewTrack(trk); - - switch (curNoteType) - { + return C_CONTINUE; + + case C_DOWN: + state_on = TRUE; + oldPos = pos; + return C_CONTINUE; + + case C_MOVE: + oldPos = pos; + return C_CONTINUE; + + case C_UP: + UndoStart(_("New Note"), "New Note"); + state_on = FALSE; + + switch (curNoteType) { case OP_NOTETEXT: - NewTextNoteUI(trk); + NewTextNoteUI(pos); break; case OP_NOTELINK: - NewLinkNoteUI(trk); + NewLinkNoteUI(pos); break; case OP_NOTEFILE: - NewFileNoteUI(trk); + NewFileNoteUI(pos); break; } - inDescribeCmd = FALSE; - return C_CONTINUE; - case C_REDRAW: - if (state_on) { + case C_REDRAW: + if (state_on) { switch (curNoteType) { case OP_NOTETEXT: DrawBitMap(&tempD, oldPos, note_bm, normalColor); @@ -682,17 +563,20 @@ static STATUS_T CmdNote(wAction_t action, coOrd pos) case OP_NOTELINK: DrawBitMap(&tempD, oldPos, link_bm, normalColor); break; + case OP_NOTEFILE: + DrawBitMap(&tempD, oldPos, document_bm, normalColor); + break; } - } - return C_CONTINUE; + } + return C_CONTINUE; - case C_CANCEL: - DescribeCancel(); - state_on = FALSE; - return C_CONTINUE; - } + case C_CANCEL: + DescribeCancel(); + state_on = FALSE; + return C_CONTINUE; + } - return C_INFO; + return C_INFO; } #include "bitmaps/note.xbm" @@ -702,9 +586,10 @@ static STATUS_T CmdNote(wAction_t action, coOrd pos) void InitTrkNote(wMenu_p menu) { - note_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, note_bits); - link_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, link_bits); - document_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, clip_bits); + note_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, note_bits); + link_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, link_bits); + document_bm = wDrawBitMapCreate(mainD.d, note_width, note_width, 8, 8, + clip_bits); ButtonGroupBegin(_("Notes"), "cmdNoteCmd", _("Add notes")); for (int i = 0; i < NOTETYPESCOUNT; i++) { @@ -713,7 +598,8 @@ void InitTrkNote(wMenu_p menu) nt = noteTypes + i; icon = wIconCreatePixMap(nt->xpm[iconSize]); - AddMenuButton(menu, CmdNote, nt->helpKey, _(nt->cmdName), icon, LEVEL0_50, IC_STICKY | IC_POPUP2, nt->acclKey, I2VP(nt->OP)); + AddMenuButton(menu, CmdNote, nt->helpKey, _(nt->cmdName), icon, LEVEL0_50, + IC_STICKY | IC_POPUP2, nt->acclKey, I2VP(nt->OP)); } ButtonGroupEnd(); -- cgit v1.2.3