Skip to content

Commit ea8b29f

Browse files
author
Travis Cobbs
committed
Fix RCDATA resources to work in Win9x.
1 parent 852ab19 commit ea8b29f

14 files changed

+398
-79
lines changed

CUI/CUIWindow.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -2611,13 +2611,14 @@ void CUIWindow::setMenuCheck(
26112611
bool radio)
26122612
{
26132613
MENUITEMINFO itemInfo;
2614-
char title[256];
2614+
//char title[256];
26152615

26162616
memset(&itemInfo, 0, sizeof(MENUITEMINFO));
26172617
itemInfo.cbSize = sizeof(MENUITEMINFO);
2618-
itemInfo.fMask = MIIM_STATE | MIIM_TYPE;
2619-
itemInfo.dwTypeData = title;
2620-
itemInfo.cch = 256;
2618+
itemInfo.fMask = MIIM_STATE;// | MIIM_TYPE;
2619+
//itemInfo.fType = MFT_STRING;
2620+
//itemInfo.dwTypeData = title;
2621+
//itemInfo.cch = 256;
26212622
GetMenuItemInfo(hParentMenu, uItem, FALSE, &itemInfo);
26222623
if (checked)
26232624
{

ChangeHistory.html

+7
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ <h2>Change history</h2>
8989
<b>Additions</b>
9090
<ul>
9191
<li>Added ability to randomize colors (useful for part authoring).</li>
92+
<li>Added toolbar customization, along with the ability to put a lot of LDView
93+
functionality on the toolbar.</li>
94+
</ul>
95+
<b>Updates</b>
96+
<ul>
97+
<li>Removed BFC and Show Axes from the default toolbar.</li>
98+
<li>Updated examine/fly-through status bar icons.</li>
9299
</ul>
93100
<b>Bug Fixes</b>
94101
<ul>

Icons/toolbar_zoom2fit.png

-30 Bytes
Loading

LDView.rc

+17-14
Original file line numberDiff line numberDiff line change
@@ -1700,8 +1700,8 @@ IDB_ERROR_LOOP_MASK BITMAP DISCARDABLE "icons\\error_loop_mask.bmp"
17001700
//
17011701

17021702
VS_VERSION_INFO VERSIONINFO
1703-
FILEVERSION 4,0,1,6
1704-
PRODUCTVERSION 4,0,1,6
1703+
FILEVERSION 4,0,1,7
1704+
PRODUCTVERSION 4,0,1,7
17051705
FILEFLAGSMASK 0x3fL
17061706
#ifdef _DEBUG
17071707
FILEFLAGS 0x9L
@@ -1719,14 +1719,14 @@ BEGIN
17191719
VALUE "Comments", "3D Lego Model Viewer for models in LDraw format.\0"
17201720
VALUE "CompanyName", "\0"
17211721
VALUE "FileDescription", "LDView\0"
1722-
VALUE "FileVersion", "4.0.1f test build\0"
1722+
VALUE "FileVersion", "4.0.1g test build\0"
17231723
VALUE "InternalName", "LDView\0"
17241724
VALUE "LegalCopyright", "Copyright � 2009 Travis Cobbs & Peter Bartfai\0"
17251725
VALUE "LegalTrademarks", "\0"
17261726
VALUE "OriginalFilename", "LDView.exe\0"
17271727
VALUE "PrivateBuild", "\0"
17281728
VALUE "ProductName", "LDView\0"
1729-
VALUE "ProductVersion", "4.0.1f test build\0"
1729+
VALUE "ProductVersion", "4.0.1g test build\0"
17301730
VALUE "SpecialBuild", "\0"
17311731
END
17321732
END
@@ -1754,27 +1754,30 @@ IDC_SHOW_AXES RCDATA DISCARDABLE "Icons\\toolbar_axes.png"
17541754
IDC_BFC RCDATA DISCARDABLE "Icons\\toolbar_bfc.png"
17551755
IDC_CONDITIONAL_CONTROLS RCDATA DISCARDABLE "Icons\\toolbar_cond_ctrl.png"
17561756
IDC_HIGHLIGHTS RCDATA DISCARDABLE "Icons\\toolbar_edge.png"
1757-
ID_TOOLS_ERRORS RCDATA DISCARDABLE "Icons\\toolbar_errors.png"
1757+
IDR_TB_ERRORS RCDATA DISCARDABLE "Icons\\toolbar_errors.png"
1758+
IDR_TB_EXAMINE RCDATA DISCARDABLE "Icons\\toolbar_examine.png"
17581759
IDC_FLAT_SHADING RCDATA DISCARDABLE "Icons\\toolbar_flat.png"
1759-
ID_VIEW_FULLSCREEN RCDATA DISCARDABLE "Icons\\toolbar_fullscreen.png"
1760+
IDR_TB_FLYTHROUGH RCDATA DISCARDABLE "Icons\\toolbar_fly.png"
1761+
IDR_TB_FULLSCREEN RCDATA DISCARDABLE "Icons\\toolbar_fullscreen.png"
17601762
IDC_LIGHTING RCDATA DISCARDABLE "Icons\\toolbar_light.png"
17611763
IDC_STUD_QUALITY RCDATA DISCARDABLE "Icons\\toolbar_low_studs.png"
1762-
ID_FILE_OPEN RCDATA DISCARDABLE "Icons\\toolbar_open.png"
1764+
IDR_TB_OPEN RCDATA DISCARDABLE "Icons\\toolbar_open.png"
17631765
IDC_PART_BOUNDING_BOXES RCDATA DISCARDABLE "Icons\\toolbar_part_bbox.png"
1764-
ID_EDIT_PREFERENCES RCDATA DISCARDABLE "Icons\\toolbar_preferences.png"
1766+
IDR_TB_PREFERENCES RCDATA DISCARDABLE "Icons\\toolbar_preferences.png"
17651767
IDC_PRIMITIVE_SUBSTITUTION RCDATA DISCARDABLE "Icons\\toolbar_primsubs.png"
17661768
IDC_RANDOM_COLORS RCDATA DISCARDABLE "Icons\\toolbar_random.png"
1767-
ID_FILE_RELOAD RCDATA DISCARDABLE "Icons\\toolbar_reload.png"
1769+
IDR_TB_RELOAD RCDATA DISCARDABLE "Icons\\toolbar_reload.png"
17681770
IDC_SEAMS RCDATA DISCARDABLE "Icons\\toolbar_seams.png"
17691771
IDC_SMOOTH_CURVES RCDATA DISCARDABLE "Icons\\toolbar_smooth.png"
1770-
ID_FILE_SAVE RCDATA DISCARDABLE "Icons\\toolbar_snapshot.png"
1772+
IDR_TB_SAVE RCDATA DISCARDABLE "Icons\\toolbar_snapshot.png"
17711773
IDC_TRANS_DEFAULT_COLOR RCDATA DISCARDABLE "Icons\\toolbar_trans_default.png"
17721774
ID_VIEWANGLE RCDATA DISCARDABLE "Icons\\toolbar_view.png"
17731775
IDC_WIREFRAME RCDATA DISCARDABLE "Icons\\toolbar_wireframe.png"
1774-
ID_FIRST_STEP RCDATA DISCARDABLE "Icons\\toolbar_step_first.png"
1775-
ID_LAST_STEP RCDATA DISCARDABLE "Icons\\toolbar_step_last.png"
1776-
ID_NEXT_STEP RCDATA DISCARDABLE "Icons\\toolbar_step_next.png"
1777-
ID_PREV_STEP RCDATA DISCARDABLE "Icons\\toolbar_step_prev.png"
1776+
IDR_TB_ZOOMTOFIT RCDATA DISCARDABLE "Icons\\toolbar_zoom2fit.png"
1777+
IDR_TB_FIRST_STEP RCDATA DISCARDABLE "Icons\\toolbar_step_first.png"
1778+
IDR_TB_LAST_STEP RCDATA DISCARDABLE "Icons\\toolbar_step_last.png"
1779+
IDR_TB_NEXT_STEP RCDATA DISCARDABLE "Icons\\toolbar_step_next.png"
1780+
IDR_TB_PREV_STEP RCDATA DISCARDABLE "Icons\\toolbar_step_prev.png"
17781781

17791782
/////////////////////////////////////////////////////////////////////////////
17801783
//

LDViewMessages.ini

+2
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,8 @@ PrevStep =Previous Step
611611
NextStep =Next Step
612612
Errors&Warnings =Errors and Warnings
613613
FullScreen =Full Screen
614+
ZoomToFit =Zoom to Fit
615+
ViewMode =View Mode
614616
ShowAllConditionals =Show All Conditional Lines
615617
ShowConditionalControls =Show Conditional Control Points
616618
FlatShading =Flat Shading

LDViewWindow.cpp

+20-7
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,13 @@ mpdDialog(NULL)
187187
extraSearchDirs = new TCStringArray;
188188
populateExtraSearchDirs();
189189
}
190-
hExamineIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_EXAMINE),
191-
IMAGE_ICON, 32, 16, LR_DEFAULTCOLOR);
192-
hFlythroughIcon = (HICON)LoadImage(hInstance,
193-
MAKEINTRESOURCE(IDI_FLYTHROUGH), IMAGE_ICON, 32, 16, LR_DEFAULTCOLOR);
190+
hExamineIcon = TCImage::loadIconFromPngResource(hInstance, IDR_TB_EXAMINE);
191+
hFlythroughIcon = TCImage::loadIconFromPngResource(hInstance,
192+
IDR_TB_FLYTHROUGH);
193+
//hExamineIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_EXAMINE),
194+
// IMAGE_ICON, 32, 16, LR_DEFAULTCOLOR);
195+
//hFlythroughIcon = (HICON)LoadImage(hInstance,
196+
// MAKEINTRESOURCE(IDI_FLYTHROUGH), IMAGE_ICON, 32, 16, LR_DEFAULTCOLOR);
194197
TCAlertManager::registerHandler(TCProgressAlert::alertClass(), this,
195198
(TCAlertCallback)&LDViewWindow::progressAlertCallback);
196199
char userAgent[256];
@@ -210,6 +213,8 @@ LDViewWindow::~LDViewWindow(void)
210213

