Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer and boolean types with their C99/C++ standard equivalents, as the latter is more appropriate for a cross-platform application. With matter-of-course exceptions in the Win32-specific code, the types/values have been converted as follows: QWORD --> uint64_t SQWORD --> int64_t DWORD --> uint32_t SDWORD --> int32_t WORD --> uint16_t SWORD --> int16_t BYTE --> uint8_t BOOL --> bool TRUE --> true FALSE --> false The following related changes are also included: * Added C99 integer type definitions for Windows, as stdint.h is not available prior to Visual Studio 2010 * Changed types of some variables in the SolveSpace class from 'int' to 'bool', as they actually represent boolean settings * Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean variables in the Registry * Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int() * TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names inspired by the OpenType spec) * RGB colors are packed into an integer of type uint32_t (nee DWORD), but in a few places, these were represented by an int; these have been corrected to uint32_tpull/3/head
parent
505e3d869c
commit
dd168ad22c
|
@ -1,4 +1,4 @@
|
||||||
static const BYTE FontTexture[256*16*16] = {
|
static const uint8_t FontTexture[256*16*16] = {
|
||||||
0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0,
|
0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0,
|
||||||
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0,
|
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0,
|
||||||
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0,
|
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0,
|
||||||
|
|
|
@ -277,7 +277,7 @@ bool TextWindow::EditControlDoneForPaste(const char *s) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangePasteTransformed(int link, DWORD v) {
|
void TextWindow::ScreenChangePasteTransformed(int link, uint32_t v) {
|
||||||
char str[300];
|
char str[300];
|
||||||
switch(link) {
|
switch(link) {
|
||||||
case 't':
|
case 't':
|
||||||
|
@ -300,7 +300,7 @@ void TextWindow::ScreenChangePasteTransformed(int link, DWORD v) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenPasteTransformed(int link, DWORD v) {
|
void TextWindow::ScreenPasteTransformed(int link, uint32_t v) {
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
switch(link) {
|
switch(link) {
|
||||||
case 'o':
|
case 'o':
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
void TextWindow::ScreenChangeLightDirection(int link, DWORD v) {
|
void TextWindow::ScreenChangeLightDirection(int link, uint32_t v) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
sprintf(str, "%.2f, %.2f, %.2f", CO(SS.lightDir[v]));
|
sprintf(str, "%.2f, %.2f, %.2f", CO(SS.lightDir[v]));
|
||||||
SS.TW.ShowEditControl(29+2*v, 8, str);
|
SS.TW.ShowEditControl(29+2*v, 8, str);
|
||||||
|
@ -14,7 +14,7 @@ void TextWindow::ScreenChangeLightDirection(int link, DWORD v) {
|
||||||
SS.TW.edit.i = v;
|
SS.TW.edit.i = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeLightIntensity(int link, DWORD v) {
|
void TextWindow::ScreenChangeLightIntensity(int link, uint32_t v) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
sprintf(str, "%.2f", SS.lightIntensity[v]);
|
sprintf(str, "%.2f", SS.lightIntensity[v]);
|
||||||
SS.TW.ShowEditControl(29+2*v, 31, str);
|
SS.TW.ShowEditControl(29+2*v, 31, str);
|
||||||
|
@ -22,47 +22,47 @@ void TextWindow::ScreenChangeLightIntensity(int link, DWORD v) {
|
||||||
SS.TW.edit.i = v;
|
SS.TW.edit.i = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeColor(int link, DWORD v) {
|
void TextWindow::ScreenChangeColor(int link, uint32_t v) {
|
||||||
SS.TW.ShowEditControlWithColorPicker(9+2*v, 13, SS.modelColor[v]);
|
SS.TW.ShowEditControlWithColorPicker(9+2*v, 13, SS.modelColor[v]);
|
||||||
|
|
||||||
SS.TW.edit.meaning = EDIT_COLOR;
|
SS.TW.edit.meaning = EDIT_COLOR;
|
||||||
SS.TW.edit.i = v;
|
SS.TW.edit.i = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeChordTolerance(int link, DWORD v) {
|
void TextWindow::ScreenChangeChordTolerance(int link, uint32_t v) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
sprintf(str, "%.2f", SS.chordTol);
|
sprintf(str, "%.2f", SS.chordTol);
|
||||||
SS.TW.ShowEditControl(37, 3, str);
|
SS.TW.ShowEditControl(37, 3, str);
|
||||||
SS.TW.edit.meaning = EDIT_CHORD_TOLERANCE;
|
SS.TW.edit.meaning = EDIT_CHORD_TOLERANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeMaxSegments(int link, DWORD v) {
|
void TextWindow::ScreenChangeMaxSegments(int link, uint32_t v) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
sprintf(str, "%d", SS.maxSegments);
|
sprintf(str, "%d", SS.maxSegments);
|
||||||
SS.TW.ShowEditControl(41, 3, str);
|
SS.TW.ShowEditControl(41, 3, str);
|
||||||
SS.TW.edit.meaning = EDIT_MAX_SEGMENTS;
|
SS.TW.edit.meaning = EDIT_MAX_SEGMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeCameraTangent(int link, DWORD v) {
|
void TextWindow::ScreenChangeCameraTangent(int link, uint32_t v) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
sprintf(str, "%.3f", 1000*SS.cameraTangent);
|
sprintf(str, "%.3f", 1000*SS.cameraTangent);
|
||||||
SS.TW.ShowEditControl(47, 3, str);
|
SS.TW.ShowEditControl(47, 3, str);
|
||||||
SS.TW.edit.meaning = EDIT_CAMERA_TANGENT;
|
SS.TW.edit.meaning = EDIT_CAMERA_TANGENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeGridSpacing(int link, DWORD v) {
|
void TextWindow::ScreenChangeGridSpacing(int link, uint32_t v) {
|
||||||
SS.TW.ShowEditControl(51, 3, SS.MmToString(SS.gridSpacing));
|
SS.TW.ShowEditControl(51, 3, SS.MmToString(SS.gridSpacing));
|
||||||
SS.TW.edit.meaning = EDIT_GRID_SPACING;
|
SS.TW.edit.meaning = EDIT_GRID_SPACING;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeDigitsAfterDecimal(int link, DWORD v) {
|
void TextWindow::ScreenChangeDigitsAfterDecimal(int link, uint32_t v) {
|
||||||
char buf[128];
|
char buf[128];
|
||||||
sprintf(buf, "%d", SS.UnitDigitsAfterDecimal());
|
sprintf(buf, "%d", SS.UnitDigitsAfterDecimal());
|
||||||
SS.TW.ShowEditControl(55, 3, buf);
|
SS.TW.ShowEditControl(55, 3, buf);
|
||||||
SS.TW.edit.meaning = EDIT_DIGITS_AFTER_DECIMAL;
|
SS.TW.edit.meaning = EDIT_DIGITS_AFTER_DECIMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeExportScale(int link, DWORD v) {
|
void TextWindow::ScreenChangeExportScale(int link, uint32_t v) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
sprintf(str, "%.3f", (double)SS.exportScale);
|
sprintf(str, "%.3f", (double)SS.exportScale);
|
||||||
|
|
||||||
|
@ -70,36 +70,36 @@ void TextWindow::ScreenChangeExportScale(int link, DWORD v) {
|
||||||
SS.TW.edit.meaning = EDIT_EXPORT_SCALE;
|
SS.TW.edit.meaning = EDIT_EXPORT_SCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeExportOffset(int link, DWORD v) {
|
void TextWindow::ScreenChangeExportOffset(int link, uint32_t v) {
|
||||||
SS.TW.ShowEditControl(65, 3, SS.MmToString(SS.exportOffset));
|
SS.TW.ShowEditControl(65, 3, SS.MmToString(SS.exportOffset));
|
||||||
SS.TW.edit.meaning = EDIT_EXPORT_OFFSET;
|
SS.TW.edit.meaning = EDIT_EXPORT_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeFixExportColors(int link, DWORD v) {
|
void TextWindow::ScreenChangeFixExportColors(int link, uint32_t v) {
|
||||||
SS.fixExportColors = !SS.fixExportColors;
|
SS.fixExportColors = !SS.fixExportColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeBackFaces(int link, DWORD v) {
|
void TextWindow::ScreenChangeBackFaces(int link, uint32_t v) {
|
||||||
SS.drawBackFaces = !SS.drawBackFaces;
|
SS.drawBackFaces = !SS.drawBackFaces;
|
||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeCheckClosedContour(int link, DWORD v) {
|
void TextWindow::ScreenChangeCheckClosedContour(int link, uint32_t v) {
|
||||||
SS.checkClosedContour = !SS.checkClosedContour;
|
SS.checkClosedContour = !SS.checkClosedContour;
|
||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeShadedTriangles(int link, DWORD v) {
|
void TextWindow::ScreenChangeShadedTriangles(int link, uint32_t v) {
|
||||||
SS.exportShadedTriangles = !SS.exportShadedTriangles;
|
SS.exportShadedTriangles = !SS.exportShadedTriangles;
|
||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangePwlCurves(int link, DWORD v) {
|
void TextWindow::ScreenChangePwlCurves(int link, uint32_t v) {
|
||||||
SS.exportPwlCurves = !SS.exportPwlCurves;
|
SS.exportPwlCurves = !SS.exportPwlCurves;
|
||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeCanvasSizeAuto(int link, DWORD v) {
|
void TextWindow::ScreenChangeCanvasSizeAuto(int link, uint32_t v) {
|
||||||
if(link == 't') {
|
if(link == 't') {
|
||||||
SS.exportCanvasSizeAuto = true;
|
SS.exportCanvasSizeAuto = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -108,7 +108,7 @@ void TextWindow::ScreenChangeCanvasSizeAuto(int link, DWORD v) {
|
||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeCanvasSize(int link, DWORD v) {
|
void TextWindow::ScreenChangeCanvasSize(int link, uint32_t v) {
|
||||||
double d;
|
double d;
|
||||||
switch(v) {
|
switch(v) {
|
||||||
case 0: d = SS.exportMargin.left; break;
|
case 0: d = SS.exportMargin.left; break;
|
||||||
|
@ -136,7 +136,7 @@ void TextWindow::ScreenChangeCanvasSize(int link, DWORD v) {
|
||||||
SS.TW.edit.i = v;
|
SS.TW.edit.i = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeGCodeParameter(int link, DWORD v) {
|
void TextWindow::ScreenChangeGCodeParameter(int link, uint32_t v) {
|
||||||
char buf[1024] = "";
|
char buf[1024] = "";
|
||||||
int row = 93;
|
int row = 93;
|
||||||
switch(link) {
|
switch(link) {
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
void TextWindow::ScreenUnselectAll(int link, DWORD v) {
|
void TextWindow::ScreenUnselectAll(int link, uint32_t v) {
|
||||||
GraphicsWindow::MenuEdit(GraphicsWindow::MNU_UNSELECT_ALL);
|
GraphicsWindow::MenuEdit(GraphicsWindow::MNU_UNSELECT_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenEditTtfText(int link, DWORD v) {
|
void TextWindow::ScreenEditTtfText(int link, uint32_t v) {
|
||||||
hRequest hr = { v };
|
hRequest hr = { v };
|
||||||
Request *r = SK.GetRequest(hr);
|
Request *r = SK.GetRequest(hr);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ void TextWindow::ScreenEditTtfText(int link, DWORD v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define gs (SS.GW.gs)
|
#define gs (SS.GW.gs)
|
||||||
void TextWindow::ScreenSetTtfFont(int link, DWORD v) {
|
void TextWindow::ScreenSetTtfFont(int link, uint32_t v) {
|
||||||
int i = (int)v;
|
int i = (int)v;
|
||||||
if(i < 0) return;
|
if(i < 0) return;
|
||||||
if(i >= SS.fonts.l.n) return;
|
if(i >= SS.fonts.l.n) return;
|
||||||
|
|
6
draw.cpp
6
draw.cpp
|
@ -61,7 +61,7 @@ void GraphicsWindow::Selection::Draw(void) {
|
||||||
topLeft = topLeft.Minus(SS.GW.offset);
|
topLeft = topLeft.Minus(SS.GW.offset);
|
||||||
|
|
||||||
glLineWidth(40);
|
glLineWidth(40);
|
||||||
DWORD rgb = Style::Color(Style::HOVERED);
|
uint32_t rgb = Style::Color(Style::HOVERED);
|
||||||
glColor4d(REDf(rgb), GREENf(rgb), BLUEf(rgb), 0.2);
|
glColor4d(REDf(rgb), GREENf(rgb), BLUEf(rgb), 0.2);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(topLeft);
|
glxVertex3v(topLeft);
|
||||||
|
@ -366,7 +366,7 @@ void GraphicsWindow::HitTestMakeSelection(Point2d mp) {
|
||||||
Group *g = SK.GetGroup(activeGroup);
|
Group *g = SK.GetGroup(activeGroup);
|
||||||
SMesh *m = &(g->displayMesh);
|
SMesh *m = &(g->displayMesh);
|
||||||
|
|
||||||
DWORD v = m->FirstIntersectionWith(mp);
|
uint32_t v = m->FirstIntersectionWith(mp);
|
||||||
if(v) {
|
if(v) {
|
||||||
s.entity.v = v;
|
s.entity.v = v;
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ void GraphicsWindow::Paint(void) {
|
||||||
BLUEf(SS.backgroundColor), 1.0f);
|
BLUEf(SS.backgroundColor), 1.0f);
|
||||||
} else {
|
} else {
|
||||||
// Draw a different background whenever we're having solve problems.
|
// Draw a different background whenever we're having solve problems.
|
||||||
DWORD rgb = Style::Color(Style::DRAW_ERROR);
|
uint32_t rgb = Style::Color(Style::DRAW_ERROR);
|
||||||
glClearColor(0.4f*REDf(rgb), 0.4f*GREENf(rgb), 0.4f*BLUEf(rgb), 1.0f);
|
glClearColor(0.4f*REDf(rgb), 0.4f*GREENf(rgb), 0.4f*BLUEf(rgb), 1.0f);
|
||||||
// And show the text window, which has info to debug it
|
// And show the text window, which has info to debug it
|
||||||
ForceTextWindowShown();
|
ForceTextWindowShown();
|
||||||
|
|
|
@ -562,8 +562,8 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
|
||||||
// Let's adjust the color of this constraint to have the same
|
// Let's adjust the color of this constraint to have the same
|
||||||
// rough luma as the point color, so that the constraint does not
|
// rough luma as the point color, so that the constraint does not
|
||||||
// stand out in an ugly way.
|
// stand out in an ugly way.
|
||||||
DWORD cd = Style::Color(Style::DATUM),
|
uint32_t cd = Style::Color(Style::DATUM),
|
||||||
cc = Style::Color(Style::CONSTRAINT);
|
cc = Style::Color(Style::CONSTRAINT);
|
||||||
// convert from 8-bit color to a vector
|
// convert from 8-bit color to a vector
|
||||||
Vector vd = Vector::From(REDf(cd), GREENf(cd), BLUEf(cd)),
|
Vector vd = Vector::From(REDf(cd), GREENf(cd), BLUEf(cd)),
|
||||||
vc = Vector::From(REDf(cc), GREENf(cc), BLUEf(cc));
|
vc = Vector::From(REDf(cc), GREENf(cc), BLUEf(cc));
|
||||||
|
|
7
dsc.h
7
dsc.h
|
@ -7,9 +7,6 @@
|
||||||
#ifndef __DSC_H
|
#ifndef __DSC_H
|
||||||
#define __DSC_H
|
#define __DSC_H
|
||||||
|
|
||||||
typedef unsigned long DWORD;
|
|
||||||
typedef unsigned char BYTE;
|
|
||||||
|
|
||||||
class Vector;
|
class Vector;
|
||||||
class Vector4;
|
class Vector4;
|
||||||
class Point2d;
|
class Point2d;
|
||||||
|
@ -232,8 +229,8 @@ public:
|
||||||
int n;
|
int n;
|
||||||
int elemsAllocated;
|
int elemsAllocated;
|
||||||
|
|
||||||
DWORD MaximumId(void) {
|
uint32_t MaximumId(void) {
|
||||||
DWORD id = 0;
|
uint32_t id = 0;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < n; i++) {
|
for(i = 0; i < n; i++) {
|
||||||
|
|
14
export.cpp
14
export.cpp
|
@ -503,11 +503,11 @@ void VectorFileWriter::Output(SBezierLoopSetSet *sblss, SMesh *sm) {
|
||||||
b = sbl->l.First();
|
b = sbl->l.First();
|
||||||
if(!b || !Style::Exportable(b->auxA)) continue;
|
if(!b || !Style::Exportable(b->auxA)) continue;
|
||||||
|
|
||||||
hStyle hs = { (DWORD)b->auxA };
|
hStyle hs = { (uint32_t)b->auxA };
|
||||||
Style *stl = Style::Get(hs);
|
Style *stl = Style::Get(hs);
|
||||||
double lineWidth = Style::WidthMm(b->auxA)*s;
|
double lineWidth = Style::WidthMm(b->auxA)*s;
|
||||||
DWORD strokeRgb = Style::Color(hs, true);
|
uint32_t strokeRgb = Style::Color(hs, true);
|
||||||
DWORD fillRgb = Style::FillColor(hs, true);
|
uint32_t fillRgb = Style::FillColor(hs, true);
|
||||||
|
|
||||||
StartPath(strokeRgb, lineWidth, stl->filled, fillRgb);
|
StartPath(strokeRgb, lineWidth, stl->filled, fillRgb);
|
||||||
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
|
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
|
||||||
|
@ -608,7 +608,7 @@ void SolveSpace::ExportMeshAsStlTo(FILE *f, SMesh *sm) {
|
||||||
strcpy(str, "STL exported mesh");
|
strcpy(str, "STL exported mesh");
|
||||||
fwrite(str, 1, 80, f);
|
fwrite(str, 1, 80, f);
|
||||||
|
|
||||||
DWORD n = sm->l.n;
|
uint32_t n = sm->l.n;
|
||||||
fwrite(&n, 4, 1, f);
|
fwrite(&n, 4, 1, f);
|
||||||
|
|
||||||
double s = SS.exportScale;
|
double s = SS.exportScale;
|
||||||
|
@ -677,7 +677,7 @@ void SolveSpace::ExportAsPngTo(char *filename) {
|
||||||
int w = (int)SS.GW.width, h = (int)SS.GW.height;
|
int w = (int)SS.GW.width, h = (int)SS.GW.height;
|
||||||
// No guarantee that the back buffer contains anything valid right now,
|
// No guarantee that the back buffer contains anything valid right now,
|
||||||
// so repaint the scene. And hide the toolbar too.
|
// so repaint the scene. And hide the toolbar too.
|
||||||
int prevShowToolbar = SS.showToolbar;
|
bool prevShowToolbar = SS.showToolbar;
|
||||||
SS.showToolbar = false;
|
SS.showToolbar = false;
|
||||||
SS.GW.Paint();
|
SS.GW.Paint();
|
||||||
SS.showToolbar = prevShowToolbar;
|
SS.showToolbar = prevShowToolbar;
|
||||||
|
@ -708,8 +708,8 @@ void SolveSpace::ExportAsPngTo(char *filename) {
|
||||||
png_write_info(png_ptr, info_ptr);
|
png_write_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
// Get the pixel data from the framebuffer
|
// Get the pixel data from the framebuffer
|
||||||
BYTE *pixels; pixels = (BYTE *)AllocTemporary(3*w*h);
|
uint8_t *pixels; pixels = (uint8_t *)AllocTemporary(3*w*h);
|
||||||
BYTE **rowptrs; rowptrs = (BYTE **)AllocTemporary(h*sizeof(BYTE *));
|
uint8_t **rowptrs; rowptrs = (uint8_t **)AllocTemporary(h*sizeof(uint8_t *));
|
||||||
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
|
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
|
||||||
|
|
||||||
int y;
|
int y;
|
||||||
|
|
|
@ -64,12 +64,12 @@ void DxfFileWriter::StartFile(void) {
|
||||||
"ENTITIES\r\n");
|
"ENTITIES\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DxfFileWriter::StartPath(DWORD strokeRgb, double lineWidth,
|
void DxfFileWriter::StartPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void DxfFileWriter::FinishPath(DWORD strokeRgb, double lineWidth,
|
void DxfFileWriter::FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,14 +165,14 @@ void EpsFileWriter::StartFile(void) {
|
||||||
MmToPts(ptMax.y - ptMin.y));
|
MmToPts(ptMax.y - ptMin.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EpsFileWriter::StartPath(DWORD strokeRgb, double lineWidth,
|
void EpsFileWriter::StartPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
fprintf(f, "newpath\r\n");
|
fprintf(f, "newpath\r\n");
|
||||||
prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
|
prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
|
||||||
}
|
}
|
||||||
void EpsFileWriter::FinishPath(DWORD strokeRgb, double lineWidth,
|
void EpsFileWriter::FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
fprintf(f, " %.3f setlinewidth\r\n"
|
fprintf(f, " %.3f setlinewidth\r\n"
|
||||||
" %.3f %.3f %.3f setrgbcolor\r\n"
|
" %.3f %.3f %.3f setrgbcolor\r\n"
|
||||||
|
@ -277,7 +277,7 @@ void PdfFileWriter::StartFile(void) {
|
||||||
"%%%c%c%c%c\r\n",
|
"%%%c%c%c%c\r\n",
|
||||||
0xe2, 0xe3, 0xcf, 0xd3);
|
0xe2, 0xe3, 0xcf, 0xd3);
|
||||||
|
|
||||||
xref[1] = (DWORD)ftell(f);
|
xref[1] = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"1 0 obj\r\n"
|
"1 0 obj\r\n"
|
||||||
" << /Type /Catalog\r\n"
|
" << /Type /Catalog\r\n"
|
||||||
|
@ -286,7 +286,7 @@ void PdfFileWriter::StartFile(void) {
|
||||||
" >>\r\n"
|
" >>\r\n"
|
||||||
"endobj\r\n");
|
"endobj\r\n");
|
||||||
|
|
||||||
xref[2] = (DWORD)ftell(f);
|
xref[2] = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"2 0 obj\r\n"
|
"2 0 obj\r\n"
|
||||||
" << /Type /Outlines\r\n"
|
" << /Type /Outlines\r\n"
|
||||||
|
@ -294,7 +294,7 @@ void PdfFileWriter::StartFile(void) {
|
||||||
" >>\r\n"
|
" >>\r\n"
|
||||||
"endobj\r\n");
|
"endobj\r\n");
|
||||||
|
|
||||||
xref[3] = (DWORD)ftell(f);
|
xref[3] = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"3 0 obj\r\n"
|
"3 0 obj\r\n"
|
||||||
" << /Type /Pages\r\n"
|
" << /Type /Pages\r\n"
|
||||||
|
@ -303,7 +303,7 @@ void PdfFileWriter::StartFile(void) {
|
||||||
" >>\r\n"
|
" >>\r\n"
|
||||||
"endobj\r\n");
|
"endobj\r\n");
|
||||||
|
|
||||||
xref[4] = (DWORD)ftell(f);
|
xref[4] = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"4 0 obj\r\n"
|
"4 0 obj\r\n"
|
||||||
" << /Type /Page\r\n"
|
" << /Type /Page\r\n"
|
||||||
|
@ -318,35 +318,35 @@ void PdfFileWriter::StartFile(void) {
|
||||||
MmToPts(ptMax.x - ptMin.x),
|
MmToPts(ptMax.x - ptMin.x),
|
||||||
MmToPts(ptMax.y - ptMin.y));
|
MmToPts(ptMax.y - ptMin.y));
|
||||||
|
|
||||||
xref[5] = (DWORD)ftell(f);
|
xref[5] = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"5 0 obj\r\n"
|
"5 0 obj\r\n"
|
||||||
" << /Length 6 0 R >>\r\n"
|
" << /Length 6 0 R >>\r\n"
|
||||||
"stream\r\n");
|
"stream\r\n");
|
||||||
bodyStart = (DWORD)ftell(f);
|
bodyStart = (uint32_t)ftell(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfFileWriter::FinishAndCloseFile(void) {
|
void PdfFileWriter::FinishAndCloseFile(void) {
|
||||||
DWORD bodyEnd = (DWORD)ftell(f);
|
uint32_t bodyEnd = (uint32_t)ftell(f);
|
||||||
|
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"endstream\r\n"
|
"endstream\r\n"
|
||||||
"endobj\r\n");
|
"endobj\r\n");
|
||||||
|
|
||||||
xref[6] = (DWORD)ftell(f);
|
xref[6] = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"6 0 obj\r\n"
|
"6 0 obj\r\n"
|
||||||
" %d\r\n"
|
" %d\r\n"
|
||||||
"endobj\r\n",
|
"endobj\r\n",
|
||||||
bodyEnd - bodyStart);
|
bodyEnd - bodyStart);
|
||||||
|
|
||||||
xref[7] = (DWORD)ftell(f);
|
xref[7] = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"7 0 obj\r\n"
|
"7 0 obj\r\n"
|
||||||
" [/PDF /Text]\r\n"
|
" [/PDF /Text]\r\n"
|
||||||
"endobj\r\n");
|
"endobj\r\n");
|
||||||
|
|
||||||
xref[8] = (DWORD)ftell(f);
|
xref[8] = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"8 0 obj\r\n"
|
"8 0 obj\r\n"
|
||||||
" << /Type /Font\r\n"
|
" << /Type /Font\r\n"
|
||||||
|
@ -357,13 +357,13 @@ void PdfFileWriter::FinishAndCloseFile(void) {
|
||||||
" >>\r\n"
|
" >>\r\n"
|
||||||
"endobj\r\n");
|
"endobj\r\n");
|
||||||
|
|
||||||
xref[9] = (DWORD)ftell(f);
|
xref[9] = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"9 0 obj\r\n"
|
"9 0 obj\r\n"
|
||||||
" << /Creator (SolveSpace)\r\n"
|
" << /Creator (SolveSpace)\r\n"
|
||||||
" >>\r\n");
|
" >>\r\n");
|
||||||
|
|
||||||
DWORD xrefStart = (DWORD)ftell(f);
|
uint32_t xrefStart = (uint32_t)ftell(f);
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"xref\r\n"
|
"xref\r\n"
|
||||||
"0 10\r\n"
|
"0 10\r\n"
|
||||||
|
@ -390,8 +390,8 @@ void PdfFileWriter::FinishAndCloseFile(void) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfFileWriter::StartPath(DWORD strokeRgb, double lineWidth,
|
void PdfFileWriter::StartPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
fprintf(f, "1 J 1 j " // round endcaps and joins
|
fprintf(f, "1 J 1 j " // round endcaps and joins
|
||||||
"%.3f w "
|
"%.3f w "
|
||||||
|
@ -405,8 +405,8 @@ void PdfFileWriter::StartPath(DWORD strokeRgb, double lineWidth,
|
||||||
|
|
||||||
prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
|
prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
|
||||||
}
|
}
|
||||||
void PdfFileWriter::FinishPath(DWORD strokeRgb, double lineWidth,
|
void PdfFileWriter::FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
if(filled) {
|
if(filled) {
|
||||||
fprintf(f, "b\r\n");
|
fprintf(f, "b\r\n");
|
||||||
|
@ -480,14 +480,14 @@ void SvgFileWriter::StartFile(void) {
|
||||||
// A little bit of extra space for the stroke width.
|
// A little bit of extra space for the stroke width.
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgFileWriter::StartPath(DWORD strokeRgb, double lineWidth,
|
void SvgFileWriter::StartPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
fprintf(f, "<path d='");
|
fprintf(f, "<path d='");
|
||||||
prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
|
prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE);
|
||||||
}
|
}
|
||||||
void SvgFileWriter::FinishPath(DWORD strokeRgb, double lineWidth,
|
void SvgFileWriter::FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
char fill[100];
|
char fill[100];
|
||||||
if(filled) {
|
if(filled) {
|
||||||
|
@ -585,12 +585,12 @@ void HpglFileWriter::StartFile(void) {
|
||||||
fprintf(f, "SP1;\r\n");
|
fprintf(f, "SP1;\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void HpglFileWriter::StartPath(DWORD strokeRgb, double lineWidth,
|
void HpglFileWriter::StartPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void HpglFileWriter::FinishPath(DWORD strokeRgb, double lineWidth,
|
void HpglFileWriter::FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,12 +622,12 @@ void HpglFileWriter::FinishAndCloseFile(void) {
|
||||||
void GCodeFileWriter::StartFile(void) {
|
void GCodeFileWriter::StartFile(void) {
|
||||||
ZERO(&sel);
|
ZERO(&sel);
|
||||||
}
|
}
|
||||||
void GCodeFileWriter::StartPath(DWORD strokeRgb, double lineWidth,
|
void GCodeFileWriter::StartPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void GCodeFileWriter::FinishPath(DWORD strokeRgb, double lineWidth,
|
void GCodeFileWriter::FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void GCodeFileWriter::Triangle(STriangle *tr) {
|
void GCodeFileWriter::Triangle(STriangle *tr) {
|
||||||
|
@ -691,12 +691,12 @@ void Step2dFileWriter::StartFile(void) {
|
||||||
void Step2dFileWriter::Triangle(STriangle *tr) {
|
void Step2dFileWriter::Triangle(STriangle *tr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Step2dFileWriter::StartPath(DWORD strokeRgb, double lineWidth,
|
void Step2dFileWriter::StartPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void Step2dFileWriter::FinishPath(DWORD strokeRgb, double lineWidth,
|
void Step2dFileWriter::FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb)
|
bool filled, uint32_t fillRgb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
|
||||||
// Nothing to do for now.
|
// Nothing to do for now.
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoMessageBox(char *str, int rows, int cols, BOOL error)
|
void DoMessageBox(char *str, int rows, int cols, bool error)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef DWORD Slvs_hParam;
|
typedef uint32_t Slvs_hParam;
|
||||||
typedef DWORD Slvs_hEntity;
|
typedef uint32_t Slvs_hEntity;
|
||||||
typedef DWORD Slvs_hConstraint;
|
typedef uint32_t Slvs_hConstraint;
|
||||||
typedef DWORD Slvs_hGroup;
|
typedef uint32_t Slvs_hGroup;
|
||||||
|
|
||||||
// To obtain the 3d (not projected into a workplane) of a constraint or
|
// To obtain the 3d (not projected into a workplane) of a constraint or
|
||||||
// an entity, specify this instead of the workplane.
|
// an entity, specify this instead of the workplane.
|
||||||
|
|
8
expr.cpp
8
expr.cpp
|
@ -372,10 +372,10 @@ Expr *Expr::PartialWrt(hParam p) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QWORD Expr::ParamsUsed(void) {
|
uint64_t Expr::ParamsUsed(void) {
|
||||||
QWORD r = 0;
|
uint64_t r = 0;
|
||||||
if(op == PARAM) r |= ((QWORD)1 << (x.parh.v % 61));
|
if(op == PARAM) r |= ((uint64_t)1 << (x.parh.v % 61));
|
||||||
if(op == PARAM_PTR) r |= ((QWORD)1 << (x.parp->h.v % 61));
|
if(op == PARAM_PTR) r |= ((uint64_t)1 << (x.parp->h.v % 61));
|
||||||
|
|
||||||
int c = Children();
|
int c = Children();
|
||||||
if(c >= 1) r |= a->ParamsUsed();
|
if(c >= 1) r |= a->ParamsUsed();
|
||||||
|
|
4
expr.h
4
expr.h
|
@ -12,7 +12,7 @@ class Expr;
|
||||||
|
|
||||||
class Expr {
|
class Expr {
|
||||||
public:
|
public:
|
||||||
DWORD marker;
|
uint32_t marker;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// A parameter, by the hParam handle
|
// A parameter, by the hParam handle
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
Expr *PartialWrt(hParam p);
|
Expr *PartialWrt(hParam p);
|
||||||
double Eval(void);
|
double Eval(void);
|
||||||
QWORD ParamsUsed(void);
|
uint64_t ParamsUsed(void);
|
||||||
bool DependsOn(hParam p);
|
bool DependsOn(hParam p);
|
||||||
static bool Tol(double a, double b);
|
static bool Tol(double a, double b);
|
||||||
Expr *FoldConstants(void);
|
Expr *FoldConstants(void);
|
||||||
|
|
11
file.cpp
11
file.cpp
|
@ -209,16 +209,16 @@ void SolveSpace::SaveUsingTable(int type) {
|
||||||
int fmt = SAVED[i].fmt;
|
int fmt = SAVED[i].fmt;
|
||||||
void *p = SAVED[i].ptr;
|
void *p = SAVED[i].ptr;
|
||||||
// Any items that aren't specified are assumed to be zero
|
// Any items that aren't specified are assumed to be zero
|
||||||
if(fmt == 'd' && *((int *)p) == 0) continue;
|
if(fmt == 'd' && *((int *)p) == 0) continue;
|
||||||
if(fmt == 'x' && *((DWORD *)p) == 0) continue;
|
if(fmt == 'x' && *((uint32_t *)p) == 0) continue;
|
||||||
if(fmt == 'f' && *((double *)p) == 0.0) continue;
|
if(fmt == 'f' && *((double *)p) == 0.0) continue;
|
||||||
if(fmt == 'N' && strlen(((NameStr *)p)->str) == 0) continue;
|
if(fmt == 'N' && strlen(((NameStr *)p)->str) == 0) continue;
|
||||||
|
|
||||||
fprintf(fh, "%s=", SAVED[i].desc);
|
fprintf(fh, "%s=", SAVED[i].desc);
|
||||||
switch(fmt) {
|
switch(fmt) {
|
||||||
case 'd': fprintf(fh, "%d", *((int *)p)); break;
|
case 'd': fprintf(fh, "%d", *((int *)p)); break;
|
||||||
case 'b': fprintf(fh, "%d", *((bool *)p) ? 1 : 0); break;
|
case 'b': fprintf(fh, "%d", *((bool *)p) ? 1 : 0); break;
|
||||||
case 'x': fprintf(fh, "%08x", *((DWORD *)p)); break;
|
case 'x': fprintf(fh, "%08x", *((uint32_t *)p)); break;
|
||||||
case 'f': fprintf(fh, "%.20f", *((double *)p)); break;
|
case 'f': fprintf(fh, "%.20f", *((double *)p)); break;
|
||||||
case 'N': fprintf(fh, "%s", ((NameStr *)p)->str); break;
|
case 'N': fprintf(fh, "%s", ((NameStr *)p)->str); break;
|
||||||
case 'P': fprintf(fh, "%s", (char *)p); break;
|
case 'P': fprintf(fh, "%s", (char *)p); break;
|
||||||
|
@ -360,10 +360,11 @@ void SolveSpace::LoadUsingTable(char *key, char *val) {
|
||||||
for(i = 0; SAVED[i].type != 0; i++) {
|
for(i = 0; SAVED[i].type != 0; i++) {
|
||||||
if(strcmp(SAVED[i].desc, key)==0) {
|
if(strcmp(SAVED[i].desc, key)==0) {
|
||||||
void *p = SAVED[i].ptr;
|
void *p = SAVED[i].ptr;
|
||||||
|
unsigned int u = 0;
|
||||||
switch(SAVED[i].fmt) {
|
switch(SAVED[i].fmt) {
|
||||||
case 'd': *((int *)p) = atoi(val); break;
|
case 'd': *((int *)p) = atoi(val); break;
|
||||||
case 'b': *((bool *)p) = (atoi(val) != 0); break;
|
case 'b': *((bool *)p) = (atoi(val) != 0); break;
|
||||||
case 'x': sscanf(val, "%x", (DWORD *)p); break;
|
case 'x': sscanf(val, "%x", &u); *((uint32_t *)p) = u; break;
|
||||||
case 'f': *((double *)p) = atof(val); break;
|
case 'f': *((double *)p) = atof(val); break;
|
||||||
case 'N': ((NameStr *)p)->strcpy(val); break;
|
case 'N': ((NameStr *)p)->strcpy(val); break;
|
||||||
|
|
||||||
|
|
|
@ -179,13 +179,13 @@ void SolveSpace::GenerateAll(int first, int last, bool andFindFree) {
|
||||||
SK.param.MoveSelfInto(&prev);
|
SK.param.MoveSelfInto(&prev);
|
||||||
SK.entity.Clear();
|
SK.entity.Clear();
|
||||||
|
|
||||||
SDWORD inTime = GetMilliseconds();
|
int32_t inTime = GetMilliseconds();
|
||||||
|
|
||||||
bool displayedStatusMessage = false;
|
bool displayedStatusMessage = false;
|
||||||
for(i = 0; i < SK.group.n; i++) {
|
for(i = 0; i < SK.group.n; i++) {
|
||||||
Group *g = &(SK.group.elem[i]);
|
Group *g = &(SK.group.elem[i]);
|
||||||
|
|
||||||
SDWORD now = GetMilliseconds();
|
int32_t now = GetMilliseconds();
|
||||||
// Display the status message if we've taken more than 400 ms, or
|
// Display the status message if we've taken more than 400 ms, or
|
||||||
// if we've taken 200 ms but we're not even halfway done, or if
|
// if we've taken 200 ms but we're not even halfway done, or if
|
||||||
// we've already started displaying the status message.
|
// we've already started displaying the status message.
|
||||||
|
|
38
glhelper.cpp
38
glhelper.cpp
|
@ -178,7 +178,7 @@ void glxFatLine(Vector a, Vector b, double width)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void glxLockColorTo(DWORD rgb)
|
void glxLockColorTo(uint32_t rgb)
|
||||||
{
|
{
|
||||||
ColorLocked = false;
|
ColorLocked = false;
|
||||||
glColor3d(REDf(rgb), GREENf(rgb), BLUEf(rgb));
|
glColor3d(REDf(rgb), GREENf(rgb), BLUEf(rgb));
|
||||||
|
@ -190,21 +190,21 @@ void glxUnlockColor(void)
|
||||||
ColorLocked = false;
|
ColorLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxColorRGB(DWORD rgb)
|
void glxColorRGB(uint32_t rgb)
|
||||||
{
|
{
|
||||||
// Is there a bug in some graphics drivers where this is not equivalent
|
// Is there a bug in some graphics drivers where this is not equivalent
|
||||||
// to glColor3d? There seems to be...
|
// to glColor3d? There seems to be...
|
||||||
glxColorRGBa(rgb, 1.0);
|
glxColorRGBa(rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxColorRGBa(DWORD rgb, double a)
|
void glxColorRGBa(uint32_t rgb, double a)
|
||||||
{
|
{
|
||||||
if(!ColorLocked) glColor4d(REDf(rgb), GREENf(rgb), BLUEf(rgb), a);
|
if(!ColorLocked) glColor4d(REDf(rgb), GREENf(rgb), BLUEf(rgb), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Stipple(BOOL forSel)
|
static void Stipple(bool forSel)
|
||||||
{
|
{
|
||||||
static BOOL Init;
|
static bool Init;
|
||||||
const int BYTES = (32*32)/8;
|
const int BYTES = (32*32)/8;
|
||||||
static GLubyte HoverMask[BYTES];
|
static GLubyte HoverMask[BYTES];
|
||||||
static GLubyte SelMask[BYTES];
|
static GLubyte SelMask[BYTES];
|
||||||
|
@ -222,7 +222,7 @@ static void Stipple(BOOL forSel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Init = TRUE;
|
Init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_POLYGON_STIPPLE);
|
glEnable(GL_POLYGON_STIPPLE);
|
||||||
|
@ -233,7 +233,7 @@ static void Stipple(BOOL forSel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StippleTriangle(STriangle *tr, BOOL s, DWORD rgb)
|
static void StippleTriangle(STriangle *tr, bool s, uint32_t rgb)
|
||||||
{
|
{
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
|
@ -249,19 +249,19 @@ static void StippleTriangle(STriangle *tr, BOOL s, DWORD rgb)
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxFillMesh(int specColor, SMesh *m, DWORD h, DWORD s1, DWORD s2)
|
void glxFillMesh(uint32_t specColor, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2)
|
||||||
{
|
{
|
||||||
DWORD rgbHovered = Style::Color(Style::HOVERED),
|
uint32_t rgbHovered = Style::Color(Style::HOVERED),
|
||||||
rgbSelected = Style::Color(Style::SELECTED);
|
rgbSelected = Style::Color(Style::SELECTED);
|
||||||
|
|
||||||
glEnable(GL_NORMALIZE);
|
glEnable(GL_NORMALIZE);
|
||||||
int prevColor = -1;
|
uint32_t prevColor = (uint32_t)-1;
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
for(int i = 0; i < m->l.n; i++) {
|
for(int i = 0; i < m->l.n; i++) {
|
||||||
STriangle *tr = &(m->l.elem[i]);
|
STriangle *tr = &(m->l.elem[i]);
|
||||||
|
|
||||||
int color;
|
uint32_t color;
|
||||||
if(specColor < 0) {
|
if(specColor & 0x80000000) {
|
||||||
color = tr->meta.color;
|
color = tr->meta.color;
|
||||||
} else {
|
} else {
|
||||||
color = specColor;
|
color = specColor;
|
||||||
|
@ -296,10 +296,10 @@ void glxFillMesh(int specColor, SMesh *m, DWORD h, DWORD s1, DWORD s2)
|
||||||
if((s1 != 0 && tr->meta.face == s1) ||
|
if((s1 != 0 && tr->meta.face == s1) ||
|
||||||
(s2 != 0 && tr->meta.face == s2))
|
(s2 != 0 && tr->meta.face == s2))
|
||||||
{
|
{
|
||||||
StippleTriangle(tr, TRUE, rgbSelected);
|
StippleTriangle(tr, true, rgbSelected);
|
||||||
}
|
}
|
||||||
if(h != 0 && tr->meta.face == h) {
|
if(h != 0 && tr->meta.face == h) {
|
||||||
StippleTriangle(tr, FALSE, rgbHovered);
|
StippleTriangle(tr, false, rgbHovered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
@ -488,7 +488,7 @@ void glxCreateBitmapFont(void)
|
||||||
// Place the font in our texture in a two-dimensional grid; 1d would
|
// Place the font in our texture in a two-dimensional grid; 1d would
|
||||||
// be simpler, but long skinny textures (256*16 = 4096 pixels wide)
|
// be simpler, but long skinny textures (256*16 = 4096 pixels wide)
|
||||||
// won't work.
|
// won't work.
|
||||||
static BYTE MappedTexture[4*16*64*16];
|
static uint8_t MappedTexture[4*16*64*16];
|
||||||
int a, i;
|
int a, i;
|
||||||
for(a = 0; a < 256; a++) {
|
for(a = 0; a < 256; a++) {
|
||||||
int row = a / 4, col = a % 4;
|
int row = a / 4, col = a % 4;
|
||||||
|
@ -515,7 +515,7 @@ void glxCreateBitmapFont(void)
|
||||||
|
|
||||||
void glxBitmapCharQuad(char c, double x, double y)
|
void glxBitmapCharQuad(char c, double x, double y)
|
||||||
{
|
{
|
||||||
BYTE b = (BYTE)c;
|
uint8_t b = (uint8_t)c;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
if(b & 0x80) {
|
if(b & 0x80) {
|
||||||
|
@ -563,10 +563,10 @@ void glxBitmapText(const char *str, Vector p)
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxDrawPixelsWithTexture(BYTE *data, int w, int h)
|
void glxDrawPixelsWithTexture(uint8_t *data, int w, int h)
|
||||||
{
|
{
|
||||||
#define MAX_DIM 32
|
#define MAX_DIM 32
|
||||||
static BYTE Texture[MAX_DIM*MAX_DIM*3];
|
static uint8_t Texture[MAX_DIM*MAX_DIM*3];
|
||||||
int i, j;
|
int i, j;
|
||||||
if(w > MAX_DIM || h > MAX_DIM) oops();
|
if(w > MAX_DIM || h > MAX_DIM) oops();
|
||||||
|
|
||||||
|
|
|
@ -249,13 +249,13 @@ void GraphicsWindow::AnimateOnto(Quaternion quatf, Vector offsetf) {
|
||||||
double mo = (offset0.Minus(offsetf)).Magnitude()*scale;
|
double mo = (offset0.Minus(offsetf)).Magnitude()*scale;
|
||||||
|
|
||||||
// Animate transition, unless it's a tiny move.
|
// Animate transition, unless it's a tiny move.
|
||||||
SDWORD dt = (mp < 0.01 && mo < 10) ? (-20) :
|
int32_t dt = (mp < 0.01 && mo < 10) ? (-20) :
|
||||||
(SDWORD)(100 + 1000*mp + 0.4*mo);
|
(int32_t)(100 + 1000*mp + 0.4*mo);
|
||||||
// Don't ever animate for longer than 2000 ms; we can get absurdly
|
// Don't ever animate for longer than 2000 ms; we can get absurdly
|
||||||
// long translations (as measured in pixels) if the user zooms out, moves,
|
// long translations (as measured in pixels) if the user zooms out, moves,
|
||||||
// and then zooms in again.
|
// and then zooms in again.
|
||||||
if(dt > 2000) dt = 2000;
|
if(dt > 2000) dt = 2000;
|
||||||
SDWORD tn, t0 = GetMilliseconds();
|
int32_t tn, t0 = GetMilliseconds();
|
||||||
double s = 0;
|
double s = 0;
|
||||||
Quaternion dq = quatf.Times(quat0.Inverse());
|
Quaternion dq = quatf.Times(quat0.Inverse());
|
||||||
do {
|
do {
|
||||||
|
@ -621,7 +621,7 @@ void GraphicsWindow::ForceTextWindowShown(void) {
|
||||||
if(!showTextWindow) {
|
if(!showTextWindow) {
|
||||||
showTextWindow = true;
|
showTextWindow = true;
|
||||||
CheckMenuById(MNU_SHOW_TEXT_WND, true);
|
CheckMenuById(MNU_SHOW_TEXT_WND, true);
|
||||||
ShowTextWindow(TRUE);
|
ShowTextWindow(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -448,7 +448,7 @@ void Group::DrawDisplayItems(int t) {
|
||||||
|
|
||||||
// When we fill the mesh, we need to know which triangles are selected
|
// When we fill the mesh, we need to know which triangles are selected
|
||||||
// or hovered, in order to draw them differently.
|
// or hovered, in order to draw them differently.
|
||||||
DWORD mh = 0, ms1 = 0, ms2 = 0;
|
uint32_t mh = 0, ms1 = 0, ms2 = 0;
|
||||||
hEntity he = SS.GW.hover.entity;
|
hEntity he = SS.GW.hover.entity;
|
||||||
if(he.v != 0 && SK.GetEntity(he)->IsFace()) {
|
if(he.v != 0 && SK.GetEntity(he)->IsFace()) {
|
||||||
mh = he.v;
|
mh = he.v;
|
||||||
|
@ -546,7 +546,7 @@ void Group::DrawFilledPaths(void) {
|
||||||
// In an assembled loop, all the styles should be the same; so doesn't
|
// In an assembled loop, all the styles should be the same; so doesn't
|
||||||
// matter which one we grab.
|
// matter which one we grab.
|
||||||
SBezier *sb = &(sbls->l.elem[0].l.elem[0]);
|
SBezier *sb = &(sbls->l.elem[0].l.elem[0]);
|
||||||
hStyle hs = { (DWORD)sb->auxA };
|
hStyle hs = { (uint32_t)sb->auxA };
|
||||||
Style *s = Style::Get(hs);
|
Style *s = Style::Get(hs);
|
||||||
if(s->filled) {
|
if(s->filled) {
|
||||||
// This is a filled loop, where the user specified a fill color.
|
// This is a filled loop, where the user specified a fill color.
|
||||||
|
|
8
mesh.cpp
8
mesh.cpp
|
@ -324,12 +324,12 @@ bool SMesh::IsEmpty(void) {
|
||||||
return (l.n == 0);
|
return (l.n == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD SMesh::FirstIntersectionWith(Point2d mp) {
|
uint32_t SMesh::FirstIntersectionWith(Point2d mp) {
|
||||||
Vector p0 = Vector::From(mp.x, mp.y, 0);
|
Vector p0 = Vector::From(mp.x, mp.y, 0);
|
||||||
Vector gn = Vector::From(0, 0, 1);
|
Vector gn = Vector::From(0, 0, 1);
|
||||||
|
|
||||||
double maxT = -1e12;
|
double maxT = -1e12;
|
||||||
DWORD face = 0;
|
uint32_t face = 0;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < l.n; i++) {
|
for(i = 0; i < l.n; i++) {
|
||||||
|
@ -795,7 +795,7 @@ void SKdNode::OcclusionTestLine(SEdge orig, SEdgeList *sel, int cnt) {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void SKdNode::FindEdgeOn(Vector a, Vector b, int *n, int cnt,
|
void SKdNode::FindEdgeOn(Vector a, Vector b, int *n, int cnt,
|
||||||
bool coplanarIsInter, bool *inter, bool *fwd,
|
bool coplanarIsInter, bool *inter, bool *fwd,
|
||||||
DWORD *face)
|
uint32_t *face)
|
||||||
{
|
{
|
||||||
if(gt && lt) {
|
if(gt && lt) {
|
||||||
double ac = a.Element(which),
|
double ac = a.Element(which),
|
||||||
|
@ -919,7 +919,7 @@ void SKdNode::MakeCertainEdgesInto(SEdgeList *sel, int how,
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
bool thisIntersects = false, fwd;
|
bool thisIntersects = false, fwd;
|
||||||
DWORD face;
|
uint32_t face;
|
||||||
FindEdgeOn(a, b, &n, cnt, coplanarIsInter,
|
FindEdgeOn(a, b, &n, cnt, coplanarIsInter,
|
||||||
&thisIntersects, &fwd, &face);
|
&thisIntersects, &fwd, &face);
|
||||||
|
|
||||||
|
|
|
@ -689,7 +689,7 @@ void GraphicsWindow::MouseRightUp(double x, double y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case CMNU_NEW_CUSTOM_STYLE: {
|
case CMNU_NEW_CUSTOM_STYLE: {
|
||||||
DWORD v = Style::CreateCustomStyle();
|
uint32_t v = Style::CreateCustomStyle();
|
||||||
Style::AssignSelectionToStyle(v);
|
Style::AssignSelectionToStyle(v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1291,7 +1291,7 @@ void GraphicsWindow::SpaceNavigatorMoved(double tx, double ty, double tz,
|
||||||
// If we go five seconds without SpaceNavigator input, or if we've
|
// If we go five seconds without SpaceNavigator input, or if we've
|
||||||
// switched groups, then consider that a new action and save an undo
|
// switched groups, then consider that a new action and save an undo
|
||||||
// point.
|
// point.
|
||||||
SDWORD now = GetMilliseconds();
|
int32_t now = GetMilliseconds();
|
||||||
if(now - lastSpaceNavigatorTime > 5000 ||
|
if(now - lastSpaceNavigatorTime > 5000 ||
|
||||||
lastSpaceNavigatorGroup.v != g->h.v)
|
lastSpaceNavigatorGroup.v != g->h.v)
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,8 +122,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DWORD face;
|
uint32_t face;
|
||||||
int color;
|
uint32_t color;
|
||||||
} STriMeta;
|
} STriMeta;
|
||||||
|
|
||||||
class SPolygon {
|
class SPolygon {
|
||||||
|
@ -251,7 +251,7 @@ public:
|
||||||
bool IsEmpty(void);
|
bool IsEmpty(void);
|
||||||
void RemapFaces(Group *g, int remap);
|
void RemapFaces(Group *g, int remap);
|
||||||
|
|
||||||
DWORD FirstIntersectionWith(Point2d mp);
|
uint32_t FirstIntersectionWith(Point2d mp);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A linked list of triangles
|
// A linked list of triangles
|
||||||
|
@ -284,7 +284,7 @@ public:
|
||||||
|
|
||||||
void FindEdgeOn(Vector a, Vector b, int *n, int cnt, bool coplanarIsInter,
|
void FindEdgeOn(Vector a, Vector b, int *n, int cnt, bool coplanarIsInter,
|
||||||
bool *inter, bool *fwd,
|
bool *inter, bool *fwd,
|
||||||
DWORD *face);
|
uint32_t *face);
|
||||||
enum {
|
enum {
|
||||||
NAKED_OR_SELF_INTER_EDGES = 100,
|
NAKED_OR_SELF_INTER_EDGES = 100,
|
||||||
SELF_INTER_EDGES = 200,
|
SELF_INTER_EDGES = 200,
|
||||||
|
|
40
sketch.h
40
sketch.h
|
@ -26,7 +26,7 @@ class Equation;
|
||||||
class hGroup {
|
class hGroup {
|
||||||
public:
|
public:
|
||||||
// bits 15: 0 -- group index
|
// bits 15: 0 -- group index
|
||||||
DWORD v;
|
uint32_t v;
|
||||||
|
|
||||||
inline hEntity entity(int i);
|
inline hEntity entity(int i);
|
||||||
inline hParam param(int i);
|
inline hParam param(int i);
|
||||||
|
@ -35,7 +35,7 @@ public:
|
||||||
class hRequest {
|
class hRequest {
|
||||||
public:
|
public:
|
||||||
// bits 15: 0 -- request index
|
// bits 15: 0 -- request index
|
||||||
DWORD v;
|
uint32_t v;
|
||||||
|
|
||||||
inline hEntity entity(int i);
|
inline hEntity entity(int i);
|
||||||
inline hParam param(int i);
|
inline hParam param(int i);
|
||||||
|
@ -46,7 +46,7 @@ class hEntity {
|
||||||
public:
|
public:
|
||||||
// bits 15: 0 -- entity index
|
// bits 15: 0 -- entity index
|
||||||
// 31:16 -- request index
|
// 31:16 -- request index
|
||||||
DWORD v;
|
uint32_t v;
|
||||||
|
|
||||||
inline bool isFromRequest(void);
|
inline bool isFromRequest(void);
|
||||||
inline hRequest request(void);
|
inline hRequest request(void);
|
||||||
|
@ -57,20 +57,20 @@ class hParam {
|
||||||
public:
|
public:
|
||||||
// bits 15: 0 -- param index
|
// bits 15: 0 -- param index
|
||||||
// 31:16 -- request index
|
// 31:16 -- request index
|
||||||
DWORD v;
|
uint32_t v;
|
||||||
|
|
||||||
inline hRequest request(void);
|
inline hRequest request(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
class hStyle {
|
class hStyle {
|
||||||
public:
|
public:
|
||||||
DWORD v;
|
uint32_t v;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class EntityId {
|
class EntityId {
|
||||||
public:
|
public:
|
||||||
DWORD v; // entity ID, starting from 0
|
uint32_t v; // entity ID, starting from 0
|
||||||
};
|
};
|
||||||
class EntityMap {
|
class EntityMap {
|
||||||
public:
|
public:
|
||||||
|
@ -118,7 +118,7 @@ public:
|
||||||
double valA;
|
double valA;
|
||||||
double valB;
|
double valB;
|
||||||
double valC;
|
double valC;
|
||||||
DWORD color;
|
uint32_t color;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int how;
|
int how;
|
||||||
|
@ -242,8 +242,8 @@ public:
|
||||||
void GenerateDisplayItems(void);
|
void GenerateDisplayItems(void);
|
||||||
void DrawDisplayItems(int t);
|
void DrawDisplayItems(int t);
|
||||||
void Draw(void);
|
void Draw(void);
|
||||||
DWORD GetLoopSetFillColor(SBezierLoopSet *sbls,
|
uint32_t GetLoopSetFillColor(SBezierLoopSet *sbls,
|
||||||
bool *allSame, Vector *errorAt);
|
bool *allSame, Vector *errorAt);
|
||||||
void FillLoopSetAsPolygon(SBezierLoopSet *sbls);
|
void FillLoopSetAsPolygon(SBezierLoopSet *sbls);
|
||||||
void DrawFilledPaths(void);
|
void DrawFilledPaths(void);
|
||||||
|
|
||||||
|
@ -527,7 +527,7 @@ public:
|
||||||
|
|
||||||
class hConstraint {
|
class hConstraint {
|
||||||
public:
|
public:
|
||||||
DWORD v;
|
uint32_t v;
|
||||||
|
|
||||||
inline hEquation equation(int i);
|
inline hEquation equation(int i);
|
||||||
};
|
};
|
||||||
|
@ -666,7 +666,7 @@ public:
|
||||||
|
|
||||||
class hEquation {
|
class hEquation {
|
||||||
public:
|
public:
|
||||||
DWORD v;
|
uint32_t v;
|
||||||
|
|
||||||
inline bool isFromConstraint(void);
|
inline bool isFromConstraint(void);
|
||||||
inline hConstraint constraint(void);
|
inline hConstraint constraint(void);
|
||||||
|
@ -729,9 +729,9 @@ public:
|
||||||
};
|
};
|
||||||
int textOrigin;
|
int textOrigin;
|
||||||
double textAngle;
|
double textAngle;
|
||||||
DWORD color;
|
uint32_t color;
|
||||||
bool filled;
|
bool filled;
|
||||||
DWORD fillColor;
|
uint32_t fillColor;
|
||||||
bool visible;
|
bool visible;
|
||||||
bool exportable;
|
bool exportable;
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ public:
|
||||||
typedef struct {
|
typedef struct {
|
||||||
hStyle h;
|
hStyle h;
|
||||||
const char *cnfPrefix;
|
const char *cnfPrefix;
|
||||||
DWORD color;
|
uint32_t color;
|
||||||
double width;
|
double width;
|
||||||
} Default;
|
} Default;
|
||||||
static const Default Defaults[];
|
static const Default Defaults[];
|
||||||
|
@ -754,16 +754,16 @@ public:
|
||||||
static void FreezeDefaultStyles(void);
|
static void FreezeDefaultStyles(void);
|
||||||
static void LoadFactoryDefaults(void);
|
static void LoadFactoryDefaults(void);
|
||||||
|
|
||||||
static void AssignSelectionToStyle(DWORD v);
|
static void AssignSelectionToStyle(uint32_t v);
|
||||||
static DWORD CreateCustomStyle(void);
|
static uint32_t CreateCustomStyle(void);
|
||||||
|
|
||||||
static DWORD RewriteColor(DWORD rgb);
|
static uint32_t RewriteColor(uint32_t rgb);
|
||||||
|
|
||||||
static Style *Get(hStyle hs);
|
static Style *Get(hStyle hs);
|
||||||
static DWORD Color(hStyle hs, bool forExport=false);
|
static uint32_t Color(hStyle hs, bool forExport=false);
|
||||||
static DWORD FillColor(hStyle hs, bool forExport=false);
|
static uint32_t FillColor(hStyle hs, bool forExport=false);
|
||||||
static float Width(hStyle hs);
|
static float Width(hStyle hs);
|
||||||
static DWORD Color(int hs, bool forExport=false);
|
static uint32_t Color(int hs, bool forExport=false);
|
||||||
static float Width(int hs);
|
static float Width(int hs);
|
||||||
static double WidthMm(int hs);
|
static double WidthMm(int hs);
|
||||||
static double TextHeight(hStyle hs);
|
static double TextHeight(hStyle hs);
|
||||||
|
|
|
@ -15,14 +15,14 @@ void SolveSpace::Init(char *cmdLine) {
|
||||||
// Then, load the registry settings.
|
// Then, load the registry settings.
|
||||||
int i;
|
int i;
|
||||||
// Default list of colors for the model material
|
// Default list of colors for the model material
|
||||||
modelColor[0] = CnfThawDWORD(RGB(150, 150, 150), "ModelColor_0");
|
modelColor[0] = CnfThawInt(RGB(150, 150, 150), "ModelColor_0");
|
||||||
modelColor[1] = CnfThawDWORD(RGB(100, 100, 100), "ModelColor_1");
|
modelColor[1] = CnfThawInt(RGB(100, 100, 100), "ModelColor_1");
|
||||||
modelColor[2] = CnfThawDWORD(RGB( 30, 30, 30), "ModelColor_2");
|
modelColor[2] = CnfThawInt(RGB( 30, 30, 30), "ModelColor_2");
|
||||||
modelColor[3] = CnfThawDWORD(RGB(150, 0, 0), "ModelColor_3");
|
modelColor[3] = CnfThawInt(RGB(150, 0, 0), "ModelColor_3");
|
||||||
modelColor[4] = CnfThawDWORD(RGB( 0, 100, 0), "ModelColor_4");
|
modelColor[4] = CnfThawInt(RGB( 0, 100, 0), "ModelColor_4");
|
||||||
modelColor[5] = CnfThawDWORD(RGB( 0, 80, 80), "ModelColor_5");
|
modelColor[5] = CnfThawInt(RGB( 0, 80, 80), "ModelColor_5");
|
||||||
modelColor[6] = CnfThawDWORD(RGB( 0, 0, 130), "ModelColor_6");
|
modelColor[6] = CnfThawInt(RGB( 0, 0, 130), "ModelColor_6");
|
||||||
modelColor[7] = CnfThawDWORD(RGB( 80, 0, 80), "ModelColor_7");
|
modelColor[7] = CnfThawInt(RGB( 80, 0, 80), "ModelColor_7");
|
||||||
// Light intensities
|
// Light intensities
|
||||||
lightIntensity[0] = CnfThawFloat(1.0f, "LightIntensity_0");
|
lightIntensity[0] = CnfThawFloat(1.0f, "LightIntensity_0");
|
||||||
lightIntensity[1] = CnfThawFloat(0.5f, "LightIntensity_1");
|
lightIntensity[1] = CnfThawFloat(0.5f, "LightIntensity_1");
|
||||||
|
@ -37,12 +37,12 @@ void SolveSpace::Init(char *cmdLine) {
|
||||||
// Chord tolerance
|
// Chord tolerance
|
||||||
chordTol = CnfThawFloat(2.0f, "ChordTolerance");
|
chordTol = CnfThawFloat(2.0f, "ChordTolerance");
|
||||||
// Max pwl segments to generate
|
// Max pwl segments to generate
|
||||||
maxSegments = CnfThawDWORD(10, "MaxSegments");
|
maxSegments = CnfThawInt(10, "MaxSegments");
|
||||||
// View units
|
// View units
|
||||||
viewUnits = (Unit)CnfThawDWORD((DWORD)UNIT_MM, "ViewUnits");
|
viewUnits = (Unit)CnfThawInt((uint32_t)UNIT_MM, "ViewUnits");
|
||||||
// Number of digits after the decimal point
|
// Number of digits after the decimal point
|
||||||
afterDecimalMm = CnfThawDWORD(2, "AfterDecimalMm");
|
afterDecimalMm = CnfThawInt(2, "AfterDecimalMm");
|
||||||
afterDecimalInch = CnfThawDWORD(3, "AfterDecimalInch");
|
afterDecimalInch = CnfThawInt(3, "AfterDecimalInch");
|
||||||
// Camera tangent (determines perspective)
|
// Camera tangent (determines perspective)
|
||||||
cameraTangent = CnfThawFloat(0.3f/1e3f, "CameraTangent");
|
cameraTangent = CnfThawFloat(0.3f/1e3f, "CameraTangent");
|
||||||
// Grid spacing
|
// Grid spacing
|
||||||
|
@ -52,19 +52,19 @@ void SolveSpace::Init(char *cmdLine) {
|
||||||
// Export offset (cutter radius comp)
|
// Export offset (cutter radius comp)
|
||||||
exportOffset = CnfThawFloat(0.0f, "ExportOffset");
|
exportOffset = CnfThawFloat(0.0f, "ExportOffset");
|
||||||
// Rewrite exported colors close to white into black (assuming white bg)
|
// Rewrite exported colors close to white into black (assuming white bg)
|
||||||
fixExportColors = CnfThawDWORD(1, "FixExportColors");
|
fixExportColors = CnfThawBool(true, "FixExportColors");
|
||||||
// Draw back faces of triangles (when mesh is leaky/self-intersecting)
|
// Draw back faces of triangles (when mesh is leaky/self-intersecting)
|
||||||
drawBackFaces = CnfThawDWORD(1, "DrawBackFaces");
|
drawBackFaces = CnfThawBool(true, "DrawBackFaces");
|
||||||
// Check that contours are closed and not self-intersecting
|
// Check that contours are closed and not self-intersecting
|
||||||
checkClosedContour = CnfThawDWORD(1, "CheckClosedContour");
|
checkClosedContour = CnfThawBool(true, "CheckClosedContour");
|
||||||
// Export shaded triangles in a 2d view
|
// Export shaded triangles in a 2d view
|
||||||
exportShadedTriangles = CnfThawDWORD(1, "ExportShadedTriangles");
|
exportShadedTriangles = CnfThawBool(true, "ExportShadedTriangles");
|
||||||
// Export pwl curves (instead of exact) always
|
// Export pwl curves (instead of exact) always
|
||||||
exportPwlCurves = CnfThawDWORD(0, "ExportPwlCurves");
|
exportPwlCurves = CnfThawBool(false, "ExportPwlCurves");
|
||||||
// Background color on-screen
|
// Background color on-screen
|
||||||
backgroundColor = CnfThawDWORD(RGB(0, 0, 0), "BackgroundColor");
|
backgroundColor = CnfThawInt(RGB(0, 0, 0), "BackgroundColor");
|
||||||
// Whether export canvas size is fixed or derived from bbox
|
// Whether export canvas size is fixed or derived from bbox
|
||||||
exportCanvasSizeAuto = CnfThawDWORD(1, "ExportCanvasSizeAuto");
|
exportCanvasSizeAuto = CnfThawBool(true, "ExportCanvasSizeAuto");
|
||||||
// Margins for automatic canvas size
|
// Margins for automatic canvas size
|
||||||
exportMargin.left = CnfThawFloat(5.0f, "ExportMargin_Left");
|
exportMargin.left = CnfThawFloat(5.0f, "ExportMargin_Left");
|
||||||
exportMargin.right = CnfThawFloat(5.0f, "ExportMargin_Right");
|
exportMargin.right = CnfThawFloat(5.0f, "ExportMargin_Right");
|
||||||
|
@ -77,11 +77,11 @@ void SolveSpace::Init(char *cmdLine) {
|
||||||
exportCanvas.dy = CnfThawFloat( 5.0f, "ExportCanvas_Dy");
|
exportCanvas.dy = CnfThawFloat( 5.0f, "ExportCanvas_Dy");
|
||||||
// Extra parameters when exporting G code
|
// Extra parameters when exporting G code
|
||||||
gCode.depth = CnfThawFloat(10.0f, "GCode_Depth");
|
gCode.depth = CnfThawFloat(10.0f, "GCode_Depth");
|
||||||
gCode.passes = CnfThawDWORD(1, "GCode_Passes");
|
gCode.passes = CnfThawInt(1, "GCode_Passes");
|
||||||
gCode.feed = CnfThawFloat(10.0f, "GCode_Feed");
|
gCode.feed = CnfThawFloat(10.0f, "GCode_Feed");
|
||||||
gCode.plungeFeed = CnfThawFloat(10.0f, "GCode_PlungeFeed");
|
gCode.plungeFeed = CnfThawFloat(10.0f, "GCode_PlungeFeed");
|
||||||
// Show toolbar in the graphics window
|
// Show toolbar in the graphics window
|
||||||
showToolbar = CnfThawDWORD(1, "ShowToolbar");
|
showToolbar = CnfThawBool(true, "ShowToolbar");
|
||||||
// Recent files menus
|
// Recent files menus
|
||||||
for(i = 0; i < MAX_RECENT; i++) {
|
for(i = 0; i < MAX_RECENT; i++) {
|
||||||
char name[100];
|
char name[100];
|
||||||
|
@ -120,7 +120,7 @@ void SolveSpace::Exit(void) {
|
||||||
// Model colors
|
// Model colors
|
||||||
for(i = 0; i < MODEL_COLORS; i++) {
|
for(i = 0; i < MODEL_COLORS; i++) {
|
||||||
sprintf(name, "ModelColor_%d", i);
|
sprintf(name, "ModelColor_%d", i);
|
||||||
CnfFreezeDWORD(modelColor[i], name);
|
CnfFreezeInt(modelColor[i], name);
|
||||||
}
|
}
|
||||||
// Light intensities
|
// Light intensities
|
||||||
CnfFreezeFloat((float)lightIntensity[0], "LightIntensity_0");
|
CnfFreezeFloat((float)lightIntensity[0], "LightIntensity_0");
|
||||||
|
@ -135,34 +135,34 @@ void SolveSpace::Exit(void) {
|
||||||
// Chord tolerance
|
// Chord tolerance
|
||||||
CnfFreezeFloat((float)chordTol, "ChordTolerance");
|
CnfFreezeFloat((float)chordTol, "ChordTolerance");
|
||||||
// Max pwl segments to generate
|
// Max pwl segments to generate
|
||||||
CnfFreezeDWORD((DWORD)maxSegments, "MaxSegments");
|
CnfFreezeInt((uint32_t)maxSegments, "MaxSegments");
|
||||||
// View units
|
// View units
|
||||||
CnfFreezeDWORD((DWORD)viewUnits, "ViewUnits");
|
CnfFreezeInt((uint32_t)viewUnits, "ViewUnits");
|
||||||
// Number of digits after the decimal point
|
// Number of digits after the decimal point
|
||||||
CnfFreezeDWORD((DWORD)afterDecimalMm, "AfterDecimalMm");
|
CnfFreezeInt((uint32_t)afterDecimalMm, "AfterDecimalMm");
|
||||||
CnfFreezeDWORD((DWORD)afterDecimalInch, "AfterDecimalInch");
|
CnfFreezeInt((uint32_t)afterDecimalInch, "AfterDecimalInch");
|
||||||
// Camera tangent (determines perspective)
|
// Camera tangent (determines perspective)
|
||||||
CnfFreezeFloat((float)cameraTangent, "CameraTangent");
|
CnfFreezeFloat((float)cameraTangent, "CameraTangent");
|
||||||
// Grid spacing
|
// Grid spacing
|
||||||
CnfFreezeFloat(gridSpacing, "GridSpacing");
|
CnfFreezeFloat(gridSpacing, "GridSpacing");
|
||||||
// Export scale (a float, stored as a DWORD)
|
// Export scale
|
||||||
CnfFreezeFloat(exportScale, "ExportScale");
|
CnfFreezeFloat(exportScale, "ExportScale");
|
||||||
// Export offset (cutter radius comp)
|
// Export offset (cutter radius comp)
|
||||||
CnfFreezeFloat(exportOffset, "ExportOffset");
|
CnfFreezeFloat(exportOffset, "ExportOffset");
|
||||||
// Rewrite exported colors close to white into black (assuming white bg)
|
// Rewrite exported colors close to white into black (assuming white bg)
|
||||||
CnfFreezeDWORD(fixExportColors, "FixExportColors");
|
CnfFreezeBool(fixExportColors, "FixExportColors");
|
||||||
// Draw back faces of triangles (when mesh is leaky/self-intersecting)
|
// Draw back faces of triangles (when mesh is leaky/self-intersecting)
|
||||||
CnfFreezeDWORD(drawBackFaces, "DrawBackFaces");
|
CnfFreezeBool(drawBackFaces, "DrawBackFaces");
|
||||||
// Check that contours are closed and not self-intersecting
|
// Check that contours are closed and not self-intersecting
|
||||||
CnfFreezeDWORD(checkClosedContour, "CheckClosedContour");
|
CnfFreezeBool(checkClosedContour, "CheckClosedContour");
|
||||||
// Export shaded triangles in a 2d view
|
// Export shaded triangles in a 2d view
|
||||||
CnfFreezeDWORD(exportShadedTriangles, "ExportShadedTriangles");
|
CnfFreezeBool(exportShadedTriangles, "ExportShadedTriangles");
|
||||||
// Export pwl curves (instead of exact) always
|
// Export pwl curves (instead of exact) always
|
||||||
CnfFreezeDWORD(exportPwlCurves, "ExportPwlCurves");
|
CnfFreezeBool(exportPwlCurves, "ExportPwlCurves");
|
||||||
// Background color on-screen
|
// Background color on-screen
|
||||||
CnfFreezeDWORD(backgroundColor, "BackgroundColor");
|
CnfFreezeInt(backgroundColor, "BackgroundColor");
|
||||||
// Whether export canvas size is fixed or derived from bbox
|
// Whether export canvas size is fixed or derived from bbox
|
||||||
CnfFreezeDWORD(exportCanvasSizeAuto, "ExportCanvasSizeAuto");
|
CnfFreezeBool(exportCanvasSizeAuto, "ExportCanvasSizeAuto");
|
||||||
// Margins for automatic canvas size
|
// Margins for automatic canvas size
|
||||||
CnfFreezeFloat(exportMargin.left, "ExportMargin_Left");
|
CnfFreezeFloat(exportMargin.left, "ExportMargin_Left");
|
||||||
CnfFreezeFloat(exportMargin.right, "ExportMargin_Right");
|
CnfFreezeFloat(exportMargin.right, "ExportMargin_Right");
|
||||||
|
@ -175,11 +175,11 @@ void SolveSpace::Exit(void) {
|
||||||
CnfFreezeFloat(exportCanvas.dy, "ExportCanvas_Dy");
|
CnfFreezeFloat(exportCanvas.dy, "ExportCanvas_Dy");
|
||||||
// Extra parameters when exporting G code
|
// Extra parameters when exporting G code
|
||||||
CnfFreezeFloat(gCode.depth, "GCode_Depth");
|
CnfFreezeFloat(gCode.depth, "GCode_Depth");
|
||||||
CnfFreezeDWORD(gCode.passes, "GCode_Passes");
|
CnfFreezeInt(gCode.passes, "GCode_Passes");
|
||||||
CnfFreezeFloat(gCode.feed, "GCode_Feed");
|
CnfFreezeFloat(gCode.feed, "GCode_Feed");
|
||||||
CnfFreezeFloat(gCode.plungeFeed, "GCode_PlungeFeed");
|
CnfFreezeFloat(gCode.plungeFeed, "GCode_PlungeFeed");
|
||||||
// Show toolbar in the graphics window
|
// Show toolbar in the graphics window
|
||||||
CnfFreezeDWORD(showToolbar, "ShowToolbar");
|
CnfFreezeBool(showToolbar, "ShowToolbar");
|
||||||
|
|
||||||
// And the default styles, colors and line widths and such.
|
// And the default styles, colors and line widths and such.
|
||||||
Style::FreezeDefaultStyles();
|
Style::FreezeDefaultStyles();
|
||||||
|
|
191
solvespace.h
191
solvespace.h
|
@ -51,20 +51,29 @@ inline double ffabs(double v) { return (v > 0) ? v : (-v); }
|
||||||
|
|
||||||
#define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#')
|
#define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#')
|
||||||
|
|
||||||
typedef unsigned __int64 QWORD;
|
|
||||||
typedef signed __int64 SQWORD;
|
|
||||||
typedef signed long SDWORD;
|
|
||||||
typedef signed short SWORD;
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <windows.h> // required for GL stuff
|
#ifdef WIN32
|
||||||
#include <gl/gl.h>
|
# include <windows.h> // required by GL headers
|
||||||
#include <gl/glu.h>
|
#endif
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// Define some useful C99 integer types.
|
||||||
|
typedef UINT64 uint64_t;
|
||||||
|
typedef INT64 int64_t;
|
||||||
|
typedef UINT32 uint32_t;
|
||||||
|
typedef INT32 int32_t;
|
||||||
|
typedef USHORT uint16_t;
|
||||||
|
typedef SHORT int16_t;
|
||||||
|
typedef UCHAR uint8_t;
|
||||||
|
typedef CHAR int8_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
inline double Random(double vmax) {
|
inline double Random(double vmax) {
|
||||||
return (vmax*rand()) / RAND_MAX;
|
return (vmax*rand()) / RAND_MAX;
|
||||||
|
@ -121,23 +130,23 @@ int SaveFileYesNoCancel(void);
|
||||||
// Comma-separated value, like a spreadsheet would use
|
// Comma-separated value, like a spreadsheet would use
|
||||||
#define CSV_PATTERN "CSV File (*.csv)\0*.csv\0All Files (*)\0*\0\0"
|
#define CSV_PATTERN "CSV File (*.csv)\0*.csv\0All Files (*)\0*\0\0"
|
||||||
#define CSV_EXT "csv"
|
#define CSV_EXT "csv"
|
||||||
BOOL GetSaveFile(char *file, const char *defExtension, const char *selPattern);
|
bool GetSaveFile(char *file, const char *defExtension, const char *selPattern);
|
||||||
BOOL GetOpenFile(char *file, const char *defExtension, const char *selPattern);
|
bool GetOpenFile(char *file, const char *defExtension, const char *selPattern);
|
||||||
void GetAbsoluteFilename(char *file);
|
void GetAbsoluteFilename(char *file);
|
||||||
void LoadAllFontFiles(void);
|
void LoadAllFontFiles(void);
|
||||||
|
|
||||||
void OpenWebsite(const char *url);
|
void OpenWebsite(const char *url);
|
||||||
|
|
||||||
void CheckMenuById(int id, BOOL checked);
|
void CheckMenuById(int id, bool checked);
|
||||||
void RadioMenuById(int id, BOOL selected);
|
void RadioMenuById(int id, bool selected);
|
||||||
void EnableMenuById(int id, BOOL enabled);
|
void EnableMenuById(int id, bool enabled);
|
||||||
|
|
||||||
void ShowGraphicsEditControl(int x, int y, char *s);
|
void ShowGraphicsEditControl(int x, int y, char *s);
|
||||||
void HideGraphicsEditControl(void);
|
void HideGraphicsEditControl(void);
|
||||||
BOOL GraphicsEditControlIsVisible(void);
|
bool GraphicsEditControlIsVisible(void);
|
||||||
void ShowTextEditControl(int x, int y, char *s);
|
void ShowTextEditControl(int x, int y, char *s);
|
||||||
void HideTextEditControl(void);
|
void HideTextEditControl(void);
|
||||||
BOOL TextEditControlIsVisible(void);
|
bool TextEditControlIsVisible(void);
|
||||||
void MoveTextScrollbarTo(int pos, int maxPos, int page);
|
void MoveTextScrollbarTo(int pos, int maxPos, int page);
|
||||||
|
|
||||||
#define CONTEXT_SUBMENU (-1)
|
#define CONTEXT_SUBMENU (-1)
|
||||||
|
@ -146,14 +155,14 @@ void AddContextMenuItem(const char *legend, int id);
|
||||||
void CreateContextSubmenu(void);
|
void CreateContextSubmenu(void);
|
||||||
int ShowContextMenu(void);
|
int ShowContextMenu(void);
|
||||||
|
|
||||||
void ShowTextWindow(BOOL visible);
|
void ShowTextWindow(bool visible);
|
||||||
void InvalidateText(void);
|
void InvalidateText(void);
|
||||||
void InvalidateGraphics(void);
|
void InvalidateGraphics(void);
|
||||||
void PaintGraphics(void);
|
void PaintGraphics(void);
|
||||||
void GetGraphicsWindowSize(int *w, int *h);
|
void GetGraphicsWindowSize(int *w, int *h);
|
||||||
void GetTextWindowSize(int *w, int *h);
|
void GetTextWindowSize(int *w, int *h);
|
||||||
SDWORD GetMilliseconds(void);
|
int32_t GetMilliseconds(void);
|
||||||
SQWORD GetUnixTime(void);
|
int64_t GetUnixTime(void);
|
||||||
|
|
||||||
void dbp(const char *str, ...);
|
void dbp(const char *str, ...);
|
||||||
#define DBPTRI(tri) \
|
#define DBPTRI(tri) \
|
||||||
|
@ -162,16 +171,18 @@ void dbp(const char *str, ...);
|
||||||
|
|
||||||
void SetWindowTitle(const char *str);
|
void SetWindowTitle(const char *str);
|
||||||
void SetMousePointerToHand(bool yes);
|
void SetMousePointerToHand(bool yes);
|
||||||
void DoMessageBox(const char *str, int rows, int cols, BOOL error);
|
void DoMessageBox(const char *str, int rows, int cols, bool error);
|
||||||
void SetTimerFor(int milliseconds);
|
void SetTimerFor(int milliseconds);
|
||||||
void ExitNow(void);
|
void ExitNow(void);
|
||||||
|
|
||||||
void CnfFreezeString(const char *str, const char *name);
|
void CnfFreezeString(const char *str, const char *name);
|
||||||
void CnfFreezeDWORD(DWORD v, const char *name);
|
void CnfFreezeInt(uint32_t v, const char *name);
|
||||||
void CnfFreezeFloat(float v, const char *name);
|
void CnfFreezeFloat(float v, const char *name);
|
||||||
|
void CnfFreezeBool(bool v, const char *name);
|
||||||
void CnfThawString(char *str, int maxLen, const char *name);
|
void CnfThawString(char *str, int maxLen, const char *name);
|
||||||
DWORD CnfThawDWORD(DWORD v, const char *name);
|
uint32_t CnfThawInt(uint32_t v, const char *name);
|
||||||
float CnfThawFloat(float v, const char *name);
|
float CnfThawFloat(float v, const char *name);
|
||||||
|
bool CnfThawBool(bool v, const char *name);
|
||||||
|
|
||||||
void *AllocTemporary(size_t n);
|
void *AllocTemporary(size_t n);
|
||||||
void FreeTemporary(void *p);
|
void FreeTemporary(void *p);
|
||||||
|
@ -212,7 +223,7 @@ void glxAxisAlignedLineLoop(double l, double r, double t, double b);
|
||||||
typedef void GLX_CALLBACK glxCallbackFptr(void);
|
typedef void GLX_CALLBACK glxCallbackFptr(void);
|
||||||
void glxTesselatePolygon(GLUtesselator *gt, SPolygon *p);
|
void glxTesselatePolygon(GLUtesselator *gt, SPolygon *p);
|
||||||
void glxFillPolygon(SPolygon *p);
|
void glxFillPolygon(SPolygon *p);
|
||||||
void glxFillMesh(int color, SMesh *m, DWORD h, DWORD s1, DWORD s2);
|
void glxFillMesh(uint32_t color, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2);
|
||||||
void glxDebugPolygon(SPolygon *p);
|
void glxDebugPolygon(SPolygon *p);
|
||||||
void glxDrawEdges(SEdgeList *l, bool endpointsToo);
|
void glxDrawEdges(SEdgeList *l, bool endpointsToo);
|
||||||
void glxDebugMesh(SMesh *m);
|
void glxDebugMesh(SMesh *m);
|
||||||
|
@ -224,14 +235,14 @@ void glxWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vector
|
||||||
glxLineFn *fn, void *fndata);
|
glxLineFn *fn, void *fndata);
|
||||||
double glxStrWidth(const char *str, double h);
|
double glxStrWidth(const char *str, double h);
|
||||||
double glxStrHeight(double h);
|
double glxStrHeight(double h);
|
||||||
void glxLockColorTo(DWORD rgb);
|
void glxLockColorTo(uint32_t rgb);
|
||||||
void glxFatLine(Vector a, Vector b, double width);
|
void glxFatLine(Vector a, Vector b, double width);
|
||||||
void glxUnlockColor(void);
|
void glxUnlockColor(void);
|
||||||
void glxColorRGB(DWORD rgb);
|
void glxColorRGB(uint32_t rgb);
|
||||||
void glxColorRGBa(DWORD rgb, double a);
|
void glxColorRGBa(uint32_t rgb, double a);
|
||||||
void glxDepthRangeOffset(int units);
|
void glxDepthRangeOffset(int units);
|
||||||
void glxDepthRangeLockToFront(bool yes);
|
void glxDepthRangeLockToFront(bool yes);
|
||||||
void glxDrawPixelsWithTexture(BYTE *data, int w, int h);
|
void glxDrawPixelsWithTexture(uint8_t *data, int w, int h);
|
||||||
void glxCreateBitmapFont(void);
|
void glxCreateBitmapFont(void);
|
||||||
void glxBitmapText(const char *str, Vector p);
|
void glxBitmapText(const char *str, Vector p);
|
||||||
void glxBitmapCharQuad(char c, double x, double y);
|
void glxBitmapCharQuad(char c, double x, double y);
|
||||||
|
@ -340,8 +351,8 @@ public:
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool onCurve;
|
bool onCurve;
|
||||||
bool lastInContour;
|
bool lastInContour;
|
||||||
SWORD x;
|
int16_t x;
|
||||||
SWORD y;
|
int16_t y;
|
||||||
} FontPoint;
|
} FontPoint;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -388,9 +399,9 @@ public:
|
||||||
Vector origin, u, v;
|
Vector origin, u, v;
|
||||||
|
|
||||||
int Getc(void);
|
int Getc(void);
|
||||||
BYTE GetBYTE(void);
|
uint8_t GetBYTE(void);
|
||||||
WORD GetWORD(void);
|
uint16_t GetUSHORT(void);
|
||||||
DWORD GetDWORD(void);
|
uint32_t GetULONG(void);
|
||||||
|
|
||||||
void LoadGlyph(int index);
|
void LoadGlyph(int index);
|
||||||
bool LoadFontFromFile(bool nameOnly);
|
bool LoadFontFromFile(bool nameOnly);
|
||||||
|
@ -448,10 +459,10 @@ public:
|
||||||
void BezierAsPwl(SBezier *sb);
|
void BezierAsPwl(SBezier *sb);
|
||||||
void BezierAsNonrationalCubic(SBezier *sb, int depth=0);
|
void BezierAsNonrationalCubic(SBezier *sb, int depth=0);
|
||||||
|
|
||||||
virtual void StartPath( DWORD strokeRgb, double lineWidth,
|
virtual void StartPath( uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb) = 0;
|
bool filled, uint32_t fillRgb) = 0;
|
||||||
virtual void FinishPath(DWORD strokeRgb, double lineWidth,
|
virtual void FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb) = 0;
|
bool filled, uint32_t fillRgb) = 0;
|
||||||
virtual void Bezier(SBezier *sb) = 0;
|
virtual void Bezier(SBezier *sb) = 0;
|
||||||
virtual void Triangle(STriangle *tr) = 0;
|
virtual void Triangle(STriangle *tr) = 0;
|
||||||
virtual void StartFile(void) = 0;
|
virtual void StartFile(void) = 0;
|
||||||
|
@ -460,10 +471,10 @@ public:
|
||||||
};
|
};
|
||||||
class DxfFileWriter : public VectorFileWriter {
|
class DxfFileWriter : public VectorFileWriter {
|
||||||
public:
|
public:
|
||||||
void StartPath( DWORD strokeRgb, double lineWidth,
|
void StartPath( uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void FinishPath(DWORD strokeRgb, double lineWidth,
|
void FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void Triangle(STriangle *tr);
|
void Triangle(STriangle *tr);
|
||||||
void Bezier(SBezier *sb);
|
void Bezier(SBezier *sb);
|
||||||
void StartFile(void);
|
void StartFile(void);
|
||||||
|
@ -475,10 +486,10 @@ public:
|
||||||
Vector prevPt;
|
Vector prevPt;
|
||||||
void MaybeMoveTo(Vector s, Vector f);
|
void MaybeMoveTo(Vector s, Vector f);
|
||||||
|
|
||||||
void StartPath( DWORD strokeRgb, double lineWidth,
|
void StartPath( uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void FinishPath(DWORD strokeRgb, double lineWidth,
|
void FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void Triangle(STriangle *tr);
|
void Triangle(STriangle *tr);
|
||||||
void Bezier(SBezier *sb);
|
void Bezier(SBezier *sb);
|
||||||
void StartFile(void);
|
void StartFile(void);
|
||||||
|
@ -487,15 +498,15 @@ public:
|
||||||
};
|
};
|
||||||
class PdfFileWriter : public VectorFileWriter {
|
class PdfFileWriter : public VectorFileWriter {
|
||||||
public:
|
public:
|
||||||
DWORD xref[10];
|
uint32_t xref[10];
|
||||||
DWORD bodyStart;
|
uint32_t bodyStart;
|
||||||
Vector prevPt;
|
Vector prevPt;
|
||||||
void MaybeMoveTo(Vector s, Vector f);
|
void MaybeMoveTo(Vector s, Vector f);
|
||||||
|
|
||||||
void StartPath( DWORD strokeRgb, double lineWidth,
|
void StartPath( uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void FinishPath(DWORD strokeRgb, double lineWidth,
|
void FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void Triangle(STriangle *tr);
|
void Triangle(STriangle *tr);
|
||||||
void Bezier(SBezier *sb);
|
void Bezier(SBezier *sb);
|
||||||
void StartFile(void);
|
void StartFile(void);
|
||||||
|
@ -507,10 +518,10 @@ public:
|
||||||
Vector prevPt;
|
Vector prevPt;
|
||||||
void MaybeMoveTo(Vector s, Vector f);
|
void MaybeMoveTo(Vector s, Vector f);
|
||||||
|
|
||||||
void StartPath( DWORD strokeRgb, double lineWidth,
|
void StartPath( uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void FinishPath(DWORD strokeRgb, double lineWidth,
|
void FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void Triangle(STriangle *tr);
|
void Triangle(STriangle *tr);
|
||||||
void Bezier(SBezier *sb);
|
void Bezier(SBezier *sb);
|
||||||
void StartFile(void);
|
void StartFile(void);
|
||||||
|
@ -520,10 +531,10 @@ public:
|
||||||
class HpglFileWriter : public VectorFileWriter {
|
class HpglFileWriter : public VectorFileWriter {
|
||||||
public:
|
public:
|
||||||
static double MmToHpglUnits(double mm);
|
static double MmToHpglUnits(double mm);
|
||||||
void StartPath( DWORD strokeRgb, double lineWidth,
|
void StartPath( uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void FinishPath(DWORD strokeRgb, double lineWidth,
|
void FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void Triangle(STriangle *tr);
|
void Triangle(STriangle *tr);
|
||||||
void Bezier(SBezier *sb);
|
void Bezier(SBezier *sb);
|
||||||
void StartFile(void);
|
void StartFile(void);
|
||||||
|
@ -532,10 +543,10 @@ public:
|
||||||
};
|
};
|
||||||
class Step2dFileWriter : public VectorFileWriter {
|
class Step2dFileWriter : public VectorFileWriter {
|
||||||
StepFileWriter sfw;
|
StepFileWriter sfw;
|
||||||
void StartPath( DWORD strokeRgb, double lineWidth,
|
void StartPath( uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void FinishPath(DWORD strokeRgb, double lineWidth,
|
void FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void Triangle(STriangle *tr);
|
void Triangle(STriangle *tr);
|
||||||
void Bezier(SBezier *sb);
|
void Bezier(SBezier *sb);
|
||||||
void StartFile(void);
|
void StartFile(void);
|
||||||
|
@ -545,10 +556,10 @@ class Step2dFileWriter : public VectorFileWriter {
|
||||||
class GCodeFileWriter : public VectorFileWriter {
|
class GCodeFileWriter : public VectorFileWriter {
|
||||||
public:
|
public:
|
||||||
SEdgeList sel;
|
SEdgeList sel;
|
||||||
void StartPath( DWORD strokeRgb, double lineWidth,
|
void StartPath( uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void FinishPath(DWORD strokeRgb, double lineWidth,
|
void FinishPath(uint32_t strokeRgb, double lineWidth,
|
||||||
bool filled, DWORD fillRgb);
|
bool filled, uint32_t fillRgb);
|
||||||
void Triangle(STriangle *tr);
|
void Triangle(STriangle *tr);
|
||||||
void Bezier(SBezier *sb);
|
void Bezier(SBezier *sb);
|
||||||
void StartFile(void);
|
void StartFile(void);
|
||||||
|
@ -629,50 +640,50 @@ public:
|
||||||
|
|
||||||
// Little bits of extra configuration state
|
// Little bits of extra configuration state
|
||||||
enum { MODEL_COLORS = 8 };
|
enum { MODEL_COLORS = 8 };
|
||||||
int modelColor[MODEL_COLORS];
|
uint32_t modelColor[MODEL_COLORS];
|
||||||
Vector lightDir[2];
|
Vector lightDir[2];
|
||||||
double lightIntensity[2];
|
double lightIntensity[2];
|
||||||
double ambientIntensity;
|
double ambientIntensity;
|
||||||
double chordTol;
|
double chordTol;
|
||||||
int maxSegments;
|
int maxSegments;
|
||||||
double cameraTangent;
|
double cameraTangent;
|
||||||
float gridSpacing;
|
float gridSpacing;
|
||||||
float exportScale;
|
float exportScale;
|
||||||
float exportOffset;
|
float exportOffset;
|
||||||
int fixExportColors;
|
bool fixExportColors;
|
||||||
int drawBackFaces;
|
bool drawBackFaces;
|
||||||
int checkClosedContour;
|
bool checkClosedContour;
|
||||||
int showToolbar;
|
bool showToolbar;
|
||||||
DWORD backgroundColor;
|
uint32_t backgroundColor;
|
||||||
int exportShadedTriangles;
|
bool exportShadedTriangles;
|
||||||
int exportPwlCurves;
|
bool exportPwlCurves;
|
||||||
int exportCanvasSizeAuto;
|
bool exportCanvasSizeAuto;
|
||||||
struct {
|
struct {
|
||||||
float left;
|
float left;
|
||||||
float right;
|
float right;
|
||||||
float bottom;
|
float bottom;
|
||||||
float top;
|
float top;
|
||||||
} exportMargin;
|
} exportMargin;
|
||||||
struct {
|
struct {
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
float dx;
|
float dx;
|
||||||
float dy;
|
float dy;
|
||||||
} exportCanvas;
|
} exportCanvas;
|
||||||
struct {
|
struct {
|
||||||
float depth;
|
float depth;
|
||||||
int passes;
|
int passes;
|
||||||
float feed;
|
float feed;
|
||||||
float plungeFeed;
|
float plungeFeed;
|
||||||
} gCode;
|
} gCode;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UNIT_MM = 0,
|
UNIT_MM = 0,
|
||||||
UNIT_INCHES
|
UNIT_INCHES
|
||||||
} Unit;
|
} Unit;
|
||||||
Unit viewUnits;
|
Unit viewUnits;
|
||||||
int afterDecimalMm;
|
int afterDecimalMm;
|
||||||
int afterDecimalInch;
|
int afterDecimalInch;
|
||||||
|
|
||||||
char *MmToString(double v);
|
char *MmToString(double v);
|
||||||
double ExprToMm(Expr *e);
|
double ExprToMm(Expr *e);
|
||||||
|
@ -761,7 +772,7 @@ public:
|
||||||
Vector ptB;
|
Vector ptB;
|
||||||
} extraLine;
|
} extraLine;
|
||||||
struct {
|
struct {
|
||||||
BYTE *fromFile;
|
uint8_t *fromFile;
|
||||||
int w, h;
|
int w, h;
|
||||||
int rw, rh;
|
int rw, rh;
|
||||||
double scale; // pixels per mm
|
double scale; // pixels per mm
|
||||||
|
|
|
@ -359,7 +359,7 @@ void SSurface::EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
|
||||||
Vector *pt,
|
Vector *pt,
|
||||||
Vector *enin, Vector *enout,
|
Vector *enin, Vector *enout,
|
||||||
Vector *surfn,
|
Vector *surfn,
|
||||||
DWORD auxA,
|
uint32_t auxA,
|
||||||
SShell *shell, SShell *sha, SShell *shb)
|
SShell *shell, SShell *sha, SShell *shb)
|
||||||
{
|
{
|
||||||
// the midpoint of the edge
|
// the midpoint of the edge
|
||||||
|
|
|
@ -490,7 +490,7 @@ typedef struct {
|
||||||
} TrimLine;
|
} TrimLine;
|
||||||
|
|
||||||
void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1,
|
void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1,
|
||||||
int color)
|
uint32_t color)
|
||||||
{
|
{
|
||||||
// Make the extrusion direction consistent with respect to the normal
|
// Make the extrusion direction consistent with respect to the normal
|
||||||
// of the sketch we're extruding.
|
// of the sketch we're extruding.
|
||||||
|
@ -610,7 +610,7 @@ typedef struct {
|
||||||
} Revolved;
|
} Revolved;
|
||||||
|
|
||||||
void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
|
void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
|
||||||
int color)
|
uint32_t color)
|
||||||
{
|
{
|
||||||
SBezierLoop *sbl;
|
SBezierLoop *sbl;
|
||||||
|
|
||||||
|
|
|
@ -58,12 +58,12 @@ class SShell;
|
||||||
|
|
||||||
class hSSurface {
|
class hSSurface {
|
||||||
public:
|
public:
|
||||||
DWORD v;
|
uint32_t v;
|
||||||
};
|
};
|
||||||
|
|
||||||
class hSCurve {
|
class hSCurve {
|
||||||
public:
|
public:
|
||||||
DWORD v;
|
uint32_t v;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Stuff for rational polynomial curves, of degree one to three. These are
|
// Stuff for rational polynomial curves, of degree one to three. These are
|
||||||
|
@ -250,8 +250,8 @@ public:
|
||||||
// when I copy things over.
|
// when I copy things over.
|
||||||
hSSurface newH;
|
hSSurface newH;
|
||||||
|
|
||||||
int color;
|
uint32_t color;
|
||||||
DWORD face;
|
uint32_t face;
|
||||||
|
|
||||||
int degm, degn;
|
int degm, degn;
|
||||||
Vector ctrl[4][4];
|
Vector ctrl[4][4];
|
||||||
|
@ -279,7 +279,7 @@ public:
|
||||||
void EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
|
void EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
|
||||||
Vector *pt, Vector *enin, Vector *enout,
|
Vector *pt, Vector *enin, Vector *enout,
|
||||||
Vector *surfn,
|
Vector *surfn,
|
||||||
DWORD auxA,
|
uint32_t auxA,
|
||||||
SShell *shell, SShell *sha, SShell *shb);
|
SShell *shell, SShell *sha, SShell *shb);
|
||||||
void FindChainAvoiding(SEdgeList *src, SEdgeList *dest, SPointList *avoid);
|
void FindChainAvoiding(SEdgeList *src, SEdgeList *dest, SPointList *avoid);
|
||||||
SSurface MakeCopyTrimAgainst(SShell *parent, SShell *a, SShell *b,
|
SSurface MakeCopyTrimAgainst(SShell *parent, SShell *a, SShell *b,
|
||||||
|
@ -361,9 +361,9 @@ public:
|
||||||
bool booleanFailed;
|
bool booleanFailed;
|
||||||
|
|
||||||
void MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1,
|
void MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1,
|
||||||
int color);
|
uint32_t color);
|
||||||
void MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
|
void MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis,
|
||||||
int color);
|
uint32_t color);
|
||||||
|
|
||||||
void MakeFromUnionOf(SShell *a, SShell *b);
|
void MakeFromUnionOf(SShell *a, SShell *b);
|
||||||
void MakeFromDifferenceOf(SShell *a, SShell *b);
|
void MakeFromDifferenceOf(SShell *a, SShell *b);
|
||||||
|
|
|
@ -334,7 +334,7 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
|
||||||
if(lsi.n == 0) continue;
|
if(lsi.n == 0) continue;
|
||||||
|
|
||||||
// Find the other surface that this curve trims.
|
// Find the other surface that this curve trims.
|
||||||
hSCurve hsc = { (DWORD)se->auxA };
|
hSCurve hsc = { (uint32_t)se->auxA };
|
||||||
SCurve *sc = shA->curve.FindById(hsc);
|
SCurve *sc = shA->curve.FindById(hsc);
|
||||||
hSSurface hother = (sc->surfA.v == srfA->h.v) ?
|
hSSurface hother = (sc->surfA.v == srfA->h.v) ?
|
||||||
sc->surfB : sc->surfA;
|
sc->surfB : sc->surfA;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
void SPolygon::UvTriangulateInto(SMesh *m, SSurface *srf) {
|
void SPolygon::UvTriangulateInto(SMesh *m, SSurface *srf) {
|
||||||
if(l.n <= 0) return;
|
if(l.n <= 0) return;
|
||||||
|
|
||||||
SDWORD in = GetMilliseconds();
|
int32_t in = GetMilliseconds();
|
||||||
|
|
||||||
normal = Vector::From(0, 0, 1);
|
normal = Vector::From(0, 0, 1);
|
||||||
|
|
||||||
|
|
66
style.cpp
66
style.cpp
|
@ -74,7 +74,7 @@ void Style::CreateDefaultStyle(hStyle h) {
|
||||||
|
|
||||||
Style ns;
|
Style ns;
|
||||||
ZERO(&ns);
|
ZERO(&ns);
|
||||||
ns.color = CnfThawDWORD(d->color, CnfColor(d->cnfPrefix));
|
ns.color = CnfThawInt(d->color, CnfColor(d->cnfPrefix));
|
||||||
ns.width = CnfThawFloat((float)(d->width), CnfWidth(d->cnfPrefix));
|
ns.width = CnfThawFloat((float)(d->width), CnfWidth(d->cnfPrefix));
|
||||||
ns.widthAs = UNITS_AS_PIXELS;
|
ns.widthAs = UNITS_AS_PIXELS;
|
||||||
ns.textHeight = DEFAULT_TEXT_HEIGHT;
|
ns.textHeight = DEFAULT_TEXT_HEIGHT;
|
||||||
|
@ -121,20 +121,20 @@ void Style::LoadFactoryDefaults(void) {
|
||||||
void Style::FreezeDefaultStyles(void) {
|
void Style::FreezeDefaultStyles(void) {
|
||||||
const Default *d;
|
const Default *d;
|
||||||
for(d = &(Defaults[0]); d->h.v; d++) {
|
for(d = &(Defaults[0]); d->h.v; d++) {
|
||||||
CnfFreezeDWORD(Color(d->h), CnfColor(d->cnfPrefix));
|
CnfFreezeInt(Color(d->h), CnfColor(d->cnfPrefix));
|
||||||
CnfFreezeFloat((float)Width(d->h), CnfWidth(d->cnfPrefix));
|
CnfFreezeFloat((float)Width(d->h), CnfWidth(d->cnfPrefix));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD Style::CreateCustomStyle(void) {
|
uint32_t Style::CreateCustomStyle(void) {
|
||||||
SS.UndoRemember();
|
SS.UndoRemember();
|
||||||
DWORD vs = max((DWORD)Style::FIRST_CUSTOM, SK.style.MaximumId() + 1);
|
uint32_t vs = max((uint32_t)Style::FIRST_CUSTOM, SK.style.MaximumId() + 1);
|
||||||
hStyle hs = { vs };
|
hStyle hs = { vs };
|
||||||
(void)Style::Get(hs);
|
(void)Style::Get(hs);
|
||||||
return hs.v;
|
return hs.v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Style::AssignSelectionToStyle(DWORD v) {
|
void Style::AssignSelectionToStyle(uint32_t v) {
|
||||||
bool showError = false;
|
bool showError = false;
|
||||||
SS.GW.GroupSelection();
|
SS.GW.GroupSelection();
|
||||||
|
|
||||||
|
@ -197,12 +197,12 @@ Style *Style::Get(hStyle h) {
|
||||||
// A couple of wrappers, so that I can call these functions with either an
|
// A couple of wrappers, so that I can call these functions with either an
|
||||||
// hStyle or with the integer corresponding to that hStyle.v.
|
// hStyle or with the integer corresponding to that hStyle.v.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
DWORD Style::Color(int s, bool forExport) {
|
uint32_t Style::Color(int s, bool forExport) {
|
||||||
hStyle hs = { (DWORD)s };
|
hStyle hs = { (uint32_t)s };
|
||||||
return Color(hs, forExport);
|
return Color(hs, forExport);
|
||||||
}
|
}
|
||||||
float Style::Width(int s) {
|
float Style::Width(int s) {
|
||||||
hStyle hs = { (DWORD)s };
|
hStyle hs = { (uint32_t)s };
|
||||||
return Width(hs);
|
return Width(hs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ float Style::Width(int s) {
|
||||||
// If a color is almost white, then we can rewrite it to black, just so that
|
// If a color is almost white, then we can rewrite it to black, just so that
|
||||||
// it won't disappear on file formats with a light background.
|
// it won't disappear on file formats with a light background.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
DWORD Style::RewriteColor(DWORD rgbin) {
|
uint32_t Style::RewriteColor(uint32_t rgbin) {
|
||||||
Vector rgb = Vector::From(REDf(rgbin), GREENf(rgbin), BLUEf(rgbin));
|
Vector rgb = Vector::From(REDf(rgbin), GREENf(rgbin), BLUEf(rgbin));
|
||||||
rgb = rgb.Minus(Vector::From(1, 1, 1));
|
rgb = rgb.Minus(Vector::From(1, 1, 1));
|
||||||
if(rgb.Magnitude() < 0.4 && SS.fixExportColors) {
|
if(rgb.Magnitude() < 0.4 && SS.fixExportColors) {
|
||||||
|
@ -227,7 +227,7 @@ DWORD Style::RewriteColor(DWORD rgbin) {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Return the stroke color associated with our style as 8-bit RGB.
|
// Return the stroke color associated with our style as 8-bit RGB.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
DWORD Style::Color(hStyle h, bool forExport) {
|
uint32_t Style::Color(hStyle h, bool forExport) {
|
||||||
Style *s = Get(h);
|
Style *s = Get(h);
|
||||||
if(forExport) {
|
if(forExport) {
|
||||||
return RewriteColor(s->color);
|
return RewriteColor(s->color);
|
||||||
|
@ -239,7 +239,7 @@ DWORD Style::Color(hStyle h, bool forExport) {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Return the fill color associated with our style as 8-bit RGB.
|
// Return the fill color associated with our style as 8-bit RGB.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
DWORD Style::FillColor(hStyle h, bool forExport) {
|
uint32_t Style::FillColor(hStyle h, bool forExport) {
|
||||||
Style *s = Get(h);
|
Style *s = Get(h);
|
||||||
if(forExport) {
|
if(forExport) {
|
||||||
return RewriteColor(s->fillColor);
|
return RewriteColor(s->fillColor);
|
||||||
|
@ -290,7 +290,7 @@ double Style::TextHeight(hStyle hs) {
|
||||||
// if it's both shown and exportable.
|
// if it's both shown and exportable.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool Style::Exportable(int si) {
|
bool Style::Exportable(int si) {
|
||||||
hStyle hs = { (DWORD)si };
|
hStyle hs = { (uint32_t)si };
|
||||||
Style *s = Get(hs);
|
Style *s = Get(hs);
|
||||||
return (s->exportable) && (s->visible);
|
return (s->exportable) && (s->visible);
|
||||||
}
|
}
|
||||||
|
@ -331,25 +331,25 @@ char *Style::DescriptionString(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextWindow::ScreenShowListOfStyles(int link, DWORD v) {
|
void TextWindow::ScreenShowListOfStyles(int link, uint32_t v) {
|
||||||
SS.TW.GoToScreen(SCREEN_LIST_OF_STYLES);
|
SS.TW.GoToScreen(SCREEN_LIST_OF_STYLES);
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenShowStyleInfo(int link, DWORD v) {
|
void TextWindow::ScreenShowStyleInfo(int link, uint32_t v) {
|
||||||
SS.TW.GoToScreen(SCREEN_STYLE_INFO);
|
SS.TW.GoToScreen(SCREEN_STYLE_INFO);
|
||||||
SS.TW.shown.style.v = v;
|
SS.TW.shown.style.v = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenLoadFactoryDefaultStyles(int link, DWORD v) {
|
void TextWindow::ScreenLoadFactoryDefaultStyles(int link, uint32_t v) {
|
||||||
Style::LoadFactoryDefaults();
|
Style::LoadFactoryDefaults();
|
||||||
SS.TW.GoToScreen(SCREEN_LIST_OF_STYLES);
|
SS.TW.GoToScreen(SCREEN_LIST_OF_STYLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenCreateCustomStyle(int link, DWORD v) {
|
void TextWindow::ScreenCreateCustomStyle(int link, uint32_t v) {
|
||||||
Style::CreateCustomStyle();
|
Style::CreateCustomStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeBackgroundColor(int link, DWORD v) {
|
void TextWindow::ScreenChangeBackgroundColor(int link, uint32_t v) {
|
||||||
DWORD rgb = SS.backgroundColor;
|
uint32_t rgb = SS.backgroundColor;
|
||||||
SS.TW.ShowEditControlWithColorPicker(v, 3, rgb);
|
SS.TW.ShowEditControlWithColorPicker(v, 3, rgb);
|
||||||
SS.TW.edit.meaning = EDIT_BACKGROUND_COLOR;
|
SS.TW.edit.meaning = EDIT_BACKGROUND_COLOR;
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ static int RoundUpToPowerOfTwo(int v)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenBackgroundImage(int link, DWORD v) {
|
void TextWindow::ScreenBackgroundImage(int link, uint32_t v) {
|
||||||
if(SS.bgImage.fromFile) MemFree(SS.bgImage.fromFile);
|
if(SS.bgImage.fromFile) MemFree(SS.bgImage.fromFile);
|
||||||
SS.bgImage.fromFile = NULL;
|
SS.bgImage.fromFile = NULL;
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ void TextWindow::ScreenBackgroundImage(int link, DWORD v) {
|
||||||
f = fopen(importFile, "rb");
|
f = fopen(importFile, "rb");
|
||||||
if(!f) goto err;
|
if(!f) goto err;
|
||||||
|
|
||||||
BYTE header[8];
|
uint8_t header[8];
|
||||||
if (fread(header, 1, 8, f) != 8)
|
if (fread(header, 1, 8, f) != 8)
|
||||||
goto err;
|
goto err;
|
||||||
if(png_sig_cmp(header, 0, 8)) goto err;
|
if(png_sig_cmp(header, 0, 8)) goto err;
|
||||||
|
@ -402,14 +402,14 @@ void TextWindow::ScreenBackgroundImage(int link, DWORD v) {
|
||||||
|
|
||||||
int w; w = (int)png_get_image_width(png_ptr, info_ptr);
|
int w; w = (int)png_get_image_width(png_ptr, info_ptr);
|
||||||
int h; h = (int)png_get_image_height(png_ptr, info_ptr);
|
int h; h = (int)png_get_image_height(png_ptr, info_ptr);
|
||||||
BYTE **rows; rows = png_get_rows(png_ptr, info_ptr);
|
uint8_t **rows; rows = png_get_rows(png_ptr, info_ptr);
|
||||||
|
|
||||||
// Round to next-highest powers of two, since the textures require
|
// Round to next-highest powers of two, since the textures require
|
||||||
// that. And round up to 4, to guarantee DWORD alignment.
|
// that. And round up to 4, to guarantee 32-bit alignment.
|
||||||
int rw; rw = max(4, RoundUpToPowerOfTwo(w));
|
int rw; rw = max(4, RoundUpToPowerOfTwo(w));
|
||||||
int rh; rh = max(4, RoundUpToPowerOfTwo(h));
|
int rh; rh = max(4, RoundUpToPowerOfTwo(h));
|
||||||
|
|
||||||
SS.bgImage.fromFile = (BYTE *)MemAlloc(rw*rh*3);
|
SS.bgImage.fromFile = (uint8_t *)MemAlloc(rw*rh*3);
|
||||||
for(int i = 0; i < h; i++) {
|
for(int i = 0; i < h; i++) {
|
||||||
memcpy(SS.bgImage.fromFile + ((h - 1) - i)*(rw*3), rows[i], w*3);
|
memcpy(SS.bgImage.fromFile + ((h - 1) - i)*(rw*3), rows[i], w*3);
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,7 @@ err:
|
||||||
SS.later.showTW = true;
|
SS.later.showTW = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeBackgroundImageScale(int link, DWORD v) {
|
void TextWindow::ScreenChangeBackgroundImageScale(int link, uint32_t v) {
|
||||||
char str[300];
|
char str[300];
|
||||||
sprintf(str, "%.3f", SS.bgImage.scale * SS.MmPerUnit());
|
sprintf(str, "%.3f", SS.bgImage.scale * SS.MmPerUnit());
|
||||||
SS.TW.edit.meaning = EDIT_BACKGROUND_IMG_SCALE;
|
SS.TW.edit.meaning = EDIT_BACKGROUND_IMG_SCALE;
|
||||||
|
@ -455,7 +455,7 @@ void TextWindow::ShowListOfStyles(void) {
|
||||||
|
|
||||||
Printf(false, "");
|
Printf(false, "");
|
||||||
|
|
||||||
DWORD rgb = SS.backgroundColor;
|
uint32_t rgb = SS.backgroundColor;
|
||||||
Printf(false, "%Ft background color (r, g, b)%E");
|
Printf(false, "%Ft background color (r, g, b)%E");
|
||||||
Printf(false, "%Ba %@, %@, %@ %Fl%D%f%Ll[change]%E",
|
Printf(false, "%Ba %@, %@, %@ %Fl%D%f%Ll[change]%E",
|
||||||
REDf(rgb), GREENf(rgb), BLUEf(rgb),
|
REDf(rgb), GREENf(rgb), BLUEf(rgb),
|
||||||
|
@ -486,7 +486,7 @@ void TextWindow::ShowListOfStyles(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextWindow::ScreenChangeStyleName(int link, DWORD v) {
|
void TextWindow::ScreenChangeStyleName(int link, uint32_t v) {
|
||||||
hStyle hs = { v };
|
hStyle hs = { v };
|
||||||
Style *s = Style::Get(hs);
|
Style *s = Style::Get(hs);
|
||||||
SS.TW.ShowEditControl(10, 12, s->name.str);
|
SS.TW.ShowEditControl(10, 12, s->name.str);
|
||||||
|
@ -494,7 +494,7 @@ void TextWindow::ScreenChangeStyleName(int link, DWORD v) {
|
||||||
SS.TW.edit.meaning = EDIT_STYLE_NAME;
|
SS.TW.edit.meaning = EDIT_STYLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenDeleteStyle(int link, DWORD v) {
|
void TextWindow::ScreenDeleteStyle(int link, uint32_t v) {
|
||||||
SS.UndoRemember();
|
SS.UndoRemember();
|
||||||
hStyle hs = { v };
|
hStyle hs = { v };
|
||||||
Style *s = SK.style.FindByIdNoOops(hs);
|
Style *s = SK.style.FindByIdNoOops(hs);
|
||||||
|
@ -507,7 +507,7 @@ void TextWindow::ScreenDeleteStyle(int link, DWORD v) {
|
||||||
InvalidateGraphics();
|
InvalidateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeStyleWidthOrTextHeight(int link, DWORD v) {
|
void TextWindow::ScreenChangeStyleWidthOrTextHeight(int link, uint32_t v) {
|
||||||
hStyle hs = { v };
|
hStyle hs = { v };
|
||||||
Style *s = Style::Get(hs);
|
Style *s = Style::Get(hs);
|
||||||
double val = (link == 't') ? s->textHeight : s->width;
|
double val = (link == 't') ? s->textHeight : s->width;
|
||||||
|
@ -534,7 +534,7 @@ void TextWindow::ScreenChangeStyleWidthOrTextHeight(int link, DWORD v) {
|
||||||
EDIT_STYLE_WIDTH;
|
EDIT_STYLE_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeStyleTextAngle(int link, DWORD v) {
|
void TextWindow::ScreenChangeStyleTextAngle(int link, uint32_t v) {
|
||||||
hStyle hs = { v };
|
hStyle hs = { v };
|
||||||
Style *s = Style::Get(hs);
|
Style *s = Style::Get(hs);
|
||||||
char str[300];
|
char str[300];
|
||||||
|
@ -544,12 +544,12 @@ void TextWindow::ScreenChangeStyleTextAngle(int link, DWORD v) {
|
||||||
SS.TW.edit.meaning = EDIT_STYLE_TEXT_ANGLE;
|
SS.TW.edit.meaning = EDIT_STYLE_TEXT_ANGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeStyleColor(int link, DWORD v) {
|
void TextWindow::ScreenChangeStyleColor(int link, uint32_t v) {
|
||||||
hStyle hs = { v };
|
hStyle hs = { v };
|
||||||
Style *s = Style::Get(hs);
|
Style *s = Style::Get(hs);
|
||||||
// Same function used for stroke and fill colors
|
// Same function used for stroke and fill colors
|
||||||
int row, col, em;
|
int row, col, em;
|
||||||
DWORD rgb;
|
uint32_t rgb;
|
||||||
if(link == 's') {
|
if(link == 's') {
|
||||||
row = 15; col = 13;
|
row = 15; col = 13;
|
||||||
em = EDIT_STYLE_COLOR;
|
em = EDIT_STYLE_COLOR;
|
||||||
|
@ -566,7 +566,7 @@ void TextWindow::ScreenChangeStyleColor(int link, DWORD v) {
|
||||||
SS.TW.edit.meaning = em;
|
SS.TW.edit.meaning = em;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeStyleYesNo(int link, DWORD v) {
|
void TextWindow::ScreenChangeStyleYesNo(int link, uint32_t v) {
|
||||||
SS.UndoRemember();
|
SS.UndoRemember();
|
||||||
hStyle hs = { v };
|
hStyle hs = { v };
|
||||||
Style *s = Style::Get(hs);
|
Style *s = Style::Get(hs);
|
||||||
|
@ -867,7 +867,7 @@ void TextWindow::ShowStyleInfo(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenAssignSelectionToStyle(int link, DWORD v) {
|
void TextWindow::ScreenAssignSelectionToStyle(int link, uint32_t v) {
|
||||||
Style::AssignSelectionToStyle(v);
|
Style::AssignSelectionToStyle(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,10 @@ bool System::WriteJacobian(int tag) {
|
||||||
f = f->FoldConstants();
|
f = f->FoldConstants();
|
||||||
|
|
||||||
// Hash table (61 bits) to accelerate generation of zero partials.
|
// Hash table (61 bits) to accelerate generation of zero partials.
|
||||||
QWORD scoreboard = f->ParamsUsed();
|
uint64_t scoreboard = f->ParamsUsed();
|
||||||
for(j = 0; j < mat.n; j++) {
|
for(j = 0; j < mat.n; j++) {
|
||||||
Expr *pd;
|
Expr *pd;
|
||||||
if(scoreboard & ((QWORD)1 << (mat.param[j].v % 61)) &&
|
if(scoreboard & ((uint64_t)1 << (mat.param[j].v % 61)) &&
|
||||||
f->DependsOn(mat.param[j]))
|
f->DependsOn(mat.param[j]))
|
||||||
{
|
{
|
||||||
pd = f->PartialWrt(mat.param[j]);
|
pd = f->PartialWrt(mat.param[j]);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// A navigation bar that always appears at the top of the window, with a
|
// A navigation bar that always appears at the top of the window, with a
|
||||||
// link to bring us back home.
|
// link to bring us back home.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void TextWindow::ScreenHome(int link, DWORD v) {
|
void TextWindow::ScreenHome(int link, uint32_t v) {
|
||||||
SS.TW.GoToScreen(SCREEN_LIST_OF_GROUPS);
|
SS.TW.GoToScreen(SCREEN_LIST_OF_GROUPS);
|
||||||
}
|
}
|
||||||
void TextWindow::ShowHeader(bool withNav) {
|
void TextWindow::ShowHeader(bool withNav) {
|
||||||
|
@ -42,11 +42,11 @@ void TextWindow::ShowHeader(bool withNav) {
|
||||||
// The screen that shows a list of every group in the sketch, with options
|
// The screen that shows a list of every group in the sketch, with options
|
||||||
// to hide or show them, and to view them in detail. This is our home page.
|
// to hide or show them, and to view them in detail. This is our home page.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void TextWindow::ScreenSelectGroup(int link, DWORD v) {
|
void TextWindow::ScreenSelectGroup(int link, uint32_t v) {
|
||||||
SS.TW.GoToScreen(SCREEN_GROUP_INFO);
|
SS.TW.GoToScreen(SCREEN_GROUP_INFO);
|
||||||
SS.TW.shown.group.v = v;
|
SS.TW.shown.group.v = v;
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenToggleGroupShown(int link, DWORD v) {
|
void TextWindow::ScreenToggleGroupShown(int link, uint32_t v) {
|
||||||
hGroup hg = { v };
|
hGroup hg = { v };
|
||||||
Group *g = SK.GetGroup(hg);
|
Group *g = SK.GetGroup(hg);
|
||||||
g->visible = !(g->visible);
|
g->visible = !(g->visible);
|
||||||
|
@ -54,7 +54,7 @@ void TextWindow::ScreenToggleGroupShown(int link, DWORD v) {
|
||||||
// previously, so regenerate.
|
// previously, so regenerate.
|
||||||
SS.GenerateAll();
|
SS.GenerateAll();
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenShowGroupsSpecial(int link, DWORD v) {
|
void TextWindow::ScreenShowGroupsSpecial(int link, uint32_t v) {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < SK.group.n; i++) {
|
for(i = 0; i < SK.group.n; i++) {
|
||||||
Group *g = &(SK.group.elem[i]);
|
Group *g = &(SK.group.elem[i]);
|
||||||
|
@ -66,7 +66,7 @@ void TextWindow::ScreenShowGroupsSpecial(int link, DWORD v) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenActivateGroup(int link, DWORD v) {
|
void TextWindow::ScreenActivateGroup(int link, uint32_t v) {
|
||||||
hGroup hg = { v };
|
hGroup hg = { v };
|
||||||
Group *g = SK.GetGroup(hg);
|
Group *g = SK.GetGroup(hg);
|
||||||
g->visible = true;
|
g->visible = true;
|
||||||
|
@ -80,20 +80,20 @@ void TextWindow::ReportHowGroupSolved(hGroup hg) {
|
||||||
SS.TW.shown.group.v = hg.v;
|
SS.TW.shown.group.v = hg.v;
|
||||||
SS.later.showTW = true;
|
SS.later.showTW = true;
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenHowGroupSolved(int link, DWORD v) {
|
void TextWindow::ScreenHowGroupSolved(int link, uint32_t v) {
|
||||||
if(SS.GW.activeGroup.v != v) {
|
if(SS.GW.activeGroup.v != v) {
|
||||||
ScreenActivateGroup(link, v);
|
ScreenActivateGroup(link, v);
|
||||||
}
|
}
|
||||||
SS.TW.GoToScreen(SCREEN_GROUP_SOLVE_INFO);
|
SS.TW.GoToScreen(SCREEN_GROUP_SOLVE_INFO);
|
||||||
SS.TW.shown.group.v = v;
|
SS.TW.shown.group.v = v;
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenShowConfiguration(int link, DWORD v) {
|
void TextWindow::ScreenShowConfiguration(int link, uint32_t v) {
|
||||||
SS.TW.GoToScreen(SCREEN_CONFIGURATION);
|
SS.TW.GoToScreen(SCREEN_CONFIGURATION);
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenShowEditView(int link, DWORD v) {
|
void TextWindow::ScreenShowEditView(int link, uint32_t v) {
|
||||||
SS.TW.GoToScreen(SCREEN_EDIT_VIEW);
|
SS.TW.GoToScreen(SCREEN_EDIT_VIEW);
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenGoToWebsite(int link, DWORD v) {
|
void TextWindow::ScreenGoToWebsite(int link, uint32_t v) {
|
||||||
OpenWebsite("http://solvespace.com/txtlink");
|
OpenWebsite("http://solvespace.com/txtlink");
|
||||||
}
|
}
|
||||||
void TextWindow::ShowListOfGroups(void) {
|
void TextWindow::ShowListOfGroups(void) {
|
||||||
|
@ -154,7 +154,7 @@ void TextWindow::ShowListOfGroups(void) {
|
||||||
// The screen that shows information about a specific group, and allows the
|
// The screen that shows information about a specific group, and allows the
|
||||||
// user to edit various things about it.
|
// user to edit various things about it.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void TextWindow::ScreenHoverConstraint(int link, DWORD v) {
|
void TextWindow::ScreenHoverConstraint(int link, uint32_t v) {
|
||||||
if(!SS.GW.showConstraints) return;
|
if(!SS.GW.showConstraints) return;
|
||||||
|
|
||||||
hConstraint hc = { v };
|
hConstraint hc = { v };
|
||||||
|
@ -167,20 +167,20 @@ void TextWindow::ScreenHoverConstraint(int link, DWORD v) {
|
||||||
SS.GW.hover.constraint = hc;
|
SS.GW.hover.constraint = hc;
|
||||||
SS.GW.hover.emphasized = true;
|
SS.GW.hover.emphasized = true;
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenHoverRequest(int link, DWORD v) {
|
void TextWindow::ScreenHoverRequest(int link, uint32_t v) {
|
||||||
SS.GW.hover.Clear();
|
SS.GW.hover.Clear();
|
||||||
hRequest hr = { v };
|
hRequest hr = { v };
|
||||||
SS.GW.hover.entity = hr.entity(0);
|
SS.GW.hover.entity = hr.entity(0);
|
||||||
SS.GW.hover.emphasized = true;
|
SS.GW.hover.emphasized = true;
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenSelectConstraint(int link, DWORD v) {
|
void TextWindow::ScreenSelectConstraint(int link, uint32_t v) {
|
||||||
SS.GW.ClearSelection();
|
SS.GW.ClearSelection();
|
||||||
GraphicsWindow::Selection sel;
|
GraphicsWindow::Selection sel;
|
||||||
ZERO(&sel);
|
ZERO(&sel);
|
||||||
sel.constraint.v = v;
|
sel.constraint.v = v;
|
||||||
SS.GW.selection.Add(&sel);
|
SS.GW.selection.Add(&sel);
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenSelectRequest(int link, DWORD v) {
|
void TextWindow::ScreenSelectRequest(int link, uint32_t v) {
|
||||||
SS.GW.ClearSelection();
|
SS.GW.ClearSelection();
|
||||||
GraphicsWindow::Selection sel;
|
GraphicsWindow::Selection sel;
|
||||||
ZERO(&sel);
|
ZERO(&sel);
|
||||||
|
@ -189,7 +189,7 @@ void TextWindow::ScreenSelectRequest(int link, DWORD v) {
|
||||||
SS.GW.selection.Add(&sel);
|
SS.GW.selection.Add(&sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeGroupOption(int link, DWORD v) {
|
void TextWindow::ScreenChangeGroupOption(int link, uint32_t v) {
|
||||||
SS.UndoRemember();
|
SS.UndoRemember();
|
||||||
Group *g = SK.GetGroup(SS.TW.shown.group);
|
Group *g = SK.GetGroup(SS.TW.shown.group);
|
||||||
|
|
||||||
|
@ -218,14 +218,14 @@ void TextWindow::ScreenChangeGroupOption(int link, DWORD v) {
|
||||||
SS.GW.ClearSuper();
|
SS.GW.ClearSuper();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenColor(int link, DWORD v) {
|
void TextWindow::ScreenColor(int link, uint32_t v) {
|
||||||
SS.UndoRemember();
|
SS.UndoRemember();
|
||||||
|
|
||||||
Group *g = SK.GetGroup(SS.TW.shown.group);
|
Group *g = SK.GetGroup(SS.TW.shown.group);
|
||||||
SS.TW.ShowEditControlWithColorPicker(v, 3, g->color);
|
SS.TW.ShowEditControlWithColorPicker(v, 3, g->color);
|
||||||
SS.TW.edit.meaning = EDIT_GROUP_COLOR;
|
SS.TW.edit.meaning = EDIT_GROUP_COLOR;
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenChangeExprA(int link, DWORD v) {
|
void TextWindow::ScreenChangeExprA(int link, uint32_t v) {
|
||||||
Group *g = SK.GetGroup(SS.TW.shown.group);
|
Group *g = SK.GetGroup(SS.TW.shown.group);
|
||||||
|
|
||||||
// There's an extra line for the skipFirst parameter in one-sided groups.
|
// There's an extra line for the skipFirst parameter in one-sided groups.
|
||||||
|
@ -237,13 +237,13 @@ void TextWindow::ScreenChangeExprA(int link, DWORD v) {
|
||||||
SS.TW.edit.meaning = EDIT_TIMES_REPEATED;
|
SS.TW.edit.meaning = EDIT_TIMES_REPEATED;
|
||||||
SS.TW.edit.group.v = v;
|
SS.TW.edit.group.v = v;
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenChangeGroupName(int link, DWORD v) {
|
void TextWindow::ScreenChangeGroupName(int link, uint32_t v) {
|
||||||
Group *g = SK.GetGroup(SS.TW.shown.group);
|
Group *g = SK.GetGroup(SS.TW.shown.group);
|
||||||
SS.TW.ShowEditControl(7, 12, g->DescriptionString()+5);
|
SS.TW.ShowEditControl(7, 12, g->DescriptionString()+5);
|
||||||
SS.TW.edit.meaning = EDIT_GROUP_NAME;
|
SS.TW.edit.meaning = EDIT_GROUP_NAME;
|
||||||
SS.TW.edit.group.v = v;
|
SS.TW.edit.group.v = v;
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenChangeGroupScale(int link, DWORD v) {
|
void TextWindow::ScreenChangeGroupScale(int link, uint32_t v) {
|
||||||
Group *g = SK.GetGroup(SS.TW.shown.group);
|
Group *g = SK.GetGroup(SS.TW.shown.group);
|
||||||
|
|
||||||
char str[1024];
|
char str[1024];
|
||||||
|
@ -252,7 +252,7 @@ void TextWindow::ScreenChangeGroupScale(int link, DWORD v) {
|
||||||
SS.TW.edit.meaning = EDIT_GROUP_SCALE;
|
SS.TW.edit.meaning = EDIT_GROUP_SCALE;
|
||||||
SS.TW.edit.group.v = v;
|
SS.TW.edit.group.v = v;
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenDeleteGroup(int link, DWORD v) {
|
void TextWindow::ScreenDeleteGroup(int link, uint32_t v) {
|
||||||
SS.UndoRemember();
|
SS.UndoRemember();
|
||||||
|
|
||||||
hGroup hg = SS.TW.shown.group;
|
hGroup hg = SS.TW.shown.group;
|
||||||
|
@ -497,7 +497,7 @@ void TextWindow::ShowGroupSolveInfo(void) {
|
||||||
// how many steps to take in between current and finish, re-solving each
|
// how many steps to take in between current and finish, re-solving each
|
||||||
// time.
|
// time.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void TextWindow::ScreenStepDimFinish(int link, DWORD v) {
|
void TextWindow::ScreenStepDimFinish(int link, uint32_t v) {
|
||||||
SS.TW.edit.meaning = EDIT_STEP_DIM_FINISH;
|
SS.TW.edit.meaning = EDIT_STEP_DIM_FINISH;
|
||||||
char s[1024];
|
char s[1024];
|
||||||
if(SS.TW.shown.dimIsDistance) {
|
if(SS.TW.shown.dimIsDistance) {
|
||||||
|
@ -507,13 +507,13 @@ void TextWindow::ScreenStepDimFinish(int link, DWORD v) {
|
||||||
}
|
}
|
||||||
SS.TW.ShowEditControl(12, 12, s);
|
SS.TW.ShowEditControl(12, 12, s);
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenStepDimSteps(int link, DWORD v) {
|
void TextWindow::ScreenStepDimSteps(int link, uint32_t v) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
sprintf(str, "%d", SS.TW.shown.dimSteps);
|
sprintf(str, "%d", SS.TW.shown.dimSteps);
|
||||||
SS.TW.edit.meaning = EDIT_STEP_DIM_STEPS;
|
SS.TW.edit.meaning = EDIT_STEP_DIM_STEPS;
|
||||||
SS.TW.ShowEditControl(14, 12, str);
|
SS.TW.ShowEditControl(14, 12, str);
|
||||||
}
|
}
|
||||||
void TextWindow::ScreenStepDimGo(int link, DWORD v) {
|
void TextWindow::ScreenStepDimGo(int link, uint32_t v) {
|
||||||
hConstraint hc = SS.TW.shown.constraint;
|
hConstraint hc = SS.TW.shown.constraint;
|
||||||
Constraint *c = SK.constraint.FindByIdNoOops(hc);
|
Constraint *c = SK.constraint.FindByIdNoOops(hc);
|
||||||
if(c) {
|
if(c) {
|
||||||
|
@ -567,7 +567,7 @@ void TextWindow::ShowStepDimension(void) {
|
||||||
// thing). User gets to specify the radius, and whether the old untrimmed
|
// thing). User gets to specify the radius, and whether the old untrimmed
|
||||||
// curves are kept or deleted.
|
// curves are kept or deleted.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void TextWindow::ScreenChangeTangentArc(int link, DWORD v) {
|
void TextWindow::ScreenChangeTangentArc(int link, uint32_t v) {
|
||||||
switch(link) {
|
switch(link) {
|
||||||
case 'r': {
|
case 'r': {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
|
|
41
textwin.cpp
41
textwin.cpp
|
@ -85,7 +85,7 @@ void TextWindow::ShowEditControl(int halfRow, int col, char *s) {
|
||||||
ShowTextEditControl(x - 3, y + 2, s);
|
ShowTextEditControl(x - 3, y + 2, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ShowEditControlWithColorPicker(int halfRow, int col, DWORD rgb)
|
void TextWindow::ShowEditControlWithColorPicker(int halfRow, int col, uint32_t rgb)
|
||||||
{
|
{
|
||||||
char str[1024];
|
char str[1024];
|
||||||
sprintf(str, "%.2f, %.2f, %.2f", REDf(rgb), GREENf(rgb), BLUEf(rgb));
|
sprintf(str, "%.2f, %.2f, %.2f", REDf(rgb), GREENf(rgb), BLUEf(rgb));
|
||||||
|
@ -133,7 +133,7 @@ void TextWindow::Printf(bool halfLine, const char *fmt, ...) {
|
||||||
char fg = 'd';
|
char fg = 'd';
|
||||||
int bg = 'd';
|
int bg = 'd';
|
||||||
int link = NOT_A_LINK;
|
int link = NOT_A_LINK;
|
||||||
DWORD data = 0;
|
uint32_t data = 0;
|
||||||
LinkFunction *f = NULL, *h = NULL;
|
LinkFunction *f = NULL, *h = NULL;
|
||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
|
@ -151,7 +151,7 @@ void TextWindow::Printf(bool halfLine, const char *fmt, ...) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'x': {
|
case 'x': {
|
||||||
DWORD v = va_arg(vl, DWORD);
|
unsigned int v = va_arg(vl, unsigned int);
|
||||||
sprintf(buf, "%08x", v);
|
sprintf(buf, "%08x", v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -237,10 +237,11 @@ void TextWindow::Printf(bool halfLine, const char *fmt, ...) {
|
||||||
h = va_arg(vl, LinkFunction *);
|
h = va_arg(vl, LinkFunction *);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D':
|
case 'D': {
|
||||||
data = va_arg(vl, DWORD);
|
unsigned int v = va_arg(vl, unsigned int);
|
||||||
|
data = (uint32_t)v;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case '%':
|
case '%':
|
||||||
strcpy(buf, "%");
|
strcpy(buf, "%");
|
||||||
break;
|
break;
|
||||||
|
@ -495,8 +496,8 @@ Vector TextWindow::HsvToRgb(Vector hsv) {
|
||||||
return rgb;
|
return rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE *TextWindow::HsvPattern2d(void) {
|
uint8_t *TextWindow::HsvPattern2d(void) {
|
||||||
static BYTE Texture[256*256*3];
|
static uint8_t Texture[256*256*3];
|
||||||
static bool Init;
|
static bool Init;
|
||||||
|
|
||||||
if(!Init) {
|
if(!Init) {
|
||||||
|
@ -507,9 +508,9 @@ BYTE *TextWindow::HsvPattern2d(void) {
|
||||||
Vector hsv = Vector::From(6.0*i/255.0, 1.0*j/255.0, 1);
|
Vector hsv = Vector::From(6.0*i/255.0, 1.0*j/255.0, 1);
|
||||||
Vector rgb = HsvToRgb(hsv);
|
Vector rgb = HsvToRgb(hsv);
|
||||||
rgb = rgb.ScaledBy(255);
|
rgb = rgb.ScaledBy(255);
|
||||||
Texture[p++] = (BYTE)rgb.x;
|
Texture[p++] = (uint8_t)rgb.x;
|
||||||
Texture[p++] = (BYTE)rgb.y;
|
Texture[p++] = (uint8_t)rgb.y;
|
||||||
Texture[p++] = (BYTE)rgb.z;
|
Texture[p++] = (uint8_t)rgb.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Init = true;
|
Init = true;
|
||||||
|
@ -517,8 +518,8 @@ BYTE *TextWindow::HsvPattern2d(void) {
|
||||||
return Texture;
|
return Texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE *TextWindow::HsvPattern1d(double h, double s) {
|
uint8_t *TextWindow::HsvPattern1d(double h, double s) {
|
||||||
static BYTE Texture[256*4];
|
static uint8_t Texture[256*4];
|
||||||
|
|
||||||
int i, p;
|
int i, p;
|
||||||
p = 0;
|
p = 0;
|
||||||
|
@ -526,9 +527,9 @@ BYTE *TextWindow::HsvPattern1d(double h, double s) {
|
||||||
Vector hsv = Vector::From(6*h, s, 1.0*(255 - i)/255.0);
|
Vector hsv = Vector::From(6*h, s, 1.0*(255 - i)/255.0);
|
||||||
Vector rgb = HsvToRgb(hsv);
|
Vector rgb = HsvToRgb(hsv);
|
||||||
rgb = rgb.ScaledBy(255);
|
rgb = rgb.ScaledBy(255);
|
||||||
Texture[p++] = (BYTE)rgb.x;
|
Texture[p++] = (uint8_t)rgb.x;
|
||||||
Texture[p++] = (BYTE)rgb.y;
|
Texture[p++] = (uint8_t)rgb.y;
|
||||||
Texture[p++] = (BYTE)rgb.z;
|
Texture[p++] = (uint8_t)rgb.z;
|
||||||
// Needs a padding byte, to make things four-aligned
|
// Needs a padding byte, to make things four-aligned
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
@ -537,13 +538,13 @@ BYTE *TextWindow::HsvPattern1d(double h, double s) {
|
||||||
|
|
||||||
void TextWindow::ColorPickerDone(void) {
|
void TextWindow::ColorPickerDone(void) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
DWORD rgb = editControl.colorPicker.rgb;
|
uint32_t rgb = editControl.colorPicker.rgb;
|
||||||
sprintf(str, "%.2f, %.2f, %.3f", REDf(rgb), GREENf(rgb), BLUEf(rgb));
|
sprintf(str, "%.2f, %.2f, %.3f", REDf(rgb), GREENf(rgb), BLUEf(rgb));
|
||||||
EditControlDone(str);
|
EditControlDone(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown,
|
bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown,
|
||||||
double x, double y)
|
double x, double y)
|
||||||
{
|
{
|
||||||
bool mousePointerAsHand = false;
|
bool mousePointerAsHand = false;
|
||||||
|
|
||||||
|
@ -555,7 +556,7 @@ bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown,
|
||||||
if(!editControl.colorPicker.show) return false;
|
if(!editControl.colorPicker.show) return false;
|
||||||
if(how == CLICK || (how == HOVER && leftDown)) InvalidateText();
|
if(how == CLICK || (how == HOVER && leftDown)) InvalidateText();
|
||||||
|
|
||||||
static const DWORD BaseColor[12] = {
|
static const uint32_t BaseColor[12] = {
|
||||||
RGB(255, 0, 0),
|
RGB(255, 0, 0),
|
||||||
RGB( 0, 255, 0),
|
RGB( 0, 255, 0),
|
||||||
RGB( 0, 0, 255),
|
RGB( 0, 0, 255),
|
||||||
|
@ -608,7 +609,7 @@ bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown,
|
||||||
for(i = 0; i < WIDTH/2; i++) {
|
for(i = 0; i < WIDTH/2; i++) {
|
||||||
for(j = 0; j < HEIGHT; j++) {
|
for(j = 0; j < HEIGHT; j++) {
|
||||||
Vector rgb;
|
Vector rgb;
|
||||||
DWORD d;
|
uint32_t d;
|
||||||
if(i == 0 && j < 8) {
|
if(i == 0 && j < 8) {
|
||||||
d = SS.modelColor[j];
|
d = SS.modelColor[j];
|
||||||
rgb = Vector::From(REDf(d), GREENf(d), BLUEf(d));
|
rgb = Vector::From(REDf(d), GREENf(d), BLUEf(d));
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
#include <icons.h>
|
#include <icons.h>
|
||||||
|
|
||||||
BYTE SPACER[1];
|
uint8_t SPACER[1];
|
||||||
static const struct {
|
static const struct {
|
||||||
BYTE *image;
|
uint8_t *image;
|
||||||
int menu;
|
int menu;
|
||||||
const char *tip;
|
const char *tip;
|
||||||
} Toolbar[] = {
|
} Toolbar[] = {
|
||||||
|
|
|
@ -10,8 +10,8 @@ int main(void)
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
|
||||||
// A monospaced font
|
// A monospaced font
|
||||||
HFONT font = CreateFont(16, 9, 0, 0, FW_REGULAR, FALSE,
|
HFONT font = CreateFont(16, 9, 0, 0, FW_REGULAR, false,
|
||||||
FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||||
DEFAULT_QUALITY, FF_DONTCARE, "Lucida Console");
|
DEFAULT_QUALITY, FF_DONTCARE, "Lucida Console");
|
||||||
|
|
||||||
HDC hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
|
HDC hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
|
||||||
|
@ -20,7 +20,7 @@ int main(void)
|
||||||
SelectObject(hdc, bitmap);
|
SelectObject(hdc, bitmap);
|
||||||
SelectObject(hdc, font);
|
SelectObject(hdc, font);
|
||||||
|
|
||||||
printf("static const BYTE FontTexture[256*16*16] = {\n");
|
printf("static const uint8_t FontTexture[256*16*16] = {\n");
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
for(c = 0; c < 128; c++) {
|
for(c = 0; c < 128; c++) {
|
||||||
|
|
306
ttf.cpp
306
ttf.cpp
|
@ -67,23 +67,24 @@ int TtfFont::Getc(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Helpers to get 1, 2, or 4 bytes from the .ttf file. Big endian.
|
// Helpers to get 1, 2, or 4 bytes from the .ttf file. Big endian.
|
||||||
|
// The BYTE, USHORT and ULONG nomenclature comes from the OpenType spec.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
BYTE TtfFont::GetBYTE(void) {
|
uint8_t TtfFont::GetBYTE(void) {
|
||||||
return (BYTE)Getc();
|
return (uint8_t)Getc();
|
||||||
}
|
}
|
||||||
WORD TtfFont::GetWORD(void) {
|
uint16_t TtfFont::GetUSHORT(void) {
|
||||||
BYTE b0, b1;
|
uint8_t b0, b1;
|
||||||
b1 = (BYTE)Getc();
|
b1 = (uint8_t)Getc();
|
||||||
b0 = (BYTE)Getc();
|
b0 = (uint8_t)Getc();
|
||||||
|
|
||||||
return (b1 << 8) | b0;
|
return (b1 << 8) | b0;
|
||||||
}
|
}
|
||||||
DWORD TtfFont::GetDWORD(void) {
|
uint32_t TtfFont::GetULONG(void) {
|
||||||
BYTE b0, b1, b2, b3;
|
uint8_t b0, b1, b2, b3;
|
||||||
b3 = (BYTE)Getc();
|
b3 = (uint8_t)Getc();
|
||||||
b2 = (BYTE)Getc();
|
b2 = (uint8_t)Getc();
|
||||||
b1 = (BYTE)Getc();
|
b1 = (uint8_t)Getc();
|
||||||
b0 = (BYTE)Getc();
|
b0 = (uint8_t)Getc();
|
||||||
|
|
||||||
return (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
|
return (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
|
||||||
}
|
}
|
||||||
|
@ -98,35 +99,35 @@ void TtfFont::LoadGlyph(int index) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
SWORD contours = (SWORD)GetWORD();
|
int16_t contours = (int16_t)GetUSHORT();
|
||||||
SWORD xMin = (SWORD)GetWORD();
|
int16_t xMin = (int16_t)GetUSHORT();
|
||||||
SWORD yMin = (SWORD)GetWORD();
|
int16_t yMin = (int16_t)GetUSHORT();
|
||||||
SWORD xMax = (SWORD)GetWORD();
|
int16_t xMax = (int16_t)GetUSHORT();
|
||||||
SWORD yMax = (SWORD)GetWORD();
|
int16_t yMax = (int16_t)GetUSHORT();
|
||||||
|
|
||||||
if(useGlyph['A'] == index) {
|
if(useGlyph['A'] == index) {
|
||||||
scale = (1024*1024) / yMax;
|
scale = (1024*1024) / yMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(contours > 0) {
|
if(contours > 0) {
|
||||||
WORD *endPointsOfContours =
|
uint16_t *endPointsOfContours =
|
||||||
(WORD *)AllocTemporary(contours*sizeof(WORD));
|
(uint16_t *)AllocTemporary(contours*sizeof(uint16_t));
|
||||||
|
|
||||||
for(i = 0; i < contours; i++) {
|
for(i = 0; i < contours; i++) {
|
||||||
endPointsOfContours[i] = GetWORD();
|
endPointsOfContours[i] = GetUSHORT();
|
||||||
}
|
}
|
||||||
WORD totalPts = endPointsOfContours[i-1] + 1;
|
uint16_t totalPts = endPointsOfContours[i-1] + 1;
|
||||||
|
|
||||||
WORD instructionLength = GetWORD();
|
uint16_t instructionLength = GetUSHORT();
|
||||||
for(i = 0; i < instructionLength; i++) {
|
for(i = 0; i < instructionLength; i++) {
|
||||||
// We can ignore the instructions, since we're doing vector
|
// We can ignore the instructions, since we're doing vector
|
||||||
// output.
|
// output.
|
||||||
(void)GetBYTE();
|
(void)GetBYTE();
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE *flags = (BYTE *)AllocTemporary(totalPts*sizeof(BYTE));
|
uint8_t *flags = (uint8_t *)AllocTemporary(totalPts*sizeof(uint8_t));
|
||||||
SWORD *x = (SWORD *)AllocTemporary(totalPts*sizeof(SWORD));
|
int16_t *x = (int16_t *)AllocTemporary(totalPts*sizeof(int16_t));
|
||||||
SWORD *y = (SWORD *)AllocTemporary(totalPts*sizeof(SWORD));
|
int16_t *y = (int16_t *)AllocTemporary(totalPts*sizeof(int16_t));
|
||||||
|
|
||||||
// Flags, that indicate format of the coordinates
|
// Flags, that indicate format of the coordinates
|
||||||
#define FLAG_ON_CURVE (1 << 0)
|
#define FLAG_ON_CURVE (1 << 0)
|
||||||
|
@ -141,7 +142,7 @@ void TtfFont::LoadGlyph(int index) {
|
||||||
flags[i] = GetBYTE();
|
flags[i] = GetBYTE();
|
||||||
if(flags[i] & FLAG_REPEAT) {
|
if(flags[i] & FLAG_REPEAT) {
|
||||||
int n = GetBYTE();
|
int n = GetBYTE();
|
||||||
BYTE f = flags[i];
|
uint8_t f = flags[i];
|
||||||
int j;
|
int j;
|
||||||
for(j = 0; j < n; j++) {
|
for(j = 0; j < n; j++) {
|
||||||
i++;
|
i++;
|
||||||
|
@ -154,10 +155,10 @@ void TtfFont::LoadGlyph(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// x coordinates
|
// x coordinates
|
||||||
SWORD xa = 0;
|
int16_t xa = 0;
|
||||||
for(i = 0; i < totalPts; i++) {
|
for(i = 0; i < totalPts; i++) {
|
||||||
if(flags[i] & FLAG_DX_IS_BYTE) {
|
if(flags[i] & FLAG_DX_IS_BYTE) {
|
||||||
BYTE v = GetBYTE();
|
uint8_t v = GetBYTE();
|
||||||
if(flags[i] & FLAG_X_IS_POSITIVE) {
|
if(flags[i] & FLAG_X_IS_POSITIVE) {
|
||||||
xa += v;
|
xa += v;
|
||||||
} else {
|
} else {
|
||||||
|
@ -167,7 +168,7 @@ void TtfFont::LoadGlyph(int index) {
|
||||||
if(flags[i] & FLAG_X_IS_SAME) {
|
if(flags[i] & FLAG_X_IS_SAME) {
|
||||||
// no change
|
// no change
|
||||||
} else {
|
} else {
|
||||||
SWORD d = (SWORD)GetWORD();
|
int16_t d = (int16_t)GetUSHORT();
|
||||||
xa += d;
|
xa += d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,10 +176,10 @@ void TtfFont::LoadGlyph(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// y coordinates
|
// y coordinates
|
||||||
SWORD ya = 0;
|
int16_t ya = 0;
|
||||||
for(i = 0; i < totalPts; i++) {
|
for(i = 0; i < totalPts; i++) {
|
||||||
if(flags[i] & FLAG_DY_IS_BYTE) {
|
if(flags[i] & FLAG_DY_IS_BYTE) {
|
||||||
BYTE v = GetBYTE();
|
uint8_t v = GetBYTE();
|
||||||
if(flags[i] & FLAG_Y_IS_POSITIVE) {
|
if(flags[i] & FLAG_Y_IS_POSITIVE) {
|
||||||
ya += v;
|
ya += v;
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,7 +189,7 @@ void TtfFont::LoadGlyph(int index) {
|
||||||
if(flags[i] & FLAG_Y_IS_SAME) {
|
if(flags[i] & FLAG_Y_IS_SAME) {
|
||||||
// no change
|
// no change
|
||||||
} else {
|
} else {
|
||||||
SWORD d = (SWORD)GetWORD();
|
int16_t d = (int16_t)GetUSHORT();
|
||||||
ya += d;
|
ya += d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +202,7 @@ void TtfFont::LoadGlyph(int index) {
|
||||||
for(i = 0; i < totalPts; i++) {
|
for(i = 0; i < totalPts; i++) {
|
||||||
g->pt[i].x = x[i];
|
g->pt[i].x = x[i];
|
||||||
g->pt[i].y = y[i];
|
g->pt[i].y = y[i];
|
||||||
g->pt[i].onCurve = (BYTE)(flags[i] & FLAG_ON_CURVE);
|
g->pt[i].onCurve = (uint8_t)(flags[i] & FLAG_ON_CURVE);
|
||||||
|
|
||||||
if(i == endPointsOfContours[contour]) {
|
if(i == endPointsOfContours[contour]) {
|
||||||
g->pt[i].lastInContour = true;
|
g->pt[i].lastInContour = true;
|
||||||
|
@ -248,22 +249,22 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// First, load the Offset Table
|
// First, load the Offset Table
|
||||||
DWORD version = GetDWORD();
|
uint32_t version = GetULONG();
|
||||||
WORD numTables = GetWORD();
|
uint16_t numTables = GetUSHORT();
|
||||||
WORD searchRange = GetWORD();
|
uint16_t searchRange = GetUSHORT();
|
||||||
WORD entrySelector = GetWORD();
|
uint16_t entrySelector = GetUSHORT();
|
||||||
WORD rangeShift = GetWORD();
|
uint16_t rangeShift = GetUSHORT();
|
||||||
|
|
||||||
// Now load the Table Directory; our goal in doing this will be to
|
// Now load the Table Directory; our goal in doing this will be to
|
||||||
// find the addresses of the tables that we will need.
|
// find the addresses of the tables that we will need.
|
||||||
DWORD glyfAddr = (DWORD)-1, glyfLen;
|
uint32_t glyfAddr = (uint32_t)-1, glyfLen;
|
||||||
DWORD cmapAddr = (DWORD)-1, cmapLen;
|
uint32_t cmapAddr = (uint32_t)-1, cmapLen;
|
||||||
DWORD headAddr = (DWORD)-1, headLen;
|
uint32_t headAddr = (uint32_t)-1, headLen;
|
||||||
DWORD locaAddr = (DWORD)-1, locaLen;
|
uint32_t locaAddr = (uint32_t)-1, locaLen;
|
||||||
DWORD maxpAddr = (DWORD)-1, maxpLen;
|
uint32_t maxpAddr = (uint32_t)-1, maxpLen;
|
||||||
DWORD nameAddr = (DWORD)-1, nameLen;
|
uint32_t nameAddr = (uint32_t)-1, nameLen;
|
||||||
DWORD hmtxAddr = (DWORD)-1, hmtxLen;
|
uint32_t hmtxAddr = (uint32_t)-1, hmtxLen;
|
||||||
DWORD hheaAddr = (DWORD)-1, hheaLen;
|
uint32_t hheaAddr = (uint32_t)-1, hheaLen;
|
||||||
|
|
||||||
for(i = 0; i < numTables; i++) {
|
for(i = 0; i < numTables; i++) {
|
||||||
char tag[5] = "xxxx";
|
char tag[5] = "xxxx";
|
||||||
|
@ -271,9 +272,9 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
tag[1] = (char)GetBYTE();
|
tag[1] = (char)GetBYTE();
|
||||||
tag[2] = (char)GetBYTE();
|
tag[2] = (char)GetBYTE();
|
||||||
tag[3] = (char)GetBYTE();
|
tag[3] = (char)GetBYTE();
|
||||||
DWORD checksum = GetDWORD();
|
uint32_t checksum = GetULONG();
|
||||||
DWORD offset = GetDWORD();
|
uint32_t offset = GetULONG();
|
||||||
DWORD length = GetDWORD();
|
uint32_t length = GetULONG();
|
||||||
|
|
||||||
if(strcmp(tag, "glyf")==0) {
|
if(strcmp(tag, "glyf")==0) {
|
||||||
glyfAddr = offset;
|
glyfAddr = offset;
|
||||||
|
@ -302,9 +303,14 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(glyfAddr == (DWORD)-1 || cmapAddr == (DWORD)-1 || headAddr == (DWORD)-1 ||
|
if(glyfAddr == (uint32_t)-1 ||
|
||||||
locaAddr == (DWORD)-1 || maxpAddr == (DWORD)-1 || hmtxAddr == (DWORD)-1 ||
|
cmapAddr == (uint32_t)-1 ||
|
||||||
nameAddr == (DWORD)-1 || hheaAddr == (DWORD)-1)
|
headAddr == (uint32_t)-1 ||
|
||||||
|
locaAddr == (uint32_t)-1 ||
|
||||||
|
maxpAddr == (uint32_t)-1 ||
|
||||||
|
hmtxAddr == (uint32_t)-1 ||
|
||||||
|
nameAddr == (uint32_t)-1 ||
|
||||||
|
hheaAddr == (uint32_t)-1)
|
||||||
{
|
{
|
||||||
throw "missing table addr";
|
throw "missing table addr";
|
||||||
}
|
}
|
||||||
|
@ -313,19 +319,19 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
// we need when we're giving the user a list to choose from.
|
// we need when we're giving the user a list to choose from.
|
||||||
fseek(fh, nameAddr, SEEK_SET);
|
fseek(fh, nameAddr, SEEK_SET);
|
||||||
|
|
||||||
WORD nameFormat = GetWORD();
|
uint16_t nameFormat = GetUSHORT();
|
||||||
WORD nameCount = GetWORD();
|
uint16_t nameCount = GetUSHORT();
|
||||||
WORD nameStringOffset = GetWORD();
|
uint16_t nameStringOffset = GetUSHORT();
|
||||||
// And now we're at the name records. Go through those till we find
|
// And now we're at the name records. Go through those till we find
|
||||||
// one that we want.
|
// one that we want.
|
||||||
int displayNameOffset = 0, displayNameLength = 0;
|
int displayNameOffset = 0, displayNameLength = 0;
|
||||||
for(i = 0; i < nameCount; i++) {
|
for(i = 0; i < nameCount; i++) {
|
||||||
WORD platformID = GetWORD();
|
uint16_t platformID = GetUSHORT();
|
||||||
WORD encodingID = GetWORD();
|
uint16_t encodingID = GetUSHORT();
|
||||||
WORD languageID = GetWORD();
|
uint16_t languageID = GetUSHORT();
|
||||||
WORD nameId = GetWORD();
|
uint16_t nameId = GetUSHORT();
|
||||||
WORD length = GetWORD();
|
uint16_t length = GetUSHORT();
|
||||||
WORD offset = GetWORD();
|
uint16_t offset = GetUSHORT();
|
||||||
|
|
||||||
if(nameId == 4) {
|
if(nameId == 4) {
|
||||||
displayNameOffset = offset;
|
displayNameOffset = offset;
|
||||||
|
@ -342,7 +348,7 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
fseek(fh, nameAddr+nameStringOffset+displayNameOffset, SEEK_SET);
|
fseek(fh, nameAddr+nameStringOffset+displayNameOffset, SEEK_SET);
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for(i = 0; i < displayNameLength; i++) {
|
for(i = 0; i < displayNameLength; i++) {
|
||||||
BYTE b = GetBYTE();
|
uint8_t b = GetBYTE();
|
||||||
if(b && c < ((int)sizeof(name.str) - 2)) {
|
if(b && c < ((int)sizeof(name.str) - 2)) {
|
||||||
name.str[c++] = b;
|
name.str[c++] = b;
|
||||||
}
|
}
|
||||||
|
@ -358,25 +364,25 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
// loca table, 16- or 32-bit entries
|
// loca table, 16- or 32-bit entries
|
||||||
fseek(fh, headAddr, SEEK_SET);
|
fseek(fh, headAddr, SEEK_SET);
|
||||||
|
|
||||||
DWORD headVersion = GetDWORD();
|
uint32_t headVersion = GetULONG();
|
||||||
DWORD headFontRevision = GetDWORD();
|
uint32_t headFontRevision = GetULONG();
|
||||||
DWORD headCheckSumAdj = GetDWORD();
|
uint32_t headCheckSumAdj = GetULONG();
|
||||||
DWORD headMagicNumber = GetDWORD();
|
uint32_t headMagicNumber = GetULONG();
|
||||||
WORD headFlags = GetWORD();
|
uint16_t headFlags = GetUSHORT();
|
||||||
WORD headUnitsPerEm = GetWORD();
|
uint16_t headUnitsPerEm = GetUSHORT();
|
||||||
(void)GetDWORD(); // created time
|
(void)GetULONG(); // created time
|
||||||
(void)GetDWORD();
|
(void)GetULONG();
|
||||||
(void)GetDWORD(); // modified time
|
(void)GetULONG(); // modified time
|
||||||
(void)GetDWORD();
|
(void)GetULONG();
|
||||||
WORD headXmin = GetWORD();
|
uint16_t headXmin = GetUSHORT();
|
||||||
WORD headYmin = GetWORD();
|
uint16_t headYmin = GetUSHORT();
|
||||||
WORD headXmax = GetWORD();
|
uint16_t headXmax = GetUSHORT();
|
||||||
WORD headYmax = GetWORD();
|
uint16_t headYmax = GetUSHORT();
|
||||||
WORD headMacStyle = GetWORD();
|
uint16_t headMacStyle = GetUSHORT();
|
||||||
WORD headLowestRecPPEM = GetWORD();
|
uint16_t headLowestRecPPEM = GetUSHORT();
|
||||||
WORD headFontDirectionHint = GetWORD();
|
uint16_t headFontDirectionHint = GetUSHORT();
|
||||||
WORD headIndexToLocFormat = GetWORD();
|
uint16_t headIndexToLocFormat = GetUSHORT();
|
||||||
WORD headGlyphDataFormat = GetWORD();
|
uint16_t headGlyphDataFormat = GetUSHORT();
|
||||||
|
|
||||||
if(headMagicNumber != 0x5F0F3CF5) {
|
if(headMagicNumber != 0x5F0F3CF5) {
|
||||||
throw "bad magic number";
|
throw "bad magic number";
|
||||||
|
@ -385,43 +391,43 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
// Load the hhea table, which contains the number of entries in the
|
// Load the hhea table, which contains the number of entries in the
|
||||||
// horizontal metrics (hmtx) table.
|
// horizontal metrics (hmtx) table.
|
||||||
fseek(fh, hheaAddr, SEEK_SET);
|
fseek(fh, hheaAddr, SEEK_SET);
|
||||||
DWORD hheaVersion = GetDWORD();
|
uint32_t hheaVersion = GetULONG();
|
||||||
WORD hheaAscender = GetWORD();
|
uint16_t hheaAscender = GetUSHORT();
|
||||||
WORD hheaDescender = GetWORD();
|
uint16_t hheaDescender = GetUSHORT();
|
||||||
WORD hheaLineGap = GetWORD();
|
uint16_t hheaLineGap = GetUSHORT();
|
||||||
WORD hheaAdvanceWidthMax = GetWORD();
|
uint16_t hheaAdvanceWidthMax = GetUSHORT();
|
||||||
WORD hheaMinLsb = GetWORD();
|
uint16_t hheaMinLsb = GetUSHORT();
|
||||||
WORD hheaMinRsb = GetWORD();
|
uint16_t hheaMinRsb = GetUSHORT();
|
||||||
WORD hheaXMaxExtent = GetWORD();
|
uint16_t hheaXMaxExtent = GetUSHORT();
|
||||||
WORD hheaCaretSlopeRise = GetWORD();
|
uint16_t hheaCaretSlopeRise = GetUSHORT();
|
||||||
WORD hheaCaretSlopeRun = GetWORD();
|
uint16_t hheaCaretSlopeRun = GetUSHORT();
|
||||||
WORD hheaCaretOffset = GetWORD();
|
uint16_t hheaCaretOffset = GetUSHORT();
|
||||||
(void)GetWORD();
|
(void)GetUSHORT();
|
||||||
(void)GetWORD();
|
(void)GetUSHORT();
|
||||||
(void)GetWORD();
|
(void)GetUSHORT();
|
||||||
(void)GetWORD();
|
(void)GetUSHORT();
|
||||||
WORD hheaMetricDataFormat = GetWORD();
|
uint16_t hheaMetricDataFormat = GetUSHORT();
|
||||||
WORD hheaNumberOfMetrics = GetWORD();
|
uint16_t hheaNumberOfMetrics = GetUSHORT();
|
||||||
|
|
||||||
// Load the maxp table, which determines (among other things) the number
|
// Load the maxp table, which determines (among other things) the number
|
||||||
// of glyphs in the font
|
// of glyphs in the font
|
||||||
fseek(fh, maxpAddr, SEEK_SET);
|
fseek(fh, maxpAddr, SEEK_SET);
|
||||||
|
|
||||||
DWORD maxpVersion = GetDWORD();
|
uint32_t maxpVersion = GetULONG();
|
||||||
WORD maxpNumGlyphs = GetWORD();
|
uint16_t maxpNumGlyphs = GetUSHORT();
|
||||||
WORD maxpMaxPoints = GetWORD();
|
uint16_t maxpMaxPoints = GetUSHORT();
|
||||||
WORD maxpMaxContours = GetWORD();
|
uint16_t maxpMaxContours = GetUSHORT();
|
||||||
WORD maxpMaxComponentPoints = GetWORD();
|
uint16_t maxpMaxComponentPoints = GetUSHORT();
|
||||||
WORD maxpMaxComponentContours = GetWORD();
|
uint16_t maxpMaxComponentContours = GetUSHORT();
|
||||||
WORD maxpMaxZones = GetWORD();
|
uint16_t maxpMaxZones = GetUSHORT();
|
||||||
WORD maxpMaxTwilightPoints = GetWORD();
|
uint16_t maxpMaxTwilightPoints = GetUSHORT();
|
||||||
WORD maxpMaxStorage = GetWORD();
|
uint16_t maxpMaxStorage = GetUSHORT();
|
||||||
WORD maxpMaxFunctionDefs = GetWORD();
|
uint16_t maxpMaxFunctionDefs = GetUSHORT();
|
||||||
WORD maxpMaxInstructionDefs = GetWORD();
|
uint16_t maxpMaxInstructionDefs = GetUSHORT();
|
||||||
WORD maxpMaxStackElements = GetWORD();
|
uint16_t maxpMaxStackElements = GetUSHORT();
|
||||||
WORD maxpMaxSizeOfInstructions = GetWORD();
|
uint16_t maxpMaxSizeOfInstructions = GetUSHORT();
|
||||||
WORD maxpMaxComponentElements = GetWORD();
|
uint16_t maxpMaxComponentElements = GetUSHORT();
|
||||||
WORD maxpMaxComponentDepth = GetWORD();
|
uint16_t maxpMaxComponentDepth = GetUSHORT();
|
||||||
|
|
||||||
glyphs = maxpNumGlyphs;
|
glyphs = maxpNumGlyphs;
|
||||||
glyph = (Glyph *)MemAlloc(glyphs*sizeof(glyph[0]));
|
glyph = (Glyph *)MemAlloc(glyphs*sizeof(glyph[0]));
|
||||||
|
@ -430,11 +436,11 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
// and advance width) of the font.
|
// and advance width) of the font.
|
||||||
fseek(fh, hmtxAddr, SEEK_SET);
|
fseek(fh, hmtxAddr, SEEK_SET);
|
||||||
|
|
||||||
WORD hmtxAdvanceWidth = 0;
|
uint16_t hmtxAdvanceWidth = 0;
|
||||||
SWORD hmtxLsb = 0;
|
int16_t hmtxLsb = 0;
|
||||||
for(i = 0; i < min(glyphs, hheaNumberOfMetrics); i++) {
|
for(i = 0; i < min(glyphs, hheaNumberOfMetrics); i++) {
|
||||||
hmtxAdvanceWidth = GetWORD();
|
hmtxAdvanceWidth = GetUSHORT();
|
||||||
hmtxLsb = (SWORD)GetWORD();
|
hmtxLsb = (int16_t)GetUSHORT();
|
||||||
|
|
||||||
glyph[i].leftSideBearing = hmtxLsb;
|
glyph[i].leftSideBearing = hmtxLsb;
|
||||||
glyph[i].advanceWidth = hmtxAdvanceWidth;
|
glyph[i].advanceWidth = hmtxAdvanceWidth;
|
||||||
|
@ -449,14 +455,14 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
// glyphs.
|
// glyphs.
|
||||||
fseek(fh, cmapAddr, SEEK_SET);
|
fseek(fh, cmapAddr, SEEK_SET);
|
||||||
|
|
||||||
DWORD usedTableAddr = (DWORD)-1;
|
uint32_t usedTableAddr = (uint32_t)-1;
|
||||||
|
|
||||||
WORD cmapVersion = GetWORD();
|
uint16_t cmapVersion = GetUSHORT();
|
||||||
WORD cmapTableCount = GetWORD();
|
uint16_t cmapTableCount = GetUSHORT();
|
||||||
for(i = 0; i < cmapTableCount; i++) {
|
for(i = 0; i < cmapTableCount; i++) {
|
||||||
WORD platformId = GetWORD();
|
uint16_t platformId = GetUSHORT();
|
||||||
WORD encodingId = GetWORD();
|
uint16_t encodingId = GetUSHORT();
|
||||||
DWORD offset = GetDWORD();
|
uint32_t offset = GetULONG();
|
||||||
|
|
||||||
if(platformId == 3 && encodingId == 1) {
|
if(platformId == 3 && encodingId == 1) {
|
||||||
// The Windows Unicode mapping is our preference
|
// The Windows Unicode mapping is our preference
|
||||||
|
@ -464,7 +470,7 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(usedTableAddr == (DWORD)-1) {
|
if(usedTableAddr == (uint32_t)-1) {
|
||||||
throw "no used table addr";
|
throw "no used table addr";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,13 +478,13 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
// which is us.
|
// which is us.
|
||||||
fseek(fh, usedTableAddr, SEEK_SET);
|
fseek(fh, usedTableAddr, SEEK_SET);
|
||||||
|
|
||||||
WORD mapFormat = GetWORD();
|
uint16_t mapFormat = GetUSHORT();
|
||||||
WORD mapLength = GetWORD();
|
uint16_t mapLength = GetUSHORT();
|
||||||
WORD mapVersion = GetWORD();
|
uint16_t mapVersion = GetUSHORT();
|
||||||
WORD mapSegCountX2 = GetWORD();
|
uint16_t mapSegCountX2 = GetUSHORT();
|
||||||
WORD mapSearchRange = GetWORD();
|
uint16_t mapSearchRange = GetUSHORT();
|
||||||
WORD mapEntrySelector = GetWORD();
|
uint16_t mapEntrySelector = GetUSHORT();
|
||||||
WORD mapRangeShift = GetWORD();
|
uint16_t mapRangeShift = GetUSHORT();
|
||||||
|
|
||||||
if(mapFormat != 4) {
|
if(mapFormat != 4) {
|
||||||
// Required to use format 4 per spec
|
// Required to use format 4 per spec
|
||||||
|
@ -486,26 +492,26 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int segCount = mapSegCountX2 / 2;
|
int segCount = mapSegCountX2 / 2;
|
||||||
WORD *endChar = (WORD *)AllocTemporary(segCount*sizeof(WORD));
|
uint16_t *endChar = (uint16_t *)AllocTemporary(segCount*sizeof(uint16_t));
|
||||||
WORD *startChar = (WORD *)AllocTemporary(segCount*sizeof(WORD));
|
uint16_t *startChar = (uint16_t *)AllocTemporary(segCount*sizeof(uint16_t));
|
||||||
WORD *idDelta = (WORD *)AllocTemporary(segCount*sizeof(WORD));
|
uint16_t *idDelta = (uint16_t *)AllocTemporary(segCount*sizeof(uint16_t));
|
||||||
WORD *idRangeOffset = (WORD *)AllocTemporary(segCount*sizeof(WORD));
|
uint16_t *idRangeOffset = (uint16_t *)AllocTemporary(segCount*sizeof(uint16_t));
|
||||||
|
|
||||||
DWORD *filePos = (DWORD *)AllocTemporary(segCount*sizeof(DWORD));
|
uint32_t *filePos = (uint32_t *)AllocTemporary(segCount*sizeof(uint32_t));
|
||||||
|
|
||||||
for(i = 0; i < segCount; i++) {
|
for(i = 0; i < segCount; i++) {
|
||||||
endChar[i] = GetWORD();
|
endChar[i] = GetUSHORT();
|
||||||
}
|
}
|
||||||
WORD mapReservedPad = GetWORD();
|
uint16_t mapReservedPad = GetUSHORT();
|
||||||
for(i = 0; i < segCount; i++) {
|
for(i = 0; i < segCount; i++) {
|
||||||
startChar[i] = GetWORD();
|
startChar[i] = GetUSHORT();
|
||||||
}
|
}
|
||||||
for(i = 0; i < segCount; i++) {
|
for(i = 0; i < segCount; i++) {
|
||||||
idDelta[i] = GetWORD();
|
idDelta[i] = GetUSHORT();
|
||||||
}
|
}
|
||||||
for(i = 0; i < segCount; i++) {
|
for(i = 0; i < segCount; i++) {
|
||||||
filePos[i] = (DWORD)ftell(fh);
|
filePos[i] = (uint32_t)ftell(fh);
|
||||||
idRangeOffset[i] = GetWORD();
|
idRangeOffset[i] = GetUSHORT();
|
||||||
}
|
}
|
||||||
|
|
||||||
// So first, null out the glyph table in our in-memory representation
|
// So first, null out the glyph table in our in-memory representation
|
||||||
|
@ -516,16 +522,16 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < segCount; i++) {
|
for(i = 0; i < segCount; i++) {
|
||||||
WORD v = idDelta[i];
|
uint16_t v = idDelta[i];
|
||||||
if(idRangeOffset[i] == 0) {
|
if(idRangeOffset[i] == 0) {
|
||||||
int j;
|
int j;
|
||||||
for(j = startChar[i]; j <= endChar[i]; j++) {
|
for(j = startChar[i]; j <= endChar[i]; j++) {
|
||||||
if(j > 0 && j < (int)arraylen(useGlyph)) {
|
if(j > 0 && j < (int)arraylen(useGlyph)) {
|
||||||
// Don't create a reference to a glyph that we won't
|
// Don't create a reference to a glyph that we won't
|
||||||
// store because it's bigger than the table.
|
// store because it's bigger than the table.
|
||||||
if((WORD)(j + v) < glyphs) {
|
if((uint16_t)(j + v) < glyphs) {
|
||||||
// Arithmetic is modulo 2^16
|
// Arithmetic is modulo 2^16
|
||||||
useGlyph[j] = (WORD)(j + v);
|
useGlyph[j] = (uint16_t)(j + v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,11 +540,11 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
for(j = startChar[i]; j <= endChar[i]; j++) {
|
for(j = startChar[i]; j <= endChar[i]; j++) {
|
||||||
if(j > 0 && j < (int)arraylen(useGlyph)) {
|
if(j > 0 && j < (int)arraylen(useGlyph)) {
|
||||||
int fp = filePos[i];
|
int fp = filePos[i];
|
||||||
fp += (j - startChar[i])*sizeof(WORD);
|
fp += (j - startChar[i])*sizeof(uint16_t);
|
||||||
fp += idRangeOffset[i];
|
fp += idRangeOffset[i];
|
||||||
fseek(fh, fp, SEEK_SET);
|
fseek(fh, fp, SEEK_SET);
|
||||||
|
|
||||||
useGlyph[j] = GetWORD();
|
useGlyph[j] = GetUSHORT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,15 +554,15 @@ bool TtfFont::LoadFontFromFile(bool nameOnly) {
|
||||||
// relative to the beginning of the glyf table.
|
// relative to the beginning of the glyf table.
|
||||||
fseek(fh, locaAddr, SEEK_SET);
|
fseek(fh, locaAddr, SEEK_SET);
|
||||||
|
|
||||||
DWORD *glyphOffsets = (DWORD *)AllocTemporary(glyphs*sizeof(DWORD));
|
uint32_t *glyphOffsets = (uint32_t *)AllocTemporary(glyphs*sizeof(uint32_t));
|
||||||
|
|
||||||
for(i = 0; i < glyphs; i++) {
|
for(i = 0; i < glyphs; i++) {
|
||||||
if(headIndexToLocFormat == 1) {
|
if(headIndexToLocFormat == 1) {
|
||||||
// long offsets, 32 bits
|
// long offsets, 32 bits
|
||||||
glyphOffsets[i] = GetDWORD();
|
glyphOffsets[i] = GetULONG();
|
||||||
} else if(headIndexToLocFormat == 0) {
|
} else if(headIndexToLocFormat == 0) {
|
||||||
// short offsets, 16 bits but divided by 2
|
// short offsets, 16 bits but divided by 2
|
||||||
glyphOffsets[i] = GetWORD()*2;
|
glyphOffsets[i] = GetUSHORT()*2;
|
||||||
} else {
|
} else {
|
||||||
throw "bad headIndexToLocFormat";
|
throw "bad headIndexToLocFormat";
|
||||||
}
|
}
|
||||||
|
|
158
ui.h
158
ui.h
|
@ -27,8 +27,8 @@ public:
|
||||||
#define GREENf(v) (GREEN(v) / 255.0f)
|
#define GREENf(v) (GREEN(v) / 255.0f)
|
||||||
#define BLUEf(v) (BLUE (v) / 255.0f)
|
#define BLUEf(v) (BLUE (v) / 255.0f)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char c;
|
char c;
|
||||||
int color;
|
uint32_t color;
|
||||||
} Color;
|
} Color;
|
||||||
static const Color fgColors[];
|
static const Color fgColors[];
|
||||||
static const Color bgColors[];
|
static const Color bgColors[];
|
||||||
|
@ -51,14 +51,14 @@ public:
|
||||||
int scrollPos; // The scrollbar position, in half-row units
|
int scrollPos; // The scrollbar position, in half-row units
|
||||||
int halfRows; // The height of our window, in half-row units
|
int halfRows; // The height of our window, in half-row units
|
||||||
|
|
||||||
BYTE text[MAX_ROWS][MAX_COLS];
|
uint8_t text[MAX_ROWS][MAX_COLS];
|
||||||
typedef void LinkFunction(int link, DWORD v);
|
typedef void LinkFunction(int link, uint32_t v);
|
||||||
enum { NOT_A_LINK = 0 };
|
enum { NOT_A_LINK = 0 };
|
||||||
struct {
|
struct {
|
||||||
char fg;
|
char fg;
|
||||||
int bg;
|
int bg;
|
||||||
int link;
|
int link;
|
||||||
DWORD data;
|
uint32_t data;
|
||||||
LinkFunction *f;
|
LinkFunction *f;
|
||||||
LinkFunction *h;
|
LinkFunction *h;
|
||||||
} meta[MAX_ROWS][MAX_COLS];
|
} meta[MAX_ROWS][MAX_COLS];
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
// The row of icons at the top of the text window, to hide/show things
|
// The row of icons at the top of the text window, to hide/show things
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool *var;
|
bool *var;
|
||||||
BYTE *icon;
|
uint8_t *icon;
|
||||||
const char *tip;
|
const char *tip;
|
||||||
} HideShowIcon;
|
} HideShowIcon;
|
||||||
static HideShowIcon hideShowIcons[];
|
static HideShowIcon hideShowIcons[];
|
||||||
|
@ -95,8 +95,8 @@ public:
|
||||||
HideShowIcon *hoveredIcon, *tooltippedIcon;
|
HideShowIcon *hoveredIcon, *tooltippedIcon;
|
||||||
|
|
||||||
Vector HsvToRgb(Vector hsv);
|
Vector HsvToRgb(Vector hsv);
|
||||||
BYTE *HsvPattern2d(void);
|
uint8_t *HsvPattern2d(void);
|
||||||
BYTE *HsvPattern1d(double h, double s);
|
uint8_t *HsvPattern1d(double h, double s);
|
||||||
void ColorPickerDone(void);
|
void ColorPickerDone(void);
|
||||||
bool DrawOrHitTestColorPicker(int how, bool leftDown, double x, double y);
|
bool DrawOrHitTestColorPicker(int how, bool leftDown, double x, double y);
|
||||||
|
|
||||||
|
@ -206,17 +206,17 @@ public:
|
||||||
int col;
|
int col;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
DWORD rgb;
|
uint32_t rgb;
|
||||||
double h, s, v;
|
double h, s, v;
|
||||||
bool show;
|
bool show;
|
||||||
bool picker1dActive;
|
bool picker1dActive;
|
||||||
bool picker2dActive;
|
bool picker2dActive;
|
||||||
} colorPicker;
|
} colorPicker;
|
||||||
} editControl;
|
} editControl;
|
||||||
|
|
||||||
void HideEditControl(void);
|
void HideEditControl(void);
|
||||||
void ShowEditControl(int halfRow, int col, char *s);
|
void ShowEditControl(int halfRow, int col, char *s);
|
||||||
void ShowEditControlWithColorPicker(int halfRow, int col, DWORD rgb);
|
void ShowEditControlWithColorPicker(int halfRow, int col, uint32_t rgb);
|
||||||
|
|
||||||
void ClearSuper(void);
|
void ClearSuper(void);
|
||||||
|
|
||||||
|
@ -240,82 +240,82 @@ public:
|
||||||
|
|
||||||
// All of these are callbacks from the GUI code; first from when
|
// All of these are callbacks from the GUI code; first from when
|
||||||
// we're describing an entity
|
// we're describing an entity
|
||||||
static void ScreenEditTtfText(int link, DWORD v);
|
static void ScreenEditTtfText(int link, uint32_t v);
|
||||||
static void ScreenSetTtfFont(int link, DWORD v);
|
static void ScreenSetTtfFont(int link, uint32_t v);
|
||||||
static void ScreenUnselectAll(int link, DWORD v);
|
static void ScreenUnselectAll(int link, uint32_t v);
|
||||||
|
|
||||||
// and the rest from the stuff in textscreens.cpp
|
// and the rest from the stuff in textscreens.cpp
|
||||||
static void ScreenSelectGroup(int link, DWORD v);
|
static void ScreenSelectGroup(int link, uint32_t v);
|
||||||
static void ScreenActivateGroup(int link, DWORD v);
|
static void ScreenActivateGroup(int link, uint32_t v);
|
||||||
static void ScreenToggleGroupShown(int link, DWORD v);
|
static void ScreenToggleGroupShown(int link, uint32_t v);
|
||||||
static void ScreenHowGroupSolved(int link, DWORD v);
|
static void ScreenHowGroupSolved(int link, uint32_t v);
|
||||||
static void ScreenShowGroupsSpecial(int link, DWORD v);
|
static void ScreenShowGroupsSpecial(int link, uint32_t v);
|
||||||
static void ScreenDeleteGroup(int link, DWORD v);
|
static void ScreenDeleteGroup(int link, uint32_t v);
|
||||||
|
|
||||||
static void ScreenHoverConstraint(int link, DWORD v);
|
static void ScreenHoverConstraint(int link, uint32_t v);
|
||||||
static void ScreenHoverRequest(int link, DWORD v);
|
static void ScreenHoverRequest(int link, uint32_t v);
|
||||||
static void ScreenSelectRequest(int link, DWORD v);
|
static void ScreenSelectRequest(int link, uint32_t v);
|
||||||
static void ScreenSelectConstraint(int link, DWORD v);
|
static void ScreenSelectConstraint(int link, uint32_t v);
|
||||||
|
|
||||||
static void ScreenChangeGroupOption(int link, DWORD v);
|
static void ScreenChangeGroupOption(int link, uint32_t v);
|
||||||
static void ScreenColor(int link, DWORD v);
|
static void ScreenColor(int link, uint32_t v);
|
||||||
|
|
||||||
static void ScreenShowListOfStyles(int link, DWORD v);
|
static void ScreenShowListOfStyles(int link, uint32_t v);
|
||||||
static void ScreenShowStyleInfo(int link, DWORD v);
|
static void ScreenShowStyleInfo(int link, uint32_t v);
|
||||||
static void ScreenDeleteStyle(int link, DWORD v);
|
static void ScreenDeleteStyle(int link, uint32_t v);
|
||||||
static void ScreenChangeStyleYesNo(int link, DWORD v);
|
static void ScreenChangeStyleYesNo(int link, uint32_t v);
|
||||||
static void ScreenCreateCustomStyle(int link, DWORD v);
|
static void ScreenCreateCustomStyle(int link, uint32_t v);
|
||||||
static void ScreenLoadFactoryDefaultStyles(int link, DWORD v);
|
static void ScreenLoadFactoryDefaultStyles(int link, uint32_t v);
|
||||||
static void ScreenAssignSelectionToStyle(int link, DWORD v);
|
static void ScreenAssignSelectionToStyle(int link, uint32_t v);
|
||||||
static void ScreenBackgroundImage(int link, DWORD v);
|
static void ScreenBackgroundImage(int link, uint32_t v);
|
||||||
|
|
||||||
static void ScreenShowConfiguration(int link, DWORD v);
|
static void ScreenShowConfiguration(int link, uint32_t v);
|
||||||
static void ScreenShowEditView(int link, DWORD v);
|
static void ScreenShowEditView(int link, uint32_t v);
|
||||||
static void ScreenGoToWebsite(int link, DWORD v);
|
static void ScreenGoToWebsite(int link, uint32_t v);
|
||||||
|
|
||||||
static void ScreenChangeFixExportColors(int link, DWORD v);
|
static void ScreenChangeFixExportColors(int link, uint32_t v);
|
||||||
static void ScreenChangeBackFaces(int link, DWORD v);
|
static void ScreenChangeBackFaces(int link, uint32_t v);
|
||||||
static void ScreenChangeCheckClosedContour(int link, DWORD v);
|
static void ScreenChangeCheckClosedContour(int link, uint32_t v);
|
||||||
static void ScreenChangePwlCurves(int link, DWORD v);
|
static void ScreenChangePwlCurves(int link, uint32_t v);
|
||||||
static void ScreenChangeCanvasSizeAuto(int link, DWORD v);
|
static void ScreenChangeCanvasSizeAuto(int link, uint32_t v);
|
||||||
static void ScreenChangeCanvasSize(int link, DWORD v);
|
static void ScreenChangeCanvasSize(int link, uint32_t v);
|
||||||
static void ScreenChangeShadedTriangles(int link, DWORD v);
|
static void ScreenChangeShadedTriangles(int link, uint32_t v);
|
||||||
|
|
||||||
static void ScreenStepDimSteps(int link, DWORD v);
|
static void ScreenStepDimSteps(int link, uint32_t v);
|
||||||
static void ScreenStepDimFinish(int link, DWORD v);
|
static void ScreenStepDimFinish(int link, uint32_t v);
|
||||||
static void ScreenStepDimGo(int link, DWORD v);
|
static void ScreenStepDimGo(int link, uint32_t v);
|
||||||
|
|
||||||
static void ScreenChangeTangentArc(int link, DWORD v);
|
static void ScreenChangeTangentArc(int link, uint32_t v);
|
||||||
|
|
||||||
static void ScreenPasteTransformed(int link, DWORD v);
|
static void ScreenPasteTransformed(int link, uint32_t v);
|
||||||
|
|
||||||
static void ScreenHome(int link, DWORD v);
|
static void ScreenHome(int link, uint32_t v);
|
||||||
|
|
||||||
// These ones do stuff with the edit control
|
// These ones do stuff with the edit control
|
||||||
static void ScreenChangeExprA(int link, DWORD v);
|
static void ScreenChangeExprA(int link, uint32_t v);
|
||||||
static void ScreenChangeGroupName(int link, DWORD v);
|
static void ScreenChangeGroupName(int link, uint32_t v);
|
||||||
static void ScreenChangeGroupScale(int link, DWORD v);
|
static void ScreenChangeGroupScale(int link, uint32_t v);
|
||||||
static void ScreenChangeLightDirection(int link, DWORD v);
|
static void ScreenChangeLightDirection(int link, uint32_t v);
|
||||||
static void ScreenChangeLightIntensity(int link, DWORD v);
|
static void ScreenChangeLightIntensity(int link, uint32_t v);
|
||||||
static void ScreenChangeColor(int link, DWORD v);
|
static void ScreenChangeColor(int link, uint32_t v);
|
||||||
static void ScreenChangeChordTolerance(int link, DWORD v);
|
static void ScreenChangeChordTolerance(int link, uint32_t v);
|
||||||
static void ScreenChangeMaxSegments(int link, DWORD v);
|
static void ScreenChangeMaxSegments(int link, uint32_t v);
|
||||||
static void ScreenChangeCameraTangent(int link, DWORD v);
|
static void ScreenChangeCameraTangent(int link, uint32_t v);
|
||||||
static void ScreenChangeGridSpacing(int link, DWORD v);
|
static void ScreenChangeGridSpacing(int link, uint32_t v);
|
||||||
static void ScreenChangeDigitsAfterDecimal(int link, DWORD v);
|
static void ScreenChangeDigitsAfterDecimal(int link, uint32_t v);
|
||||||
static void ScreenChangeExportScale(int link, DWORD v);
|
static void ScreenChangeExportScale(int link, uint32_t v);
|
||||||
static void ScreenChangeExportOffset(int link, DWORD v);
|
static void ScreenChangeExportOffset(int link, uint32_t v);
|
||||||
static void ScreenChangeGCodeParameter(int link, DWORD v);
|
static void ScreenChangeGCodeParameter(int link, uint32_t v);
|
||||||
static void ScreenChangeStyleName(int link, DWORD v);
|
static void ScreenChangeStyleName(int link, uint32_t v);
|
||||||
static void ScreenChangeStyleWidthOrTextHeight(int link, DWORD v);
|
static void ScreenChangeStyleWidthOrTextHeight(int link, uint32_t v);
|
||||||
static void ScreenChangeStyleTextAngle(int link, DWORD v);
|
static void ScreenChangeStyleTextAngle(int link, uint32_t v);
|
||||||
static void ScreenChangeStyleColor(int link, DWORD v);
|
static void ScreenChangeStyleColor(int link, uint32_t v);
|
||||||
static void ScreenChangeBackgroundColor(int link, DWORD v);
|
static void ScreenChangeBackgroundColor(int link, uint32_t v);
|
||||||
static void ScreenChangeBackgroundImageScale(int link, DWORD v);
|
static void ScreenChangeBackgroundImageScale(int link, uint32_t v);
|
||||||
static void ScreenChangePasteTransformed(int link, DWORD v);
|
static void ScreenChangePasteTransformed(int link, uint32_t v);
|
||||||
static void ScreenChangeViewScale(int link, DWORD v);
|
static void ScreenChangeViewScale(int link, uint32_t v);
|
||||||
static void ScreenChangeViewOrigin(int link, DWORD v);
|
static void ScreenChangeViewOrigin(int link, uint32_t v);
|
||||||
static void ScreenChangeViewProjection(int link, DWORD v);
|
static void ScreenChangeViewProjection(int link, uint32_t v);
|
||||||
|
|
||||||
bool EditControlDoneForStyles(const char *s);
|
bool EditControlDoneForStyles(const char *s);
|
||||||
bool EditControlDoneForConfiguration(const char *s);
|
bool EditControlDoneForConfiguration(const char *s);
|
||||||
|
@ -643,7 +643,7 @@ public:
|
||||||
CMNU_FIRST_STYLE = 0x40000000
|
CMNU_FIRST_STYLE = 0x40000000
|
||||||
};
|
};
|
||||||
void ContextMenuListStyles(void);
|
void ContextMenuListStyles(void);
|
||||||
SDWORD contextMenuCancelTime;
|
int32_t contextMenuCancelTime;
|
||||||
|
|
||||||
// The toolbar, in toolbar.cpp
|
// The toolbar, in toolbar.cpp
|
||||||
bool ToolbarDrawOrHitTest(int x, int y, bool paint, int *menu);
|
bool ToolbarDrawOrHitTest(int x, int y, bool paint, int *menu);
|
||||||
|
@ -690,7 +690,7 @@ public:
|
||||||
bool KeyDown(int c);
|
bool KeyDown(int c);
|
||||||
void EditControlDone(const char *s);
|
void EditControlDone(const char *s);
|
||||||
|
|
||||||
SDWORD lastSpaceNavigatorTime;
|
int32_t lastSpaceNavigatorTime;
|
||||||
hGroup lastSpaceNavigatorGroup;
|
hGroup lastSpaceNavigatorGroup;
|
||||||
void SpaceNavigatorMoved(double tx, double ty, double tz,
|
void SpaceNavigatorMoved(double tx, double ty, double tz,
|
||||||
double rx, double ry, double rz, bool shiftDown);
|
double rx, double ry, double rz, bool shiftDown);
|
||||||
|
|
6
view.cpp
6
view.cpp
|
@ -37,7 +37,7 @@ void TextWindow::ShowEditView(void) {
|
||||||
Printf(false, "configuration screen.");
|
Printf(false, "configuration screen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeViewScale(int link, DWORD v) {
|
void TextWindow::ScreenChangeViewScale(int link, uint32_t v) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
sprintf(buf, "%.3f", SS.GW.scale * SS.MmPerUnit());
|
sprintf(buf, "%.3f", SS.GW.scale * SS.MmPerUnit());
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ void TextWindow::ScreenChangeViewScale(int link, DWORD v) {
|
||||||
SS.TW.ShowEditControl(12, 3, buf);
|
SS.TW.ShowEditControl(12, 3, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeViewOrigin(int link, DWORD v) {
|
void TextWindow::ScreenChangeViewOrigin(int link, uint32_t v) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
sprintf(buf, "%s, %s, %s",
|
sprintf(buf, "%s, %s, %s",
|
||||||
SS.MmToString(-SS.GW.offset.x),
|
SS.MmToString(-SS.GW.offset.x),
|
||||||
|
@ -56,7 +56,7 @@ void TextWindow::ScreenChangeViewOrigin(int link, DWORD v) {
|
||||||
SS.TW.ShowEditControl(18, 3, buf);
|
SS.TW.ShowEditControl(18, 3, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWindow::ScreenChangeViewProjection(int link, DWORD v) {
|
void TextWindow::ScreenChangeViewProjection(int link, uint32_t v) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
sprintf(buf, "%.3f, %.3f, %.3f", CO(SS.GW.projRight));
|
sprintf(buf, "%.3f, %.3f, %.3f", CO(SS.GW.projRight));
|
||||||
SS.TW.edit.meaning = EDIT_VIEW_PROJ_RIGHT;
|
SS.TW.edit.meaning = EDIT_VIEW_PROJ_RIGHT;
|
||||||
|
|
|
@ -5,24 +5,18 @@
|
||||||
//
|
//
|
||||||
// Copyright 2008-2013 Jonathan Westhues.
|
// Copyright 2008-2013 Jonathan Westhues.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include <windows.h>
|
#include "solvespace.h"
|
||||||
|
#include <time.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
#include <gl/gl.h>
|
|
||||||
#include <gl/glu.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_SPACEWARE_INPUT
|
#ifdef HAVE_SPACEWARE_INPUT
|
||||||
# include <si/si.h>
|
# include <si/si.h>
|
||||||
# include <si/siapp.h>
|
# include <si/siapp.h>
|
||||||
|
# undef uint32_t // thanks but no thanks
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "solvespace.h"
|
|
||||||
|
|
||||||
#define FREEZE_SUBKEY "SolveSpace"
|
#define FREEZE_SUBKEY "SolveSpace"
|
||||||
#include "freeze.h"
|
#include "freeze.h"
|
||||||
|
|
||||||
|
@ -66,7 +60,7 @@ SiHdl SpaceNavigator = SI_NO_HANDLE;
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
HWND MessageWnd, OkButton;
|
HWND MessageWnd, OkButton;
|
||||||
BOOL MessageDone;
|
bool MessageDone;
|
||||||
const char *MessageString;
|
const char *MessageString;
|
||||||
|
|
||||||
static LRESULT CALLBACK MessageProc(HWND hwnd, UINT msg, WPARAM wParam,
|
static LRESULT CALLBACK MessageProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||||
|
@ -75,13 +69,13 @@ static LRESULT CALLBACK MessageProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
if((HWND)lParam == OkButton && wParam == BN_CLICKED) {
|
if((HWND)lParam == OkButton && wParam == BN_CLICKED) {
|
||||||
MessageDone = TRUE;
|
MessageDone = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
MessageDone = TRUE;
|
MessageDone = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_PAINT: {
|
case WM_PAINT: {
|
||||||
|
@ -130,10 +124,10 @@ HWND CreateWindowClient(DWORD exStyle, char *className, char *windowName,
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoMessageBox(const char *str, int rows, int cols, BOOL error)
|
void DoMessageBox(const char *str, int rows, int cols, bool error)
|
||||||
{
|
{
|
||||||
EnableWindow(GraphicsWnd, FALSE);
|
EnableWindow(GraphicsWnd, false);
|
||||||
EnableWindow(TextWnd, FALSE);
|
EnableWindow(TextWnd, false);
|
||||||
HWND h = GetForegroundWindow();
|
HWND h = GetForegroundWindow();
|
||||||
|
|
||||||
// Register the window class for our dialog.
|
// Register the window class for our dialog.
|
||||||
|
@ -168,14 +162,14 @@ void DoMessageBox(const char *str, int rows, int cols, BOOL error)
|
||||||
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
|
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
|
||||||
(width - 70)/2, rows*SS.TW.LINE_HEIGHT + 20,
|
(width - 70)/2, rows*SS.TW.LINE_HEIGHT + 20,
|
||||||
70, 25, MessageWnd, NULL, Instance, NULL);
|
70, 25, MessageWnd, NULL, Instance, NULL);
|
||||||
SendMessage(OkButton, WM_SETFONT, (WPARAM)FixedFont, TRUE);
|
SendMessage(OkButton, WM_SETFONT, (WPARAM)FixedFont, true);
|
||||||
|
|
||||||
ShowWindow(MessageWnd, TRUE);
|
ShowWindow(MessageWnd, true);
|
||||||
SetFocus(OkButton);
|
SetFocus(OkButton);
|
||||||
|
|
||||||
MSG msg;
|
MSG msg;
|
||||||
DWORD ret;
|
DWORD ret;
|
||||||
MessageDone = FALSE;
|
MessageDone = false;
|
||||||
while((ret = GetMessage(&msg, NULL, 0, 0)) != 0 && !MessageDone) {
|
while((ret = GetMessage(&msg, NULL, 0, 0)) != 0 && !MessageDone) {
|
||||||
if((msg.message == WM_KEYDOWN &&
|
if((msg.message == WM_KEYDOWN &&
|
||||||
(msg.wParam == VK_RETURN ||
|
(msg.wParam == VK_RETURN ||
|
||||||
|
@ -183,7 +177,7 @@ void DoMessageBox(const char *str, int rows, int cols, BOOL error)
|
||||||
(msg.message == WM_KEYUP &&
|
(msg.message == WM_KEYUP &&
|
||||||
(msg.wParam == VK_SPACE)))
|
(msg.wParam == VK_SPACE)))
|
||||||
{
|
{
|
||||||
MessageDone = TRUE;
|
MessageDone = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,8 +186,8 @@ void DoMessageBox(const char *str, int rows, int cols, BOOL error)
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageString = NULL;
|
MessageString = NULL;
|
||||||
EnableWindow(TextWnd, TRUE);
|
EnableWindow(TextWnd, true);
|
||||||
EnableWindow(GraphicsWnd, TRUE);
|
EnableWindow(GraphicsWnd, true);
|
||||||
SetForegroundWindow(GraphicsWnd);
|
SetForegroundWindow(GraphicsWnd);
|
||||||
DestroyWindow(MessageWnd);
|
DestroyWindow(MessageWnd);
|
||||||
}
|
}
|
||||||
|
@ -277,23 +271,29 @@ void ExitNow(void) {
|
||||||
void CnfFreezeString(const char *str, const char *name)
|
void CnfFreezeString(const char *str, const char *name)
|
||||||
{ FreezeStringF(str, FREEZE_SUBKEY, name); }
|
{ FreezeStringF(str, FREEZE_SUBKEY, name); }
|
||||||
|
|
||||||
void CnfFreezeDWORD(DWORD v, const char *name)
|
void CnfFreezeInt(uint32_t v, const char *name)
|
||||||
{ FreezeDWORDF(v, FREEZE_SUBKEY, name); }
|
{ FreezeDWORDF((DWORD)v, FREEZE_SUBKEY, name); }
|
||||||
|
|
||||||
void CnfFreezeFloat(float v, const char *name)
|
void CnfFreezeFloat(float v, const char *name)
|
||||||
{ FreezeDWORDF(*((DWORD *)&v), FREEZE_SUBKEY, name); }
|
{ FreezeDWORDF(*((DWORD *)&v), FREEZE_SUBKEY, name); }
|
||||||
|
|
||||||
|
void CnfFreezeBool(bool v, const char *name)
|
||||||
|
{ FreezeDWORDF((DWORD)v, FREEZE_SUBKEY, name); }
|
||||||
|
|
||||||
void CnfThawString(char *str, int maxLen, const char *name)
|
void CnfThawString(char *str, int maxLen, const char *name)
|
||||||
{ ThawStringF(str, maxLen, FREEZE_SUBKEY, name); }
|
{ ThawStringF(str, maxLen, FREEZE_SUBKEY, name); }
|
||||||
|
|
||||||
DWORD CnfThawDWORD(DWORD v, const char *name)
|
uint32_t CnfThawInt(uint32_t v, const char *name)
|
||||||
{ return ThawDWORDF(v, FREEZE_SUBKEY, name); }
|
{ return (uint32_t)ThawDWORDF((DWORD)v, FREEZE_SUBKEY, name); }
|
||||||
|
|
||||||
float CnfThawFloat(float v, const char *name) {
|
float CnfThawFloat(float v, const char *name) {
|
||||||
DWORD d = ThawDWORDF(*((DWORD *)&v), FREEZE_SUBKEY, name);
|
DWORD d = ThawDWORDF(*((DWORD *)&v), FREEZE_SUBKEY, name);
|
||||||
return *((float *)&d);
|
return *((float *)&d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CnfThawBool(bool v, const char *name)
|
||||||
|
{ return ThawDWORDF((DWORD)v, FREEZE_SUBKEY, name) ? true : false; }
|
||||||
|
|
||||||
void SetWindowTitle(const char *str) {
|
void SetWindowTitle(const char *str) {
|
||||||
SetWindowText(GraphicsWnd, str);
|
SetWindowText(GraphicsWnd, str);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ void MoveTextScrollbarTo(int pos, int maxPos, int page)
|
||||||
si.nMax = maxPos;
|
si.nMax = maxPos;
|
||||||
si.nPos = pos;
|
si.nPos = pos;
|
||||||
si.nPage = page;
|
si.nPage = page;
|
||||||
SetScrollInfo(TextWndScrollBar, SB_CTL, &si, TRUE);
|
SetScrollInfo(TextWndScrollBar, SB_CTL, &si, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleTextWindowScrollBar(WPARAM wParam, LPARAM lParam)
|
void HandleTextWindowScrollBar(WPARAM wParam, LPARAM lParam)
|
||||||
|
@ -479,11 +479,11 @@ LRESULT CALLBACK TextWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
int sw = r.right - r.left;
|
int sw = r.right - r.left;
|
||||||
GetClientRect(hwnd, &r);
|
GetClientRect(hwnd, &r);
|
||||||
MoveWindow(TextWndScrollBar, r.right - sw, r.top, sw,
|
MoveWindow(TextWndScrollBar, r.right - sw, r.top, sw,
|
||||||
(r.bottom - r.top), TRUE);
|
(r.bottom - r.top), true);
|
||||||
// If the window is growing, then the scrollbar position may
|
// If the window is growing, then the scrollbar position may
|
||||||
// be moving, so it's as if we're dragging the scrollbar.
|
// be moving, so it's as if we're dragging the scrollbar.
|
||||||
HandleTextWindowScrollBar((WPARAM)-1, -1);
|
HandleTextWindowScrollBar((WPARAM)-1, -1);
|
||||||
InvalidateRect(TextWnd, NULL, FALSE);
|
InvalidateRect(TextWnd, NULL, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ LRESULT CALLBACK TextWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL ProcessKeyDown(WPARAM wParam)
|
static bool ProcessKeyDown(WPARAM wParam)
|
||||||
{
|
{
|
||||||
if(GraphicsEditControlIsVisible() && wParam != VK_ESCAPE) {
|
if(GraphicsEditControlIsVisible() && wParam != VK_ESCAPE) {
|
||||||
if(wParam == VK_RETURN) {
|
if(wParam == VK_RETURN) {
|
||||||
|
@ -510,9 +510,9 @@ static BOOL ProcessKeyDown(WPARAM wParam)
|
||||||
memset(s, 0, sizeof(s));
|
memset(s, 0, sizeof(s));
|
||||||
SendMessage(GraphicsEditControl, WM_GETTEXT, 900, (LPARAM)s);
|
SendMessage(GraphicsEditControl, WM_GETTEXT, 900, (LPARAM)s);
|
||||||
SS.GW.EditControlDone(s);
|
SS.GW.EditControlDone(s);
|
||||||
return TRUE;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(TextEditControlIsVisible() && wParam != VK_ESCAPE) {
|
if(TextEditControlIsVisible() && wParam != VK_ESCAPE) {
|
||||||
|
@ -522,7 +522,7 @@ static BOOL ProcessKeyDown(WPARAM wParam)
|
||||||
SendMessage(TextEditControl, WM_GETTEXT, 900, (LPARAM)s);
|
SendMessage(TextEditControl, WM_GETTEXT, 900, (LPARAM)s);
|
||||||
SS.TW.EditControlDone(s);
|
SS.TW.EditControlDone(s);
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ static BOOL ProcessKeyDown(WPARAM wParam)
|
||||||
case VK_EXECUTE:
|
case VK_EXECUTE:
|
||||||
case VK_APPS:
|
case VK_APPS:
|
||||||
case VK_LWIN:
|
case VK_LWIN:
|
||||||
case VK_RWIN: return FALSE;
|
case VK_RWIN: return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
c = (int)wParam;
|
c = (int)wParam;
|
||||||
|
@ -584,13 +584,13 @@ static BOOL ProcessKeyDown(WPARAM wParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SS.GW.KeyDown(c)) return TRUE;
|
if(SS.GW.KeyDown(c)) return true;
|
||||||
|
|
||||||
// No accelerator; process the key as normal.
|
// No accelerator; process the key as normal.
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowTextWindow(BOOL visible)
|
void ShowTextWindow(bool visible)
|
||||||
{
|
{
|
||||||
ShowWindow(TextWnd, visible ? SW_SHOWNOACTIVATE : SW_HIDE);
|
ShowWindow(TextWnd, visible ? SW_SHOWNOACTIVATE : SW_HIDE);
|
||||||
}
|
}
|
||||||
|
@ -630,32 +630,32 @@ void PaintGraphics(void)
|
||||||
}
|
}
|
||||||
void InvalidateGraphics(void)
|
void InvalidateGraphics(void)
|
||||||
{
|
{
|
||||||
InvalidateRect(GraphicsWnd, NULL, FALSE);
|
InvalidateRect(GraphicsWnd, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDWORD GetMilliseconds(void)
|
int32_t GetMilliseconds(void)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER t, f;
|
LARGE_INTEGER t, f;
|
||||||
QueryPerformanceCounter(&t);
|
QueryPerformanceCounter(&t);
|
||||||
QueryPerformanceFrequency(&f);
|
QueryPerformanceFrequency(&f);
|
||||||
LONGLONG d = t.QuadPart/(f.QuadPart/1000);
|
LONGLONG d = t.QuadPart/(f.QuadPart/1000);
|
||||||
return (SDWORD)d;
|
return (int32_t)d;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQWORD GetUnixTime(void)
|
int64_t GetUnixTime(void)
|
||||||
{
|
{
|
||||||
__time64_t ret;
|
__time64_t ret;
|
||||||
_time64(&ret);
|
_time64(&ret);
|
||||||
return ret;
|
return (int64_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InvalidateText(void)
|
void InvalidateText(void)
|
||||||
{
|
{
|
||||||
InvalidateRect(TextWnd, NULL, FALSE);
|
InvalidateRect(TextWnd, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowEditControl(HWND h, int x, int y, char *s) {
|
static void ShowEditControl(HWND h, int x, int y, char *s) {
|
||||||
MoveWindow(h, x, y, EDIT_WIDTH, EDIT_HEIGHT, TRUE);
|
MoveWindow(h, x, y, EDIT_WIDTH, EDIT_HEIGHT, true);
|
||||||
ShowWindow(h, SW_SHOW);
|
ShowWindow(h, SW_SHOW);
|
||||||
if(s) {
|
if(s) {
|
||||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
||||||
|
@ -673,9 +673,9 @@ void HideTextEditControl(void)
|
||||||
{
|
{
|
||||||
ShowWindow(TextEditControl, SW_HIDE);
|
ShowWindow(TextEditControl, SW_HIDE);
|
||||||
}
|
}
|
||||||
BOOL TextEditControlIsVisible(void)
|
bool TextEditControlIsVisible(void)
|
||||||
{
|
{
|
||||||
return IsWindowVisible(TextEditControl);
|
return IsWindowVisible(TextEditControl) ? true : false;
|
||||||
}
|
}
|
||||||
void ShowGraphicsEditControl(int x, int y, char *s)
|
void ShowGraphicsEditControl(int x, int y, char *s)
|
||||||
{
|
{
|
||||||
|
@ -696,9 +696,9 @@ void HideGraphicsEditControl(void)
|
||||||
{
|
{
|
||||||
ShowWindow(GraphicsEditControl, SW_HIDE);
|
ShowWindow(GraphicsEditControl, SW_HIDE);
|
||||||
}
|
}
|
||||||
BOOL GraphicsEditControlIsVisible(void)
|
bool GraphicsEditControlIsVisible(void)
|
||||||
{
|
{
|
||||||
return IsWindowVisible(GraphicsEditControl);
|
return IsWindowVisible(GraphicsEditControl) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK GraphicsWndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
LRESULT CALLBACK GraphicsWndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||||
|
@ -709,7 +709,7 @@ LRESULT CALLBACK GraphicsWndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
InvalidateRect(GraphicsWnd, NULL, FALSE);
|
InvalidateRect(GraphicsWnd, NULL, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_PAINT: {
|
case WM_PAINT: {
|
||||||
|
@ -817,7 +817,7 @@ LRESULT CALLBACK GraphicsWndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Common dialog routines, to open or save a file.
|
// Common dialog routines, to open or save a file.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
BOOL GetOpenFile(char *file, const char *defExtension, const char *selPattern)
|
bool GetOpenFile(char *file, const char *defExtension, const char *selPattern)
|
||||||
{
|
{
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
|
|
||||||
|
@ -831,18 +831,18 @@ BOOL GetOpenFile(char *file, const char *defExtension, const char *selPattern)
|
||||||
ofn.nMaxFile = MAX_PATH;
|
ofn.nMaxFile = MAX_PATH;
|
||||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
|
||||||
|
|
||||||
EnableWindow(GraphicsWnd, FALSE);
|
EnableWindow(GraphicsWnd, false);
|
||||||
EnableWindow(TextWnd, FALSE);
|
EnableWindow(TextWnd, false);
|
||||||
|
|
||||||
BOOL r = GetOpenFileName(&ofn);
|
BOOL r = GetOpenFileName(&ofn);
|
||||||
|
|
||||||
EnableWindow(TextWnd, TRUE);
|
EnableWindow(TextWnd, true);
|
||||||
EnableWindow(GraphicsWnd, TRUE);
|
EnableWindow(GraphicsWnd, true);
|
||||||
SetForegroundWindow(GraphicsWnd);
|
SetForegroundWindow(GraphicsWnd);
|
||||||
|
|
||||||
return r;
|
return r ? true : false;
|
||||||
}
|
}
|
||||||
BOOL GetSaveFile(char *file, const char *defExtension, const char *selPattern)
|
bool GetSaveFile(char *file, const char *defExtension, const char *selPattern)
|
||||||
{
|
{
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
|
|
||||||
|
@ -856,29 +856,29 @@ BOOL GetSaveFile(char *file, const char *defExtension, const char *selPattern)
|
||||||
ofn.nMaxFile = MAX_PATH;
|
ofn.nMaxFile = MAX_PATH;
|
||||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
|
||||||
|
|
||||||
EnableWindow(GraphicsWnd, FALSE);
|
EnableWindow(GraphicsWnd, false);
|
||||||
EnableWindow(TextWnd, FALSE);
|
EnableWindow(TextWnd, false);
|
||||||
|
|
||||||
BOOL r = GetSaveFileName(&ofn);
|
BOOL r = GetSaveFileName(&ofn);
|
||||||
|
|
||||||
EnableWindow(TextWnd, TRUE);
|
EnableWindow(TextWnd, true);
|
||||||
EnableWindow(GraphicsWnd, TRUE);
|
EnableWindow(GraphicsWnd, true);
|
||||||
SetForegroundWindow(GraphicsWnd);
|
SetForegroundWindow(GraphicsWnd);
|
||||||
|
|
||||||
return r;
|
return r ? true : false;
|
||||||
}
|
}
|
||||||
int SaveFileYesNoCancel(void)
|
int SaveFileYesNoCancel(void)
|
||||||
{
|
{
|
||||||
EnableWindow(GraphicsWnd, FALSE);
|
EnableWindow(GraphicsWnd, false);
|
||||||
EnableWindow(TextWnd, FALSE);
|
EnableWindow(TextWnd, false);
|
||||||
|
|
||||||
int r = MessageBox(GraphicsWnd,
|
int r = MessageBox(GraphicsWnd,
|
||||||
"The program has changed since it was last saved.\r\n\r\n"
|
"The program has changed since it was last saved.\r\n\r\n"
|
||||||
"Do you want to save the changes?", "SolveSpace",
|
"Do you want to save the changes?", "SolveSpace",
|
||||||
MB_YESNOCANCEL | MB_ICONWARNING);
|
MB_YESNOCANCEL | MB_ICONWARNING);
|
||||||
|
|
||||||
EnableWindow(TextWnd, TRUE);
|
EnableWindow(TextWnd, true);
|
||||||
EnableWindow(GraphicsWnd, TRUE);
|
EnableWindow(GraphicsWnd, true);
|
||||||
SetForegroundWindow(GraphicsWnd);
|
SetForegroundWindow(GraphicsWnd);
|
||||||
|
|
||||||
switch(r) {
|
switch(r) {
|
||||||
|
@ -916,7 +916,7 @@ void LoadAllFontFiles(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MenuById(int id, BOOL yes, BOOL check)
|
static void MenuById(int id, bool yes, bool check)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int subMenu = -1;
|
int subMenu = -1;
|
||||||
|
@ -940,18 +940,18 @@ static void MenuById(int id, BOOL yes, BOOL check)
|
||||||
}
|
}
|
||||||
oops();
|
oops();
|
||||||
}
|
}
|
||||||
void CheckMenuById(int id, BOOL checked)
|
void CheckMenuById(int id, bool checked)
|
||||||
{
|
{
|
||||||
MenuById(id, checked, TRUE);
|
MenuById(id, checked, true);
|
||||||
}
|
}
|
||||||
void RadioMenuById(int id, BOOL selected)
|
void RadioMenuById(int id, bool selected)
|
||||||
{
|
{
|
||||||
// Windows does not natively support radio-button menu items
|
// Windows does not natively support radio-button menu items
|
||||||
MenuById(id, selected, TRUE);
|
MenuById(id, selected, true);
|
||||||
}
|
}
|
||||||
void EnableMenuById(int id, BOOL enabled)
|
void EnableMenuById(int id, bool enabled)
|
||||||
{
|
{
|
||||||
MenuById(id, enabled, FALSE);
|
MenuById(id, enabled, false);
|
||||||
}
|
}
|
||||||
static void DoRecent(HMENU m, int base)
|
static void DoRecent(HMENU m, int base)
|
||||||
{
|
{
|
||||||
|
@ -1050,7 +1050,7 @@ static void CreateMainWindows(void)
|
||||||
GraphicsEditControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
|
GraphicsEditControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
|
||||||
WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS,
|
WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS,
|
||||||
50, 50, 100, 21, GraphicsWnd, NULL, Instance, NULL);
|
50, 50, 100, 21, GraphicsWnd, NULL, Instance, NULL);
|
||||||
SendMessage(GraphicsEditControl, WM_SETFONT, (WPARAM)FixedFont, TRUE);
|
SendMessage(GraphicsEditControl, WM_SETFONT, (WPARAM)FixedFont, true);
|
||||||
|
|
||||||
// The text window, with a comand line and some textual information
|
// The text window, with a comand line and some textual information
|
||||||
// about the sketch.
|
// about the sketch.
|
||||||
|
@ -1077,7 +1077,7 @@ static void CreateMainWindows(void)
|
||||||
TextEditControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
|
TextEditControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
|
||||||
WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS,
|
WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS,
|
||||||
50, 50, 100, 21, TextWnd, NULL, Instance, NULL);
|
50, 50, 100, 21, TextWnd, NULL, Instance, NULL);
|
||||||
SendMessage(TextEditControl, WM_SETFONT, (WPARAM)FixedFont, TRUE);
|
SendMessage(TextEditControl, WM_SETFONT, (WPARAM)FixedFont, true);
|
||||||
|
|
||||||
// Now that all our windows exist, set up gl contexts.
|
// Now that all our windows exist, set up gl contexts.
|
||||||
CreateGlContext(TextWnd, &TextGl);
|
CreateGlContext(TextWnd, &TextGl);
|
||||||
|
@ -1092,17 +1092,17 @@ static void CreateMainWindows(void)
|
||||||
#ifdef HAVE_SPACEWARE_INPUT
|
#ifdef HAVE_SPACEWARE_INPUT
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Test if a message comes from the SpaceNavigator device. If yes, dispatch
|
// Test if a message comes from the SpaceNavigator device. If yes, dispatch
|
||||||
// it appropriately and return TRUE. Otherwise, do nothing and return FALSE.
|
// it appropriately and return true. Otherwise, do nothing and return false.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static BOOL ProcessSpaceNavigatorMsg(MSG *msg) {
|
static bool ProcessSpaceNavigatorMsg(MSG *msg) {
|
||||||
if(SpaceNavigator == SI_NO_HANDLE) return FALSE;
|
if(SpaceNavigator == SI_NO_HANDLE) return false;
|
||||||
|
|
||||||
SiGetEventData sged;
|
SiGetEventData sged;
|
||||||
SiSpwEvent sse;
|
SiSpwEvent sse;
|
||||||
|
|
||||||
SiGetEventWinInit(&sged, msg->message, msg->wParam, msg->lParam);
|
SiGetEventWinInit(&sged, msg->message, msg->wParam, msg->lParam);
|
||||||
int ret = SiGetEvent(SpaceNavigator, 0, &sged, &sse);
|
int ret = SiGetEvent(SpaceNavigator, 0, &sged, &sse);
|
||||||
if(ret == SI_NOT_EVENT) return FALSE;
|
if(ret == SI_NOT_EVENT) return false;
|
||||||
// So the device is a SpaceNavigator event, or a SpaceNavigator error.
|
// So the device is a SpaceNavigator event, or a SpaceNavigator error.
|
||||||
|
|
||||||
if(ret == SI_IS_EVENT) {
|
if(ret == SI_IS_EVENT) {
|
||||||
|
@ -1123,7 +1123,7 @@ static BOOL ProcessSpaceNavigatorMsg(MSG *msg) {
|
||||||
if(button == SI_APP_FIT_BUTTON) SS.GW.SpaceNavigatorButtonUp();
|
if(button == SI_APP_FIT_BUTTON) SS.GW.SpaceNavigatorButtonUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // HAVE_SPACEWARE_INPUT
|
#endif // HAVE_SPACEWARE_INPUT
|
||||||
|
|
||||||
|
@ -1139,8 +1139,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
|
|
||||||
// A monospaced font
|
// A monospaced font
|
||||||
FixedFont = CreateFont(SS.TW.CHAR_HEIGHT, SS.TW.CHAR_WIDTH, 0, 0,
|
FixedFont = CreateFont(SS.TW.CHAR_HEIGHT, SS.TW.CHAR_WIDTH, 0, 0,
|
||||||
FW_REGULAR, FALSE,
|
FW_REGULAR, false,
|
||||||
FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||||
DEFAULT_QUALITY, FF_DONTCARE, "Lucida Console");
|
DEFAULT_QUALITY, FF_DONTCARE, "Lucida Console");
|
||||||
if(!FixedFont)
|
if(!FixedFont)
|
||||||
FixedFont = (HFONT)GetStockObject(SYSTEM_FONT);
|
FixedFont = (HFONT)GetStockObject(SYSTEM_FONT);
|
||||||
|
|
Loading…
Reference in New Issue