summaryrefslogtreecommitdiff
path: root/app/bin/cblock.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2022-02-06 16:04:24 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2022-02-06 16:04:24 +0100
commit5d2c2b27a6323e2666378b986129b2a7c2c39e5c (patch)
treece8982b6c0111f79791068de2c2d4c6ce3138a49 /app/bin/cblock.c
parentb623f5953691b2a0614e6f1f4def86bdbb9a4113 (diff)
New upstream version 5.2.2GAupstream/5.2.2GA
Diffstat (limited to 'app/bin/cblock.c')
-rw-r--r--app/bin/cblock.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/app/bin/cblock.c b/app/bin/cblock.c
index b395306..0291b4a 100644
--- a/app/bin/cblock.c
+++ b/app/bin/cblock.c
@@ -46,24 +46,19 @@
* $Header: /home/dmarkle/xtrkcad-fork-cvs/xtrkcad/app/bin/cblock.c,v 1.5 2009-11-23 19:46:16 rheller Exp $
*/
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
+#include "common.h"
#include "compound.h"
#include "cundo.h"
#include "custom.h"
#include "fileio.h"
-#include "i18n.h"
-#include "messages.h"
#include "param.h"
#include "track.h"
#include "trackx.h"
-#include "utility.h"
+#include "common-ui.h"
-#ifdef WINDOWS
+#ifdef UTFCONVERT
#include "include/utf8convert.h"
-#endif // WINDOWS
+#endif // UTFCONVERT
EXPORT TRKTYP_T T_BLOCK = -1;
@@ -78,19 +73,20 @@ static void NoDrawString( drawCmd_p d, coOrd p, ANGLE_T a, char * s,
wFont_p fp, FONTSIZE_T fontSize, wDrawColor color ) {}
static void NoDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm,
wDrawColor color) {}
-static void NoDrawFillPoly( drawCmd_p d, int cnt, coOrd * pts, int * types,
- wDrawColor color, wDrawWidth width, int fill, int open) {}
+static void NoDrawPoly( drawCmd_p d, int cnt, coOrd * pts, int * types,
+ wDrawColor color, wDrawWidth width, drawFill_e eFillOpt ) {}
static void NoDrawFillCircle( drawCmd_p d, coOrd p, DIST_T r,
wDrawColor color ) {}
+static void NoDrawRectangle( drawCmd_p d, coOrd orig, coOrd size, wDrawColor color, drawFill_e eFill ) {}
static drawFuncs_t noDrawFuncs = {
- 0,
NoDrawLine,
NoDrawArc,
NoDrawString,
NoDrawBitMap,
- NoDrawFillPoly,
- NoDrawFillCircle };
+ NoDrawPoly,
+ NoDrawFillCircle,
+ NoDrawRectangle};
static drawCmd_t blockD = {
NULL,
@@ -108,10 +104,10 @@ static track_p first_block;
static track_p last_block;
static paramData_t blockPLs[] = {
-/*0*/ { PD_STRING, blockName, "name", PDO_NOPREF | PDO_STRINGLIMITLENGTH, (void*)200, N_("Name"), 0, 0, sizeof( blockName )},
-/*1*/ { PD_STRING, blockScript, "script", PDO_NOPREF | PDO_STRINGLIMITLENGTH, (void*)350, N_("Script"), 0, 0, sizeof( blockScript)}
+/*0*/ { PD_STRING, blockName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof( blockName )},
+/*1*/ { PD_STRING, blockScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof( blockScript)}
};
-static paramGroup_t blockPG = { "block", 0, blockPLs, sizeof blockPLs/sizeof blockPLs[0] };
+static paramGroup_t blockPG = { "block", 0, blockPLs, COUNT( blockPLs ) };
static wWin_p blockW;
static char blockEditName[STR_SHORT_SIZE];
@@ -120,11 +116,11 @@ static char blockEditSegs[STR_LONG_SIZE];
static track_p blockEditTrack;
static paramData_t blockEditPLs[] = {
-/*0*/ { PD_STRING, blockEditName, "name", PDO_NOPREF | PDO_STRINGLIMITLENGTH, (void*)200, N_("Name"), 0, 0, sizeof(blockEditName)},
-/*1*/ { PD_STRING, blockEditScript, "script", PDO_NOPREF | PDO_STRINGLIMITLENGTH, (void*)350, N_("Script"), 0, 0, sizeof(blockEditScript)},
-/*2*/ { PD_STRING, blockEditSegs, "segments", PDO_NOPREF, (void*)350, N_("Segments"), BO_READONLY },
+/*0*/ { PD_STRING, blockEditName, "name", PDO_NOPREF | PDO_NOTBLANK, I2VP(200), N_("Name"), 0, 0, sizeof(blockEditName)},
+/*1*/ { PD_STRING, blockEditScript, "script", PDO_NOPREF, I2VP(350), N_("Script"), 0, 0, sizeof(blockEditScript)},
+/*2*/ { PD_STRING, blockEditSegs, "segments", PDO_NOPREF, I2VP(350), N_("Segments"), BO_READONLY, 0, sizeof(blockEditSegs) },
};
-static paramGroup_t blockEditPG = { "block", 0, blockEditPLs, sizeof blockEditPLs/sizeof blockEditPLs[0] };
+static paramGroup_t blockEditPG = { "block", 0, blockEditPLs, COUNT( blockEditPLs ) };
static wWin_p blockEditW;
typedef struct btrackinfo_t {
@@ -133,12 +129,14 @@ typedef struct btrackinfo_t {
} btrackinfo_t, *btrackinfo_p;
static dynArr_t blockTrk_da;
+
#define blockTrk(N) DYNARR_N( btrackinfo_t , blockTrk_da, N )
#define tracklist(N) (&(xx->trackList))[N]
typedef struct blockData_t {
+ extraDataBase_t base;
char * name;
char * script;
BOOL_T IsHilite;
@@ -149,7 +147,7 @@ typedef struct blockData_t {
static blockData_p GetblockData ( track_p trk )
{
- return (blockData_p) GetTrkExtraData(trk);
+ return GET_EXTRA_DATA( trk, T_BLOCK, blockData_t );
}
static void DrawBlock (track_p t, drawCmd_p d, wDrawColor color )
@@ -393,9 +391,9 @@ static BOOL_T WriteBlock ( track_p t, FILE * f )
blockData_p xx = GetblockData(t);
char *blockName = MyStrdup(xx->name);
-#ifdef WINDOWS
+#ifdef UTFCONVERT
blockName = Convert2UTF8(blockName);
-#endif // WINDOWS
+#endif // UTFCONVERT
rc &= fprintf(f, "BLOCK %d \"%s\" \"%s\"\n",
GetTrkIndex(t), blockName, xx->script)>0;
@@ -426,11 +424,12 @@ static BOOL_T ReadBlock ( char * line )
return FALSE;
}
-#ifdef WINDOWS
+#ifdef UTFCONVERT
ConvertUTF8ToSystem(name);
-#endif // WINDOWS
+#endif // UTFCONVERT
+
- DYNARR_RESET( btrackinfo_p , blockTrk_da );
+ DYNARR_RESET( btrackinfo_t , blockTrk_da );
while ( (cp = GetNextLine()) != NULL ) {
if ( IsEND( END_BLOCK ) ) {
break;
@@ -442,12 +441,12 @@ static BOOL_T ReadBlock ( char * line )
if ( strncmp( cp, "TRK", 3 ) == 0 ) {
if (!GetArgs(cp+4,"d",&trkindex)) return FALSE;
/*trk = FindTrack(trkindex);*/
- DYNARR_APPEND( btrackinfo_p *, blockTrk_da, 10 );
- blockTrk(blockTrk_da.cnt-1).i = trkindex;
+ DYNARR_APPEND( btrackinfo_t, blockTrk_da, 10 );
+ DYNARR_LAST( btrackinfo_t, blockTrk_da ).i = trkindex;
}
}
/*blockCheckContigiousPath(); save for ResolveBlockTracks */
- trk = NewTrack(index, T_BLOCK, tempEndPts_da.cnt, sizeof(blockData_t)+(sizeof(btrackinfo_t)*(blockTrk_da.cnt-1))+1);
+ trk = NewTrack(index, T_BLOCK, tempEndPts_da.cnt, sizeof(blockData_t)+(sizeof(btrackinfo_t)*(blockTrk_da.cnt))+1);
for ( ep=0; ep<tempEndPts_da.cnt; ep++) {
endPtP = &tempEndPts(ep);
SetTrkEndPoint( trk, ep, endPtP->pos, endPtP->angle );
@@ -771,7 +770,7 @@ static STATUS_T CmdBlock (wAction_t action, coOrd pos )
{
LOG( log_block, 1, ("*** CmdBlock(%08x,{%f,%f})\n",action,pos.x,pos.y))
- switch ((long)commandContext) {
+ switch (VP2L(commandContext)) {
case BLOCK_CREATE: return CmdBlockCreate(action,pos);
case BLOCK_EDIT: return CmdBlockEdit(action,pos);
case BLOCK_DELETE: return CmdBlockDelete(action,pos);
@@ -857,13 +856,10 @@ static POS_T blkhiliteBorder;
static wDrawColor blkhiliteColor = 0;
static void DrawBlockTrackHilite( void )
{
- wPos_t x, y, w, h;
if (blkhiliteColor==0)
blkhiliteColor = wDrawColorGray(87);
- w = (wPos_t)((blkhiliteSize.x/mainD.scale)*mainD.dpi+0.5);
- h = (wPos_t)((blkhiliteSize.y/mainD.scale)*mainD.dpi+0.5);
- mainD.CoOrd2Pix(&mainD,blkhiliteOrig,&x,&y);
- wDrawFilledRectangle( mainD.d, x, y, w, h, blkhiliteColor, wDrawOptTemp|wDrawOptTransparent );
+ // This is incomplete. We should be in temp drawing mode and clearing temp draw on UN_HILIGHT
+ DrawRectangle( &tempD, blkhiliteOrig, blkhiliteSize, blkhiliteColor, DRAW_TRANSPARENT );
}
@@ -984,11 +980,11 @@ EXPORT void BlockMgmLoad( void )
static wIcon_p blockI = NULL;
if ( blockI == NULL)
- blockI = wIconCreatePixMap( block_xpm );
+ blockI = wIconCreatePixMap( block_xpm[iconSize] );
TRK_ITERATE(trk) {
if (GetTrkType(trk) != T_BLOCK) continue;
- ContMgmLoad( blockI, BlockMgmProc, (void *)trk );
+ ContMgmLoad( blockI, BlockMgmProc, trk );
}
}
@@ -998,7 +994,7 @@ EXPORT void InitCmdBlock( wMenu_p menu )
blockName[0] = '\0';
blockScript[0] = '\0';
AddMenuButton( menu, CmdBlockCreate, "cmdBlockCreate", _("Block"),
- wIconCreatePixMap( block_xpm ), LEVEL0_50,
+ wIconCreatePixMap( block_xpm[iconSize] ), LEVEL0_50,
IC_STICKY|IC_POPUP2, ACCL_BLOCK1, NULL );
ParamRegister( &blockPG );
}
@@ -1008,6 +1004,10 @@ EXPORT void InitTrkBlock( void )
{
T_BLOCK = InitObject ( &blockCmds );
log_block = LogFindIndex ( "block" );
+ blockTrk_da.max = 0;
+ blockTrk_da.cnt = 0;
+ blockTrk_da.ptr = NULL;
+ last_block = NULL;
}