211214
void LDViewWindow::dealloc(void)
212215
{
216+
DestroyIcon(hExamineIcon);
217+
DestroyIcon(hFlythroughIcon);
213218
TCAlertManager::unregisterHandler(this);
214219
TCObject::release(modelTreeDialog);
215220
TCObject::release(boundingBoxDialog);
@@ -662,7 +667,7 @@ void LDViewWindow::updateStatusParts(void)
662667
RECT rect;
663668
int numParts = 3;
664669
bool latLon = inLatLonMode();
665-
int rightMargin = 32;
670+
int rightMargin = 20;
666671
int latLonWidth = 100;
667672

668673
if (latLon)
@@ -2485,8 +2490,12 @@ LRESULT LDViewWindow::switchToExamineMode(bool saveSetting)
24852490
setMenuRadioCheck(hViewMenu, ID_VIEW_FLYTHROUGH, false);
24862491
modelWindow->setViewMode(LDInputHandler::VMExamine, examineLatLong,
24872492
saveSetting);
2488-
showStatusIcon(true);
2493+
updateStatusParts();
24892494
setMenuCheck(hViewMenu, ID_VIEW_EXAMINE_LAT_LONG, examineLatLong);
2495+
if (toolbarStrip)
2496+
{
2497+
toolbarStrip->viewModeReflect();
2498+
}
24902499
return 0;
24912500
}
24922501

