Added const qualifiers to edit-control string handling

FLTK's Fl_Input widget, instantiated as {Graphics,Text}EditControl, returns
a 'const char *' string. In order to handle this properly, several of
SolveSpace's internal routines needed to gain a "const" qualifier on the
edit-control string argument.
This commit is contained in:
Daniel Richard G 2013-09-16 15:51:20 -04:00
parent bcb6c7b19b
commit 66315d5eea
9 changed files with 16 additions and 16 deletions

View File

@ -240,7 +240,7 @@ void GraphicsWindow::MenuClipboard(int id) {
} }
} }
bool TextWindow::EditControlDoneForPaste(char *s) { bool TextWindow::EditControlDoneForPaste(const char *s) {
Expr *e; Expr *e;
switch(edit.meaning) { switch(edit.meaning) {
case EDIT_PASTE_TIMES_REPEATED: { case EDIT_PASTE_TIMES_REPEATED: {

View File

@ -300,7 +300,7 @@ void TextWindow::ShowConfiguration(void) {
Printf(false, " %Ft version %E%s", glGetString(GL_VERSION)); Printf(false, " %Ft version %E%s", glGetString(GL_VERSION));
} }
bool TextWindow::EditControlDoneForConfiguration(char *s) { bool TextWindow::EditControlDoneForConfiguration(const char *s) {
switch(edit.meaning) { switch(edit.meaning) {
case EDIT_LIGHT_INTENSITY: case EDIT_LIGHT_INTENSITY:
SS.lightIntensity[edit.i] = min(1, max(0, atof(s))); SS.lightIntensity[edit.i] = min(1, max(0, atof(s)));

View File

@ -714,7 +714,7 @@ void Expr::Parse(void) {
PopOperator(); // discard the ALL_RESOLVED marker PopOperator(); // discard the ALL_RESOLVED marker
} }
void Expr::Lex(char *in) { void Expr::Lex(const char *in) {
while(*in) { while(*in) {
if(UnparsedCnt >= MAX_UNPARSED) throw "too long"; if(UnparsedCnt >= MAX_UNPARSED) throw "too long";
@ -771,7 +771,7 @@ void Expr::Lex(char *in) {
} }
} }
Expr *Expr::From(char *in, bool popUpError) { Expr *Expr::From(const char *in, bool popUpError) {
UnparsedCnt = 0; UnparsedCnt = 0;
UnparsedP = 0; UnparsedP = 0;
OperandsP = 0; OperandsP = 0;

4
expr.h
View File

@ -113,8 +113,8 @@ public:
Expr *DeepCopyWithParamsAsPointers(IdList<Param,hParam> *firstTry, Expr *DeepCopyWithParamsAsPointers(IdList<Param,hParam> *firstTry,
IdList<Param,hParam> *thenTry); IdList<Param,hParam> *thenTry);
static Expr *From(char *in, bool popUpError); static Expr *From(const char *in, bool popUpError);
static void Lex(char *in); static void Lex(const char *in);
static Expr *Next(void); static Expr *Next(void);
static void Consume(void); static void Consume(void);

View File

@ -1161,7 +1161,7 @@ void GraphicsWindow::MouseLeftDoubleClick(double mx, double my) {
} }
} }
void GraphicsWindow::EditControlDone(char *s) { void GraphicsWindow::EditControlDone(const char *s) {
HideGraphicsEditControl(); HideGraphicsEditControl();
Constraint *c = SK.GetConstraint(constraintBeingEdited); Constraint *c = SK.GetConstraint(constraintBeingEdited);

View File

@ -643,7 +643,7 @@ void TextWindow::ScreenChangeStyleYesNo(int link, DWORD v) {
InvalidateGraphics(); InvalidateGraphics();
} }
bool TextWindow::EditControlDoneForStyles(char *str) { bool TextWindow::EditControlDoneForStyles(const char *str) {
Style *s; Style *s;
switch(edit.meaning) { switch(edit.meaning) {
case EDIT_STYLE_TEXT_HEIGHT: case EDIT_STYLE_TEXT_HEIGHT:

View File

@ -611,7 +611,7 @@ void TextWindow::ShowTangentArc(void) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// The edit control is visible, and the user just pressed enter. // The edit control is visible, and the user just pressed enter.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void TextWindow::EditControlDone(char *s) { void TextWindow::EditControlDone(const char *s) {
edit.showAgain = false; edit.showAgain = false;
switch(edit.meaning) { switch(edit.meaning) {

12
ui.h
View File

@ -317,11 +317,11 @@ public:
static void ScreenChangeViewOrigin(int link, DWORD v); static void ScreenChangeViewOrigin(int link, DWORD v);
static void ScreenChangeViewProjection(int link, DWORD v); static void ScreenChangeViewProjection(int link, DWORD v);
bool EditControlDoneForStyles(char *s); bool EditControlDoneForStyles(const char *s);
bool EditControlDoneForConfiguration(char *s); bool EditControlDoneForConfiguration(const char *s);
bool EditControlDoneForPaste(char *s); bool EditControlDoneForPaste(const char *s);
bool EditControlDoneForView(char *s); bool EditControlDoneForView(const char *s);
void EditControlDone(char *s); void EditControlDone(const char *s);
}; };
class GraphicsWindow { class GraphicsWindow {
@ -679,7 +679,7 @@ public:
void MouseScroll(double x, double y, int delta); void MouseScroll(double x, double y, int delta);
void MouseLeave(void); void MouseLeave(void);
bool KeyDown(int c); bool KeyDown(int c);
void EditControlDone(char *s); void EditControlDone(const char *s);
SDWORD lastSpaceNavigatorTime; SDWORD lastSpaceNavigatorTime;
hGroup lastSpaceNavigatorGroup; hGroup lastSpaceNavigatorGroup;

View File

@ -63,7 +63,7 @@ void TextWindow::ScreenChangeViewProjection(int link, DWORD v) {
SS.TW.ShowEditControl(24, 10, buf); SS.TW.ShowEditControl(24, 10, buf);
} }
bool TextWindow::EditControlDoneForView(char *s) { bool TextWindow::EditControlDoneForView(const char *s) {
switch(edit.meaning) { switch(edit.meaning) {
case EDIT_VIEW_SCALE: { case EDIT_VIEW_SCALE: {
Expr *e = Expr::From(s, true); Expr *e = Expr::From(s, true);