cmwind: use 'const' with readonly data

This then required a cascade of function APIs to also now receive
const arguments.

This reduces the .data segment use of this module.
This commit is contained in:
Darryl L. Miles 2024-10-04 11:33:56 +01:00 committed by Tim Edwards
parent 34038ee687
commit 6b4d409d74
3 changed files with 17 additions and 17 deletions

View File

@ -143,8 +143,8 @@ cmwButtonDown(
Point *p, Point *p,
int button) int button)
{ {
ColorBar *cb; const ColorBar *cb;
ColorPump *cp; const ColorPump *cp;
Point surfacePoint; Point surfacePoint;
int x; int x;
double dx; double dx;
@ -598,8 +598,8 @@ cmwRedisplayFunc(
* color bars in the window. * color bars in the window.
*/ */
{ {
ColorBar *cb; const ColorBar *cb;
ColorPump *cp; const ColorPump *cp;
Rect screenR; Rect screenR;
CMWclientRec *cr = (CMWclientRec *) w->w_clientData; CMWclientRec *cr = (CMWclientRec *) w->w_clientData;
@ -649,7 +649,7 @@ CMWCheckWritten(void)
{ {
bool indx; bool indx;
char *prompt; char *prompt;
static char *(yesno[]) = {"no", "yes", NULL}; static const char * const (yesno[]) = {"no", "yes", NULL};
if (!cmwModified) return TRUE; if (!cmwModified) return TRUE;
prompt = TxPrintString("The color map has been modified.\n" prompt = TxPrintString("The color map has been modified.\n"

View File

@ -89,7 +89,7 @@ extern void CMWundoInit(void);
* which pump is hit and which mouse button is used to hit it. * which pump is hit and which mouse button is used to hit it.
*/ */
ColorBar colorBars[] = const ColorBar const colorBars[] =
{ {
{"Red", CB_RED, STYLE_RED, {{ 2000, 8000}, {10000, 9000}}, {"Red", CB_RED, STYLE_RED, {{ 2000, 8000}, {10000, 9000}},
{{ 2000, 9500}, {10000, 10500}}}, {{ 2000, 9500}, {10000, 10500}}},
@ -106,7 +106,7 @@ ColorBar colorBars[] =
{0} {0}
}; };
ColorPump colorPumps[] = const ColorPump const colorPumps[] =
{ {
{CB_RED, -.0078, {{ 500, 8000}, { 1500, 9000}}}, {CB_RED, -.0078, {{ 500, 8000}, { 1500, 9000}}},
{CB_RED, .0078, {{10500, 8000}, {11500, 9000}}}, {CB_RED, .0078, {{10500, 8000}, {11500, 9000}}},
@ -123,13 +123,13 @@ ColorPump colorPumps[] =
{-1} {-1}
}; };
Rect cmwCurrentColorArea = {{6000, 12000}, {18000, 15000}}; const Rect cmwCurrentColorArea = {{6000, 12000}, {18000, 15000}};
Rect cmwCurrentColorTextBox = {{6000, 15500}, {18000, 16500}}; const Rect cmwCurrentColorTextBox = {{6000, 15500}, {18000, 16500}};
char *cmwCurrentColorText = "Color Being Edited"; const char * const cmwCurrentColorText = "Color Being Edited";
/* Bounding rectangle for entire window */ /* Bounding rectangle for entire window */
Rect colorWindowRect = {{0, 1500}, {24000, 17000}}; const Rect colorWindowRect = {{0, 1500}, {24000, 17000}};
/* /*
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
@ -250,8 +250,8 @@ CMWredisplay(
Rect *clipArea) /* An area on the screen to clip to. */ Rect *clipArea) /* An area on the screen to clip to. */
{ {
CMWclientRec *cr; CMWclientRec *cr;
ColorBar *cb; const ColorBar *cb;
ColorPump *cp; const ColorPump *cp;
Rect rect, screenR; Rect rect, screenR;
Point screenP; Point screenP;
double values[6], x; double values[6], x;

View File

@ -69,11 +69,11 @@ typedef struct
extern void CMWloadWindow(MagWindow *, int); extern void CMWloadWindow(MagWindow *, int);
extern void CMWcommand(MagWindow *, TxCommand *); extern void CMWcommand(MagWindow *, TxCommand *);
extern Rect colorWindowRect; extern const Rect colorWindowRect;
extern WindClient CMWclientID; extern WindClient CMWclientID;
extern ColorBar colorBars[]; extern const ColorBar colorBars[];
extern ColorPump colorPumps[]; extern const ColorPump colorPumps[];
extern Rect cmwCurrentColorArea; extern const Rect cmwCurrentColorArea;
extern void cmwUndoColor(int, int, int, int, int, int, int); extern void cmwUndoColor(int, int, int, int, int, int, int);
extern bool CMWCheckWritten(void); extern bool CMWCheckWritten(void);