@@ -2496,7 +2505,11 @@ LRESULT LDViewWindow::switchToFlythroughMode(bool saveSetting)
24962505
setMenuRadioCheck(hViewMenu, ID_VIEW_FLYTHROUGH, true);
24972506
modelWindow->setViewMode(LDInputHandler::VMFlyThrough, examineLatLong,
24982507
saveSetting);
2499-
showStatusIcon(false);
2508+
updateStatusParts();
2509+
if (toolbarStrip)
2510+
{
2511+
toolbarStrip->viewModeReflect();
2512+
}
25002513
return 0;
25012514
}
25022515

LDViewWindow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class LDViewWindow: public CUIWindow
112112
bool redraw = true);
113113
virtual void stopAnimation(void);
114114
virtual void switchModes(void);
115+
virtual void zoomToFit(void);
115116

116117
static char* getLDrawDir(void);
117118
char* lastOpenPath(char* pathKey = NULL);
@@ -200,7 +201,6 @@ class LDViewWindow: public CUIWindow
200201
virtual LRESULT windowProc(HWND, UINT, WPARAM, LPARAM);
201202
virtual void resetView(LDVAngle viewAngle = LDVAngleDefault);
202203
virtual void saveDefaultView(void);
203-
virtual void zoomToFit(void);
204204
virtual void resetDefaultView(void);
205205
virtual int getMenuItemIndex(HMENU hMenu, UINT itemID);
206206
virtual int clearRecentFileMenuItems(void);

