Put wrappers around the functions to show and hide the edit control
in the text window. This means that I can move the conversion from half-row and column to (x, y) into the platform-independent code, and that I'll be ready to add my color picker. [git-p4: depot-paths = "//depot/solvespace/": change = 2171]
This commit is contained in:
parent
319ba16541
commit
824cc00915
@ -270,19 +270,19 @@ void TextWindow::ScreenChangePasteTransformed(int link, DWORD v) {
|
||||
switch(link) {
|
||||
case 't':
|
||||
sprintf(str, "%d", SS.TW.shown.paste.times);
|
||||
ShowTextEditControl(10, 13, str);
|
||||
SS.TW.ShowEditControl(10, 13, str);
|
||||
SS.TW.edit.meaning = EDIT_PASTE_TIMES_REPEATED;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
sprintf(str, "%.3f", SS.TW.shown.paste.theta*180/PI);
|
||||
ShowTextEditControl(12, 13, str);
|
||||
SS.TW.ShowEditControl(12, 13, str);
|
||||
SS.TW.edit.meaning = EDIT_PASTE_ANGLE;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
sprintf(str, "%.3f", SS.TW.shown.paste.scale);
|
||||
ShowTextEditControl(18, 13, str);
|
||||
SS.TW.ShowEditControl(18, 13, str);
|
||||
SS.TW.edit.meaning = EDIT_PASTE_SCALE;
|
||||
break;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
void TextWindow::ScreenChangeLightDirection(int link, DWORD v) {
|
||||
char str[1024];
|
||||
sprintf(str, "%.2f, %.2f, %.2f", CO(SS.lightDir[v]));
|
||||
ShowTextEditControl(29+2*v, 8, str);
|
||||
SS.TW.ShowEditControl(29+2*v, 8, str);
|
||||
SS.TW.edit.meaning = EDIT_LIGHT_DIRECTION;
|
||||
SS.TW.edit.i = v;
|
||||
}
|
||||
@ -15,7 +15,7 @@ void TextWindow::ScreenChangeLightDirection(int link, DWORD v) {
|
||||
void TextWindow::ScreenChangeLightIntensity(int link, DWORD v) {
|
||||
char str[1024];
|
||||
sprintf(str, "%.2f", SS.lightIntensity[v]);
|
||||
ShowTextEditControl(29+2*v, 31, str);
|
||||
SS.TW.ShowEditControl(29+2*v, 31, str);
|
||||
SS.TW.edit.meaning = EDIT_LIGHT_INTENSITY;
|
||||
SS.TW.edit.i = v;
|
||||
}
|
||||
@ -26,7 +26,7 @@ void TextWindow::ScreenChangeColor(int link, DWORD v) {
|
||||
REDf(SS.modelColor[v]),
|
||||
GREENf(SS.modelColor[v]),
|
||||
BLUEf(SS.modelColor[v]));
|
||||
ShowTextEditControl(9+2*v, 13, str);
|
||||
SS.TW.ShowEditControl(9+2*v, 13, str);
|
||||
SS.TW.edit.meaning = EDIT_COLOR;
|
||||
SS.TW.edit.i = v;
|
||||
}
|
||||
@ -34,26 +34,26 @@ void TextWindow::ScreenChangeColor(int link, DWORD v) {
|
||||
void TextWindow::ScreenChangeChordTolerance(int link, DWORD v) {
|
||||
char str[1024];
|
||||
sprintf(str, "%.2f", SS.chordTol);
|
||||
ShowTextEditControl(37, 3, str);
|
||||
SS.TW.ShowEditControl(37, 3, str);
|
||||
SS.TW.edit.meaning = EDIT_CHORD_TOLERANCE;
|
||||
}
|
||||
|
||||
void TextWindow::ScreenChangeMaxSegments(int link, DWORD v) {
|
||||
char str[1024];
|
||||
sprintf(str, "%d", SS.maxSegments);
|
||||
ShowTextEditControl(41, 3, str);
|
||||
SS.TW.ShowEditControl(41, 3, str);
|
||||
SS.TW.edit.meaning = EDIT_MAX_SEGMENTS;
|
||||
}
|
||||
|
||||
void TextWindow::ScreenChangeCameraTangent(int link, DWORD v) {
|
||||
char str[1024];
|
||||
sprintf(str, "%.3f", 1000*SS.cameraTangent);
|
||||
ShowTextEditControl(47, 3, str);
|
||||
SS.TW.ShowEditControl(47, 3, str);
|
||||
SS.TW.edit.meaning = EDIT_CAMERA_TANGENT;
|
||||
}
|
||||
|
||||
void TextWindow::ScreenChangeGridSpacing(int link, DWORD v) {
|
||||
ShowTextEditControl(51, 3, SS.MmToString(SS.gridSpacing));
|
||||
SS.TW.ShowEditControl(51, 3, SS.MmToString(SS.gridSpacing));
|
||||
SS.TW.edit.meaning = EDIT_GRID_SPACING;
|
||||
}
|
||||
|
||||
@ -61,12 +61,12 @@ void TextWindow::ScreenChangeExportScale(int link, DWORD v) {
|
||||
char str[1024];
|
||||
sprintf(str, "%.3f", (double)SS.exportScale);
|
||||
|
||||
ShowTextEditControl(57, 5, str);
|
||||
SS.TW.ShowEditControl(57, 5, str);
|
||||
SS.TW.edit.meaning = EDIT_EXPORT_SCALE;
|
||||
}
|
||||
|
||||
void TextWindow::ScreenChangeExportOffset(int link, DWORD v) {
|
||||
ShowTextEditControl(61, 3, SS.MmToString(SS.exportOffset));
|
||||
SS.TW.ShowEditControl(61, 3, SS.MmToString(SS.exportOffset));
|
||||
SS.TW.edit.meaning = EDIT_EXPORT_OFFSET;
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ void TextWindow::ScreenChangeCanvasSize(int link, DWORD v) {
|
||||
row += (v - 10)*2;
|
||||
col = 13;
|
||||
}
|
||||
ShowTextEditControl(row, col, SS.MmToString(d));
|
||||
SS.TW.ShowEditControl(row, col, SS.MmToString(d));
|
||||
SS.TW.edit.meaning = EDIT_CANVAS_SIZE;
|
||||
SS.TW.edit.i = v;
|
||||
}
|
||||
@ -159,7 +159,7 @@ void TextWindow::ScreenChangeGCodeParameter(int link, DWORD v) {
|
||||
row += 6;
|
||||
break;
|
||||
}
|
||||
ShowTextEditControl(row, 14, buf);
|
||||
SS.TW.ShowEditControl(row, 14, buf);
|
||||
}
|
||||
|
||||
void TextWindow::ShowConfiguration(void) {
|
||||
|
@ -12,7 +12,7 @@ void TextWindow::ScreenEditTtfText(int link, DWORD v) {
|
||||
hRequest hr = { v };
|
||||
Request *r = SK.GetRequest(hr);
|
||||
|
||||
ShowTextEditControl(13, 10, r->str.str);
|
||||
SS.TW.ShowEditControl(13, 10, r->str.str);
|
||||
SS.TW.edit.meaning = EDIT_TTF_TEXT;
|
||||
SS.TW.edit.request = hr;
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ void GraphicsWindow::DeleteTaggedRequests(void) {
|
||||
// An edit might be in progress for the just-deleted item. So
|
||||
// now it's not.
|
||||
HideGraphicsEditControl();
|
||||
HideTextEditControl();
|
||||
SS.TW.HideEditControl();
|
||||
// And clear out the selection, which could contain that item.
|
||||
ClearSuper();
|
||||
// And regenerate to get rid of what it generates, plus anything
|
||||
@ -640,7 +640,7 @@ void GraphicsWindow::MenuEdit(int id) {
|
||||
}
|
||||
}
|
||||
SS.GW.ClearSuper();
|
||||
HideTextEditControl();
|
||||
SS.TW.HideEditControl();
|
||||
SS.nakedEdges.Clear();
|
||||
SS.justExportedInfo.draw = false;
|
||||
// This clears the marks drawn to indicate which points are
|
||||
|
@ -769,7 +769,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
|
||||
HideGraphicsEditControl();
|
||||
return;
|
||||
}
|
||||
HideTextEditControl();
|
||||
SS.TW.HideEditControl();
|
||||
|
||||
if(SS.showToolbar) {
|
||||
if(ToolbarMouseDown((int)mx, (int)my)) return;
|
||||
@ -1104,7 +1104,7 @@ void GraphicsWindow::MouseLeftUp(double mx, double my) {
|
||||
|
||||
void GraphicsWindow::MouseLeftDoubleClick(double mx, double my) {
|
||||
if(GraphicsEditControlIsVisible()) return;
|
||||
HideTextEditControl();
|
||||
SS.TW.HideEditControl();
|
||||
|
||||
if(hover.constraint.v) {
|
||||
constraintBeingEdited = hover.constraint;
|
||||
|
@ -128,7 +128,7 @@ void EnableMenuById(int id, BOOL checked);
|
||||
void ShowGraphicsEditControl(int x, int y, char *s);
|
||||
void HideGraphicsEditControl(void);
|
||||
BOOL GraphicsEditControlIsVisible(void);
|
||||
void ShowTextEditControl(int hr, int c, char *s);
|
||||
void ShowTextEditControl(int x, int y, char *s);
|
||||
void HideTextEditControl(void);
|
||||
BOOL TextEditControlIsVisible(void);
|
||||
void MoveTextScrollbarTo(int pos, int maxPos, int page);
|
||||
|
12
style.cpp
12
style.cpp
@ -326,7 +326,7 @@ void TextWindow::ScreenChangeBackgroundColor(int link, DWORD v) {
|
||||
DWORD rgb = SS.backgroundColor;
|
||||
char str[300];
|
||||
sprintf(str, "%.2f, %.2f, %.2f", REDf(rgb), GREENf(rgb), BLUEf(rgb));
|
||||
ShowTextEditControl(v, 3, str);
|
||||
SS.TW.ShowEditControl(v, 3, str);
|
||||
SS.TW.edit.meaning = EDIT_BACKGROUND_COLOR;
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ void TextWindow::ScreenChangeBackgroundImageScale(int link, DWORD v) {
|
||||
char str[300];
|
||||
sprintf(str, "%.3f", SS.bgImage.scale * SS.MmPerUnit());
|
||||
SS.TW.edit.meaning = EDIT_BACKGROUND_IMG_SCALE;
|
||||
ShowTextEditControl(v, 10, str);
|
||||
SS.TW.ShowEditControl(v, 10, str);
|
||||
}
|
||||
|
||||
void TextWindow::ShowListOfStyles(void) {
|
||||
@ -464,7 +464,7 @@ void TextWindow::ShowListOfStyles(void) {
|
||||
void TextWindow::ScreenChangeStyleName(int link, DWORD v) {
|
||||
hStyle hs = { v };
|
||||
Style *s = Style::Get(hs);
|
||||
ShowTextEditControl(10, 12, s->name.str);
|
||||
SS.TW.ShowEditControl(10, 12, s->name.str);
|
||||
SS.TW.edit.style = hs;
|
||||
SS.TW.edit.meaning = EDIT_STYLE_NAME;
|
||||
}
|
||||
@ -503,7 +503,7 @@ void TextWindow::ScreenChangeStyleWidthOrTextHeight(int link, DWORD v) {
|
||||
row = 33; // text height (for custom styles only)
|
||||
col++;
|
||||
}
|
||||
ShowTextEditControl(row, col, str);
|
||||
SS.TW.ShowEditControl(row, col, str);
|
||||
SS.TW.edit.style = hs;
|
||||
SS.TW.edit.meaning = (link == 't') ? EDIT_STYLE_TEXT_HEIGHT :
|
||||
EDIT_STYLE_WIDTH;
|
||||
@ -514,7 +514,7 @@ void TextWindow::ScreenChangeStyleTextAngle(int link, DWORD v) {
|
||||
Style *s = Style::Get(hs);
|
||||
char str[300];
|
||||
sprintf(str, "%.2f", s->textAngle);
|
||||
ShowTextEditControl(37, 9, str);
|
||||
SS.TW.ShowEditControl(37, 9, str);
|
||||
SS.TW.edit.style = hs;
|
||||
SS.TW.edit.meaning = EDIT_STYLE_TEXT_ANGLE;
|
||||
}
|
||||
@ -538,7 +538,7 @@ void TextWindow::ScreenChangeStyleColor(int link, DWORD v) {
|
||||
}
|
||||
char str[300];
|
||||
sprintf(str, "%.2f, %.2f, %.2f", REDf(rgb), GREENf(rgb), BLUEf(rgb));
|
||||
ShowTextEditControl(row, col, str);
|
||||
SS.TW.ShowEditControl(row, col, str);
|
||||
SS.TW.edit.style = hs;
|
||||
SS.TW.edit.meaning = em;
|
||||
}
|
||||
|
@ -252,13 +252,13 @@ void TextWindow::ScreenChangeExprA(int link, DWORD v) {
|
||||
|
||||
char str[1024];
|
||||
sprintf(str, "%d", (int)g->valA);
|
||||
ShowTextEditControl(r, 10, str);
|
||||
SS.TW.ShowEditControl(r, 10, str);
|
||||
SS.TW.edit.meaning = EDIT_TIMES_REPEATED;
|
||||
SS.TW.edit.group.v = v;
|
||||
}
|
||||
void TextWindow::ScreenChangeGroupName(int link, DWORD v) {
|
||||
Group *g = SK.GetGroup(SS.TW.shown.group);
|
||||
ShowTextEditControl(7, 12, g->DescriptionString()+5);
|
||||
SS.TW.ShowEditControl(7, 12, g->DescriptionString()+5);
|
||||
SS.TW.edit.meaning = EDIT_GROUP_NAME;
|
||||
SS.TW.edit.group.v = v;
|
||||
}
|
||||
@ -267,7 +267,7 @@ void TextWindow::ScreenChangeGroupScale(int link, DWORD v) {
|
||||
|
||||
char str[1024];
|
||||
sprintf(str, "%.3f", g->scale);
|
||||
ShowTextEditControl(14, 13, str);
|
||||
SS.TW.ShowEditControl(14, 13, str);
|
||||
SS.TW.edit.meaning = EDIT_GROUP_SCALE;
|
||||
SS.TW.edit.group.v = v;
|
||||
}
|
||||
@ -530,13 +530,13 @@ void TextWindow::ScreenStepDimFinish(int link, DWORD v) {
|
||||
} else {
|
||||
sprintf(s, "%.3f", SS.TW.shown.dimFinish);
|
||||
}
|
||||
ShowTextEditControl(12, 12, s);
|
||||
SS.TW.ShowEditControl(12, 12, s);
|
||||
}
|
||||
void TextWindow::ScreenStepDimSteps(int link, DWORD v) {
|
||||
char str[1024];
|
||||
sprintf(str, "%d", SS.TW.shown.dimSteps);
|
||||
SS.TW.edit.meaning = EDIT_STEP_DIM_STEPS;
|
||||
ShowTextEditControl(14, 12, str);
|
||||
SS.TW.ShowEditControl(14, 12, str);
|
||||
}
|
||||
void TextWindow::ScreenStepDimGo(int link, DWORD v) {
|
||||
hConstraint hc = SS.TW.shown.constraint;
|
||||
@ -598,7 +598,7 @@ void TextWindow::ScreenChangeTangentArc(int link, DWORD v) {
|
||||
char str[1024];
|
||||
strcpy(str, SS.MmToString(SS.tangentArcRadius));
|
||||
SS.TW.edit.meaning = EDIT_TANGENT_ARC_RADIUS;
|
||||
ShowTextEditControl(12, 3, str);
|
||||
SS.TW.ShowEditControl(12, 3, str);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -755,7 +755,7 @@ void TextWindow::EditControlDone(char *s) {
|
||||
SS.later.showTW = true;
|
||||
|
||||
if(!edit.showAgain) {
|
||||
HideTextEditControl();
|
||||
HideEditControl();
|
||||
edit.meaning = EDIT_NOTHING;
|
||||
}
|
||||
}
|
||||
|
28
textwin.cpp
28
textwin.cpp
@ -56,7 +56,7 @@ void TextWindow::Init(void) {
|
||||
}
|
||||
|
||||
void TextWindow::ClearSuper(void) {
|
||||
HideTextEditControl();
|
||||
HideEditControl();
|
||||
|
||||
memset(this, 0, sizeof(*this));
|
||||
MakeColorTable(fgColors, fgColorTable);
|
||||
@ -66,6 +66,20 @@ void TextWindow::ClearSuper(void) {
|
||||
Show();
|
||||
}
|
||||
|
||||
void TextWindow::HideEditControl(void) {
|
||||
HideTextEditControl();
|
||||
}
|
||||
|
||||
void TextWindow::ShowEditControl(int halfRow, int col, char *s) {
|
||||
editControl.halfRow = halfRow;
|
||||
editControl.col = col;
|
||||
|
||||
int x = LEFT_MARGIN + CHAR_WIDTH*col;
|
||||
int y = (halfRow - SS.TW.scrollPos)*(LINE_HEIGHT/2);
|
||||
|
||||
ShowTextEditControl(x - 3, y + 2, s);
|
||||
}
|
||||
|
||||
void TextWindow::ClearScreen(void) {
|
||||
int i, j;
|
||||
for(i = 0; i < MAX_ROWS; i++) {
|
||||
@ -249,7 +263,7 @@ void TextWindow::Show(void) {
|
||||
if(SS.GW.pending.description) {
|
||||
// A pending operation (that must be completed with the mouse in
|
||||
// the graphics window) will preempt our usual display.
|
||||
HideTextEditControl();
|
||||
HideEditControl();
|
||||
ShowHeader(false);
|
||||
Printf(false, "");
|
||||
Printf(false, "%s", SS.GW.pending.description);
|
||||
@ -258,11 +272,11 @@ void TextWindow::Show(void) {
|
||||
} else if((gs.n > 0 || gs.constraints > 0) &&
|
||||
shown.screen != SCREEN_PASTE_TRANSFORMED)
|
||||
{
|
||||
if(edit.meaning != EDIT_TTF_TEXT) HideTextEditControl();
|
||||
if(edit.meaning != EDIT_TTF_TEXT) HideEditControl();
|
||||
ShowHeader(false);
|
||||
DescribeSelection();
|
||||
} else {
|
||||
if(edit.meaning == EDIT_TTF_TEXT) HideTextEditControl();
|
||||
if(edit.meaning == EDIT_TTF_TEXT) HideEditControl();
|
||||
ShowHeader(true);
|
||||
switch(shown.screen) {
|
||||
default:
|
||||
@ -571,7 +585,7 @@ void TextWindow::Paint(void) {
|
||||
void TextWindow::MouseEvent(bool leftClick, double x, double y) {
|
||||
if(TextEditControlIsVisible() || GraphicsEditControlIsVisible()) {
|
||||
if(leftClick) {
|
||||
HideTextEditControl();
|
||||
HideEditControl();
|
||||
HideGraphicsEditControl();
|
||||
} else {
|
||||
SetMousePointerToHand(false);
|
||||
@ -653,9 +667,7 @@ void TextWindow::ScrollbarEvent(int newPos) {
|
||||
MoveTextScrollbarTo(scrollPos, top[rows - 1] + 1, halfRows);
|
||||
|
||||
if(TextEditControlIsVisible()) {
|
||||
extern int TextEditControlCol, TextEditControlHalfRow;
|
||||
ShowTextEditControl(
|
||||
TextEditControlHalfRow, TextEditControlCol, NULL);
|
||||
ShowEditControl(editControl.halfRow, editControl.col, NULL);
|
||||
}
|
||||
InvalidateText();
|
||||
}
|
||||
|
10
ui.h
10
ui.h
@ -177,6 +177,16 @@ public:
|
||||
|
||||
static void ReportHowGroupSolved(hGroup hg);
|
||||
|
||||
struct {
|
||||
int halfRow;
|
||||
int col;
|
||||
|
||||
bool showColorPicker;
|
||||
} editControl;
|
||||
|
||||
void HideEditControl(void);
|
||||
void ShowEditControl(int halfRow, int col, char *s);
|
||||
|
||||
void ClearSuper(void);
|
||||
|
||||
void ShowHeader(bool withNav);
|
||||
|
10
view.cpp
10
view.cpp
@ -36,7 +36,7 @@ void TextWindow::ScreenChangeViewScale(int link, DWORD v) {
|
||||
sprintf(buf, "%.3f", SS.GW.scale * SS.MmPerUnit());
|
||||
|
||||
SS.TW.edit.meaning = EDIT_VIEW_SCALE;
|
||||
ShowTextEditControl(12, 3, buf);
|
||||
SS.TW.ShowEditControl(12, 3, buf);
|
||||
}
|
||||
|
||||
void TextWindow::ScreenChangeViewOrigin(int link, DWORD v) {
|
||||
@ -47,14 +47,14 @@ void TextWindow::ScreenChangeViewOrigin(int link, DWORD v) {
|
||||
SS.MmToString(-SS.GW.offset.z));
|
||||
|
||||
SS.TW.edit.meaning = EDIT_VIEW_ORIGIN;
|
||||
ShowTextEditControl(18, 3, buf);
|
||||
SS.TW.ShowEditControl(18, 3, buf);
|
||||
}
|
||||
|
||||
void TextWindow::ScreenChangeViewProjection(int link, DWORD v) {
|
||||
char buf[1024];
|
||||
sprintf(buf, "%.3f, %.3f, %.3f", CO(SS.GW.projRight));
|
||||
SS.TW.edit.meaning = EDIT_VIEW_PROJ_RIGHT;
|
||||
ShowTextEditControl(24, 10, buf);
|
||||
SS.TW.ShowEditControl(24, 10, buf);
|
||||
}
|
||||
|
||||
bool TextWindow::EditControlDoneForView(char *s) {
|
||||
@ -96,8 +96,8 @@ bool TextWindow::EditControlDoneForView(char *s) {
|
||||
edit.meaning = EDIT_VIEW_PROJ_UP;
|
||||
char buf[1024];
|
||||
sprintf(buf, "%.3f, %.3f, %.3f", CO(SS.GW.projUp));
|
||||
HideTextEditControl();
|
||||
ShowTextEditControl(26, 10, buf);
|
||||
HideEditControl();
|
||||
ShowEditControl(26, 10, buf);
|
||||
edit.showAgain = true;
|
||||
} else {
|
||||
SS.GW.projUp = pt;
|
||||
|
@ -27,7 +27,6 @@ HWND TextWnd;
|
||||
HWND TextWndScrollBar;
|
||||
HWND TextEditControl;
|
||||
HGLRC TextGl;
|
||||
int TextEditControlCol, TextEditControlHalfRow;
|
||||
|
||||
HWND GraphicsWnd;
|
||||
HGLRC GraphicsGl;
|
||||
@ -649,15 +648,11 @@ static void ShowEditControl(HWND h, int x, int y, char *s) {
|
||||
SetFocus(h);
|
||||
}
|
||||
}
|
||||
void ShowTextEditControl(int hr, int c, char *s)
|
||||
void ShowTextEditControl(int x, int y, char *s)
|
||||
{
|
||||
if(GraphicsEditControlIsVisible()) return;
|
||||
|
||||
int x = SS.TW.LEFT_MARGIN + SS.TW.CHAR_WIDTH*c;
|
||||
int y = (hr - SS.TW.scrollPos)*(SS.TW.LINE_HEIGHT/2);
|
||||
TextEditControlCol = c;
|
||||
TextEditControlHalfRow = hr;
|
||||
ShowEditControl(TextEditControl, x - 1, y + 2, s);
|
||||
ShowEditControl(TextEditControl, x, y, s);
|
||||
}
|
||||
void HideTextEditControl(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user