initial
This commit is contained in:
196
utils/mxtk/_vpc_/manifest_mxtoolkitwin32/win32/manifest.txt
Normal file
196
utils/mxtk/_vpc_/manifest_mxtoolkitwin32/win32/manifest.txt
Normal file
@@ -0,0 +1,196 @@
|
||||
// ----------------------------------------- //
|
||||
// File generated by VPC //
|
||||
// ----------------------------------------- //
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\common\debug_lib_check.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\common\debug_lib_check.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\common\debug_lib_check.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mx.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mx.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mx.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxbmp.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxbmp.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxbmp.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxbutton.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxbutton.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxbutton.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxcheckbox.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxcheckbox.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxcheckbox.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxchoice.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxchoice.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxchoice.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxchoosecolor.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxchoosecolor.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxchoosecolor.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxfiledialog.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxfiledialog.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxfiledialog.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxglwindow.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxglwindow.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxglwindow.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxgroupbox.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxgroupbox.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxgroupbox.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlabel.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlabel.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlabel.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlineedit.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlineedit.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlineedit.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlistbox.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlistbox.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlistbox.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlistview.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlistview.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxlistview.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmatsyswindow.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmatsyswindow.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmatsyswindow.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmenu.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmenu.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmenu.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmenubar.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmenubar.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmenubar.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmessagebox.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmessagebox.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxmessagebox.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxpath.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxpath.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxpath.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxpcx.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxpcx.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxpcx.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxpopupmenu.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxpopupmenu.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxpopupmenu.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxprogressbar.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxprogressbar.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxprogressbar.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxradiobutton.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxradiobutton.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxradiobutton.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxscrollbar.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxscrollbar.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxscrollbar.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxslider.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxslider.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxslider.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxstring.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxstring.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxstring.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtab.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtab.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtab.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtga.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtga.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtga.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtooltip.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtooltip.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtooltip.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtreeview.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtreeview.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxtreeview.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxwidget.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxwidget.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxwidget.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\mxtk\mxwindow.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxwindow.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\mxtk\mxwindow.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
1180
utils/mxtk/mx.cpp
Normal file
1180
utils/mxtk/mx.cpp
Normal file
File diff suppressed because it is too large
Load Diff
284
utils/mxtk/mxbmp.cpp
Normal file
284
utils/mxtk/mxbmp.cpp
Normal file
@@ -0,0 +1,284 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxBmp.cpp
|
||||
// implementation: all
|
||||
// last modified: Apr 15 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
|
||||
// lbmlib.c
|
||||
|
||||
#include "mxtk/mxBmp.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
mxImage *
|
||||
mxBmpRead (const char *filename)
|
||||
{
|
||||
int i;
|
||||
FILE *pfile = 0;
|
||||
mxBitmapFileHeader bmfh;
|
||||
mxBitmapInfoHeader bmih;
|
||||
mxBitmapRGBQuad rgrgbPalette[256];
|
||||
int cbBmpBits;
|
||||
byte *pbBmpBits;
|
||||
byte *pb, *pbPal = 0;
|
||||
int cbPalBytes;
|
||||
int biTrueWidth;
|
||||
mxImage *image = 0;
|
||||
bool success = false;
|
||||
|
||||
// File exists?
|
||||
if ((pfile = fopen (filename, "rb")) == 0)
|
||||
return 0;
|
||||
|
||||
// Read file header
|
||||
if (fread (&bmfh, sizeof bmfh, 1/*count*/, pfile) != 1)
|
||||
goto GetOut;
|
||||
|
||||
// Bogus file header check
|
||||
if (!(bmfh.bfReserved1 == 0 && bmfh.bfReserved2 == 0))
|
||||
goto GetOut;
|
||||
|
||||
// Read info header
|
||||
if (fread (&bmih, sizeof bmih, 1/*count*/, pfile) != 1)
|
||||
goto GetOut;
|
||||
|
||||
// Bogus info header check
|
||||
if (!(bmih.biSize == sizeof bmih && bmih.biPlanes == 1))
|
||||
goto GetOut;
|
||||
|
||||
// Bogus bit depth? Only 8-bit supported.
|
||||
if (bmih.biBitCount != 8)
|
||||
goto GetOut;
|
||||
|
||||
// Bogus compression? Only non-compressed supported.
|
||||
if (bmih.biCompression != 0) //BI_RGB)
|
||||
goto GetOut;
|
||||
|
||||
// Figure out how many entires are actually in the table
|
||||
if (bmih.biClrUsed == 0)
|
||||
{
|
||||
bmih.biClrUsed = 256;
|
||||
cbPalBytes = (1 << bmih.biBitCount) * sizeof (mxBitmapRGBQuad);
|
||||
}
|
||||
else
|
||||
{
|
||||
cbPalBytes = bmih.biClrUsed * sizeof (mxBitmapRGBQuad);
|
||||
}
|
||||
|
||||
// Read palette (bmih.biClrUsed entries)
|
||||
if (fread (rgrgbPalette, cbPalBytes, 1/*count*/, pfile) != 1)
|
||||
goto GetOut;
|
||||
|
||||
image = new mxImage ();
|
||||
if (!image)
|
||||
goto GetOut;
|
||||
|
||||
if (!image->create (bmih.biWidth, bmih.biHeight, 8))
|
||||
{
|
||||
goto GetOut;
|
||||
}
|
||||
|
||||
pb = (byte *) image->palette;
|
||||
|
||||
// Copy over used entries
|
||||
for (i = 0; i < (int) bmih.biClrUsed; i++)
|
||||
{
|
||||
*pb++ = rgrgbPalette[i].rgbRed;
|
||||
*pb++ = rgrgbPalette[i].rgbGreen;
|
||||
*pb++ = rgrgbPalette[i].rgbBlue;
|
||||
}
|
||||
|
||||
// Fill in unused entires will 0,0,0
|
||||
for (i = bmih.biClrUsed; i < 256; i++)
|
||||
{
|
||||
*pb++ = 0;
|
||||
*pb++ = 0;
|
||||
*pb++ = 0;
|
||||
}
|
||||
|
||||
// Read bitmap bits (remainder of file)
|
||||
cbBmpBits = bmfh.bfSize - ftell (pfile);
|
||||
pb = (byte *) malloc (cbBmpBits * sizeof (byte));
|
||||
if (pb == 0)
|
||||
{
|
||||
free (pbPal);
|
||||
goto GetOut;
|
||||
}
|
||||
|
||||
if (fread (pb, cbBmpBits, 1/*count*/, pfile) != 1)
|
||||
{
|
||||
free (pb);
|
||||
free (pbPal);
|
||||
goto GetOut;
|
||||
}
|
||||
/*
|
||||
pbBmpBits = malloc(cbBmpBits);
|
||||
if (pbBmpBits == 0)
|
||||
{
|
||||
free (pb);
|
||||
free (pbPal);
|
||||
goto GetOut;
|
||||
}
|
||||
*/
|
||||
pbBmpBits = (byte *) image->data;
|
||||
|
||||
// data is actually stored with the width being rounded up to a multiple of 4
|
||||
biTrueWidth = (bmih.biWidth + 3) & ~3;
|
||||
|
||||
// reverse the order of the data.
|
||||
pb += (bmih.biHeight - 1) * biTrueWidth;
|
||||
for(i = 0; i < bmih.biHeight; i++)
|
||||
{
|
||||
memmove (&pbBmpBits[biTrueWidth * i], pb, biTrueWidth);
|
||||
pb -= biTrueWidth;
|
||||
}
|
||||
|
||||
pb += biTrueWidth;
|
||||
free (pb);
|
||||
|
||||
success = true;
|
||||
|
||||
GetOut:
|
||||
if (pfile)
|
||||
fclose (pfile);
|
||||
|
||||
if ( !success )
|
||||
{
|
||||
delete image;
|
||||
image = 0;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxBmpWrite (const char *filename, mxImage *image)
|
||||
{
|
||||
int i;
|
||||
FILE *pfile = 0;
|
||||
mxBitmapFileHeader bmfh;
|
||||
mxBitmapInfoHeader bmih;
|
||||
mxBitmapRGBQuad rgrgbPalette[256];
|
||||
int cbBmpBits;
|
||||
byte *pbBmpBits;
|
||||
byte *pb = 0;
|
||||
int cbPalBytes;
|
||||
int biTrueWidth;
|
||||
|
||||
if (!image || !image->data || !image->palette)
|
||||
return false;
|
||||
|
||||
// File exists?
|
||||
if ((pfile = fopen(filename, "wb")) == 0)
|
||||
return false;
|
||||
|
||||
biTrueWidth = ((image->width + 3) & ~3);
|
||||
cbBmpBits = biTrueWidth * image->height;
|
||||
cbPalBytes = 256 * sizeof (mxBitmapRGBQuad);
|
||||
|
||||
// Bogus file header check
|
||||
//bmfh.bfType = MAKEWORD( 'B', 'M' );
|
||||
bmfh.bfType = (word) (('M' << 8) | 'B');
|
||||
bmfh.bfSize = sizeof bmfh + sizeof bmih + cbBmpBits + cbPalBytes;
|
||||
bmfh.bfReserved1 = 0;
|
||||
bmfh.bfReserved2 = 0;
|
||||
bmfh.bfOffBits = sizeof bmfh + sizeof bmih + cbPalBytes;
|
||||
|
||||
// Write file header
|
||||
if (fwrite (&bmfh, sizeof bmfh, 1/*count*/, pfile) != 1)
|
||||
{
|
||||
fclose (pfile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Size of structure
|
||||
bmih.biSize = sizeof bmih;
|
||||
// Width
|
||||
bmih.biWidth = biTrueWidth;
|
||||
// Height
|
||||
bmih.biHeight = image->height;
|
||||
// Only 1 plane
|
||||
bmih.biPlanes = 1;
|
||||
// Only 8-bit supported.
|
||||
bmih.biBitCount = 8;
|
||||
// Only non-compressed supported.
|
||||
bmih.biCompression = 0; //BI_RGB;
|
||||
bmih.biSizeImage = 0;
|
||||
|
||||
// huh?
|
||||
bmih.biXPelsPerMeter = 0;
|
||||
bmih.biYPelsPerMeter = 0;
|
||||
|
||||
// Always full palette
|
||||
bmih.biClrUsed = 256;
|
||||
bmih.biClrImportant = 0;
|
||||
|
||||
// Write info header
|
||||
if (fwrite (&bmih, sizeof bmih, 1/*count*/, pfile) != 1)
|
||||
{
|
||||
fclose (pfile);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// convert to expanded palette
|
||||
pb = (byte *) image->palette;
|
||||
|
||||
// Copy over used entries
|
||||
for (i = 0; i < (int) bmih.biClrUsed; i++)
|
||||
{
|
||||
rgrgbPalette[i].rgbRed = *pb++;
|
||||
rgrgbPalette[i].rgbGreen = *pb++;
|
||||
rgrgbPalette[i].rgbBlue = *pb++;
|
||||
rgrgbPalette[i].rgbReserved = 0;
|
||||
}
|
||||
|
||||
// Write palette (bmih.biClrUsed entries)
|
||||
cbPalBytes = bmih.biClrUsed * sizeof (mxBitmapRGBQuad);
|
||||
if (fwrite (rgrgbPalette, cbPalBytes, 1/*count*/, pfile) != 1)
|
||||
{
|
||||
fclose (pfile);
|
||||
return false;
|
||||
}
|
||||
|
||||
pbBmpBits = (byte *) malloc (cbBmpBits * sizeof (byte));
|
||||
if (!pbBmpBits)
|
||||
{
|
||||
fclose (pfile);
|
||||
return false;
|
||||
}
|
||||
|
||||
pb = (byte *) image->data;
|
||||
// reverse the order of the data.
|
||||
pb += (image->height - 1) * image->width;
|
||||
for(i = 0; i < bmih.biHeight; i++)
|
||||
{
|
||||
memmove (&pbBmpBits[biTrueWidth * i], pb, image->width);
|
||||
pb -= image->width;
|
||||
}
|
||||
|
||||
// Write bitmap bits (remainder of file)
|
||||
if (fwrite (pbBmpBits, cbBmpBits, 1/*count*/, pfile) != 1)
|
||||
{
|
||||
free (pbBmpBits);
|
||||
fclose (pfile);
|
||||
return false;
|
||||
}
|
||||
|
||||
free (pbBmpBits);
|
||||
fclose (pfile);
|
||||
|
||||
return true;
|
||||
}
|
||||
53
utils/mxtk/mxbutton.cpp
Normal file
53
utils/mxtk/mxbutton.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxButton.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Apr 12 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxButton.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class mxButton_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxButton::mxButton (mxWindow *parent, int x, int y, int w, int h, const char *label, int id)
|
||||
: mxWidget (parent, x, y, w, h, label)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
DWORD dwStyle = WS_VISIBLE | WS_CHILD;
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, "BUTTON", label, dwStyle,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setType (MX_BUTTON);
|
||||
setHandle (handle);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxButton::~mxButton ()
|
||||
{
|
||||
}
|
||||
69
utils/mxtk/mxcheckbox.cpp
Normal file
69
utils/mxtk/mxcheckbox.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxCheckBox.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxCheckBox.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class mxCheckBox_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxCheckBox::mxCheckBox (mxWindow *parent, int x, int y, int w, int h, const char *label, int id)
|
||||
: mxWidget (parent, x, y, w, h, label)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, "BUTTON", label, WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_CHECKBOX);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
setChecked (false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxCheckBox::~mxCheckBox ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxCheckBox::setChecked (bool b)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), BM_SETCHECK, (WPARAM) b ? BST_CHECKED:BST_UNCHECKED, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxCheckBox::isChecked () const
|
||||
{
|
||||
return (SendMessage ((HWND) getHandle (), BM_GETCHECK, 0, 0L) == BST_CHECKED);
|
||||
}
|
||||
110
utils/mxtk/mxchoice.cpp
Normal file
110
utils/mxtk/mxchoice.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxChoice.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Apr 28 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxChoice.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class mxChoice_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxChoice::mxChoice (mxWindow *parent, int x, int y, int w, int h, int id)
|
||||
: mxWidget (parent, x, y, w, h)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, "COMBOBOX", "", WS_VISIBLE | WS_CHILD | WS_VSCROLL | CBS_DROPDOWNLIST,
|
||||
x, y, w, h + 500, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_CHOICE);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxChoice::~mxChoice ()
|
||||
{
|
||||
removeAll ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxChoice::add (const char *item)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxChoice::select (int index)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), CB_SETCURSEL, (WPARAM) index, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxChoice::remove (int index)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), CB_DELETESTRING, (WPARAM) index, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxChoice::removeAll ()
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), CB_RESETCONTENT, 0, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxChoice::getItemCount () const
|
||||
{
|
||||
return (int) SendMessage ((HWND) getHandle (), CB_GETCOUNT, 0, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxChoice::getSelectedIndex () const
|
||||
{
|
||||
return (int) SendMessage ((HWND) getHandle (), CB_GETCURSEL, 0, 0L);
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
mxChoice::getItemText (int index) const
|
||||
{
|
||||
static char text[256];
|
||||
SendMessage ((HWND) getHandle (), CB_GETLBTEXT, (WPARAM) index, (LPARAM) (LPCTSTR) text);
|
||||
return text;
|
||||
}
|
||||
48
utils/mxtk/mxchoosecolor.cpp
Normal file
48
utils/mxtk/mxchoosecolor.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxChooseColor.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 14 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxChooseColor.h"
|
||||
#include "mxtk/mxWindow.h"
|
||||
#include <windows.h>
|
||||
#include <commdlg.h>
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxChooseColor (mxWindow *parent, int *r, int *g, int *b)
|
||||
{
|
||||
CHOOSECOLOR cc;
|
||||
static COLORREF custColors[16];
|
||||
|
||||
BYTE rr = *r;
|
||||
BYTE gg = *g;
|
||||
BYTE bb = *b;
|
||||
|
||||
memset (&cc, 0, sizeof (CHOOSECOLOR));
|
||||
cc.lStructSize = sizeof (CHOOSECOLOR);
|
||||
cc.hwndOwner = parent ? (HWND) parent->getHandle ():NULL;
|
||||
cc.rgbResult = RGB (rr, gg, bb);
|
||||
cc.lpCustColors = custColors;
|
||||
cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
|
||||
|
||||
if (ChooseColor (&cc))
|
||||
{
|
||||
*r = (int) GetRValue (cc.rgbResult);
|
||||
*g = (int) GetGValue (cc.rgbResult);
|
||||
*b = (int) GetBValue (cc.rgbResult);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
108
utils/mxtk/mxfiledialog.cpp
Normal file
108
utils/mxtk/mxfiledialog.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxFileDialog.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 14 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxFileDialog.h"
|
||||
#include "mxtk/mxWindow.h"
|
||||
#include <windows.h>
|
||||
#include <commdlg.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
static char sd_path[_MAX_PATH] = "";
|
||||
|
||||
|
||||
|
||||
const char*
|
||||
mxGetOpenFileName (mxWindow *parent, const char *path, const char *filter)
|
||||
{
|
||||
CHAR szPath[_MAX_PATH], szFilter[_MAX_PATH];
|
||||
|
||||
strcpy (sd_path, "");
|
||||
|
||||
if (path)
|
||||
strcpy (szPath, path);
|
||||
else
|
||||
strcpy (szPath, "");
|
||||
|
||||
if (filter)
|
||||
{
|
||||
memset (szFilter, 0, _MAX_PATH);
|
||||
strcpy (szFilter, filter);
|
||||
strcpy (szFilter + strlen (szFilter) + 1, filter);
|
||||
}
|
||||
else
|
||||
strcpy (szFilter, "");
|
||||
|
||||
|
||||
OPENFILENAME ofn;
|
||||
memset (&ofn, 0, sizeof (ofn));
|
||||
ofn.lStructSize = sizeof (ofn);
|
||||
if (parent)
|
||||
ofn.hwndOwner = (HWND) parent->getHandle ();
|
||||
ofn.hInstance = (HINSTANCE) GetModuleHandle (NULL);
|
||||
ofn.lpstrFilter = szFilter;
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFile = sd_path;
|
||||
ofn.nMaxFile = _MAX_PATH;
|
||||
if (path && strlen (path))
|
||||
ofn.lpstrInitialDir = szPath;
|
||||
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
|
||||
|
||||
if (GetOpenFileName (&ofn))
|
||||
return sd_path;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char*
|
||||
mxGetSaveFileName (mxWindow *parent, const char *path, const char *filter)
|
||||
{
|
||||
CHAR szPath[_MAX_PATH], szFilter[_MAX_PATH];
|
||||
|
||||
strcpy (sd_path, "");
|
||||
|
||||
if (path)
|
||||
strcpy (szPath, path);
|
||||
else
|
||||
strcpy (szPath, "");
|
||||
|
||||
if (filter)
|
||||
{
|
||||
memset (szFilter, 0, _MAX_PATH);
|
||||
strcpy (szFilter, filter);
|
||||
strcpy (szFilter + strlen (szFilter) + 1, filter);
|
||||
}
|
||||
else
|
||||
strcpy (szFilter, "");
|
||||
|
||||
OPENFILENAME ofn;
|
||||
memset (&ofn, 0, sizeof (ofn));
|
||||
ofn.lStructSize = sizeof (ofn);
|
||||
if (parent)
|
||||
ofn.hwndOwner = (HWND) parent->getHandle ();
|
||||
ofn.hInstance = (HINSTANCE) GetModuleHandle (NULL);
|
||||
ofn.lpstrFilter = szFilter;
|
||||
ofn.lpstrFile = sd_path;
|
||||
ofn.nMaxFile = _MAX_PATH;
|
||||
if (path && strlen (path))
|
||||
ofn.lpstrInitialDir = szPath;
|
||||
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
|
||||
|
||||
if (GetSaveFileName (&ofn))
|
||||
return sd_path;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
190
utils/mxtk/mxglwindow.cpp
Normal file
190
utils/mxtk/mxglwindow.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxGlWindow.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Apr 21 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxGlWindow.h"
|
||||
#include <windows.h>
|
||||
//#include <ostream.h"
|
||||
|
||||
|
||||
|
||||
static int g_formatMode = mxGlWindow::FormatDouble;
|
||||
static int g_formatColorBits = 24;
|
||||
static int g_formatDepthBits = 16;
|
||||
|
||||
|
||||
|
||||
class mxGlWindow_i
|
||||
{
|
||||
public:
|
||||
HDC hdc;
|
||||
HGLRC hglrc;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxGlWindow::mxGlWindow (mxWindow *parent, int x, int y, int w, int h, const char *label, int style)
|
||||
: mxWindow (parent, x, y, w, h, label, style)
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd =
|
||||
{
|
||||
sizeof (PIXELFORMATDESCRIPTOR), // size of this pfd
|
||||
1, // version number
|
||||
PFD_DRAW_TO_WINDOW | // support window
|
||||
PFD_SUPPORT_OPENGL | // support OpenGL
|
||||
PFD_DOUBLEBUFFER, // double buffered
|
||||
PFD_TYPE_RGBA, // RGBA type
|
||||
24, // 24-bit color depth
|
||||
0, 0, 0, 0, 0, 0, // color bits ignored
|
||||
0, // no alpha buffer
|
||||
0, // shift bit ignored
|
||||
0, // no accumulation buffer
|
||||
0, 0, 0, 0, // accum bits ignored
|
||||
16, // 32-bit z-buffer
|
||||
0, // no stencil buffer
|
||||
0, // no auxiliary buffer
|
||||
PFD_MAIN_PLANE, // main layer
|
||||
0, // reserved
|
||||
0, 0, 0 // layer masks ignored
|
||||
};
|
||||
|
||||
d_this = new mxGlWindow_i;
|
||||
|
||||
pfd.cColorBits = g_formatColorBits;
|
||||
pfd.cDepthBits = g_formatDepthBits;
|
||||
|
||||
bool error = false;
|
||||
|
||||
if ((d_this->hdc = GetDC ((HWND) getHandle ())) == NULL)
|
||||
{
|
||||
error = true;
|
||||
goto done;
|
||||
}
|
||||
|
||||
int pfm;
|
||||
if ((pfm = ChoosePixelFormat (d_this->hdc, &pfd)) == 0)
|
||||
{
|
||||
error = true;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (SetPixelFormat (d_this->hdc, pfm, &pfd) == FALSE)
|
||||
{
|
||||
error = true;
|
||||
goto done;
|
||||
}
|
||||
|
||||
DescribePixelFormat (d_this->hdc, pfm, sizeof (pfd), &pfd);
|
||||
|
||||
if ((d_this->hglrc = wglCreateContext (d_this->hdc)) == 0)
|
||||
{
|
||||
error = true;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!wglMakeCurrent (d_this->hdc, d_this->hglrc))
|
||||
{
|
||||
error = true;
|
||||
goto done;
|
||||
}
|
||||
|
||||
setType (MX_GLWINDOW);
|
||||
setDrawFunc (0);
|
||||
|
||||
done:
|
||||
if (error)
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxGlWindow::~mxGlWindow ()
|
||||
{
|
||||
if (d_this->hglrc)
|
||||
{
|
||||
wglMakeCurrent (NULL, NULL);
|
||||
//wglDeleteContext (d_this->hglrc);
|
||||
}
|
||||
|
||||
if (d_this->hdc)
|
||||
ReleaseDC ((HWND) getHandle (), d_this->hdc);
|
||||
|
||||
delete d_this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxGlWindow::handleEvent (mxEvent *event)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxGlWindow::redraw ()
|
||||
{
|
||||
makeCurrent ();
|
||||
if (d_drawFunc)
|
||||
d_drawFunc ();
|
||||
else
|
||||
draw ();
|
||||
swapBuffers ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxGlWindow::draw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxGlWindow::makeCurrent ()
|
||||
{
|
||||
if (wglMakeCurrent (d_this->hdc, d_this->hglrc))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxGlWindow::swapBuffers ()
|
||||
{
|
||||
if (SwapBuffers (d_this->hdc))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxGlWindow::setDrawFunc (void (*func) (void))
|
||||
{
|
||||
d_drawFunc = func;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxGlWindow::setFormat (int mode, int colorBits, int depthBits)
|
||||
{
|
||||
g_formatMode = mode;
|
||||
g_formatColorBits = colorBits;
|
||||
g_formatDepthBits = depthBits;
|
||||
}
|
||||
50
utils/mxtk/mxgroupbox.cpp
Normal file
50
utils/mxtk/mxgroupbox.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxGroupBox.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxGroupBox.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class mxGroupBox_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxGroupBox::mxGroupBox (mxWindow *parent, int x, int y, int w, int h, const char *label)
|
||||
: mxWidget (parent, x, y, w, h, label)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, "BUTTON", label, WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) NULL, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_GROUPBOX);
|
||||
setParent (parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxGroupBox::~mxGroupBox ()
|
||||
{
|
||||
}
|
||||
51
utils/mxtk/mxlabel.cpp
Normal file
51
utils/mxtk/mxlabel.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxLabel.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxLabel.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class mxLabel_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxLabel::mxLabel (mxWindow *parent, int x, int y, int w, int h, const char *label)
|
||||
: mxWidget (parent, x, y, w, h, label)
|
||||
{
|
||||
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, "STATIC", label, WS_VISIBLE | WS_CHILD,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) NULL, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_LABEL);
|
||||
setParent (parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxLabel::~mxLabel ()
|
||||
{
|
||||
}
|
||||
140
utils/mxtk/mxlineedit.cpp
Normal file
140
utils/mxtk/mxlineedit.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxLineEdit.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxLineEdit.h"
|
||||
#include <windows.h>
|
||||
#include "mxtk/mxEvent.h"
|
||||
#include "mxtk/mxWindow.h"
|
||||
|
||||
|
||||
class mxLineEdit_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
#include "tier0/dbg.h"
|
||||
|
||||
|
||||
typedef LRESULT (CALLBACK * WndProc_t)(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
static WndProc_t s_OldWndProc = 0;
|
||||
|
||||
static LRESULT CALLBACK EditWndProc (HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int iret = 0;
|
||||
|
||||
// This lovely bit of hackery ensures we get return key events
|
||||
if ( uMessage == WM_CHAR)
|
||||
{
|
||||
iret = s_OldWndProc( hwnd, uMessage, wParam, lParam );
|
||||
|
||||
// Post the message directly to all windows in the hierarchy until
|
||||
// someone responds
|
||||
mxLineEdit *lineEdit = (mxLineEdit *) GetWindowLong (hwnd, GWL_USERDATA);
|
||||
mxEvent event;
|
||||
event.event = mxEvent::KeyDown;
|
||||
event.action = lineEdit->getId();
|
||||
event.key = (int) wParam;
|
||||
|
||||
mxWindow* window = lineEdit->getParent();
|
||||
while (window)
|
||||
{
|
||||
if (window->handleEvent (&event))
|
||||
break;
|
||||
|
||||
window = window->getParent ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( uMessage == WM_LBUTTONDOWN )
|
||||
{
|
||||
SetFocus( hwnd );
|
||||
}
|
||||
iret = s_OldWndProc( hwnd, uMessage, wParam, lParam );
|
||||
}
|
||||
return iret;
|
||||
}
|
||||
|
||||
mxLineEdit::mxLineEdit (mxWindow *parent, int x, int y, int w, int h, const char *label, int id, int style)
|
||||
: mxWidget (parent, x, y, w, h, label)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
DWORD dwStyle = WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP; // | ES_WANTRETURN | ES_MULTILINE;
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
if (style == ReadOnly)
|
||||
dwStyle |= ES_READONLY;
|
||||
else if (style == Password)
|
||||
dwStyle |= ES_PASSWORD;
|
||||
|
||||
if (!s_OldWndProc)
|
||||
{
|
||||
WNDCLASSEX editClass;
|
||||
GetClassInfoEx( (HINSTANCE) GetModuleHandle (NULL), "EDIT", &editClass );
|
||||
s_OldWndProc = editClass.lpfnWndProc;
|
||||
|
||||
editClass.cbSize = sizeof(WNDCLASSEX);
|
||||
editClass.cbClsExtra = 0;
|
||||
editClass.lpfnWndProc = EditWndProc;
|
||||
editClass.lpszClassName = "mx_edit";
|
||||
RegisterClassEx( &editClass );
|
||||
}
|
||||
|
||||
void *handle = (void *) CreateWindowEx (WS_EX_CLIENTEDGE, "mx_edit", label, dwStyle, //WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SendMessage ((HWND) getHandle (), EM_LIMITTEXT, (WPARAM) 256, 0L);
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_LINEEDIT);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxLineEdit::~mxLineEdit ()
|
||||
{
|
||||
}
|
||||
|
||||
void mxLineEdit::clear()
|
||||
{
|
||||
SendMessage( (HWND)getHandle(), WM_SETTEXT, (WPARAM)0, (LPARAM)"" );
|
||||
}
|
||||
|
||||
void mxLineEdit::getText( char *buf, size_t bufsize )
|
||||
{
|
||||
buf[ 0 ] = 0;
|
||||
SendMessage( (HWND) getHandle (), WM_GETTEXT, (WPARAM)bufsize, (LPARAM)buf );
|
||||
}
|
||||
|
||||
void
|
||||
mxLineEdit::setMaxLength (int max)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), EM_LIMITTEXT, (WPARAM) max, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxLineEdit::getMaxLength () const
|
||||
{
|
||||
return (int) SendMessage ((HWND) getHandle (), EM_GETLIMITTEXT, 0, 0L);
|
||||
}
|
||||
161
utils/mxtk/mxlistbox.cpp
Normal file
161
utils/mxtk/mxlistbox.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxListBox.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxListBox.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class mxListBox_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxListBox::mxListBox (mxWindow *parent, int x, int y, int w, int h, int id, int style)
|
||||
: mxWidget (parent, x, y, w, h)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
DWORD dwStyle = WS_VISIBLE | WS_CHILD | LBS_NOTIFY | WS_VSCROLL | WS_HSCROLL;
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
if (style == MultiSelection)
|
||||
dwStyle |= LBS_MULTIPLESEL | LBS_EXTENDEDSEL;
|
||||
|
||||
void *handle = (void *) CreateWindowEx (WS_EX_CLIENTEDGE, "LISTBOX", "", WS_VISIBLE | WS_CHILD | LBS_NOTIFY | WS_VSCROLL,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_LISTBOX);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxListBox::~mxListBox ()
|
||||
{
|
||||
removeAll ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxListBox::add (const char *item)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxListBox::select (int index)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), LB_SETCURSEL, (WPARAM) index, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxListBox::deselect (int index)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), LB_SETSEL, (WPARAM) FALSE, (LPARAM) (UINT) index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxListBox::remove (int index)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), LB_DELETESTRING, (WPARAM) index, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxListBox::removeAll ()
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), LB_RESETCONTENT, 0, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxListBox::setItemText (int index, const char *item)
|
||||
{
|
||||
//SendMessage ((HWND) getHandle (), LB_SETTEXT, (WPARAM) index, (LPARAM) (LPCTSTR) item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxListBox::setItemData (int index, void *data)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), LB_SETITEMDATA, (WPARAM) index, (LPARAM) data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxListBox::getItemCount () const
|
||||
{
|
||||
return (int) SendMessage ((HWND) getHandle (), LB_GETCOUNT, 0, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxListBox::getSelectedIndex () const
|
||||
{
|
||||
return (int) SendMessage ((HWND) getHandle (), LB_GETCURSEL, 0, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxListBox::isSelected (int index) const
|
||||
{
|
||||
return (bool) (SendMessage ((HWND) getHandle (), LB_GETSEL, (WPARAM) index, 0L) > 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char*
|
||||
mxListBox::getItemText (int index) const
|
||||
{
|
||||
static char text[256];
|
||||
SendMessage ((HWND) getHandle (), LB_GETTEXT, (WPARAM) index, (LPARAM) (LPCTSTR) text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void*
|
||||
mxListBox::getItemData (int index) const
|
||||
{
|
||||
return (void *) SendMessage ((HWND) getHandle (), LB_GETITEMDATA, (WPARAM) index, 0L);
|
||||
}
|
||||
|
||||
int
|
||||
mxListBox::getTopIndex () const
|
||||
{
|
||||
return (int) SendMessage ((HWND) getHandle (), LB_GETTOPINDEX, 0, 0L);
|
||||
}
|
||||
334
utils/mxtk/mxlistview.cpp
Normal file
334
utils/mxtk/mxlistview.cpp
Normal file
@@ -0,0 +1,334 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxListView.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: May 03 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxListView.h"
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
|
||||
|
||||
class mxListView_i
|
||||
{
|
||||
public:
|
||||
HWND d_hwnd;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxListView::mxListView (mxWindow *parent, int x, int y, int w, int h, int id)
|
||||
: mxWidget (parent, x, y, w, h)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
d_this = new mxListView_i;
|
||||
|
||||
DWORD dwStyle = LVS_NOSORTHEADER | LVS_REPORT | LVS_SHOWSELALWAYS | WS_VISIBLE | WS_CHILD;
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
d_this->d_hwnd = CreateWindowEx (WS_EX_CLIENTEDGE, WC_LISTVIEW, "", dwStyle,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage (d_this->d_hwnd, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong (d_this->d_hwnd, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle ((void *) d_this->d_hwnd);
|
||||
setType (MX_LISTVIEW);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxListView::~mxListView ()
|
||||
{
|
||||
remove (0);
|
||||
delete d_this;
|
||||
}
|
||||
int mxListView::add ( const char *item )
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
LVITEM lvItem;
|
||||
memset( &lvItem, 0, sizeof( lvItem ) );
|
||||
|
||||
lvItem.iItem = getItemCount();
|
||||
|
||||
lvItem.mask = LVIF_TEXT;
|
||||
lvItem.pszText = (LPSTR) item;
|
||||
lvItem.cchTextMax = 256;
|
||||
|
||||
return ListView_InsertItem( d_this->d_hwnd, &lvItem );
|
||||
}
|
||||
|
||||
void
|
||||
mxListView::remove ( int index )
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
ListView_DeleteItem (d_this->d_hwnd, index );
|
||||
}
|
||||
|
||||
void
|
||||
mxListView::removeAll ()
|
||||
{
|
||||
ListView_DeleteAllItems(d_this->d_hwnd);
|
||||
}
|
||||
|
||||
void
|
||||
mxListView::setLabel ( int item , int column, const char *label)
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
LVITEM lvItem;
|
||||
memset( &lvItem, 0, sizeof( lvItem ) );
|
||||
lvItem.mask = LVIF_TEXT;
|
||||
lvItem.iItem = item;
|
||||
lvItem.iSubItem = column;
|
||||
|
||||
lvItem.pszText = (LPSTR) label;
|
||||
lvItem.cchTextMax = 256;
|
||||
|
||||
ListView_SetItem (d_this->d_hwnd, &lvItem);
|
||||
}
|
||||
|
||||
void mxListView::setLabel( int item, int column, const wchar_t *label )
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
LV_ITEMW lvItem;
|
||||
memset( &lvItem, 0, sizeof( lvItem ) );
|
||||
lvItem.mask = LVIF_TEXT;
|
||||
lvItem.iItem = item;
|
||||
lvItem.iSubItem = column;
|
||||
|
||||
lvItem.pszText = (wchar_t *)label;
|
||||
lvItem.cchTextMax = 256;
|
||||
|
||||
SendMessage(d_this->d_hwnd, LVM_SETITEMW, 0, (LPARAM)(const LV_ITEMW FAR*)(&lvItem));
|
||||
}
|
||||
|
||||
void
|
||||
mxListView::setUserData ( int item, int column, void *userData)
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
LVITEM lvItem;
|
||||
memset( &lvItem, 0, sizeof( lvItem ) );
|
||||
lvItem.mask = LVIF_PARAM;
|
||||
lvItem.iItem = item;
|
||||
lvItem.iSubItem = column;
|
||||
lvItem.lParam = (LPARAM) userData;
|
||||
|
||||
ListView_SetItem (d_this->d_hwnd, &lvItem);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mxListView::setSelected ( int item, bool b)
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
ListView_SetItemState (d_this->d_hwnd, item, b ? ( LVIS_SELECTED | LVIS_FOCUSED ): 0 , LVIS_SELECTED | LVIS_FOCUSED );
|
||||
}
|
||||
|
||||
int mxListView::getItemCount() const
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
return ListView_GetItemCount( d_this->d_hwnd );
|
||||
}
|
||||
|
||||
int mxListView::getNextSelectedItem( int startitem /*= 0*/ ) const
|
||||
{
|
||||
if (!d_this)
|
||||
return -1;
|
||||
|
||||
if ( ListView_GetSelectedCount( d_this->d_hwnd ) == 0 )
|
||||
return -1;
|
||||
|
||||
int c = getItemCount();
|
||||
int start = startitem + 1;
|
||||
|
||||
while ( start < c )
|
||||
{
|
||||
if ( isSelected( start ) )
|
||||
return start;
|
||||
start++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mxListView::getNumSelected() const
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
return ListView_GetSelectedCount( d_this->d_hwnd );
|
||||
}
|
||||
|
||||
const char*
|
||||
mxListView::getLabel ( int item, int column ) const
|
||||
{
|
||||
static char label[256];
|
||||
strcpy (label, "");
|
||||
|
||||
if (!d_this)
|
||||
return label;
|
||||
|
||||
LVITEM lvItem;
|
||||
memset( &lvItem, 0, sizeof( lvItem ) );
|
||||
lvItem.mask = LVIF_TEXT;
|
||||
lvItem.iItem = item;
|
||||
lvItem.iSubItem = column;
|
||||
lvItem.pszText = (LPSTR) label;
|
||||
lvItem.cchTextMax = 256;
|
||||
ListView_GetItem (d_this->d_hwnd, &lvItem);
|
||||
|
||||
return lvItem.pszText;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void*
|
||||
mxListView::getUserData ( int item, int column ) const
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
LVITEM lvItem;
|
||||
memset( &lvItem, 0, sizeof( lvItem ) );
|
||||
lvItem.mask = LVIF_PARAM;
|
||||
lvItem.iItem = item;
|
||||
lvItem.iSubItem = column;
|
||||
|
||||
ListView_GetItem (d_this->d_hwnd, &lvItem);
|
||||
|
||||
return (void *) lvItem.lParam;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxListView::isSelected ( int index ) const
|
||||
{
|
||||
if (!d_this)
|
||||
return false;
|
||||
|
||||
int state = ListView_GetItemState( d_this->d_hwnd, index, LVIS_SELECTED );
|
||||
if ( state & LVIS_SELECTED )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void mxListView::setImageList( void *himagelist )
|
||||
{
|
||||
ListView_SetImageList(d_this->d_hwnd, (HIMAGELIST)himagelist, LVSIL_SMALL );
|
||||
}
|
||||
|
||||
void mxListView::setImage( int item, int column, int imagenormal )
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
LVITEM lvItem;
|
||||
memset( &lvItem, 0, sizeof( lvItem ) );
|
||||
lvItem.mask = LVIF_IMAGE;
|
||||
lvItem.iItem = item;
|
||||
lvItem.iSubItem = column;
|
||||
lvItem.iImage = imagenormal;
|
||||
//lvItem.state = INDEXTOSTATEIMAGEMASK( imagenormal );
|
||||
//lvItem.stateMask = -1;
|
||||
|
||||
ListView_SetItem (d_this->d_hwnd, &lvItem);
|
||||
}
|
||||
|
||||
void mxListView::insertTextColumn( int column, int width, char const *label )
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
LVCOLUMN col;
|
||||
memset( &col, 0, sizeof( col ) );
|
||||
|
||||
col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH | LVCF_ORDER;
|
||||
col.iOrder = column;
|
||||
col.pszText = (char *)label;
|
||||
col.cchTextMax = 256;
|
||||
col.iSubItem = column;
|
||||
col.cx = width;
|
||||
|
||||
ListView_InsertColumn( d_this->d_hwnd, column, &col );
|
||||
}
|
||||
|
||||
void mxListView::insertImageColumn( int column, int width, int imageindex )
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
LVCOLUMN col;
|
||||
memset( &col, 0, sizeof( col ) );
|
||||
|
||||
col.mask = LVCF_IMAGE | LVCF_SUBITEM | LVCF_WIDTH | LVCF_ORDER | LVCF_FMT;
|
||||
col.fmt = LVCFMT_IMAGE;
|
||||
col.iOrder = column;
|
||||
col.iSubItem = column;
|
||||
col.cx = width;
|
||||
col.iImage = imageindex;
|
||||
|
||||
ListView_InsertColumn( d_this->d_hwnd, column, &col );
|
||||
}
|
||||
|
||||
void mxListView::setDrawingEnabled( bool draw )
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
SendMessage( d_this->d_hwnd, WM_SETREDRAW, (WPARAM)draw ? TRUE : FALSE, (LPARAM)0 );
|
||||
}
|
||||
|
||||
void mxListView::deselectAll()
|
||||
{
|
||||
if ( !d_this )
|
||||
return;
|
||||
|
||||
setDrawingEnabled( false );
|
||||
int c = getItemCount();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
if ( isSelected( i ) )
|
||||
{
|
||||
setSelected( i, false );
|
||||
}
|
||||
}
|
||||
|
||||
setDrawingEnabled( true );
|
||||
}
|
||||
|
||||
void mxListView::scrollToItem( int item )
|
||||
{
|
||||
if ( !d_this )
|
||||
return;
|
||||
|
||||
ListView_EnsureVisible( d_this->d_hwnd, item, FALSE );
|
||||
}
|
||||
108
utils/mxtk/mxmatsyswindow.cpp
Normal file
108
utils/mxtk/mxmatsyswindow.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxMatSysWindow.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Apr 21 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxMatSysWindow.h"
|
||||
#include <windows.h>
|
||||
|
||||
class mxMatSysWindow_i
|
||||
{
|
||||
public:
|
||||
HDC hdc;
|
||||
HGLRC hglrc;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxMatSysWindow::mxMatSysWindow (mxWindow *parent, int x, int y, int w, int h, const char *label, int style)
|
||||
: mxWindow (parent, x, y, w, h, label, style)
|
||||
{
|
||||
d_this = new mxMatSysWindow_i;
|
||||
|
||||
bool error = false;
|
||||
|
||||
if ((d_this->hdc = GetDC ((HWND) getHandle ())) == NULL)
|
||||
{
|
||||
error = true;
|
||||
goto done;
|
||||
}
|
||||
|
||||
setDrawFunc (0);
|
||||
|
||||
done:
|
||||
if (error)
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxMatSysWindow::~mxMatSysWindow ()
|
||||
{
|
||||
if (d_this->hdc)
|
||||
ReleaseDC ((HWND) getHandle (), d_this->hdc);
|
||||
|
||||
delete d_this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxMatSysWindow::handleEvent (mxEvent *event)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMatSysWindow::redraw ()
|
||||
{
|
||||
// makeCurrent ();
|
||||
if (d_drawFunc)
|
||||
d_drawFunc ();
|
||||
else
|
||||
draw ();
|
||||
// swapBuffers ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMatSysWindow::draw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxMatSysWindow::makeCurrent ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxMatSysWindow::swapBuffers ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMatSysWindow::setDrawFunc (void (*func) (void))
|
||||
{
|
||||
d_drawFunc = func;
|
||||
}
|
||||
|
||||
|
||||
116
utils/mxtk/mxmenu.cpp
Normal file
116
utils/mxtk/mxmenu.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxMenu.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxMenu.h"
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
//#include <ostream.h"
|
||||
|
||||
|
||||
|
||||
class mxMenu_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxMenu::mxMenu ()
|
||||
: mxWidget (0, 0, 0, 0, 0)
|
||||
{
|
||||
void *handle = (void *) CreateMenu ();
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_MENU);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxMenu::~mxMenu ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMenu::add (const char *item, int id)
|
||||
{
|
||||
AppendMenu ((HMENU) getHandle (), MF_STRING, (UINT) id, item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMenu::addMenu (const char *item, mxMenu *menu)
|
||||
{
|
||||
AppendMenu ((HMENU) getHandle (), MF_POPUP, (UINT) menu->getHandle (), item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMenu::addSeparator ()
|
||||
{
|
||||
AppendMenu ((HMENU) getHandle (), MF_SEPARATOR, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMenu::setEnabled (int id, bool b)
|
||||
{
|
||||
EnableMenuItem ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | (b ? MF_ENABLED:MF_GRAYED));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMenu::setChecked (int id, bool b)
|
||||
{
|
||||
CheckMenuItem ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | (b ? MF_CHECKED:MF_UNCHECKED));
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxMenu::isEnabled (int id) const
|
||||
{
|
||||
MENUITEMINFO mii;
|
||||
|
||||
memset (&mii, 0, sizeof (mii));
|
||||
mii.cbSize = sizeof (mii);
|
||||
mii.fMask = MIIM_STATE;
|
||||
GetMenuItemInfo ((HMENU) getHandle (), (UINT) id, false, &mii);
|
||||
if (mii.fState & MFS_GRAYED)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxMenu::isChecked (int id) const
|
||||
{
|
||||
MENUITEMINFO mii;
|
||||
|
||||
memset (&mii, 0, sizeof (mii));
|
||||
mii.cbSize = sizeof (mii);
|
||||
mii.fMask = MIIM_STATE;
|
||||
GetMenuItemInfo ((HMENU) getHandle (), (UINT) id, false, &mii);
|
||||
if (mii.fState & MFS_CHECKED)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
121
utils/mxtk/mxmenubar.cpp
Normal file
121
utils/mxtk/mxmenubar.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxMenuBar.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Apr 28 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxMenuBar.h"
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
class mxMenuBar_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxMenuBar::mxMenuBar (mxWindow *parent)
|
||||
: mxWidget (0, 0, 0, 0, 0)
|
||||
{
|
||||
void *handle = (void *) CreateMenu ();
|
||||
setHandle (handle);
|
||||
setType (MX_MENUBAR);
|
||||
setParent (parent);
|
||||
|
||||
if (parent)
|
||||
{
|
||||
mxWidget *w = (mxWidget *) parent;
|
||||
SetMenu ((HWND) w->getHandle (), (HMENU) handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxMenuBar::~mxMenuBar ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMenuBar::addMenu (const char *item, mxMenu *menu)
|
||||
{
|
||||
AppendMenu ((HMENU) getHandle (), MF_POPUP, (UINT) ((mxWidget *) menu)->getHandle (), item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMenuBar::setEnabled (int id, bool b)
|
||||
{
|
||||
EnableMenuItem ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | (b ? MF_ENABLED:MF_GRAYED));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMenuBar::setChecked (int id, bool b)
|
||||
{
|
||||
CheckMenuItem ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | (b ? MF_CHECKED:MF_UNCHECKED));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxMenuBar::modify (int id, int newId, const char *newItem)
|
||||
{
|
||||
ModifyMenu ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | MF_STRING, (UINT) newId, (LPCTSTR) newItem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxMenuBar::isEnabled (int id) const
|
||||
{
|
||||
MENUITEMINFO mii;
|
||||
|
||||
memset (&mii, 0, sizeof (mii));
|
||||
mii.cbSize = sizeof (mii);
|
||||
mii.fMask = MIIM_STATE;
|
||||
GetMenuItemInfo ((HMENU) getHandle (), (UINT) id, false, &mii);
|
||||
if (mii.fState & MFS_GRAYED)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxMenuBar::isChecked (int id) const
|
||||
{
|
||||
MENUITEMINFO mii;
|
||||
|
||||
memset (&mii, 0, sizeof (mii));
|
||||
mii.cbSize = sizeof (mii);
|
||||
mii.fMask = MIIM_STATE;
|
||||
GetMenuItemInfo ((HMENU) getHandle (), (UINT) id, false, &mii);
|
||||
if (mii.fState & MFS_CHECKED)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxMenuBar::getHeight () const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
63
utils/mxtk/mxmessagebox.cpp
Normal file
63
utils/mxtk/mxmessagebox.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxMessageBox.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 14 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxMessageBox.h"
|
||||
#include "mxtk/mxWindow.h"
|
||||
#include <windows.h>
|
||||
#include <commdlg.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxMessageBox (mxWindow *parent, const char *msg, const char *title, int style)
|
||||
{
|
||||
HWND hwndParent = 0;
|
||||
if (parent)
|
||||
hwndParent = (HWND) parent->getHandle ();
|
||||
|
||||
UINT uType = 0;
|
||||
|
||||
if (style & MX_MB_OK)
|
||||
uType |= MB_OK;
|
||||
else if (style & MX_MB_YESNO)
|
||||
uType |= MB_YESNO;
|
||||
else if (style & MX_MB_YESNOCANCEL)
|
||||
uType |= MB_YESNOCANCEL;
|
||||
|
||||
if (style & MX_MB_INFORMATION)
|
||||
uType |= MB_ICONINFORMATION;
|
||||
else if (style & MX_MB_ERROR)
|
||||
uType |= MB_ICONHAND;
|
||||
else if (style & MX_MB_WARNING)
|
||||
uType |= MB_ICONEXCLAMATION;
|
||||
else if (style & MX_MB_QUESTION)
|
||||
uType |= MB_ICONQUESTION;
|
||||
|
||||
int ret = MessageBox (hwndParent, msg, title, uType);
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
case IDOK:
|
||||
case IDYES:
|
||||
return 0;
|
||||
|
||||
case IDNO:
|
||||
return 1;
|
||||
|
||||
case IDCANCEL:
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
98
utils/mxtk/mxpath.cpp
Normal file
98
utils/mxtk/mxpath.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxpath.cpp
|
||||
// implementation: all
|
||||
// last modified: May 04 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxpath.h"
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h"
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mx_setcwd (const char *path)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return (SetCurrentDirectory (path) == TRUE);
|
||||
#else
|
||||
return (chdir (path) != -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
mx_getcwd ()
|
||||
{
|
||||
static char path[256];
|
||||
#ifdef WIN32
|
||||
GetCurrentDirectory (256, path);
|
||||
#else
|
||||
getcwd (path, 256);
|
||||
#endif
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
mx_getpath (const char *filename)
|
||||
{
|
||||
static char path[256];
|
||||
#ifdef WIN32
|
||||
_splitpath (filename, 0, path, 0, 0);
|
||||
#else
|
||||
strcpy (path, filename);
|
||||
char *ptr = strrchr (path, '/');
|
||||
if (ptr)
|
||||
*ptr = '\0';
|
||||
#endif
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
mx_getextension (const char *filename)
|
||||
{
|
||||
static char ext[256];
|
||||
#ifdef WIN32
|
||||
_splitpath (filename, 0, 0, 0, ext);
|
||||
#else
|
||||
char *ptr = strrchr (filename, '.');
|
||||
if (ptr)
|
||||
strcpy (ext, ptr);
|
||||
else
|
||||
strcpy (ext, "");
|
||||
#endif
|
||||
return ext;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
mx_gettemppath ()
|
||||
{
|
||||
static char path[256];
|
||||
#ifdef WIN32
|
||||
GetTempPath (256, path);
|
||||
#else
|
||||
strcpy (path, "/tmp");
|
||||
#endif
|
||||
|
||||
return path;
|
||||
}
|
||||
98
utils/mxtk/mxpcx.cpp
Normal file
98
utils/mxtk/mxpcx.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxPcx.cpp
|
||||
// implementation: all
|
||||
// last modified: Apr 15 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxPcx.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
mxImage *
|
||||
mxPcxRead (const char *filename)
|
||||
{
|
||||
FILE *file = fopen (filename, "rb");
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
mxPcxHeader header;
|
||||
if (fread (&header, sizeof (mxPcxHeader), 1, file) == -1)
|
||||
{
|
||||
fclose (file);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
if (header.bitsPerPixel != 8 ||
|
||||
header.version != 5)
|
||||
{
|
||||
fclose (file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
(void) fseek (file, -769, SEEK_END);
|
||||
if (fgetc (file) != 12) {
|
||||
fclose (file);
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
(void) fseek (file, -768, SEEK_END);
|
||||
|
||||
int w = header.xmax - header.xmin + 1;
|
||||
int h = header.ymax - header.ymin + 1;
|
||||
|
||||
mxImage *image = new mxImage ();
|
||||
if (!image->create (w, h, 8))
|
||||
{
|
||||
delete image;
|
||||
fclose (file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fread ((byte *) image->palette, sizeof (byte), 768, file) == -1)
|
||||
{
|
||||
fclose (file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
(void) fseek(file, sizeof (mxPcxHeader), SEEK_SET);
|
||||
int ptr = 0;
|
||||
int ch, rep;
|
||||
byte *data = (byte *) image->data;
|
||||
int size = w * h;
|
||||
while (ptr < size)
|
||||
{
|
||||
ch = fgetc(file);
|
||||
if (ch >= 192)
|
||||
{
|
||||
rep = ch - 192;
|
||||
ch = fgetc(file);
|
||||
}
|
||||
else {
|
||||
rep = 1;
|
||||
}
|
||||
|
||||
while (rep--)
|
||||
data[ptr++] = (byte)ch;
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxPcxWrite (const char * /*filename*/, mxImage * /*image*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
126
utils/mxtk/mxpopupmenu.cpp
Normal file
126
utils/mxtk/mxpopupmenu.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxPopupMenu.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxPopupMenu.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class mxPopupMenu_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxPopupMenu::mxPopupMenu ()
|
||||
: mxWidget (0, 0, 0, 0, 0)
|
||||
{
|
||||
void *handle = (void *) CreatePopupMenu ();
|
||||
setHandle (handle);
|
||||
setType (MX_POPUPMENU);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxPopupMenu::~mxPopupMenu ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxPopupMenu::popup (mxWidget *widget, int x, int y)
|
||||
{
|
||||
POINT pt;
|
||||
pt.x = x;
|
||||
pt.y = y;
|
||||
|
||||
ClientToScreen ((HWND) widget->getHandle (), &pt);
|
||||
return (int) TrackPopupMenu ((HMENU) getHandle (), /*TPM_NONOTIFY | TPM_RETURNCMD | */ TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, 0, (HWND) widget->getHandle (), NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxPopupMenu::add (const char *item, int id)
|
||||
{
|
||||
AppendMenu ((HMENU) getHandle (), MF_STRING, (UINT) id, item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxPopupMenu::addMenu (const char *item, mxPopupMenu *menu)
|
||||
{
|
||||
AppendMenu ((HMENU) getHandle (), MF_POPUP, (UINT) menu->getHandle (), item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxPopupMenu::addSeparator ()
|
||||
{
|
||||
AppendMenu ((HMENU) getHandle (), MF_SEPARATOR, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxPopupMenu::setEnabled (int id, bool b)
|
||||
{
|
||||
EnableMenuItem ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | (b ? MF_ENABLED:MF_GRAYED));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxPopupMenu::setChecked (int id, bool b)
|
||||
{
|
||||
CheckMenuItem ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | (b ? MF_CHECKED:MF_UNCHECKED));
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxPopupMenu::isEnabled (int id) const
|
||||
{
|
||||
MENUITEMINFO mii;
|
||||
|
||||
memset (&mii, 0, sizeof (mii));
|
||||
mii.cbSize = sizeof (mii);
|
||||
mii.fMask = MIIM_STATE;
|
||||
GetMenuItemInfo ((HMENU) getHandle (), (UINT) id, false, &mii);
|
||||
if (mii.fState & MFS_GRAYED)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxPopupMenu::isChecked (int id) const
|
||||
{
|
||||
MENUITEMINFO mii;
|
||||
|
||||
memset (&mii, 0, sizeof (mii));
|
||||
mii.cbSize = sizeof (mii);
|
||||
mii.fMask = MIIM_STATE;
|
||||
GetMenuItemInfo ((HMENU) getHandle (), (UINT) id, false, &mii);
|
||||
if (mii.fState & MFS_CHECKED)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
89
utils/mxtk/mxprogressbar.cpp
Normal file
89
utils/mxtk/mxprogressbar.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxProgressBar.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxProgressBar.h"
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
|
||||
|
||||
class mxProgressBar_i
|
||||
{
|
||||
public:
|
||||
int d_value;
|
||||
int d_steps;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxProgressBar::mxProgressBar (mxWindow *parent, int x, int y, int w, int h, int style)
|
||||
: mxWidget (parent, x, y, w, h)
|
||||
{
|
||||
d_this = new mxProgressBar_i;
|
||||
|
||||
DWORD dwStyle = WS_VISIBLE | WS_CHILD;
|
||||
HWND hwndParent = parent ? (HWND) ((mxWidget *) parent)->getHandle () : NULL;
|
||||
|
||||
if (style == Smooth)
|
||||
dwStyle |= PBS_SMOOTH;
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, PROGRESS_CLASS, "", dwStyle,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) NULL, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_PROGRESSBAR);
|
||||
setParent (parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxProgressBar::~mxProgressBar ()
|
||||
{
|
||||
delete d_this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxProgressBar::setValue (int value)
|
||||
{
|
||||
d_this->d_value = value;
|
||||
SendMessage ((HWND) getHandle (), PBM_SETPOS, (WPARAM) value, 0L);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mxProgressBar::setTotalSteps (int steps)
|
||||
{
|
||||
d_this->d_steps = steps;
|
||||
SendMessage ((HWND) getHandle (), PBM_SETRANGE, 0, MAKELPARAM (0, steps));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxProgressBar::getValue () const
|
||||
{
|
||||
return d_this->d_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxProgressBar::getTotalSteps () const
|
||||
{
|
||||
return d_this->d_steps;
|
||||
}
|
||||
74
utils/mxtk/mxradiobutton.cpp
Normal file
74
utils/mxtk/mxradiobutton.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxRadioButton.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxRadioButton.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class mxRadioButton_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxRadioButton::mxRadioButton (mxWindow *parent, int x, int y, int w, int h, const char *label, int id, bool newGroup)
|
||||
: mxWidget (parent, x, y, w, h, label)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
DWORD dwStyle = WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON;
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
if (newGroup)
|
||||
dwStyle |= WS_GROUP;
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, "BUTTON", label, dwStyle,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_RADIOBUTTON);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
|
||||
setChecked (newGroup);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxRadioButton::~mxRadioButton ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxRadioButton::setChecked (bool b)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), BM_SETCHECK, (WPARAM) b ? BST_CHECKED:BST_UNCHECKED, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxRadioButton::isChecked () const
|
||||
{
|
||||
return (SendMessage ((HWND) getHandle (), BM_GETCHECK, 0, 0L) == BST_CHECKED);
|
||||
}
|
||||
134
utils/mxtk/mxscrollbar.cpp
Normal file
134
utils/mxtk/mxscrollbar.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxScrollbar.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxScrollbar.h"
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
|
||||
|
||||
class mxScrollbar_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxScrollbar::mxScrollbar (mxWindow *parent, int x, int y, int w, int h, int id, int style)
|
||||
: mxWidget (parent, x, y, w, h)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
DWORD dwStyle = WS_CHILD | WS_VISIBLE;
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
if (style == Horizontal)
|
||||
dwStyle = WS_CHILD | WS_VISIBLE | SBS_HORZ | SBS_RIGHTALIGN;
|
||||
else if (style == Vertical)
|
||||
dwStyle = WS_CHILD | WS_VISIBLE | SBS_VERT | SBS_RIGHTALIGN; // WS_VSCROLL;
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, "SCROLLBAR", "", dwStyle,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_SCROLLBAR);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxScrollbar::~mxScrollbar ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxScrollbar::setValue (int ivalue)
|
||||
{
|
||||
SetScrollPos( (HWND) getHandle (), SB_CTL, ivalue, FALSE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxScrollbar::setRange (int min, int max )
|
||||
{
|
||||
SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_RANGE, min, max, 0, 0, 0 };
|
||||
|
||||
SetScrollInfo( (HWND) getHandle (), SB_CTL, &si, TRUE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxScrollbar::setPagesize (int size)
|
||||
{
|
||||
SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_PAGE, 0, 0, (UINT)size, 0, 0 };
|
||||
|
||||
SetScrollInfo( (HWND) getHandle (), SB_CTL, &si, TRUE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxScrollbar::getValue () const
|
||||
{
|
||||
// SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_POS | SIF_TRACKPOS, 0, 0, 0, 0, 0 };
|
||||
// GetScrollInfo( (HWND) getHandle (), SB_CTL, &si );
|
||||
// return si.nPos;
|
||||
return GetScrollPos( (HWND) getHandle (), SB_CTL );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxScrollbar::getMinValue () const
|
||||
{
|
||||
SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_RANGE, 0, 0, 0, 0, 0 };
|
||||
|
||||
GetScrollInfo( (HWND) getHandle (), SB_CTL, &si );
|
||||
|
||||
return si.nMin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxScrollbar::getMaxValue () const
|
||||
{
|
||||
SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_RANGE, 0, 0, 0, 0, 0 };
|
||||
|
||||
GetScrollInfo( (HWND) getHandle (), SB_CTL, &si );
|
||||
|
||||
return si.nMax;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxScrollbar::getPagesize () const
|
||||
{
|
||||
SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_PAGE, 0, 0, 0, 0, 0 };
|
||||
|
||||
GetScrollInfo( (HWND) getHandle (), SB_CTL, &si );
|
||||
|
||||
return si.nPage;
|
||||
}
|
||||
137
utils/mxtk/mxslider.cpp
Normal file
137
utils/mxtk/mxslider.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxSlider.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxSlider.h"
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
|
||||
|
||||
class mxSlider_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxSlider::mxSlider (mxWindow *parent, int x, int y, int w, int h, int id, int style)
|
||||
: mxWidget (parent, x, y, w, h)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
DWORD dwStyle = WS_CHILD | WS_VISIBLE;
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
if (style == Horizontal)
|
||||
dwStyle = WS_CHILD | WS_VISIBLE | TBS_HORZ;
|
||||
else if (style == Vertical)
|
||||
dwStyle = WS_CHILD | WS_VISIBLE | TBS_VERT;
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, TRACKBAR_CLASS, "", dwStyle,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_SLIDER);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxSlider::~mxSlider ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxSlider::setValue (float value)
|
||||
{
|
||||
int ivalue = (int)((((value - m_min) / (m_max - m_min)) * m_ticks) + 0.5);
|
||||
SendMessage ((HWND) getHandle (), TBM_SETPOS, (WPARAM) true, (LPARAM) ivalue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxSlider::setRange (float min, float max, int ticks)
|
||||
{
|
||||
m_min = min;
|
||||
m_max = max;
|
||||
m_ticks = ticks;
|
||||
SendMessage ((HWND) getHandle (), TBM_SETRANGE, (WPARAM) true, (LPARAM) MAKELONG(0, ticks));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxSlider::setSteps (int line, int page)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), TBM_SETLINESIZE, 0, (LPARAM) line);
|
||||
SendMessage ((HWND) getHandle (), TBM_SETPAGESIZE, 0, (LPARAM) page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
float
|
||||
mxSlider::getValue () const
|
||||
{
|
||||
int ivalue = SendMessage ((HWND) getHandle (), TBM_GETPOS, 0, 0L);
|
||||
return (ivalue / (float)m_ticks) * (m_max - m_min) + m_min;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
mxSlider::getTrackValue ( int ivalue ) const
|
||||
{
|
||||
return (ivalue / (float)m_ticks) * (m_max - m_min) + m_min;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
mxSlider::getMinValue () const
|
||||
{
|
||||
return m_min;
|
||||
// return (int) SendMessage ((HWND) getHandle (), TBM_GETRANGEMIN, 0, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
float
|
||||
mxSlider::getMaxValue () const
|
||||
{
|
||||
return m_max;
|
||||
// return (int) SendMessage ((HWND) getHandle (), TBM_GETRANGEMAX, 0, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxSlider::getLineStep () const
|
||||
{
|
||||
return (int) SendMessage ((HWND) getHandle (), TBM_GETLINESIZE, 0, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxSlider::getPageStep () const
|
||||
{
|
||||
return (int) SendMessage ((HWND) getHandle (), TBM_GETPAGESIZE, 0, 0L);
|
||||
}
|
||||
54
utils/mxtk/mxstring.cpp
Normal file
54
utils/mxtk/mxstring.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxstring.cpp
|
||||
// implementation: all
|
||||
// last modified: May 04 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxstring.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
|
||||
int
|
||||
mx_strncasecmp (const char *s1, const char *s2, int count)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return _strnicmp (s1, s2, count);
|
||||
#else
|
||||
return strncasecmp (s1, s2, count);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mx_strcasecmp (const char *s1, const char *s2)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return _stricmp (s1, s2);
|
||||
#else
|
||||
return strcasecmp (s1, s2);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char *
|
||||
mx_strlower (char *str)
|
||||
{
|
||||
int i;
|
||||
for (i = (int)strlen (str) - 1; i >= 0; i--)
|
||||
str[i] = (char)tolower (str[i]);
|
||||
return str;
|
||||
}
|
||||
130
utils/mxtk/mxtab.cpp
Normal file
130
utils/mxtk/mxtab.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxTab.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Apr 18 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxTab.h"
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
class mxTab_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void mxTab_resizeChild (HWND hwnd)
|
||||
{
|
||||
TC_ITEM ti;
|
||||
|
||||
int index = TabCtrl_GetCurSel (hwnd);
|
||||
if (index >= 0)
|
||||
{
|
||||
ti.mask = TCIF_PARAM;
|
||||
TabCtrl_GetItem (hwnd, index, &ti);
|
||||
mxWidget *widget = (mxWidget *) ti.lParam;
|
||||
if (widget)
|
||||
{
|
||||
RECT rc, rc2;
|
||||
|
||||
GetWindowRect (hwnd, &rc);
|
||||
ScreenToClient (GetParent (hwnd), (LPPOINT) &rc.left);
|
||||
ScreenToClient (GetParent (hwnd), (LPPOINT) &rc.right);
|
||||
|
||||
TabCtrl_GetItemRect (hwnd, index, &rc2);
|
||||
|
||||
int ex = GetSystemMetrics (SM_CXEDGE);
|
||||
int ey = GetSystemMetrics (SM_CYEDGE);
|
||||
rc.top += (rc2.bottom - rc2.top) + 3 * ey;
|
||||
rc.left += 2 * ex;
|
||||
rc.right -= 2 * ex;
|
||||
rc.bottom -= 2 * ey;
|
||||
HDWP hdwp = BeginDeferWindowPos (2);
|
||||
DeferWindowPos (hdwp, hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
|
||||
DeferWindowPos (hdwp, (HWND) widget->getHandle (), HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
|
||||
EndDeferWindowPos (hdwp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxTab::mxTab (mxWindow *parent, int x, int y, int w, int h, int id)
|
||||
: mxWidget (parent, x, y, w, h)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, WC_TABCONTROL, "", dwStyle,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_TAB);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxTab::~mxTab ()
|
||||
{
|
||||
//TabCtrl_DeleteAllItems ((HWND) getHandle ());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxTab::add (mxWidget *widget, const char *text)
|
||||
{
|
||||
TC_ITEM ti;
|
||||
|
||||
ti.mask = TCIF_TEXT | TCIF_PARAM;
|
||||
ti.pszText = (LPSTR) text;
|
||||
ti.lParam = (LPARAM) widget;
|
||||
|
||||
TabCtrl_InsertItem ((HWND) getHandle (), TabCtrl_GetItemCount ((HWND) getHandle ()), &ti);
|
||||
mxTab_resizeChild ((HWND) getHandle ());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxTab::remove (int index)
|
||||
{
|
||||
TabCtrl_DeleteItem ((HWND) getHandle (), index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxTab::select (int index)
|
||||
{
|
||||
TabCtrl_SetCurSel ((HWND) getHandle (), index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxTab::getSelectedIndex () const
|
||||
{
|
||||
return (int) TabCtrl_GetCurSel ((HWND) getHandle ());
|
||||
}
|
||||
140
utils/mxtk/mxtga.cpp
Normal file
140
utils/mxtk/mxtga.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxTga.cpp
|
||||
// implementation: all
|
||||
// last modified: Apr 15 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxTga.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
mxImage *
|
||||
mxTgaRead (const char *filename)
|
||||
{
|
||||
FILE *file;
|
||||
file = fopen (filename, "rb");
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
byte identFieldLength;
|
||||
byte colorMapType;
|
||||
byte imageTypeCode;
|
||||
fread (&identFieldLength, sizeof (byte), 1, file);
|
||||
fread (&colorMapType, sizeof (byte), 1, file);
|
||||
fread (&imageTypeCode, sizeof (byte), 1, file);
|
||||
|
||||
fseek (file, 12, SEEK_SET);
|
||||
|
||||
word width, height;
|
||||
byte pixelSize;
|
||||
fread (&width, sizeof (word), 1, file);
|
||||
fread (&height, sizeof (word), 1, file);
|
||||
fread (&pixelSize, sizeof (byte), 1, file);
|
||||
|
||||
// only 24-bit RGB uncompressed
|
||||
if (colorMapType != 0 ||
|
||||
imageTypeCode != 2 ||
|
||||
pixelSize != 24)
|
||||
{
|
||||
fclose (file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek (file, 18 + identFieldLength, SEEK_SET);
|
||||
|
||||
mxImage *image = new mxImage ();
|
||||
if (!image->create (width, height, 24))
|
||||
{
|
||||
delete image;
|
||||
fclose (file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
byte *data = (byte *) image->data;
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
byte *scanline = (byte *) &data[(height - y - 1) * width * 3];
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
scanline[x * 3 + 2] = (byte) fgetc (file);
|
||||
scanline[x * 3 + 1] = (byte) fgetc (file);
|
||||
scanline[x * 3 + 0] = (byte) fgetc (file);
|
||||
//scanline[x * 4 + 3] = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
fclose (file);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxTgaWrite (const char *filename, mxImage *image)
|
||||
{
|
||||
if (!image)
|
||||
return false;
|
||||
|
||||
if (image->bpp != 24)
|
||||
return false;
|
||||
|
||||
FILE *file = fopen (filename, "wb");
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
//
|
||||
// write header
|
||||
//
|
||||
fputc (0, file); // identFieldLength
|
||||
fputc (0, file); // colorMapType == 0, no color map
|
||||
fputc (2, file); // imageTypeCode == 2, uncompressed RGB
|
||||
|
||||
word w = 0;
|
||||
fwrite (&w, sizeof (word), 1, file); // colorMapOrigin
|
||||
fwrite (&w, sizeof (word), 1, file); // colorMapLength
|
||||
fputc (0, file); // colorMapEntrySize
|
||||
|
||||
fwrite (&w, sizeof (word), 1, file); // imageOriginX
|
||||
fwrite (&w, sizeof (word), 1, file); // imageOriginY
|
||||
|
||||
w = (word) image->width;
|
||||
fwrite (&w, sizeof (word), 1, file); // imageWidth
|
||||
|
||||
w = (word) image->height;
|
||||
fwrite (&w, sizeof (word), 1, file); // imageHeight
|
||||
|
||||
fputc (24, file); // imagePixelSize
|
||||
fputc (0, file); // imageDescriptorByte
|
||||
|
||||
// write no ident field
|
||||
|
||||
// write no color map
|
||||
|
||||
// write imagedata
|
||||
|
||||
byte *data = (byte *) image->data;
|
||||
for (int y = 0; y < image->height; y++)
|
||||
{
|
||||
byte *scanline = (byte *) &data[(image->height - y - 1) * image->width * 3];
|
||||
for (int x = 0; x < image->width; x++)
|
||||
{
|
||||
fputc ((byte) scanline[x * 3 + 2], file);
|
||||
fputc ((byte) scanline[x * 3 + 1], file);
|
||||
fputc ((byte) scanline[x * 3 + 0], file);
|
||||
}
|
||||
}
|
||||
|
||||
fclose (file);
|
||||
|
||||
return true;
|
||||
}
|
||||
69
utils/mxtk/mxtogglebutton.cpp
Normal file
69
utils/mxtk/mxtogglebutton.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxToggleButton.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Apr 28 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include <mx/mxToggleButton.h>
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
class mxToggleButton_i
|
||||
{
|
||||
public:
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxToggleButton::mxToggleButton (mxWindow *parent, int x, int y, int w, int h, const char *label, int id)
|
||||
: mxWidget (parent, x, y, w, h, label)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, "BUTTON", label, WS_VISIBLE | WS_CHILD | BS_PUSHLIKE | BS_AUTOCHECKBOX | WS_TABSTOP,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_TOGGLEBUTTON);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
setChecked (false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxToggleButton::~mxToggleButton ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxToggleButton::setChecked (bool b)
|
||||
{
|
||||
SendMessage ((HWND) getHandle (), BM_SETCHECK, (WPARAM) b ? BST_CHECKED:BST_UNCHECKED, 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxToggleButton::isChecked () const
|
||||
{
|
||||
return (SendMessage ((HWND) getHandle (), BM_GETCHECK, 0, 0L) == BST_CHECKED);
|
||||
}
|
||||
99
utils/mxtk/mxtoolkitwin32.vpc
Normal file
99
utils/mxtk/mxtoolkitwin32.vpc
Normal file
@@ -0,0 +1,99 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// MXTOOLKITWIN32.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
// ***** AUTO-GENERATED: PLEASE FIXUP MANUALLY BEFORE USING THIS SCRIPT! *****
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro OUTLIBDIR "$SRCDIR\lib\common"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_lib_win32_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE,..\..\public"
|
||||
$PreprocessorDefinitions "$BASE;_CRT_SECURE_NO_DEPRECATE"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Mxtoolkitwin32"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
$File "mx.cpp"
|
||||
$File "mxbmp.cpp"
|
||||
$File "mxbutton.cpp"
|
||||
$File "mxcheckbox.cpp"
|
||||
$File "mxchoice.cpp"
|
||||
$File "mxchoosecolor.cpp"
|
||||
$File "mxfiledialog.cpp"
|
||||
$File "mxglwindow.cpp"
|
||||
$File "mxgroupbox.cpp"
|
||||
$File "mxlabel.cpp"
|
||||
$File "mxlineedit.cpp"
|
||||
$File "mxlistbox.cpp"
|
||||
$File "mxlistview.cpp"
|
||||
$File "mxmatsyswindow.cpp"
|
||||
$File "mxmenu.cpp"
|
||||
$File "mxmenubar.cpp"
|
||||
$File "mxmessagebox.cpp"
|
||||
$File "mxpath.cpp"
|
||||
$File "mxpcx.cpp"
|
||||
$File "mxpopupmenu.cpp"
|
||||
$File "mxprogressbar.cpp"
|
||||
$File "mxradiobutton.cpp"
|
||||
$File "mxscrollbar.cpp"
|
||||
$File "mxslider.cpp"
|
||||
$File "mxstring.cpp"
|
||||
$File "mxtab.cpp"
|
||||
$File "mxtga.cpp"
|
||||
$File "mxtooltip.cpp"
|
||||
$File "mxtreeview.cpp"
|
||||
$File "mxwidget.cpp"
|
||||
$File "mxwindow.cpp"
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
$File "..\..\public\mxtk\gl.h"
|
||||
$File "..\..\public\mxtk\mx.h"
|
||||
$File "..\..\public\mxtk\mxbmp.h"
|
||||
$File "..\..\public\mxtk\mxbutton.h"
|
||||
$File "..\..\public\mxtk\mxcheckbox.h"
|
||||
$File "..\..\public\mxtk\mxchoice.h"
|
||||
$File "..\..\public\mxtk\mxchoosecolor.h"
|
||||
$File "..\..\public\mxtk\mxevent.h"
|
||||
$File "..\..\public\mxtk\mxfiledialog.h"
|
||||
$File "..\..\public\mxtk\mxglwindow.h"
|
||||
$File "..\..\public\mxtk\mxgroupbox.h"
|
||||
$File "..\..\public\mxtk\mximage.h"
|
||||
$File "..\..\public\mxtk\mxinit.h"
|
||||
$File "..\..\public\mxtk\mxlabel.h"
|
||||
$File "..\..\public\mxtk\mxlineedit.h"
|
||||
$File "..\..\public\mxtk\mxlinkedlist.h"
|
||||
$File "..\..\public\mxtk\mxlistbox.h"
|
||||
$File "..\..\public\mxtk\mxlistview.h"
|
||||
$File "..\..\public\mxtk\mxmatsyswindow.h"
|
||||
$File "..\..\public\mxtk\mxmenu.h"
|
||||
$File "..\..\public\mxtk\mxmenubar.h"
|
||||
$File "..\..\public\mxtk\mxmessagebox.h"
|
||||
$File "..\..\public\mxtk\mxpath.h"
|
||||
$File "..\..\public\mxtk\mxpcx.h"
|
||||
$File "..\..\public\mxtk\mxpopupmenu.h"
|
||||
$File "..\..\public\mxtk\mxprogressbar.h"
|
||||
$File "..\..\public\mxtk\mxradiobutton.h"
|
||||
$File "..\..\public\mxtk\mxscrollbar.h"
|
||||
$File "..\..\public\mxtk\mxslider.h"
|
||||
$File "..\..\public\mxtk\mxstring.h"
|
||||
$File "..\..\public\mxtk\mxtab.h"
|
||||
$File "..\..\public\mxtk\mxtga.h"
|
||||
$File "..\..\public\mxtk\mxtogglebutton.h"
|
||||
$File "..\..\public\mxtk\mxtooltip.h"
|
||||
$File "..\..\public\mxtk\mxtreeview.h"
|
||||
$File "..\..\public\mxtk\mxwidget.h"
|
||||
$File "..\..\public\mxtk\mxwindow.h"
|
||||
}
|
||||
}
|
||||
13
utils/mxtk/mxtoolkitwin32.vpc.vpc_cache
Normal file
13
utils/mxtk/mxtoolkitwin32.vpc.vpc_cache
Normal file
@@ -0,0 +1,13 @@
|
||||
"vpc_cache"
|
||||
{
|
||||
"CacheVersion" "1"
|
||||
"win32"
|
||||
{
|
||||
"CRCFile" "mxtoolkitwin32.vcxproj.vpc_crc"
|
||||
"OutputFiles"
|
||||
{
|
||||
"0" "mxtoolkitwin32.vcxproj"
|
||||
"1" "mxtoolkitwin32.vcxproj.filters"
|
||||
}
|
||||
}
|
||||
}
|
||||
41
utils/mxtk/mxtooltip.cpp
Normal file
41
utils/mxtk/mxtooltip.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxToolTip.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 14 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxToolTip.h"
|
||||
#include "mxtk/mxWidget.h"
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
|
||||
|
||||
HWND mx_CreateToolTipControl (void);
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxToolTip::add (mxWidget *widget, const char *text)
|
||||
{
|
||||
if (!widget)
|
||||
return;
|
||||
|
||||
TOOLINFO ti;
|
||||
|
||||
memset (&ti, 0, sizeof (TOOLINFO));
|
||||
ti.cbSize = sizeof (TOOLINFO);
|
||||
ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
|
||||
ti.uId = (UINT) (HWND) widget->getHandle ();
|
||||
ti.lpszText = (LPTSTR) text;
|
||||
|
||||
HWND ctrl = mx_CreateToolTipControl ();
|
||||
SendMessage (ctrl, TTM_ADDTOOL, 0, (LPARAM) &ti);
|
||||
}
|
||||
356
utils/mxtk/mxtreeview.cpp
Normal file
356
utils/mxtk/mxtreeview.cpp
Normal file
@@ -0,0 +1,356 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxTreeView.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: May 03 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxTreeView.h"
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
|
||||
|
||||
class mxTreeView_i
|
||||
{
|
||||
public:
|
||||
HWND d_hwnd;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxTreeView::mxTreeView (mxWindow *parent, int x, int y, int w, int h, int id)
|
||||
: mxWidget (parent, x, y, w, h)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
d_this = new mxTreeView_i;
|
||||
|
||||
DWORD dwStyle = TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_VISIBLE | WS_CHILD;
|
||||
HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
|
||||
|
||||
d_this->d_hwnd = CreateWindowEx (WS_EX_CLIENTEDGE, WC_TREEVIEW, "", dwStyle,
|
||||
x, y, w, h, hwndParent,
|
||||
(HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SendMessage (d_this->d_hwnd, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
|
||||
SetWindowLong (d_this->d_hwnd, GWL_USERDATA, (LONG) this);
|
||||
|
||||
setHandle ((void *) d_this->d_hwnd);
|
||||
setType (MX_TREEVIEW);
|
||||
setParent (parent);
|
||||
setId (id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxTreeView::~mxTreeView ()
|
||||
{
|
||||
remove (0);
|
||||
delete d_this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxTreeViewItem*
|
||||
mxTreeView::add (mxTreeViewItem *parent, const char *item)
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
TV_ITEM tvItem;
|
||||
tvItem.mask = TVIF_TEXT;
|
||||
tvItem.pszText = (LPSTR) item;
|
||||
tvItem.cchTextMax = 256;
|
||||
|
||||
HTREEITEM hParent;
|
||||
if (!parent)
|
||||
hParent = TVI_ROOT;
|
||||
else
|
||||
hParent = (HTREEITEM) parent;
|
||||
|
||||
TV_INSERTSTRUCT tvInsert;
|
||||
tvInsert.hParent = hParent;
|
||||
tvInsert.hInsertAfter = TVI_LAST;
|
||||
tvInsert.item = tvItem;
|
||||
|
||||
return (mxTreeViewItem *) TreeView_InsertItem (d_this->d_hwnd, &tvInsert);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mxTreeView::remove (mxTreeViewItem *item)
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
if (!item)
|
||||
TreeView_DeleteAllItems (d_this->d_hwnd);
|
||||
else
|
||||
TreeView_DeleteItem (d_this->d_hwnd, (HTREEITEM) item);
|
||||
}
|
||||
|
||||
void
|
||||
mxTreeView::removeAll ()
|
||||
{
|
||||
remove( 0 );
|
||||
}
|
||||
|
||||
void
|
||||
mxTreeView::setLabel (mxTreeViewItem *item, const char *label)
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
if (item)
|
||||
{
|
||||
TV_ITEM tvItem;
|
||||
tvItem.mask = TVIF_HANDLE | TVIF_TEXT;
|
||||
tvItem.hItem = (HTREEITEM) item;
|
||||
tvItem.pszText = (LPSTR) label;
|
||||
tvItem.cchTextMax = 256;
|
||||
|
||||
TreeView_SetItem (d_this->d_hwnd, &tvItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxTreeView::setUserData (mxTreeViewItem *item, void *userData)
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
if (item)
|
||||
{
|
||||
TV_ITEM tvItem;
|
||||
tvItem.mask = TVIF_HANDLE | TVIF_PARAM;
|
||||
tvItem.hItem = (HTREEITEM) item;
|
||||
tvItem.lParam = (LPARAM) userData;
|
||||
|
||||
TreeView_SetItem (d_this->d_hwnd, &tvItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxTreeView::setOpen (mxTreeViewItem *item, bool b)
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
if (item)
|
||||
TreeView_Expand (d_this->d_hwnd, (HTREEITEM) item, b ? TVE_EXPAND:TVE_COLLAPSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxTreeView::setSelected (mxTreeViewItem *item, bool b)
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
if (item)
|
||||
TreeView_SelectItem (d_this->d_hwnd, (HTREEITEM) item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxTreeViewItem*
|
||||
mxTreeView::getFirstChild (mxTreeViewItem *item) const
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
return (mxTreeViewItem *) TreeView_GetChild (d_this->d_hwnd, item ? (HTREEITEM) item:TVI_ROOT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxTreeViewItem*
|
||||
mxTreeView::getNextChild (mxTreeViewItem *item) const
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
if (item)
|
||||
return (mxTreeViewItem *) TreeView_GetNextSibling (d_this->d_hwnd, (HTREEITEM) item);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxTreeViewItem*
|
||||
mxTreeView::getSelectedItem () const
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
return (mxTreeViewItem *) TreeView_GetSelection (d_this->d_hwnd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char*
|
||||
mxTreeView::getLabel (mxTreeViewItem *item) const
|
||||
{
|
||||
static char label[256];
|
||||
strcpy (label, "");
|
||||
|
||||
if (!d_this)
|
||||
return label;
|
||||
|
||||
if (item)
|
||||
{
|
||||
TV_ITEM tvItem;
|
||||
tvItem.mask = TVIF_HANDLE | TVIF_TEXT;
|
||||
tvItem.hItem = (HTREEITEM) item;
|
||||
tvItem.pszText = (LPSTR) label;
|
||||
tvItem.cchTextMax = 256;
|
||||
|
||||
TreeView_GetItem (d_this->d_hwnd, &tvItem);
|
||||
|
||||
return tvItem.pszText;
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void*
|
||||
mxTreeView::getUserData (mxTreeViewItem *item) const
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
if (item)
|
||||
{
|
||||
TV_ITEM tvItem;
|
||||
tvItem.mask = TVIF_HANDLE | TVIF_PARAM;
|
||||
tvItem.hItem = (HTREEITEM) item;
|
||||
|
||||
TreeView_GetItem (d_this->d_hwnd, &tvItem);
|
||||
|
||||
return (void *) tvItem.lParam;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxTreeView::isOpen (mxTreeViewItem *item) const
|
||||
{
|
||||
if (!d_this)
|
||||
return false;
|
||||
|
||||
if (item)
|
||||
{
|
||||
TV_ITEM tvItem;
|
||||
tvItem.mask = TVIF_HANDLE | TVIF_STATE;
|
||||
tvItem.hItem = (HTREEITEM) item;
|
||||
tvItem.stateMask = TVIS_STATEIMAGEMASK;
|
||||
|
||||
TreeView_GetItem (d_this->d_hwnd, &tvItem);
|
||||
|
||||
return ((tvItem.state & TVIS_EXPANDED) == TVIS_EXPANDED);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxTreeView::isSelected (mxTreeViewItem *item) const
|
||||
{
|
||||
if (!d_this)
|
||||
return false;
|
||||
|
||||
if (item)
|
||||
{
|
||||
TV_ITEM tvItem;
|
||||
tvItem.mask = TVIF_HANDLE | TVIF_STATE;
|
||||
tvItem.hItem = (HTREEITEM) item;
|
||||
tvItem.stateMask = TVIS_STATEIMAGEMASK;
|
||||
|
||||
TreeView_GetItem (d_this->d_hwnd, &tvItem);
|
||||
|
||||
return ((tvItem.state & TVIS_SELECTED) == TVIS_SELECTED);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxTreeViewItem *
|
||||
mxTreeView::getParent (mxTreeViewItem *item) const
|
||||
{
|
||||
if (!d_this)
|
||||
return 0;
|
||||
|
||||
if (item)
|
||||
return (mxTreeViewItem *) TreeView_GetParent (d_this->d_hwnd, (HTREEITEM) item);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mxTreeView::setImageList( void *himagelist )
|
||||
{
|
||||
TreeView_SetImageList(d_this->d_hwnd, (HIMAGELIST)himagelist, TVSIL_NORMAL);
|
||||
}
|
||||
|
||||
void mxTreeView::setImages(mxTreeViewItem *item, int imagenormal, int imageselected )
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
if (item)
|
||||
{
|
||||
TV_ITEM tvItem;
|
||||
tvItem.mask = TVIF_HANDLE | TVIF_SELECTEDIMAGE | TVIF_IMAGE ;
|
||||
tvItem.hItem = (HTREEITEM) item;
|
||||
tvItem.iImage = imagenormal;
|
||||
tvItem.iSelectedImage = imageselected;
|
||||
tvItem.stateMask = TVIS_STATEIMAGEMASK;
|
||||
|
||||
TreeView_SetItem (d_this->d_hwnd, &tvItem);
|
||||
}
|
||||
}
|
||||
void mxTreeView::sortTree( mxTreeViewItem *parent, bool recurse,
|
||||
void *func, int parameter )
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
TVSORTCB cb;
|
||||
memset( &cb, 0, sizeof( cb ) );
|
||||
|
||||
cb.hParent = (HTREEITEM)parent;
|
||||
cb.lParam = parameter;
|
||||
cb.lpfnCompare = (int (__stdcall *)(long,long,long)) func;
|
||||
|
||||
TreeView_SortChildrenCB( d_this->d_hwnd, &cb, recurse );
|
||||
}
|
||||
|
||||
void mxTreeView::scrollTo( mxTreeViewItem *item )
|
||||
{
|
||||
if (!d_this)
|
||||
return;
|
||||
|
||||
TreeView_EnsureVisible( d_this->d_hwnd, item );
|
||||
}
|
||||
306
utils/mxtk/mxwidget.cpp
Normal file
306
utils/mxtk/mxwidget.cpp
Normal file
@@ -0,0 +1,306 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxWidget.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Mar 19 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxWidget.h"
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void mxTab_resizeChild (HWND hwnd);
|
||||
void mx_addWidget (mxWidget *widget);
|
||||
void mx_removeWidget (mxWidget *widget);
|
||||
|
||||
|
||||
|
||||
class mxWidget_i
|
||||
{
|
||||
public:
|
||||
mxWindow *d_parent_p;
|
||||
HWND d_hwnd;
|
||||
void *d_userData;
|
||||
int d_type;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxWidget::mxWidget (mxWindow *parent, int x, int y, int w, int h, const char *label)
|
||||
{
|
||||
d_this = new mxWidget_i;
|
||||
|
||||
setHandle (0);
|
||||
setType (-1);
|
||||
setParent (parent);
|
||||
setBounds (x, y, w, h);
|
||||
setVisible (true);
|
||||
setEnabled (true);
|
||||
setId (0);
|
||||
setUserData (0);
|
||||
setLabel (label);
|
||||
|
||||
mx_addWidget (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxWidget::~mxWidget ()
|
||||
{
|
||||
mx_removeWidget (this);
|
||||
|
||||
if (d_this->d_type == MX_MENU ||
|
||||
d_this->d_type == MX_MENUBAR ||
|
||||
d_this->d_type == MX_POPUPMENU)
|
||||
DestroyMenu ((HMENU) d_this->d_hwnd);
|
||||
else
|
||||
DestroyWindow (d_this->d_hwnd);
|
||||
|
||||
delete d_this;
|
||||
}
|
||||
|
||||
bool mxWidget::CanClose()
|
||||
{
|
||||
// Assume yes
|
||||
return true;
|
||||
}
|
||||
|
||||
void mxWidget::OnDelete()
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
|
||||
void
|
||||
mxWidget::setHandle (void *handle)
|
||||
{
|
||||
d_this->d_hwnd = (HWND) handle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxWidget::setType (int type)
|
||||
{
|
||||
d_this->d_type = type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxWidget::setParent (mxWindow *parentWindow)
|
||||
{
|
||||
d_this->d_parent_p = parentWindow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxWidget::setBounds (int x, int y, int w, int h)
|
||||
{
|
||||
char str[128];
|
||||
GetClassName (d_this->d_hwnd, str, 128);
|
||||
|
||||
if (!strcmp (str, "COMBOBOX"))
|
||||
MoveWindow (d_this->d_hwnd, x, y, w, h + 100, TRUE);
|
||||
else
|
||||
MoveWindow (d_this->d_hwnd, x, y, w, h, TRUE);
|
||||
|
||||
if (!strcmp (str, WC_TABCONTROL))
|
||||
mxTab_resizeChild (d_this->d_hwnd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxWidget::setLabel (const char *format, ... )
|
||||
{
|
||||
if (format == NULL)
|
||||
{
|
||||
if (d_this->d_hwnd)
|
||||
{
|
||||
SetWindowText (d_this->d_hwnd, NULL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
|
||||
va_start (argptr, format);
|
||||
vsprintf (string, format,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
if (d_this->d_hwnd)
|
||||
{
|
||||
SetWindowText (d_this->d_hwnd, string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mxWidget::setVisible (bool b)
|
||||
{
|
||||
if (b)
|
||||
SetWindowPos (d_this->d_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
else
|
||||
ShowWindow (d_this->d_hwnd, SW_HIDE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxWidget::setEnabled (bool b)
|
||||
{
|
||||
EnableWindow (d_this->d_hwnd, b);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxWidget::setId (int id)
|
||||
{
|
||||
SetWindowLong (d_this->d_hwnd, GWL_ID, (LONG) id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxWidget::setUserData (void *userData)
|
||||
{
|
||||
d_this->d_userData = userData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void*
|
||||
mxWidget:: getHandle () const
|
||||
{
|
||||
return (void *) d_this->d_hwnd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxWidget::getType () const
|
||||
{
|
||||
return d_this->d_type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxWindow*
|
||||
mxWidget::getParent () const
|
||||
{
|
||||
return d_this->d_parent_p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxWidget::x () const
|
||||
{
|
||||
RECT rc;
|
||||
GetWindowRect (d_this->d_hwnd, &rc);
|
||||
return (int) rc.left;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxWidget::y () const
|
||||
{
|
||||
RECT rc;
|
||||
GetWindowRect (d_this->d_hwnd, &rc);
|
||||
return (int) rc.top;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxWidget::w () const
|
||||
{
|
||||
RECT rc;
|
||||
GetWindowRect (d_this->d_hwnd, &rc);
|
||||
return (int) (rc.right - rc.left);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxWidget::h () const
|
||||
{
|
||||
RECT rc;
|
||||
GetWindowRect (d_this->d_hwnd, &rc);
|
||||
return (int) (rc.bottom - rc.top);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxWidget::w2 () const
|
||||
{
|
||||
RECT rc;
|
||||
GetClientRect (d_this->d_hwnd, &rc);
|
||||
return (int) (rc.right - rc.left);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxWidget::h2 () const
|
||||
{
|
||||
RECT rc;
|
||||
GetClientRect (d_this->d_hwnd, &rc);
|
||||
return (int) (rc.bottom - rc.top);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char*
|
||||
mxWidget::getLabel () const
|
||||
{
|
||||
static char label[256];
|
||||
GetWindowText (d_this->d_hwnd, label, 256);
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxWidget::isVisible () const
|
||||
{
|
||||
return ( IsWindowVisible (d_this->d_hwnd) ? true : false );
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
mxWidget::isEnabled () const
|
||||
{
|
||||
return ( IsWindowEnabled (d_this->d_hwnd) ? true : false );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxWidget::getId () const
|
||||
{
|
||||
return (int) GetWindowLong (d_this->d_hwnd, GWL_ID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void*
|
||||
mxWidget::getUserData () const
|
||||
{
|
||||
return d_this->d_userData;
|
||||
}
|
||||
113
utils/mxtk/mxwindow.cpp
Normal file
113
utils/mxtk/mxwindow.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// mxToolKit (c) 1999 by Mete Ciragan
|
||||
//
|
||||
// file: mxWindow.cpp
|
||||
// implementation: Win32 API
|
||||
// last modified: Apr 12 1999, Mete Ciragan
|
||||
// copyright: The programs and associated files contained in this
|
||||
// distribution were developed by Mete Ciragan. The programs
|
||||
// are not in the public domain, but they are freely
|
||||
// distributable without licensing fees. These programs are
|
||||
// provided without guarantee or warrantee expressed or
|
||||
// implied.
|
||||
//
|
||||
#include "mxtk/mxWindow.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
extern mxWindow *g_mainWindow;
|
||||
|
||||
|
||||
|
||||
class mxWindow_i
|
||||
{
|
||||
public:
|
||||
UINT d_uTimer;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mxWindow::mxWindow (mxWindow *parent, int x, int y, int w, int h, const char *label, int style)
|
||||
: mxWidget (parent, x, y, w, h, label)
|
||||
{
|
||||
d_this = new mxWindow_i;
|
||||
d_this->d_uTimer = 0;
|
||||
|
||||
DWORD dwStyle = 0;
|
||||
if (style == Normal)
|
||||
dwStyle = WS_OVERLAPPEDWINDOW;
|
||||
else if (style == Popup)
|
||||
dwStyle = WS_POPUP;
|
||||
else if (style == Dialog || style == ModalDialog)
|
||||
dwStyle = WS_CAPTION | WS_SYSMENU;
|
||||
|
||||
void *parentHandle = 0;
|
||||
if (parent)
|
||||
{
|
||||
parentHandle = parent->getHandle ();
|
||||
dwStyle = WS_CHILD | WS_VISIBLE;
|
||||
}
|
||||
|
||||
void *handle = (void *) CreateWindowEx (0, "mx_class", label, dwStyle,
|
||||
x, y, w, h, (HWND) parentHandle,
|
||||
(HMENU) NULL, (HINSTANCE) GetModuleHandle (NULL), NULL);
|
||||
|
||||
SetWindowLong ((HWND) handle, GWL_USERDATA, reinterpret_cast< LONG >( this ) );
|
||||
|
||||
setHandle (handle);
|
||||
setType (MX_WINDOW);
|
||||
setParent (parent);
|
||||
//setLabel (label);
|
||||
//setBounds (x, y, w, h);
|
||||
|
||||
if (!parent && !g_mainWindow)
|
||||
g_mainWindow = this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
mxWindow::~mxWindow ()
|
||||
{
|
||||
SetWindowLong ((HWND) (HWND) getHandle(), GWL_USERDATA, (LONG) 0 );
|
||||
delete d_this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mxWindow::handleEvent (mxEvent * /*event*/ )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxWindow::redraw ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
mxWindow::setTimer (int milliSeconds)
|
||||
{
|
||||
if (d_this->d_uTimer)
|
||||
{
|
||||
KillTimer ((HWND) getHandle (), d_this->d_uTimer);
|
||||
d_this->d_uTimer = 0;
|
||||
}
|
||||
|
||||
if (milliSeconds > 0)
|
||||
{
|
||||
d_this->d_uTimer = 21001;
|
||||
d_this->d_uTimer = (UINT)SetTimer ((HWND) getHandle (), d_this->d_uTimer, milliSeconds, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mxWindow::setMenuBar (mxMenuBar *menuBar)
|
||||
{
|
||||
SetMenu ((HWND) getHandle (), (HMENU) ((mxWidget *) menuBar)->getHandle ());
|
||||
}
|
||||
Reference in New Issue
Block a user