Resource.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@
9191
#define IDD_LAT_LON 188
9292
#define IDD_MPD 189
9393
#define IDD_STEP 190
94+
#define IDR_TB_ERRORS 500
95+
#define IDR_TB_EXAMINE 501
96+
#define IDR_TB_FLYTHROUGH 502
97+
#define IDR_TB_FULLSCREEN 503
98+
#define IDR_TB_OPEN 504
99+
#define IDR_TB_PREFERENCES 505
100+
#define IDR_TB_RELOAD 506
101+
#define IDR_TB_SAVE 507
102+
#define IDR_TB_ZOOMTOFIT 508
103+
#define IDR_TB_FIRST_STEP 509
104+
#define IDR_TB_LAST_STEP 510
105+
#define IDR_TB_NEXT_STEP 511
106+
#define IDR_TB_PREV_STEP 512
94107
#define IDC_LIGHTING_QUALITY 1001
95108
#define IDC_FRAME_RATE 1002
96109
#define IDC_STUD_QUALITY 1002
@@ -353,7 +366,7 @@
353366
#define IDC_DEFAULT 1284
354367
#define IDC_CURRENT 1285
355368
#define IDC_HIGHLIGHT 1286
356-
#define IDC_PRINT_BACKGROUND 1300
369+
#define IDC_PRINT_BACKGROUND 1287
357370
#define PRINTDLGORD 1538
358371
#define PAGESETUPDLGORD 1546
359372
#define IDD_PRIMITIVES_PREFS 1547

TCFoundation/TCImage.cpp

+129
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ TCImageOptions *TCImage::getCompressionOptions(void)
490490
}
491491

492492
#ifdef WIN32
493+
493494
// Note: static method
494495
TCImage *TCImage::createFromResource(
495496
HMODULE hModule,
@@ -531,4 +532,132 @@ TCImage *TCImage::createFromResource(
531532
}
532533
return retVal;
533534
}
535+
536+
// Note: static method.
537+
HBITMAP TCImage::createDIBSection(
538+
HDC hBitmapDC,
539+
int bitmapWidth,
540+
int bitmapHeight,
541+
int hDPI,
542+
int vDPI,
543+
BYTE **bmBuffer)
544+
{
545+
BITMAPINFO bmi;
546+
547+
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
548+
bmi.bmiHeader.biWidth = bitmapWidth;
549+
bmi.bmiHeader.biHeight = bitmapHeight;
550+
bmi.bmiHeader.biPlanes = 1;
551+
bmi.bmiHeader.biBitCount = 24;
552+
bmi.bmiHeader.biCompression = BI_RGB;
553+
bmi.bmiHeader.biSizeImage = 0;//roundUp(bitmapWidth * 3, 4) * bitmapHeight;
554+
bmi.bmiHeader.biXPelsPerMeter = (long)(hDPI * 39.37);
555+
bmi.bmiHeader.biYPelsPerMeter = (long)(vDPI * 39.37);
556+
bmi.bmiHeader.biClrUsed = 0;
557+
bmi.bmiHeader.biClrImportant = 0;
558+
bmi.bmiColors[0].rgbRed = 0;
559+
bmi.bmiColors[0].rgbGreen = 0;
560+
bmi.bmiColors[0].rgbBlue = 0;
561+
bmi.bmiColors[0].rgbReserved = 0;
562+
return CreateDIBSection(hBitmapDC, &bmi, DIB_RGB_COLORS,
563+
(void**)bmBuffer, NULL, 0);
564+
}
565+
566+
HBITMAP TCImage::createMask(bool updateSource /*= false*/)
567+
{
568+
TCByte *dstData;
569+
int dstBytesPerLine;
570+
int srcBytesPerLine = getRowSize();
571+
HBITMAP hNewBitmap = NULL;
572+
int maskSize;
573+
574+
dstBytesPerLine = roundUp((width + 7) / 8, 2);
575+
maskSize = dstBytesPerLine * height;
576+
dstData = new TCByte[maskSize];
577+
memset(dstData, 0, maskSize);
578+
for (int y = 0; y < height; y++)
579+
{
580+
int srcYOffset = flipped ? srcBytesPerLine * (height - y - 1) :
581+
srcBytesPerLine * y;
582+
int dstYOffset = dstBytesPerLine * y;
583+
584+
for (int x = 0; x < width; x++)
585+
{
586+
TCByte alpha = imageData[srcYOffset + x * 4 + 3];
587+
588+
if (alpha < 128)
589+
{
590+
int byteOffset = dstYOffset + x / 8;
591+
int bitOffset = 7 - (x % 8);
592+
593+
dstData[byteOffset] |= (1 << bitOffset);
594+
if (updateSource)
595+
{
596+
imageData[srcYOffset + x * 4 + 0] = 0;
597+
imageData[srcYOffset + x * 4 + 1] = 0;
598+
imageData[srcYOffset + x * 4 + 2] = 0;
599+
}
600+
}
601+
}
602+
}
603+
hNewBitmap = CreateBitmap(width, height, 1, 1, dstData);
604+
delete dstData;
605+
return hNewBitmap;
606+
}
607+
608+
void TCImage::getBmpAndMask(
609+
HBITMAP &hBitmap,
610+
HBITMAP &hMask,
611+
bool updateSource /*= false*/)
612+
{
613+
HDC hdc = CreateCompatibleDC(NULL);
614+
BYTE *bmBuffer = NULL;
615+
int srcBytesPerLine = getRowSize();
616+
int dstBytesPerLine = roundUp(width * 3, 4);
617+
618+
hBitmap = createDIBSection(hdc, width, height, 0, 0, &bmBuffer);
619+
hMask = createMask(updateSource);
620+
for (int y = 0; y < height; y++)
621+
{
622+
int srcYOffset = srcBytesPerLine * y;
623+
int dstYOffset = dstBytesPerLine * y;
624+
625+
for (int x = 0; x < width; x++)
626+
{
627+
bmBuffer[dstYOffset + x * 3 + 0] =
628+
imageData[srcYOffset + x * 4 + 2];
629+
bmBuffer[dstYOffset + x * 3 + 1] =
630+
imageData[srcYOffset + x * 4 + 1];
631+
bmBuffer[dstYOffset + x * 3 + 2] =
632+
imageData[srcYOffset + x * 4 + 0];
633+
}
634+
}
635+
DeleteDC(hdc);
636+
}
637+
638+
HICON TCImage::loadIconFromPngResource(HMODULE hModule, int resourceId)
639+
{
640+
TCImage *image = TCImage::createFromResource(hModule, resourceId, 4, true);
641+
642+
if (image != NULL)
643+
{
644+
HBITMAP hBitmap;
645+
HBITMAP hMask;
646+
ICONINFO ii;
647+
HICON hIcon;
648+
649+
image->getBmpAndMask(hBitmap, hMask, true);
650+
image->release();
651+
memset(&ii, 0, sizeof(ii));
652+
ii.fIcon = FALSE;
653+
ii.hbmMask = hMask;
654+
ii.hbmColor = hBitmap;
655+
hIcon = CreateIconIndirect(&ii);
656+
DeleteObject(hBitmap);
657+
DeleteObject(hMask);
658+
return hIcon;
659+
}
660+
return NULL;
661+
}
662+
534663
#endif // WIN32

TCFoundation/TCImage.h

+7
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ class TCExport TCImage : public TCObject
6565
#ifdef WIN32
6666
static TCImage *createFromResource(HMODULE hModule, int resourceId,
6767
int lineAlignment = 1, bool flipped = false);
68+
static HBITMAP createDIBSection(HDC hBitmapDC, int bitmapWidth,
69+
int bitmapHeight, int hDPI, int vDPI, BYTE **bmBuffer);
70+
static HICON loadIconFromPngResource(HMODULE hModule, int resourceId);
71+
72+
void getBmpAndMask(HBITMAP &hBitmap, HBITMAP &hMask,
73+
bool updateSource = false);
74+
HBITMAP createMask(bool updateSource = false);
6875
#endif // WIN32
6976
protected:
7077
virtual ~TCImage(void);

TbButtonInfo.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ TbButtonInfo::TbButtonInfo(void)
1010
:m_commandId(-1),
1111
m_bmpIndex(-1),
1212
m_state(TBSTATE_ENABLED),
13-
m_style(TBSTYLE_BUTTON)
13+
m_style(TBSTYLE_BUTTON),
14+
m_selection(0)
1415
{
1516
}
1617

@@ -26,5 +27,7 @@ TbButtonInfo &TbButtonInfo::operator=(const TbButtonInfo &other)
2627
m_bmpIndex = other.m_bmpIndex;
2728
m_state = other.m_state;
2829
m_style = other.m_style;
30+
m_selection = other.m_selection;
31+
m_otherCommandIds = other.m_otherCommandIds;
2932
return *this;
3033
}

0 commit comments

Comments
 (0)