Initial Commit
This commit is contained in:
185
common/#FILEIO.CPP
Normal file
185
common/#FILEIO.CPP
Normal file
@@ -0,0 +1,185 @@
|
||||
#include <common/fileio.hpp>
|
||||
|
||||
FileIO::FileIO(void)
|
||||
: mFileDescriptor(InvalidFile), mByteOrder(LittleEndian), mInputBuffer(MaxInputBuffer),
|
||||
mOpenMode(ReadOnly)
|
||||
{
|
||||
}
|
||||
|
||||
FileIO::FileIO(String pathFileName,ByteOrder byteOrder,Mode openMode)
|
||||
: mFileDescriptor(InvalidFile), mByteOrder(byteOrder), mInputBuffer(MaxInputBuffer),
|
||||
mOpenMode(openMode)
|
||||
{
|
||||
if(!mInputBuffer.lpBuffer())return;
|
||||
open(pathFileName);
|
||||
}
|
||||
|
||||
FileIO::~FileIO()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
WORD FileIO::close(void)
|
||||
{
|
||||
if(InvalidFile==mFileDescriptor)return FALSE;
|
||||
::close(mFileDescriptor);
|
||||
mFileDescriptor=InvalidFile;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::open(String pathFileName,Mode openMode,CreationFlags creationFlags)
|
||||
{
|
||||
close();
|
||||
mOpenMode=openMode;
|
||||
if(ReadOnly==mOpenMode)mFileDescriptor=::open(pathFileName,O_RDONLY|O_BINARY,S_IREAD);
|
||||
else mFileDescriptor=::open(pathFileName,O_RDWR|O_BINARY|creationFlags,S_IREAD|S_IWRITE);
|
||||
if(InvalidFile==mFileDescriptor)return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::read(BYTE &value)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
if(ReadOnly==mOpenMode)
|
||||
{
|
||||
if(!mInputBuffer.bufferIndex())
|
||||
{
|
||||
mInputBuffer.bufferIndex(::read(mFileDescriptor,mInputBuffer.lpBuffer(),MaxInputBuffer));
|
||||
if(!mInputBuffer.bufferIndex())return FALSE;
|
||||
}
|
||||
value=*(mInputBuffer.lpBufferPointer());
|
||||
++mInputBuffer;
|
||||
}
|
||||
else if(0>=::read(mFileDescriptor,&value,1))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::read(WORD &value)
|
||||
{
|
||||
BYTE byteValue;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
if(!read(byteValue))return FALSE;
|
||||
value=byteValue;
|
||||
if(!read(byteValue))return FALSE;
|
||||
value|=((WORD)byteValue)<<8;
|
||||
if(BigEndian==mByteOrder)value=mIntelData.intelData(value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::read(DWORD &value)
|
||||
{
|
||||
WORD wordValue;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
if(!read(wordValue))return FALSE;
|
||||
value=wordValue;
|
||||
if(!read(wordValue))return FALSE;
|
||||
value|=((DWORD)wordValue)<<16;
|
||||
if(BigEndian==mByteOrder)value=mIntelData.intelData(value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::read(char *lpBuffer,WORD lengthData)
|
||||
{
|
||||
BYTE byteValue;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
for(WORD index=0;index<lengthData;index++)
|
||||
{
|
||||
if(!read(byteValue))return FALSE;
|
||||
*(lpBuffer++)=byteValue;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::read(char *lpBuffer,WORD lengthData,int stopChar)
|
||||
{
|
||||
BYTE tempChar;
|
||||
|
||||
for(int bytesRead=0;bytesRead<lengthData-1;bytesRead++)
|
||||
{
|
||||
if(!read(tempChar))return FALSE;
|
||||
if(tempChar==stopChar)break;
|
||||
*(lpBuffer++)=tempChar;
|
||||
}
|
||||
*(lpBuffer)=0;
|
||||
if(!bytesRead)return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::write(WORD value)
|
||||
{
|
||||
BYTE byteValue;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
if(BigEndian==mByteOrder)value=mIntelData.intelData(value);
|
||||
byteValue=(BYTE)(value&0x00FF);
|
||||
if(!write(byteValue))return FALSE;
|
||||
byteValue=(BYTE)(value>>8);
|
||||
if(!write(byteValue))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::write(DWORD value)
|
||||
{
|
||||
WORD wordValue;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
if(BigEndian==mByteOrder)
|
||||
{
|
||||
WORD hiWord(HIWORD(value));
|
||||
WORD loWord(LOWORD(value));
|
||||
|
||||
value=((DWORD)mIntelData.intelData(loWord))<<16;
|
||||
value|=mIntelData.intelData(hiWord);
|
||||
write((char*)&value,sizeof(value));
|
||||
return TRUE;
|
||||
}
|
||||
wordValue=(WORD)(value&0xFFFF);
|
||||
write(wordValue);
|
||||
wordValue=(WORD)(value>>16);
|
||||
write(wordValue);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::write(char *lpBuffer,WORD lengthData)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
if(!lengthData)return TRUE;
|
||||
if(-1==::write(mFileDescriptor,lpBuffer,lengthData))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
FileIO &FileIO::operator++(void)
|
||||
{
|
||||
seek(1L,SeekCurrent);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
FileIO &FileIO::operator--(void)
|
||||
{
|
||||
seek(-1L,SeekCurrent);
|
||||
return *this;
|
||||
}
|
||||
|
||||
WORD FileIO::seek(LONG seekOffset,SeekFrom seekFrom)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
if(-1==::lseek(mFileDescriptor,seekOffset,seekFrom))return FALSE;
|
||||
mInputBuffer.bufferIndex(0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FileIO::rewind(void)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
if(!seek(0L,SeekBeginning))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
129
common/ARRAY.HPP
Normal file
129
common/ARRAY.HPP
Normal file
@@ -0,0 +1,129 @@
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#define _COMMON_ARRAY_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_EXCEPTION_HPP_
|
||||
#include <common/except.hpp>
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class Array
|
||||
{
|
||||
public:
|
||||
Array(void);
|
||||
Array(const Array<T> &someArray);
|
||||
virtual ~Array();
|
||||
T &operator[](DWORD index);
|
||||
T &elementAt(DWORD index);
|
||||
Array<T> &operator=(const Array<T> &someArray);
|
||||
bool operator==(const Array<T> &someArray)const;
|
||||
DWORD size(void)const;
|
||||
void size(DWORD size);
|
||||
DWORD sizeBytes(void)const;
|
||||
private:
|
||||
void destroy(void);
|
||||
void create(DWORD elements);
|
||||
|
||||
T *mpArray;
|
||||
DWORD mElements;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array<T>::Array(void)
|
||||
: mpArray(0), mElements(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array<T>::Array(const Array<T> &someArray)
|
||||
: mpArray(0), mElements(0)
|
||||
{
|
||||
*this=someArray;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array<T>::~Array()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
T &Array<T>::operator[](DWORD index)
|
||||
{
|
||||
if(index>mElements)throw ArrayIndexOutOfBoundsException();
|
||||
return mpArray[index];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array<T> &Array<T>::operator=(const Array<T> &someArray)
|
||||
{
|
||||
destroy();
|
||||
if(!someArray.size())return *this;
|
||||
size(someArray.size());
|
||||
for(unsigned index=0;index<size();index++)operator[](index)=((Array<T>&)someArray)[index];
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
bool Array<T>::operator==(const Array<T> &someArray)const
|
||||
{
|
||||
if(!someArray.size()||(size()!=someArray.size()))return FALSE;
|
||||
for(int index=0;index<size();index++)if(!(((Array<T>&)*this).operator[](index)==((Array<T>&)someArray)[index]))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
DWORD Array<T>::sizeBytes(void)const
|
||||
{
|
||||
return mElements*sizeof(T);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
DWORD Array<T>::size(void)const
|
||||
{
|
||||
return mElements;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Array<T>::size(DWORD size)
|
||||
{
|
||||
create(size);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
void Array<T>::destroy(void)
|
||||
{
|
||||
if(!mpArray)return;
|
||||
delete[] mpArray;
|
||||
mpArray=0;
|
||||
mElements=0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
void Array<T>::create(DWORD elements)
|
||||
{
|
||||
destroy();
|
||||
if(!elements)return;
|
||||
mpArray=new T[elements];
|
||||
if(0==mpArray)throw(NullError());
|
||||
mElements=elements;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
T &Array<T>::elementAt(DWORD index)
|
||||
{
|
||||
if(index>mElements)throw ArrayIndexOutOfBoundsException();
|
||||
return mpArray[index];
|
||||
}
|
||||
#endif
|
||||
4
common/ASSERT.HPP
Normal file
4
common/ASSERT.HPP
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef _COMMON_ASSERT_HPP_
|
||||
#define _COMMON_ASSERT_HPP_
|
||||
#include <assert.h>
|
||||
#endif
|
||||
13
common/AVICAP.HPP
Normal file
13
common/AVICAP.HPP
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _COMMON_AVICAP_HPP_
|
||||
#define _COMMON_AVICAP_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_MMSYSTEM_HPP_
|
||||
#include <common/mmsystem.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_VFW_HPP_
|
||||
#include <common/vfw.hpp>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
29
common/Accelerator.hpp
Normal file
29
common/Accelerator.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef _COMMON_ACCELERATOR_HPP_
|
||||
#define _COMMON_ACCELERATOR_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class GUIWindow;
|
||||
|
||||
class Accelerator
|
||||
{
|
||||
public:
|
||||
Accelerator();
|
||||
Accelerator(const String &strTableName,HINSTANCE hInstance=GetModuleHandle(0));
|
||||
Accelerator(UINT resID,HINSTANCE hInstance=GetModuleHandle(0));
|
||||
virtual ~Accelerator();
|
||||
bool loadAccelerators(const String &strTableName,HINSTANCE hInstance=GetModuleHandle(0));
|
||||
bool loadAccelerators(UINT resID,HINSTANCE hInstance=GetModuleHandle(0));
|
||||
bool translate(const GUIWindow &parent,MSG &msg)const;
|
||||
bool translateMDISysAccelerator(const GUIWindow &parent,MSG &msg)const;
|
||||
void destroy(void);
|
||||
bool isOkay(void)const;
|
||||
private:
|
||||
Accelerator &operator=(const Accelerator &accelerator);
|
||||
HACCEL mhAccelerator;
|
||||
};
|
||||
#endif
|
||||
47
common/BINARRAY.HPP
Normal file
47
common/BINARRAY.HPP
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef _COMMON_BINARYSEARCHARRAY_HPP_
|
||||
#define _COMMON_BINARYSEARCHARRAY_HPP_
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class BinarySearchArray
|
||||
{
|
||||
public:
|
||||
BinarySearchArray(Array<T> &sortedVector);
|
||||
virtual ~BinarySearchArray();
|
||||
WORD searchItem(const T &desiredItem,T &foundItem);
|
||||
WORD searchItem(const T &desiredItem,Block<T> &foundItems);
|
||||
private:
|
||||
WORD searchItem(const T &desiredItem,T &foundItem,LONG &foundIndex);
|
||||
DWORD itemCount(void)const;
|
||||
Array<T> &mSortedVector;
|
||||
DWORD mItemCount;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
BinarySearchArray<T>::BinarySearchArray(Array<T> &sortedVector)
|
||||
: mSortedVector(sortedVector), mItemCount(mSortedVector.size())
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
BinarySearchArray<T>::~BinarySearchArray(void)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
DWORD BinarySearchArray<T>::itemCount(void)const
|
||||
{
|
||||
return mItemCount;
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
#include <common/binarray.tpp>
|
||||
#endif
|
||||
#endif
|
||||
57
common/BINARRAY.TPP
Normal file
57
common/BINARRAY.TPP
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef _COMMON_BINARYSEARCHARRAY_TPP_
|
||||
#define _COMMON_BINARYSEARCHARRAY_TPP_
|
||||
|
||||
template <class T>
|
||||
WORD BinarySearchArray<T>::searchItem(const T &desiredItem,T &foundItem)
|
||||
{
|
||||
LONG itemIndex;
|
||||
return searchItem(desiredItem,foundItem,itemIndex);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
WORD BinarySearchArray<T>::searchItem(const T &desiredItem,Block<T> &foundItems)
|
||||
{
|
||||
LONG foundIndex;
|
||||
LONG startIndex;
|
||||
LONG endIndex;
|
||||
T foundItem;
|
||||
|
||||
foundItems.remove();
|
||||
if(!searchItem(desiredItem,foundItem,foundIndex))return FALSE;
|
||||
startIndex=endIndex=foundIndex;
|
||||
for(;startIndex>=0&&foundItem==mSortedVector[startIndex];startIndex--);
|
||||
startIndex++;
|
||||
for(;endIndex<itemCount()&&foundItem==mSortedVector[endIndex];endIndex++);
|
||||
endIndex--;
|
||||
while(startIndex<=endIndex)foundItems.insert(&mSortedVector[startIndex++]);
|
||||
return foundItems.size();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
WORD BinarySearchArray<T>::searchItem(const T &desiredItem,T &foundItem,LONG &foundIndex)
|
||||
{
|
||||
LONG lowerBound;
|
||||
LONG upperBound;
|
||||
LONG itemIndex;
|
||||
WORD returnCode(FALSE);
|
||||
|
||||
if(!itemCount())return FALSE;
|
||||
lowerBound=0L;
|
||||
upperBound=mItemCount-1L;
|
||||
while(TRUE)
|
||||
{
|
||||
itemIndex=(lowerBound+upperBound)/2L;
|
||||
if(desiredItem>mSortedVector[itemIndex])lowerBound=itemIndex+1L;
|
||||
else upperBound=itemIndex-1;
|
||||
if(mSortedVector[itemIndex]==desiredItem)
|
||||
{
|
||||
foundItem=mSortedVector[itemIndex];
|
||||
foundIndex=itemIndex;
|
||||
returnCode=TRUE;
|
||||
break;
|
||||
}
|
||||
if(lowerBound>upperBound)break;
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
#endif
|
||||
47
common/BINSRCH.HPP
Normal file
47
common/BINSRCH.HPP
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef _COMMON_BINARYSEARCH_HPP_
|
||||
#define _COMMON_BINARYSEARCH_HPP_
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class BinarySearch
|
||||
{
|
||||
public:
|
||||
BinarySearch(Array<T> &sortedVector);
|
||||
~BinarySearch();
|
||||
WORD searchItem(const T &desiredItem,T &foundItem);
|
||||
WORD searchItem(const T &desiredItem,Block<T> &foundItems);
|
||||
private:
|
||||
WORD searchItem(const T &desiredItem,T &foundItem,LONG &foundIndex);
|
||||
DWORD itemCount(void)const;
|
||||
Array<T> &mSortedVector;
|
||||
DWORD mItemCount;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
BinarySearch<T>::BinarySearch(Array<T> &sortedVector)
|
||||
: mSortedVector(sortedVector), mItemCount(mSortedVector.size())
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
BinarySearch<T>::~BinarySearch(void)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
DWORD BinarySearch<T>::itemCount(void)const
|
||||
{
|
||||
return mItemCount;
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
#include <common/binsrch.tpp>
|
||||
#endif
|
||||
#endif
|
||||
57
common/BINSRCH.TPP
Normal file
57
common/BINSRCH.TPP
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef _COMMON_BINSRCH_TPP_
|
||||
#define _COMMON_BINSRCH_TPP_
|
||||
|
||||
template <class T>
|
||||
WORD BinarySearch<T>::searchItem(const T &desiredItem,T &foundItem)
|
||||
{
|
||||
LONG itemIndex;
|
||||
return searchItem(desiredItem,foundItem,itemIndex);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
WORD BinarySearch<T>::searchItem(const T &desiredItem,Block<T> &foundItems)
|
||||
{
|
||||
LONG foundIndex;
|
||||
LONG startIndex;
|
||||
LONG endIndex;
|
||||
T foundItem;
|
||||
|
||||
foundItems.remove();
|
||||
if(!searchItem(desiredItem,foundItem,foundIndex))return FALSE;
|
||||
startIndex=endIndex=foundIndex;
|
||||
for(;startIndex>=0&&foundItem==mSortedVector[startIndex];startIndex--);
|
||||
startIndex++;
|
||||
for(;endIndex<itemCount()&&foundItem==mSortedVector[endIndex];endIndex++);
|
||||
endIndex--;
|
||||
while(startIndex<=endIndex)foundItems.insert(&mSortedVector[startIndex++]);
|
||||
return foundItems.size();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
WORD BinarySearch<T>::searchItem(const T &desiredItem,T &foundItem,LONG &foundIndex)
|
||||
{
|
||||
LONG lowerBound;
|
||||
LONG upperBound;
|
||||
LONG itemIndex;
|
||||
WORD returnCode(FALSE);
|
||||
|
||||
if(!itemCount())return FALSE;
|
||||
lowerBound=0L;
|
||||
upperBound=mItemCount-1L;
|
||||
while(TRUE)
|
||||
{
|
||||
itemIndex=(lowerBound+upperBound)/2L;
|
||||
if(desiredItem>mSortedVector[itemIndex])lowerBound=itemIndex+1L;
|
||||
else upperBound=itemIndex-1;
|
||||
if(mSortedVector[itemIndex]==desiredItem)
|
||||
{
|
||||
foundItem=mSortedVector[itemIndex];
|
||||
foundIndex=itemIndex;
|
||||
returnCode=TRUE;
|
||||
break;
|
||||
}
|
||||
if(lowerBound>upperBound)break;
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
#endif
|
||||
544
common/BITMAP.CPP
Normal file
544
common/BITMAP.CPP
Normal file
@@ -0,0 +1,544 @@
|
||||
#include <common/bminfo.hpp>
|
||||
#include <common/bitmap.hpp>
|
||||
#include <common/array.hpp>
|
||||
#include <common/memfile.hpp>
|
||||
#include <bsptree/rgbtree.hpp>
|
||||
#define MaxBlock 64000L
|
||||
|
||||
Bitmap::Bitmap(void)
|
||||
: mhFile(HFILE_ERROR), mCurrentMode(Idle), mMaxColors(0), mImageExtent(0),
|
||||
mBlockSize(MaxBlock), mWidth(0), mHeight(0)
|
||||
{
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(const Bitmap &someBitmap)
|
||||
: mMaxColors(someBitmap.mMaxColors), mFileName(someBitmap.mFileName),
|
||||
mImageExtent(someBitmap.mImageExtent), mBlockSize(someBitmap.mBlockSize),
|
||||
mhFile(HFILE_ERROR), mCurrentMode(Write), mWidth(0), mHeight(0)
|
||||
{
|
||||
if(!someBitmap.isOkay())return;
|
||||
copyBitmap(someBitmap);
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(const String &pathFileName)
|
||||
: mhFile(HFILE_ERROR), mMaxColors(0), mCurrentMode(Read), mImageExtent(0),
|
||||
mBlockSize(MaxBlock), mWidth(0), mHeight(0)
|
||||
{
|
||||
processBitmap(pathFileName);
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(const String &pathFileName,HGLOBAL hGlobalImage,HGLOBAL hGlobalBitmapInfo)
|
||||
: mhFile(HFILE_ERROR), mMaxColors(0), mCurrentMode(Write), mImageExtent(0),
|
||||
mBlockSize(MaxBlock), mWidth(0), mHeight(0)
|
||||
{
|
||||
DWORD sizeBitmapInfo;
|
||||
DWORD sizeBitmapImage;
|
||||
BITMAPINFO FAR *lpSourceBitmapInfo;
|
||||
UHUGE *lpSourceImage;
|
||||
|
||||
if(!hGlobalImage||!hGlobalBitmapInfo)return;
|
||||
if(pathFileName.isNull())return;
|
||||
mFileName=pathFileName;
|
||||
sizeBitmapInfo=::GlobalSize(hGlobalBitmapInfo);
|
||||
sizeBitmapImage=::GlobalSize(hGlobalImage);
|
||||
reserveInfo(sizeBitmapInfo);
|
||||
lpSourceBitmapInfo=(BITMAPINFO FAR*)::GlobalLock(hGlobalBitmapInfo);
|
||||
copyBits((UHUGE*)getInfoPtr(),(UHUGE*)lpSourceBitmapInfo,sizeBitmapInfo);
|
||||
::GlobalUnlock(hGlobalBitmapInfo);
|
||||
mImageExtent=imageExtent();
|
||||
if(mImageExtent!=sizeBitmapImage)mImageExtent=sizeBitmapImage;
|
||||
reserveData(mImageExtent);
|
||||
lpSourceImage=(UHUGE*)::GlobalLock(hGlobalImage);
|
||||
copyBits(getDataPtr(),lpSourceImage,mImageExtent);
|
||||
::GlobalUnlock(hGlobalImage);
|
||||
if(!(mMaxColors=(WORD)getInfoPtr()->bmiHeader.biClrUsed))mMaxColors=1<<getInfoPtr()->bmiHeader.biBitCount;
|
||||
mWidth=getInfoPtr()->bmiHeader.biWidth;
|
||||
mHeight=getInfoPtr()->bmiHeader.biHeight;
|
||||
setPalette();
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(const String &pathFileName,BitmapInfo &infoData,GlobalData<BYTE> &imageData)
|
||||
: mhFile(HFILE_ERROR), mMaxColors(0), mCurrentMode(Write), mImageExtent(0),
|
||||
mBlockSize(MaxBlock), mWidth(0), mHeight(0)
|
||||
{
|
||||
DWORD sizeBitmapInfo;
|
||||
DWORD sizeBitmapImage;
|
||||
BITMAPINFO FAR *lpSourceBitmapInfo;
|
||||
UHUGE *lpSourceImage;
|
||||
|
||||
if(!imageData.size())return;
|
||||
if(pathFileName.isNull())return;
|
||||
mFileName=pathFileName;
|
||||
sizeBitmapInfo=(sizeof(BITMAPINFO)-sizeof(RGBQUAD))+(infoData.rgbColors()*sizeof(RGBQUAD));
|
||||
sizeBitmapImage=imageData.size();
|
||||
reserveInfo(sizeBitmapInfo);
|
||||
copyBits((UHUGE*)getInfoPtr(),(UHUGE*)((BITMAPINFO*)infoData),sizeBitmapInfo);
|
||||
mImageExtent=imageExtent();
|
||||
if(mImageExtent!=sizeBitmapImage)mImageExtent=sizeBitmapImage;
|
||||
reserveData(mImageExtent);
|
||||
copyBits(getDataPtr(),(BYTE*)&imageData[0],mImageExtent);
|
||||
if(BitmapInfo::Bit8==getInfoPtr()->bmiHeader.biBitCount&&!(mMaxColors=(WORD)getInfoPtr()->bmiHeader.biClrUsed))mMaxColors=1<<getInfoPtr()->bmiHeader.biBitCount;
|
||||
mWidth=getInfoPtr()->bmiHeader.biWidth;
|
||||
mHeight=getInfoPtr()->bmiHeader.biHeight;
|
||||
if(BitmapInfo::Bit8==getInfoPtr()->bmiHeader.biBitCount)setPalette();
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(const String &pathFileName,WORD bitmapWidth,WORD bitmapHeight,WORD bitmapColors,WORD bitCount)
|
||||
: mhFile(HFILE_ERROR), mMaxColors(bitmapColors), mCurrentMode(Write),
|
||||
mImageExtent(0), mBlockSize(MaxBlock), mWidth(0), mHeight(0)
|
||||
{
|
||||
BITMAPINFOHEADER bitmapInfoHeader;
|
||||
LONG rgbQuadBytes(bitmapColors*sizeof(RGBQUAD));
|
||||
UHUGE *lpPtr;
|
||||
|
||||
if(!bitmapWidth||!bitmapHeight||!bitmapColors||pathFileName.isNull())return;
|
||||
getRequiredWidth(bitmapWidth,bitmapHeight);
|
||||
mFileName=pathFileName;
|
||||
bitmapInfoHeader.biSize=sizeof(BITMAPINFOHEADER);
|
||||
mWidth=bitmapInfoHeader.biWidth=bitmapWidth;
|
||||
mHeight=bitmapInfoHeader.biHeight=bitmapHeight;
|
||||
bitmapInfoHeader.biPlanes=Planes;
|
||||
bitmapInfoHeader.biBitCount=bitCount;
|
||||
bitmapInfoHeader.biCompression=BI_RGB;
|
||||
bitmapInfoHeader.biSizeImage=0;
|
||||
bitmapInfoHeader.biXPelsPerMeter=0;
|
||||
bitmapInfoHeader.biYPelsPerMeter=0;
|
||||
bitmapInfoHeader.biClrUsed=bitmapColors;
|
||||
bitmapInfoHeader.biClrImportant=bitmapColors;
|
||||
reserveInfo(0,bitmapColors);
|
||||
copyBits((UHUGE*)getInfoPtr(),(UHUGE*)&bitmapInfoHeader,sizeof(BITMAPINFOHEADER));
|
||||
lpPtr=((UHUGE*)getInfoPtr())+sizeof(BITMAPINFOHEADER);
|
||||
setBits(lpPtr,0,rgbQuadBytes);
|
||||
mImageExtent=imageExtent();
|
||||
lpPtr=reserveData(mImageExtent);
|
||||
setBits(lpPtr,0,mImageExtent);
|
||||
}
|
||||
|
||||
Bitmap::~Bitmap()
|
||||
{
|
||||
closeFile();
|
||||
}
|
||||
|
||||
WORD Bitmap::operator+=(const BitmapOverlay &someBitmapOverlay)
|
||||
{
|
||||
Bitmap &sourceBitmap=((BitmapOverlay&)someBitmapOverlay).bitmap();
|
||||
Point placementPoint(((BitmapOverlay&)someBitmapOverlay).placementPoint());
|
||||
UHUGE *lpSrcData;
|
||||
UHUGE *lpDstData;
|
||||
UHUGE *lpSrcPtr;
|
||||
UHUGE *lpDstPtr;
|
||||
LONG srcWidth;
|
||||
LONG srcHeight;
|
||||
LONG dstWidth;
|
||||
LONG dstHeight;
|
||||
LONG copyRows;
|
||||
LONG copyCols;
|
||||
|
||||
if(!isOkay()||!sourceBitmap.isOkay())return FALSE;
|
||||
mCurrentMode=Write;
|
||||
srcWidth=copyCols=sourceBitmap.getInfoPtr()->bmiHeader.biWidth;
|
||||
srcHeight=copyRows=sourceBitmap.getInfoPtr()->bmiHeader.biHeight;
|
||||
dstWidth=getInfoPtr()->bmiHeader.biWidth;
|
||||
dstHeight=getInfoPtr()->bmiHeader.biHeight;
|
||||
if(placementPoint.x()<0)placementPoint.x(0);
|
||||
if(placementPoint.y()<0)placementPoint.y(0);
|
||||
if(placementPoint.x()>=dstWidth)return FALSE;
|
||||
if(placementPoint.y()>=dstHeight)return FALSE;
|
||||
if((LONG)placementPoint.x()+srcWidth>dstWidth)copyCols=dstWidth-placementPoint.x();
|
||||
if((LONG)placementPoint.y()+srcHeight>dstHeight)copyRows=dstHeight-placementPoint.y();
|
||||
upsideDown();
|
||||
sourceBitmap.upsideDown();
|
||||
lpSrcData=sourceBitmap.getDataPtr();
|
||||
lpDstData=getDataPtr();
|
||||
for(LONG srcRow=0;srcRow<copyRows;srcRow++)
|
||||
{
|
||||
lpSrcPtr=(lpSrcData+(srcWidth*srcRow));
|
||||
lpDstPtr=(lpDstData+(((srcRow+(LONG)placementPoint.y())*dstWidth)+(LONG)placementPoint.x()));
|
||||
copyBits(lpDstPtr,lpSrcPtr,copyCols);
|
||||
}
|
||||
upsideDown();
|
||||
sourceBitmap.upsideDown();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void Bitmap::upsideDown(void)
|
||||
{
|
||||
LONG width(getInfoPtr()->bmiHeader.biWidth);
|
||||
LONG height(getInfoPtr()->bmiHeader.biHeight);
|
||||
UHUGE *lpSrc=getDataPtr();
|
||||
UHUGE *lpDst;
|
||||
HGLOBAL hGlobalTemp;
|
||||
|
||||
hGlobalTemp=::GlobalAlloc(GMEM_ZEROINIT|GMEM_MOVEABLE,width*height);
|
||||
lpDst=(UHUGE*)::GlobalLock(hGlobalTemp);
|
||||
for(LONG rowIndex=0;rowIndex<height;rowIndex++)
|
||||
copyBits(lpDst+(rowIndex*width),(lpSrc+(height-rowIndex)*width)-width,width);
|
||||
if(BitmapData::Keep==getDataType())copyBits(lpSrc,lpDst,width*height);
|
||||
else setData(hGlobalTemp,lpDst);
|
||||
}
|
||||
|
||||
void Bitmap::copyBitmap(const Bitmap &someBitmap)
|
||||
{
|
||||
DWORD sizeBitmapInfo;
|
||||
DWORD sizeBitmapData;
|
||||
|
||||
sizeBitmapInfo=::GlobalSize(someBitmap.getInfoHnd());
|
||||
sizeBitmapData=::GlobalSize(someBitmap.getDataHnd());
|
||||
reserveData(sizeBitmapData);
|
||||
reserveInfo(sizeBitmapInfo);
|
||||
copyBits((UHUGE*)reserveInfo(sizeBitmapInfo),(UHUGE*)someBitmap.getInfoPtr(),sizeBitmapInfo);
|
||||
copyBits((UHUGE*)reserveData(sizeBitmapData),(UHUGE*)someBitmap.getDataPtr(),sizeBitmapData);
|
||||
mWidth=getInfoPtr()->bmiHeader.biWidth;
|
||||
mHeight=getInfoPtr()->bmiHeader.biHeight;
|
||||
mBitmapPalette=someBitmap.getPalette();
|
||||
}
|
||||
|
||||
WORD Bitmap::operator=(const String &pathFileName)
|
||||
{
|
||||
int returnCode;
|
||||
|
||||
mCurrentMode=Read;
|
||||
returnCode=processBitmap(pathFileName);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
Bitmap &Bitmap::operator=(const Bitmap &someBitmap)
|
||||
{
|
||||
if(!someBitmap.isOkay())return *this;
|
||||
if(getDataType()==BitmapData::Keep)return *this;
|
||||
mCurrentMode=someBitmap.mCurrentMode;
|
||||
mMaxColors=someBitmap.mMaxColors;
|
||||
mFileName=someBitmap.mFileName;
|
||||
mImageExtent=someBitmap.mImageExtent;
|
||||
copyBitmap(someBitmap);
|
||||
return *this;
|
||||
}
|
||||
|
||||
WORD Bitmap::processBitmap(const String &pathFileName)
|
||||
{
|
||||
OFSTRUCT ofStruct;
|
||||
|
||||
mFileName=pathFileName;
|
||||
if(HFILE_ERROR==(mhFile=::OpenFile(pathFileName,&ofStruct,OF_READ)))return FALSE;
|
||||
::_lread(mhFile,&mBitmapFileHeader,sizeof(BITMAPFILEHEADER));
|
||||
if(Signature!=mBitmapFileHeader.bfType){closeFile();return FALSE;}
|
||||
readPalette();
|
||||
decodeImage();
|
||||
closeFile();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Bitmap::isValidBitmap(const String &pathFileName)const
|
||||
{
|
||||
HFILE hFile;
|
||||
OFSTRUCT ofStruct;
|
||||
BITMAPFILEHEADER bitmapFileHeader;
|
||||
|
||||
if(pathFileName.isNull())return FALSE;
|
||||
if(HFILE_ERROR==(hFile=::OpenFile(pathFileName,&ofStruct,OF_READ)))return FALSE;
|
||||
::_lread(hFile,&bitmapFileHeader,sizeof(BITMAPFILEHEADER));
|
||||
::_lclose(hFile);
|
||||
if(Signature!=bitmapFileHeader.bfType)return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HPALETTE Bitmap::getPalette(void)const
|
||||
{
|
||||
return mBitmapPalette.getPalette();
|
||||
}
|
||||
|
||||
WORD Bitmap::setPalette(HPALETTE hPalette,WORD remapBitmap)
|
||||
{
|
||||
BITMAPINFOHEADER bitmapInfoHeader;
|
||||
|
||||
if(!isOkay()||!hPalette)return FALSE;
|
||||
PurePalette purePalette(hPalette);
|
||||
if(mBitmapPalette==purePalette)return FALSE;
|
||||
if(remapBitmap)mapPalette(purePalette);
|
||||
mBitmapPalette=purePalette;
|
||||
mMaxColors=mBitmapPalette.paletteEntries();
|
||||
::memcpy(&bitmapInfoHeader,getInfoPtr(),sizeof(BITMAPINFOHEADER));
|
||||
reserveInfo(0,mMaxColors);
|
||||
::memcpy(getInfoPtr(),&bitmapInfoHeader,sizeof(BITMAPINFOHEADER));
|
||||
getInfoPtr()->bmiHeader.biClrUsed=0;
|
||||
getInfoPtr()->bmiHeader.biClrImportant=0;
|
||||
for(int itemIndex=0;itemIndex<mMaxColors;itemIndex++)
|
||||
{
|
||||
getInfoPtr()->bmiColors[itemIndex].rgbRed=mBitmapPalette[itemIndex].red();
|
||||
getInfoPtr()->bmiColors[itemIndex].rgbGreen=mBitmapPalette[itemIndex].green();
|
||||
getInfoPtr()->bmiColors[itemIndex].rgbBlue=mBitmapPalette[itemIndex].blue();
|
||||
getInfoPtr()->bmiColors[itemIndex].rgbReserved=0;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void Bitmap::mapPalette(PurePalette &purePalette)
|
||||
{
|
||||
Array<RGBIndex> rgbIndexVector;
|
||||
WORD paletteEntries;
|
||||
RGBTree paletteTree;
|
||||
RGBColor rgbColor;
|
||||
RGBIndex rgbIndex;
|
||||
|
||||
paletteEntries=purePalette.paletteEntries();
|
||||
rgbIndexVector.size(paletteEntries);
|
||||
for(int paletteIndex=0;paletteIndex<paletteEntries;paletteIndex++)
|
||||
{
|
||||
rgbColor=purePalette[paletteIndex];
|
||||
rgbIndex=RGBIndex(rgbColor,paletteIndex);
|
||||
rgbIndexVector[paletteIndex]=rgbIndex;
|
||||
}
|
||||
paletteTree.insertItems(rgbIndexVector);
|
||||
for(int mapIndex=0;mapIndex<mImageExtent;mapIndex++)
|
||||
{
|
||||
paletteIndex=*(getDataPtr()+mapIndex);
|
||||
rgbColor=mBitmapPalette[paletteIndex];
|
||||
RGBIndex searchIndex(rgbColor,paletteIndex);
|
||||
if(paletteTree.searchItem(searchIndex,RGBTree::SearchNearest))
|
||||
*(getDataPtr()+mapIndex)=searchIndex.paletteIndex();
|
||||
}
|
||||
}
|
||||
|
||||
void Bitmap::setPalette(void)
|
||||
{
|
||||
RGBColor rgbColor;
|
||||
|
||||
if(!isOkay())return;
|
||||
for(int paletteIndex=0;paletteIndex<mMaxColors;paletteIndex++)
|
||||
{
|
||||
rgbColor.red(getInfoPtr()->bmiColors[paletteIndex].rgbRed);
|
||||
rgbColor.green(getInfoPtr()->bmiColors[paletteIndex].rgbGreen);
|
||||
rgbColor.blue(getInfoPtr()->bmiColors[paletteIndex].rgbBlue);
|
||||
mBitmapPalette.setPaletteColor(paletteIndex,rgbColor,PaletteEntry::NullFlag);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void Bitmap::readPalette(void)
|
||||
{
|
||||
RGBQUAD FAR *lpRGBQuad;
|
||||
BITMAPINFOHEADER bitmapInfoHeader;
|
||||
|
||||
if(HFILE_ERROR==mhFile||Read!=mCurrentMode)return;
|
||||
::_lread(mhFile,&bitmapInfoHeader,sizeof(BITMAPINFOHEADER));
|
||||
if(!(mMaxColors=(WORD)bitmapInfoHeader.biClrUsed))mMaxColors=1<<bitmapInfoHeader.biBitCount;
|
||||
reserveInfo(0,mMaxColors);
|
||||
::memcpy(getInfoPtr(),&bitmapInfoHeader,sizeof(BITMAPINFOHEADER));
|
||||
mWidth=getInfoPtr()->bmiHeader.biWidth;
|
||||
mHeight=getInfoPtr()->bmiHeader.biHeight;
|
||||
getRequiredWidth(mWidth,mHeight);
|
||||
|
||||
for(int i=0;i<mMaxColors;i++)
|
||||
{
|
||||
lpRGBQuad=(RGBQUAD FAR *)&(getInfoPtr()->bmiColors[i]);
|
||||
::_lread(mhFile,lpRGBQuad,sizeof(RGBQUAD));
|
||||
mBitmapPalette.setPaletteColor(i,RGBColor(lpRGBQuad->rgbRed,lpRGBQuad->rgbGreen,lpRGBQuad->rgbBlue),PaletteEntry::NullFlag);
|
||||
}
|
||||
}
|
||||
|
||||
void Bitmap::decodeImage(void)
|
||||
{
|
||||
switch(getInfoPtr()->bmiHeader.biCompression)
|
||||
{
|
||||
case BI_RGB :
|
||||
mImageExtent=imageExtent();
|
||||
reserveData(mImageExtent);
|
||||
::_llseek(mhFile,(mBitmapFileHeader.bfOffBits),0);
|
||||
::_hread(mhFile,getDataPtr(),mImageExtent);
|
||||
break;
|
||||
case BI_RLE4 :
|
||||
closeFile();
|
||||
::MessageBox(::GetFocus(),(LPSTR)"BI_RLE4 is not supported at this time.\nPlease try an uncompressed bitmap.",(LPSTR)"ERROR",MB_ICONEXCLAMATION);
|
||||
break;
|
||||
case BI_RLE8 :
|
||||
closeFile();
|
||||
::MessageBox(::GetFocus(),(LPSTR)"BI_RLE8 is not supported at this time.\nPlease try an uncompressed bitmap.",(LPSTR)"ERROR",MB_ICONEXCLAMATION);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HBITMAP Bitmap::createBitmap(PureDevice &somePureDevice)
|
||||
{
|
||||
HBITMAP hBitmap;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
hBitmap=::CreateDIBitmap(somePureDevice,(BITMAPINFOHEADER FAR*)getInfoPtr(),
|
||||
CBM_INIT,getDataPtr(),(BITMAPINFO FAR*)getInfoPtr(),DIB_RGB_COLORS);
|
||||
return hBitmap;
|
||||
}
|
||||
|
||||
WORD Bitmap::displayBitmap(HWND hDisplayWindow,HDC hDC,int isActive,int conforming)const
|
||||
{
|
||||
RECT windowRect;
|
||||
HPALETTE hOldPalette;
|
||||
WORD windowWidth;
|
||||
WORD windowHeight;
|
||||
int suppliedDC;
|
||||
|
||||
if(!isOkay()||!::IsWindow(hDisplayWindow))return FALSE;
|
||||
::GetClientRect(hDisplayWindow,(RECT FAR *)&windowRect);
|
||||
windowWidth=windowRect.right;
|
||||
windowHeight=windowRect.bottom;
|
||||
if(!hDC){suppliedDC=FALSE;hDC=::GetDC(hDisplayWindow);}
|
||||
if(isActive)hOldPalette=::SelectPalette(hDC,mBitmapPalette.getPalette(),FALSE);
|
||||
else hOldPalette=::SelectPalette(hDC,mBitmapPalette.getPalette(),TRUE);
|
||||
::RealizePalette(hDC);
|
||||
if(conforming)::StretchDIBits(hDC,0,0,windowRect.right,windowRect.bottom,0,0,
|
||||
width(),height(),getDataPtr(),(BITMAPINFO *)getInfoPtr(),DIB_RGB_COLORS,SRCCOPY);
|
||||
else
|
||||
{
|
||||
::StretchDIBits(hDC,0,0,width()>windowWidth?windowWidth:width(),
|
||||
height()>windowHeight?windowHeight:height(),0,0,width(),height(),
|
||||
getDataPtr(),(BITMAPINFO *)getInfoPtr(),DIB_RGB_COLORS,SRCCOPY);
|
||||
}
|
||||
if(isActive)::SelectPalette(hDC,hOldPalette,FALSE);
|
||||
else ::SelectPalette(hDC,hOldPalette,TRUE);
|
||||
if(!suppliedDC)::ReleaseDC(hDisplayWindow,hDC);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Bitmap::draw(PureDevice &pureDevice,const Rect &dstRect,const Point &srcPoint)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
::StretchDIBits(pureDevice,dstRect.left(),dstRect.top(),dstRect.right(),dstRect.bottom(),srcPoint.x(),srcPoint.y(),dstRect.right(),dstRect.bottom(),getDataPtr(),(BITMAPINFO *)getInfoPtr(),DIB_RGB_COLORS,SRCCOPY);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool Bitmap::saveBitmap(void)
|
||||
{
|
||||
BITMAPFILEHEADER bitmapFileHeader;
|
||||
OFSTRUCT ofStruct;
|
||||
|
||||
if(!isOkay())return false;
|
||||
if((HFILE_ERROR==mhFile)&&(HFILE_ERROR==(mhFile=::OpenFile(mFileName,&ofStruct,OF_WRITE|OF_CREATE))))return false;
|
||||
::memset(&bitmapFileHeader,0,sizeof(BITMAPFILEHEADER));
|
||||
bitmapFileHeader.bfType=Signature;
|
||||
bitmapFileHeader.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)+(sizeof(RGBQUAD)*(mMaxColors-1))+mImageExtent;
|
||||
bitmapFileHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)+(sizeof(RGBQUAD)*(mMaxColors-1));
|
||||
::_lwrite(mhFile,(char*)&bitmapFileHeader,sizeof(BITMAPFILEHEADER));
|
||||
::_lwrite(mhFile,(char*)getInfoPtr(),sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)+(sizeof(RGBQUAD)*(mMaxColors-1)));
|
||||
::_hwrite(mhFile,(char*)getDataPtr(),mImageExtent);
|
||||
closeFile();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bitmap::saveBitmap(MemFile &memFile)
|
||||
{
|
||||
BITMAPFILEHEADER bitmapFileHeader;
|
||||
OFSTRUCT ofStruct;
|
||||
|
||||
if(!isOkay())return false;
|
||||
if((HFILE_ERROR==mhFile)&&(HFILE_ERROR==(mhFile=::OpenFile(mFileName,&ofStruct,OF_WRITE|OF_CREATE))))return false;
|
||||
::memset(&bitmapFileHeader,0,sizeof(BITMAPFILEHEADER));
|
||||
bitmapFileHeader.bfType=Signature;
|
||||
bitmapFileHeader.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)+(sizeof(RGBQUAD)*(mMaxColors-1))+mImageExtent;
|
||||
bitmapFileHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)+(sizeof(RGBQUAD)*(mMaxColors-1));
|
||||
if(!memFile.write((char*)&bitmapFileHeader,sizeof(BITMAPFILEHEADER)))return false;
|
||||
if(!memFile.write((char*)getInfoPtr(),sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)+(sizeof(RGBQUAD)*(mMaxColors-1))))return false;
|
||||
if(!memFile.write((char*)getDataPtr(),mImageExtent))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bitmap::saveBitmap(const String &pathFileName)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
mFileName=pathFileName;
|
||||
return saveBitmap();
|
||||
}
|
||||
|
||||
void Bitmap::copyBits(UHUGE *destination,UHUGE *source,unsigned long length)const
|
||||
{
|
||||
for(unsigned long count=0;count<length;count++)*destination++=*source++;
|
||||
}
|
||||
|
||||
void Bitmap::setBits(UHUGE *lpChar,unsigned char charValue,unsigned long length)const
|
||||
{
|
||||
for(unsigned long count=0;count<length;count++)*lpChar++=charValue;
|
||||
}
|
||||
|
||||
void Bitmap::getRequiredWidth(WORD &desiredWidth,WORD desiredHeight)
|
||||
{
|
||||
DWORD imageExtent;
|
||||
|
||||
imageExtent=(((((LONG)desiredWidth*8)+31)&~31)>>3)*(LONG)desiredHeight;
|
||||
if(imageExtent==(LONG)desiredWidth*(LONG)desiredHeight)return;
|
||||
desiredWidth=(WORD)(imageExtent/(LONG)desiredHeight);
|
||||
}
|
||||
|
||||
void Bitmap::getRequiredWidth(DWORD &desiredWidth,DWORD desiredHeight)
|
||||
{
|
||||
DWORD imageExtent;
|
||||
|
||||
imageExtent=(((((LONG)desiredWidth*8)+31)&~31)>>3)*(LONG)desiredHeight;
|
||||
if(imageExtent==(LONG)desiredWidth*(LONG)desiredHeight)return;
|
||||
desiredWidth=(WORD)(imageExtent/(LONG)desiredHeight);
|
||||
}
|
||||
|
||||
Bitmap &Bitmap::rotateRight(void)
|
||||
{
|
||||
Bitmap tempBitmap(mFileName,height(),width());
|
||||
|
||||
tempBitmap.setPalette(getPalette(),FALSE);
|
||||
for(int rowIndex=0;rowIndex<height();rowIndex++)
|
||||
for(int colIndex=0;colIndex<width();colIndex++)
|
||||
tempBitmap.setByte(colIndex,(height()-1)-rowIndex,getByte(rowIndex,colIndex));
|
||||
*this=tempBitmap;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Bitmap &Bitmap::rotateLeft(void)
|
||||
{
|
||||
Bitmap tempBitmap(mFileName,height(),width());
|
||||
|
||||
tempBitmap.setPalette(getPalette(),FALSE);
|
||||
for(int rowIndex=0;rowIndex<height();rowIndex++)
|
||||
for(int colIndex=0;colIndex<width();colIndex++)
|
||||
tempBitmap.setByte((width()-1)-colIndex,rowIndex,getByte(rowIndex,colIndex));
|
||||
*this=tempBitmap;
|
||||
return *this;
|
||||
}
|
||||
|
||||
WORD Bitmap::getRow(WORD row,char FAR *lpRowData)
|
||||
{
|
||||
if(!isOkay()||row>=height()||!lpRowData)return FALSE;
|
||||
UHUGE *lpImage=getDataPtr()+mImageExtent;
|
||||
copyBits((UHUGE*)lpRowData,(lpImage-(((LONG)row*(LONG)width())+(LONG)width())),width());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD Bitmap::setRow(WORD row,char FAR *lpRowData)
|
||||
{
|
||||
if(!isOkay()||row>=height()||!lpRowData)return FALSE;
|
||||
UHUGE *lpImage=getDataPtr()+mImageExtent;
|
||||
copyBits((UHUGE*)(lpImage-(((LONG)row*(LONG)width())+(LONG)width())),(UHUGE*)lpRowData,width());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD Bitmap::getCol(WORD col,char FAR *lpColData)
|
||||
{
|
||||
if(!isOkay()||col>=width()||!lpColData)return FALSE;
|
||||
UHUGE *lpImage=getDataPtr()+mImageExtent;
|
||||
lpImage=(lpImage-(LONG)width())+(LONG)col;
|
||||
for(short rowIndex=0;rowIndex<height();rowIndex++)
|
||||
{
|
||||
*lpColData=*lpImage;
|
||||
lpImage-=(LONG)width();
|
||||
lpColData++;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD Bitmap::setCol(WORD col,char FAR *lpColData)
|
||||
{
|
||||
if(!isOkay()||col>=width()||!lpColData)return FALSE;
|
||||
UHUGE *lpImage=getDataPtr()+mImageExtent;
|
||||
lpImage=(lpImage-(LONG)width())+(LONG)col;
|
||||
for(short rowIndex=0;rowIndex<height();rowIndex++)
|
||||
{
|
||||
*lpImage=*lpColData;
|
||||
lpImage-=(LONG)width();
|
||||
lpColData++;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
205
common/BITMAP.HPP
Normal file
205
common/BITMAP.HPP
Normal file
@@ -0,0 +1,205 @@
|
||||
#ifndef _COMMON_BITMAP_HPP_
|
||||
#define _COMMON_BITMAP_HPP_
|
||||
#include <stdio.h>
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_TYPES_HPP_
|
||||
#include <common/types.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BITMAPDATA_HPP_
|
||||
#include <common/bmdata.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PUREPALETTE_HPP_
|
||||
#include <common/purepal.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GLOBALDATA_HPP_
|
||||
#include <common/gdata.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BITMAPINFO_HPP_
|
||||
#include <common/bminfo.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BITMAPOVERLAY_HPP_
|
||||
#include <common/boverlay.hpp>
|
||||
#endif
|
||||
|
||||
class MemFile;
|
||||
|
||||
class Bitmap : public BitmapData
|
||||
{
|
||||
public:
|
||||
enum {MaxColors=256,BitCount=8,Planes=1};
|
||||
Bitmap(void);
|
||||
Bitmap(const Bitmap &someBitmap);
|
||||
Bitmap(const String &pathFileName);
|
||||
Bitmap(const String &pathFileName,HGLOBAL hGlobalImage,HGLOBAL hGlobalBitmapInfo);
|
||||
Bitmap(const String &pathFileName,WORD bitmapWidth,WORD bitmapHeight,WORD bitmapColors=MaxColors,WORD bitCount=BitCount);
|
||||
Bitmap(const String &pathFileName,BitmapInfo &infoData,GlobalData<BYTE> &imageData);
|
||||
~Bitmap();
|
||||
Bitmap &rotateRight(void);
|
||||
Bitmap &rotateLeft(void);
|
||||
WORD operator=(const String &pathFileName);
|
||||
Bitmap &operator=(const Bitmap &someBitmap);
|
||||
WORD operator+=(const BitmapOverlay &someBitmapOverlay);
|
||||
WORD operator==(const Bitmap &someBitmap)const;
|
||||
WORD width(void)const;
|
||||
WORD height(void)const;
|
||||
WORD planes(void)const;
|
||||
WORD bitCount(void)const;
|
||||
DWORD getImageExtent(void)const;
|
||||
void setByte(WORD row,WORD col,BYTE byteValue);
|
||||
BYTE getByte(WORD row,WORD col)const;
|
||||
WORD getRow(WORD row,char FAR *lpRowData);
|
||||
WORD setRow(WORD row,char FAR *lpRowData);
|
||||
WORD getCol(WORD col,char FAR *lpColData);
|
||||
WORD setCol(WORD col,char FAR *lpColData);
|
||||
void setBits(BYTE byteValue);
|
||||
WORD displayBitmap(HWND hDisplayWindow,HDC hDC=(HDC)0,int isActive=FALSE,int conforming=FALSE)const;
|
||||
BOOL draw(PureDevice &pureDevice,const Rect &dstRect,const Point &srcPoint);
|
||||
bool saveBitmap(void);
|
||||
bool saveBitmap(MemFile &memFile);
|
||||
bool saveBitmap(const String &pathFileName);
|
||||
HBITMAP createBitmap(PureDevice &somePureDevice);
|
||||
WORD setPalette(HPALETTE hPalette,WORD remapBitmap=TRUE);
|
||||
HPALETTE getPalette(void)const;
|
||||
BOOL isValidBitmap(const String &pathFileName)const;
|
||||
WORD isOkay(void)const;
|
||||
void *ptrData(void);
|
||||
void upsideDown(void);
|
||||
HGLOBAL lockedImageData(void)const;
|
||||
HGLOBAL lockedBitmapInfo(void)const;
|
||||
private:
|
||||
enum Mode{Read,Write,Idle};
|
||||
enum {Signature=0x4D42};
|
||||
void mapPalette(PurePalette &purePalette);
|
||||
void closeFile(void);
|
||||
void readPalette(void);
|
||||
void setPalette(void);
|
||||
void decodeImage(void);
|
||||
void getRequiredWidth(WORD &desiredWidth,WORD desiredHeight);
|
||||
void getRequiredWidth(DWORD &desiredWidth,DWORD desiredHeight);
|
||||
void copyBitmap(const Bitmap &someBitmap);
|
||||
void copyBits(UHUGE *destination,UHUGE *source,unsigned long length)const;
|
||||
void setBits(UHUGE *lpChar,unsigned char charValue,unsigned long length)const;
|
||||
DWORD imageExtent(void)const;
|
||||
WORD processBitmap(const String &pathFileName);
|
||||
|
||||
String mFileName;
|
||||
WORD mMaxColors;
|
||||
Mode mCurrentMode;
|
||||
BITMAPFILEHEADER mBitmapFileHeader;
|
||||
PurePalette mBitmapPalette;
|
||||
const LONG mBlockSize;
|
||||
HFILE mhFile;
|
||||
DWORD mImageExtent;
|
||||
DWORD mWidth;
|
||||
DWORD mHeight;
|
||||
};
|
||||
|
||||
inline
|
||||
DWORD Bitmap::imageExtent(void)const
|
||||
{
|
||||
BITMAPINFO *lpBitmapInfo=getInfoPtr();
|
||||
return (((((lpBitmapInfo->bmiHeader.biWidth*lpBitmapInfo->bmiHeader.biBitCount)+31)&~31)>>3)*lpBitmapInfo->bmiHeader.biHeight);
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Bitmap::getImageExtent(void)const
|
||||
{
|
||||
return mImageExtent;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Bitmap::isOkay(void)const
|
||||
{
|
||||
return BitmapData::isOkay();
|
||||
}
|
||||
|
||||
inline
|
||||
HGLOBAL Bitmap::lockedImageData(void)const
|
||||
{
|
||||
return getDataHnd();
|
||||
}
|
||||
|
||||
inline
|
||||
HGLOBAL Bitmap::lockedBitmapInfo(void)const
|
||||
{
|
||||
return getInfoHnd();
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Bitmap::operator==(const Bitmap &someBitmap)const
|
||||
{
|
||||
return mFileName==someBitmap.mFileName;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Bitmap::width(void)const
|
||||
{
|
||||
return (WORD)mWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Bitmap::height(void)const
|
||||
{
|
||||
return (WORD)mHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
void Bitmap::closeFile(void)
|
||||
{
|
||||
if(HFILE_ERROR!=mhFile){::_lclose(mhFile);mhFile=HFILE_ERROR;}
|
||||
}
|
||||
|
||||
inline
|
||||
void Bitmap::setBits(BYTE byteValue)
|
||||
{
|
||||
setBits(getDataPtr(),byteValue,(LONG)width()*(LONG)height());
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE Bitmap::getByte(WORD row,WORD col)const
|
||||
{
|
||||
UHUGE *lpBitmapData;
|
||||
lpBitmapData=getDataPtr();
|
||||
if(row>=height()||col>=width())return FALSE;
|
||||
UHUGE *lpImage;
|
||||
lpImage=(lpBitmapData+((LONG)width()*(LONG)height()));
|
||||
return *((lpImage-(((LONG)row*(LONG)width())+(LONG)width()))+(LONG)col);
|
||||
}
|
||||
|
||||
inline
|
||||
void Bitmap::setByte(WORD row,WORD col,BYTE byteValue)
|
||||
{
|
||||
UHUGE *lpBitmapData;
|
||||
lpBitmapData=getDataPtr();
|
||||
if(row>=height()||col>=width())return;
|
||||
UHUGE *lpImage;
|
||||
lpImage=(lpBitmapData+((LONG)width()*(LONG)height()));
|
||||
*((lpImage-(((LONG)row*(LONG)width())+(LONG)width()))+(LONG)col)=byteValue;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Bitmap::planes(void)const
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
return getInfoPtr()->bmiHeader.biPlanes;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Bitmap::bitCount(void)const
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
return getInfoPtr()->bmiHeader.biBitCount;
|
||||
}
|
||||
|
||||
inline
|
||||
void *Bitmap::ptrData(void)
|
||||
{
|
||||
return getDataPtr();
|
||||
}
|
||||
#endif
|
||||
|
||||
172
common/BLOCK.HPP
Normal file
172
common/BLOCK.HPP
Normal file
@@ -0,0 +1,172 @@
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#define _COMMON_BLOCK_HPP_
|
||||
#ifndef _COMMON_EXCEPTION_HPP_
|
||||
#include <common/except.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
#ifndef _MSC_VER
|
||||
#ifdef _EXPAND_BLOCK_TEMPLATES_
|
||||
#pragma option -Jgd
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class Block;
|
||||
|
||||
template <class T>
|
||||
class Container
|
||||
{
|
||||
friend class Block<T>;
|
||||
public:
|
||||
Container<T> *next();
|
||||
void next(Container<T> *nextItem);
|
||||
Container<T> *prev();
|
||||
void prev(Container<T> *prevItem);
|
||||
private:
|
||||
Container *mNext;
|
||||
Container *mPrev;
|
||||
T *mItem;
|
||||
Container(void);
|
||||
virtual ~Container();
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class Block
|
||||
{
|
||||
public:
|
||||
class BlockBoundary{};
|
||||
typedef LONG Index;
|
||||
Block(void);
|
||||
Block(const Block<T> &someBlock);
|
||||
virtual ~Block(void);
|
||||
LONG size(void)const;
|
||||
void insert(const T *item);
|
||||
bool insertAfter(Index itemIndex,const T *item);
|
||||
void insert(Block<T> &newBlock);
|
||||
void remove(void);
|
||||
void remove(const T *item);
|
||||
void remove(Block<T> &removeBlock);
|
||||
void remove(Index itemIndex);
|
||||
void toArray(Array<T> &array);
|
||||
Block<T> &operator=(const Block<T> &someBlock);
|
||||
WORD operator==(const Block<T> &someBlock)const;
|
||||
T &operator[](LONG itemIndex);
|
||||
Block<T> &operator+=(const Block<T> &someBlock);
|
||||
private:
|
||||
T &find(LONG itemIndex);
|
||||
LONG mSize;
|
||||
LONG mLastIndexReferenced;
|
||||
Container<T> *mLastObjectReferenced;
|
||||
Container<T> *mLastObjectInserted;
|
||||
Container<T> *mContainer;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Block<T>::Block(void)
|
||||
: mContainer(0), mSize(0), mLastIndexReferenced(-1),
|
||||
mLastObjectReferenced(0), mLastObjectInserted(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Block<T>::Block(const Block<T> &someBlock)
|
||||
: mContainer(0), mSize(0), mLastIndexReferenced(-1),
|
||||
mLastObjectReferenced(0), mLastObjectInserted(0)
|
||||
{
|
||||
*this=someBlock;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Block<T>::~Block()
|
||||
{
|
||||
remove();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
LONG Block<T>::size(void)const
|
||||
{
|
||||
return mSize;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
T & Block<T>::operator [](LONG itemIndex)
|
||||
{
|
||||
if(itemIndex>=mSize)throw(BoundaryError());
|
||||
if(!mContainer)return *((T*)0);
|
||||
else if(itemIndex==mLastIndexReferenced&&-1!=mLastIndexReferenced&&mLastObjectReferenced)return *mLastObjectReferenced->mItem;
|
||||
else if(itemIndex==mLastIndexReferenced+1&&-1!=mLastIndexReferenced)
|
||||
{
|
||||
mLastIndexReferenced++;
|
||||
mLastObjectReferenced=mLastObjectReferenced->next();
|
||||
return *mLastObjectReferenced->mItem;
|
||||
}
|
||||
return find(itemIndex);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
void Block<T>::toArray(Array<T> &array)
|
||||
{
|
||||
array.size(size());
|
||||
for(int index=0;index<size();index++)
|
||||
array[index]=operator[](index);
|
||||
}
|
||||
|
||||
// Container class methods
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Container<T>::Container()
|
||||
: mNext(0), mPrev(0), mItem(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Container<T>::~Container()
|
||||
{
|
||||
if(mItem)delete mItem;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Container<T> *Container<T>::next(void)
|
||||
{
|
||||
return mNext;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
void Container<T>::next(Container<T> *nextItem)
|
||||
{
|
||||
mNext=nextItem;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Container<T> *Container<T>::prev(void)
|
||||
{
|
||||
return mPrev;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
void Container<T>::prev(Container<T> *prevItem)
|
||||
{
|
||||
mPrev=prevItem;
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
#include <common/block.tpp>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
178
common/BLOCK.TPP
Normal file
178
common/BLOCK.TPP
Normal file
@@ -0,0 +1,178 @@
|
||||
#ifndef _COMMON_BLOCK_TPP_
|
||||
#define _COMMON_BLOCK_TPP_
|
||||
|
||||
template <class T>
|
||||
void Block<T>::remove(void)
|
||||
{
|
||||
if(!mContainer)return;
|
||||
Container<T> *Cursor=mContainer;
|
||||
Container<T> *Thumb;
|
||||
while(Cursor)
|
||||
{
|
||||
Thumb=Cursor;
|
||||
Cursor=Cursor->next();
|
||||
::delete Thumb;
|
||||
}
|
||||
mContainer=0;
|
||||
mLastIndexReferenced=-1L;
|
||||
mLastObjectReferenced=0;
|
||||
mLastObjectInserted=0;
|
||||
mSize=0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T &Block<T>::find(LONG itemIndex)
|
||||
{
|
||||
Container<T> *lpCursor=mContainer;
|
||||
for(Index i=0;i<mSize&&i<itemIndex;i++)lpCursor=lpCursor->next();
|
||||
if(i==itemIndex)
|
||||
{
|
||||
mLastIndexReferenced=i;
|
||||
mLastObjectReferenced=lpCursor;
|
||||
return *lpCursor->mItem;
|
||||
}
|
||||
return *((T*)0);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Block<T> &Block<T>::operator+=(const Block<T> &someBlock)
|
||||
{
|
||||
size_t blockSize(someBlock.size());
|
||||
|
||||
if(!blockSize)return *this;
|
||||
for(int itemIndex=0;itemIndex<blockSize;itemIndex++)insert(&((Block<T>&)someBlock)[itemIndex]);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool Block<T>::insertAfter(Index itemIndex,const T *item)
|
||||
{
|
||||
if(itemIndex>=mSize)return false;
|
||||
mLastObjectInserted->next(::new Container<T>);
|
||||
mLastObjectInserted->next()->prev(mLastObjectInserted);
|
||||
mLastObjectInserted=mLastObjectInserted->next();
|
||||
mLastObjectInserted->mItem=::new T();
|
||||
mSize++;
|
||||
for(int index=mSize-1;index>itemIndex+1;index--)
|
||||
{
|
||||
operator[](index)=operator[](index-1);
|
||||
}
|
||||
operator[](itemIndex+1)=*item;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Block<T>::insert(Block<T> &newBlock)
|
||||
{
|
||||
LONG size(newBlock.size());
|
||||
for(Index i=0;i<size;i++)insert(&newBlock[i]);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Block<T>::insert(const T *item)
|
||||
{
|
||||
if(!mContainer)
|
||||
{
|
||||
mContainer=::new Container<T>;
|
||||
mContainer->mItem=::new T(*item);
|
||||
mLastObjectInserted=mContainer;
|
||||
mSize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mLastObjectInserted->next(::new Container<T>);
|
||||
mLastObjectInserted->next()->prev(mLastObjectInserted);
|
||||
mLastObjectInserted=mLastObjectInserted->next();
|
||||
mLastObjectInserted->mItem=::new T(*item);
|
||||
mSize++;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Block<T>::remove(Block<T> &removeBlock)
|
||||
{
|
||||
LONG size(removeBlock.size());
|
||||
|
||||
if(!size)return;
|
||||
for(long itemIndex=size-1;itemIndex>=0;itemIndex--)remove(&removeBlock[itemIndex]);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Block<T>::remove(const T *item)
|
||||
{
|
||||
Container<T> *lpThumb=mContainer;
|
||||
|
||||
if(!lpThumb)return;
|
||||
if(*item==*(mLastObjectInserted->mItem))lpThumb=mLastObjectInserted;
|
||||
else while(lpThumb){if(*item==*(lpThumb->mItem))break;lpThumb=lpThumb->next();}
|
||||
if(!lpThumb)return;
|
||||
if(lpThumb==mContainer)
|
||||
{
|
||||
if(lpThumb->next()){mContainer=lpThumb->next();mContainer->prev(0);}
|
||||
else {mContainer=0;mLastObjectInserted=0;}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(lpThumb->next()){lpThumb->prev()->next(lpThumb->next());lpThumb->next()->prev(lpThumb->prev());}
|
||||
else {lpThumb->prev()->next(0);mLastObjectInserted=lpThumb->prev();}
|
||||
}
|
||||
::delete lpThumb;
|
||||
mSize--;
|
||||
mLastIndexReferenced=-1;
|
||||
mLastObjectReferenced=0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Block<T>::remove(LONG itemIndex)
|
||||
{
|
||||
Container<T> *lpThumb=mContainer;
|
||||
|
||||
if(!lpThumb||itemIndex>=mSize)return;
|
||||
if(itemIndex==mSize-1)lpThumb=mLastObjectInserted;
|
||||
else
|
||||
{
|
||||
for(Index i=0;i<itemIndex&&lpThumb;i++)
|
||||
{
|
||||
if(itemIndex==i)break;
|
||||
lpThumb=lpThumb->next();
|
||||
}
|
||||
if(!lpThumb)return;
|
||||
}
|
||||
if(lpThumb==mContainer)
|
||||
{
|
||||
if(lpThumb->next()){mContainer=lpThumb->next();mContainer->prev(0);}
|
||||
else {mContainer=0;mLastObjectInserted=0;}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(lpThumb->next()){lpThumb->prev()->next(lpThumb->next());lpThumb->next()->prev(lpThumb->prev());}
|
||||
else {lpThumb->prev()->next(0);mLastObjectInserted=lpThumb->prev();}
|
||||
}
|
||||
::delete lpThumb;
|
||||
mSize--;
|
||||
mLastIndexReferenced=-1;
|
||||
mLastObjectReferenced=0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Block<T> &Block<T>::operator=(const Block<T> &someBlock)
|
||||
{
|
||||
LONG itemCount(someBlock.size());
|
||||
|
||||
remove();
|
||||
if(!itemCount)return *this;
|
||||
for(LONG itemIndex=0;itemIndex<itemCount;itemIndex++)insert(&(((Block<T>&)someBlock)[itemIndex]));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
WORD Block<T>::operator==(const Block<T> &someBlock)const
|
||||
{
|
||||
LONG itemCount(size());
|
||||
|
||||
if(itemCount!=someBlock.size())return FALSE;
|
||||
for(LONG itemIndex=0;itemIndex<itemCount;itemIndex++)
|
||||
if(!(((Block<T>&)*this).operator[](itemIndex)==((Block<T>&)someBlock)[itemIndex]))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
74
common/BMDATA.CPP
Normal file
74
common/BMDATA.CPP
Normal file
@@ -0,0 +1,74 @@
|
||||
#include <common/bmdata.hpp>
|
||||
|
||||
void BitmapData::cleanupData(void)
|
||||
{
|
||||
if(mhGlobalBitmapData&&Delete==mDataDisposition)
|
||||
{
|
||||
::GlobalUnlock(mhGlobalBitmapData);
|
||||
::GlobalFree(mhGlobalBitmapData);
|
||||
}
|
||||
mhGlobalBitmapData=0;
|
||||
mlpBitmapData=0;
|
||||
}
|
||||
|
||||
void BitmapData::cleanupInfo(void)
|
||||
{
|
||||
if(mhGlobalBitmapInfo&&Delete==mInfoDisposition)
|
||||
{
|
||||
::GlobalUnlock(mhGlobalBitmapInfo);
|
||||
::GlobalFree(mhGlobalBitmapInfo);
|
||||
}
|
||||
mhGlobalBitmapInfo=0;
|
||||
mlpBitmapInfo=0;
|
||||
}
|
||||
|
||||
UHUGE *BitmapData::reserveData(LONG sizeData)
|
||||
{
|
||||
cleanupData();
|
||||
if(!sizeData)return 0;
|
||||
mhGlobalBitmapData=::GlobalAlloc(GMEM_FIXED,sizeData);
|
||||
if(!mhGlobalBitmapData)return 0;
|
||||
mlpBitmapData=(UHUGE*)::GlobalLock(mhGlobalBitmapData);
|
||||
mDataDisposition=Delete;
|
||||
return mlpBitmapData;
|
||||
}
|
||||
|
||||
BITMAPINFO *BitmapData::reserveInfo(LONG sizeInfo,WORD numColors)
|
||||
{
|
||||
cleanupInfo();
|
||||
if(!sizeInfo)mhGlobalBitmapInfo=::GlobalAlloc(GMEM_FIXED,sizeof(BITMAPINFO)+(sizeof(RGBQUAD)*(numColors-1)));
|
||||
else mhGlobalBitmapInfo=::GlobalAlloc(GMEM_FIXED,sizeInfo);
|
||||
if(!mhGlobalBitmapInfo)return 0;
|
||||
mlpBitmapInfo=(BITMAPINFO FAR*)::GlobalLock(mhGlobalBitmapInfo);
|
||||
mInfoDisposition=Delete;
|
||||
return mlpBitmapInfo;
|
||||
}
|
||||
|
||||
WORD BitmapData::setData(UHUGE *lpBitmapData)
|
||||
{
|
||||
cleanupData();
|
||||
if(!lpBitmapData)return FALSE;
|
||||
mlpBitmapData=lpBitmapData;
|
||||
mDataDisposition=Keep;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD BitmapData::setData(HGLOBAL hGlobalData,UHUGE *lpBitmapData)
|
||||
{
|
||||
cleanupData();
|
||||
if(!hGlobalData||!lpBitmapData)return 0;
|
||||
mlpBitmapData=lpBitmapData;
|
||||
mhGlobalBitmapData=hGlobalData;
|
||||
mDataDisposition=Delete;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD BitmapData::setInfo(BITMAPINFO FAR*lpBitmapInfo)
|
||||
{
|
||||
cleanupInfo();
|
||||
if(!lpBitmapInfo)return FALSE;
|
||||
mlpBitmapInfo=lpBitmapInfo;
|
||||
mInfoDisposition=Keep;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
94
common/BMDATA.HPP
Normal file
94
common/BMDATA.HPP
Normal file
@@ -0,0 +1,94 @@
|
||||
#ifndef _COMMON_BITMAPDATA_HPP_
|
||||
#define _COMMON_BITMAPDATA_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_TYPES_HPP_
|
||||
#include <common/types.hpp>
|
||||
#endif
|
||||
|
||||
class BitmapData
|
||||
{
|
||||
public:
|
||||
typedef enum Disposition{Keep,Delete};
|
||||
BitmapData(void);
|
||||
~BitmapData();
|
||||
Disposition getInfoType(void)const;
|
||||
Disposition getDataType(void)const;
|
||||
UHUGE *reserveData(LONG sizeData);
|
||||
BITMAPINFO *reserveInfo(LONG sizeInfo=0,WORD numColors=0);
|
||||
WORD setData(HGLOBAL hGlobalData,UHUGE *lpBitmapData);
|
||||
WORD setData(UHUGE *lpBitmapData);
|
||||
WORD setInfo(BITMAPINFO FAR *lpBitmapInfo);
|
||||
HGLOBAL getInfoHnd(void)const;
|
||||
HGLOBAL getDataHnd(void)const;
|
||||
BITMAPINFO *getInfoPtr(void)const;
|
||||
UHUGE *getDataPtr(void)const;
|
||||
WORD isOkay(void)const;
|
||||
private:
|
||||
void cleanupData(void);
|
||||
void cleanupInfo(void);
|
||||
HGLOBAL mhGlobalBitmapData;
|
||||
HGLOBAL mhGlobalBitmapInfo;
|
||||
UHUGE *mlpBitmapData;
|
||||
BITMAPINFO *mlpBitmapInfo;
|
||||
Disposition mInfoDisposition;
|
||||
Disposition mDataDisposition;
|
||||
};
|
||||
|
||||
inline
|
||||
BitmapData::BitmapData(void)
|
||||
: mhGlobalBitmapData(0), mhGlobalBitmapInfo(0), mlpBitmapData(0), mlpBitmapInfo(0),
|
||||
mInfoDisposition(Delete), mDataDisposition(Delete)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapData::~BitmapData()
|
||||
{
|
||||
cleanupData();
|
||||
cleanupInfo();
|
||||
}
|
||||
|
||||
inline
|
||||
BITMAPINFO *BitmapData::getInfoPtr(void)const
|
||||
{
|
||||
return mlpBitmapInfo;
|
||||
}
|
||||
|
||||
inline
|
||||
UHUGE *BitmapData::getDataPtr(void)const
|
||||
{
|
||||
return mlpBitmapData;
|
||||
}
|
||||
|
||||
inline
|
||||
HGLOBAL BitmapData::getInfoHnd(void)const
|
||||
{
|
||||
return mhGlobalBitmapInfo;
|
||||
}
|
||||
|
||||
inline
|
||||
HGLOBAL BitmapData::getDataHnd(void)const
|
||||
{
|
||||
return mhGlobalBitmapData;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD BitmapData::isOkay(void)const
|
||||
{
|
||||
return (mlpBitmapData&&mlpBitmapInfo);
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapData::Disposition BitmapData::getInfoType(void)const
|
||||
{
|
||||
return mInfoDisposition;
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapData::Disposition BitmapData::getDataType(void)const
|
||||
{
|
||||
return mDataDisposition;
|
||||
}
|
||||
#endif
|
||||
167
common/BMINFO.CPP
Normal file
167
common/BMINFO.CPP
Normal file
@@ -0,0 +1,167 @@
|
||||
#include <common/bminfo.hpp>
|
||||
#include <common/purepal.hpp>
|
||||
|
||||
BitmapInfo &BitmapInfo::operator=(const BitmapInfo &someBitmapInfo)
|
||||
{
|
||||
createInfo(someBitmapInfo.rgbColors());
|
||||
planes(someBitmapInfo.planes());
|
||||
width(someBitmapInfo.width());
|
||||
height(someBitmapInfo.height());
|
||||
bitCount(someBitmapInfo.bitCount());
|
||||
compression(someBitmapInfo.compression());
|
||||
sizeImage(someBitmapInfo.sizeImage());
|
||||
xPelsPerMeter(someBitmapInfo.xPelsPerMeter());
|
||||
yPelsPerMeter(someBitmapInfo.yPelsPerMeter());
|
||||
colorUsed(someBitmapInfo.colorUsed());
|
||||
colorImportant(someBitmapInfo.colorImportant());
|
||||
for(int itemIndex=0;itemIndex<someBitmapInfo.rgbColors();itemIndex++)operator[](itemIndex)=((BitmapInfo&)someBitmapInfo)[itemIndex];
|
||||
return *this;
|
||||
}
|
||||
|
||||
BitmapInfo &BitmapInfo::operator=(const BITMAPINFO &someBITMAPINFO)
|
||||
{
|
||||
createInfo(someBITMAPINFO.bmiHeader.biClrImportant);
|
||||
planes(someBITMAPINFO.bmiHeader.biPlanes);
|
||||
width(someBITMAPINFO.bmiHeader.biWidth);
|
||||
height(someBITMAPINFO.bmiHeader.biHeight);
|
||||
bitCount(BitsPerPixel(someBITMAPINFO.bmiHeader.biBitCount));
|
||||
compression(BiCompression(someBITMAPINFO.bmiHeader.biCompression));
|
||||
sizeImage(someBITMAPINFO.bmiHeader.biSizeImage);
|
||||
xPelsPerMeter(someBITMAPINFO.bmiHeader.biXPelsPerMeter);
|
||||
yPelsPerMeter(someBITMAPINFO.bmiHeader.biYPelsPerMeter);
|
||||
colorUsed(someBITMAPINFO.bmiHeader.biClrUsed);
|
||||
colorImportant(someBITMAPINFO.bmiHeader.biClrImportant);
|
||||
for(int itemIndex=0;itemIndex<someBITMAPINFO.bmiHeader.biClrImportant;itemIndex++)
|
||||
{
|
||||
RGBQuad &rgbQuad=operator[](itemIndex);
|
||||
rgbQuad.red(someBITMAPINFO.bmiColors[itemIndex].rgbRed);
|
||||
rgbQuad.green(someBITMAPINFO.bmiColors[itemIndex].rgbGreen);
|
||||
rgbQuad.blue(someBITMAPINFO.bmiColors[itemIndex].rgbBlue);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
BitmapInfo &BitmapInfo::operator=(const PurePalette &somePurePalette)
|
||||
{
|
||||
WORD paletteEntries(somePurePalette.paletteEntries());
|
||||
PaletteEntry paletteEntry;
|
||||
|
||||
if(!paletteEntries)return *this;
|
||||
rgbColors(paletteEntries);
|
||||
for(WORD paletteIndex=0;paletteIndex<paletteEntries;paletteIndex++)
|
||||
{
|
||||
paletteEntry=somePurePalette.paletteEntry(paletteIndex);
|
||||
mlpBitmapInfo->bmiColors[paletteIndex].rgbRed=paletteEntry.red();
|
||||
mlpBitmapInfo->bmiColors[paletteIndex].rgbGreen=paletteEntry.green();
|
||||
mlpBitmapInfo->bmiColors[paletteIndex].rgbBlue=paletteEntry.blue();
|
||||
mlpBitmapInfo->bmiColors[paletteIndex].rgbReserved=0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
WORD BitmapInfo::operator==(const BitmapInfo &someBitmapInfo)const
|
||||
{
|
||||
if(rgbColors()!=someBitmapInfo.rgbColors())return FALSE;
|
||||
if (!(planes()==someBitmapInfo.planes())||
|
||||
!(width()==someBitmapInfo.width())||
|
||||
!(height()==someBitmapInfo.height())||
|
||||
!(bitCount()==someBitmapInfo.bitCount())||
|
||||
!(compression()==someBitmapInfo.compression())||
|
||||
!(sizeImage()==someBitmapInfo.sizeImage())||
|
||||
!(xPelsPerMeter()==someBitmapInfo.xPelsPerMeter())||
|
||||
!(yPelsPerMeter()==someBitmapInfo.yPelsPerMeter())||
|
||||
!(colorUsed()==someBitmapInfo.colorUsed())||
|
||||
!(colorImportant()==someBitmapInfo.colorImportant()))return FALSE;
|
||||
for(int itemIndex=0;itemIndex<rgbColors();itemIndex++)
|
||||
if(!(((BitmapInfo&)*this).operator[](itemIndex)==((BitmapInfo&)someBitmapInfo)[itemIndex]))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void BitmapInfo::rgbColors(DWORD rgbColors)
|
||||
{
|
||||
BitmapInfo bitmapInfo(*this);
|
||||
|
||||
createInfo(rgbColors);
|
||||
planes(bitmapInfo.planes());
|
||||
width(bitmapInfo.width());
|
||||
height(bitmapInfo.height());
|
||||
bitCount(bitmapInfo.bitCount());
|
||||
compression(bitmapInfo.compression());
|
||||
sizeImage(bitmapInfo.sizeImage());
|
||||
xPelsPerMeter(bitmapInfo.xPelsPerMeter());
|
||||
yPelsPerMeter(bitmapInfo.yPelsPerMeter());
|
||||
colorUsed(rgbColors);
|
||||
colorImportant(rgbColors);
|
||||
}
|
||||
|
||||
void BitmapInfo::createInfo(DWORD rgbColors)
|
||||
{
|
||||
destroyInfo();
|
||||
if(!rgbColors)rgbColors=1;
|
||||
mhGlobalHandle=::GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(BITMAPINFO)+(sizeof(RGBQUAD)*(rgbColors-1)));
|
||||
mlpBitmapInfo=(BITMAPINFO*)::GlobalLock(mhGlobalHandle);
|
||||
mlpBitmapInfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
|
||||
bitCount(BitsPerPixel(DefaultBitCount));
|
||||
compression(BiRGB);
|
||||
planes(DefaultPlanes);
|
||||
colorUsed(rgbColors);
|
||||
colorImportant(rgbColors);
|
||||
mRGBColors=rgbColors;
|
||||
}
|
||||
|
||||
void BitmapInfo::destroyInfo(void)
|
||||
{
|
||||
if(!mhGlobalHandle)return;
|
||||
::GlobalUnlock(mhGlobalHandle);
|
||||
::GlobalFree(mhGlobalHandle);
|
||||
mhGlobalHandle=0;
|
||||
mlpBitmapInfo=0;
|
||||
mRGBColors=0;
|
||||
}
|
||||
|
||||
void BitmapInfo::verifyDimensions(void)
|
||||
{
|
||||
DWORD desiredHeight(height()<0?-height():height());
|
||||
DWORD desiredWidth(width());
|
||||
DWORD imageExtent;
|
||||
|
||||
imageExtent=(((((LONG)desiredWidth*8)+31)&~31)>>3)*(LONG)desiredHeight;
|
||||
if(imageExtent==(LONG)desiredWidth*(LONG)desiredHeight)return;
|
||||
else desiredWidth=(WORD)(imageExtent/(LONG)desiredHeight);
|
||||
width(desiredWidth);
|
||||
}
|
||||
|
||||
String BitmapInfo::toString(void)const
|
||||
{
|
||||
String strCompression;
|
||||
String str;
|
||||
str+=String("[BitmapInfo::toString]planes=")+String().fromInt(planes())+String("\n");
|
||||
str+=String("[BitmapInfo::toString]width=")+String().fromInt(width())+String("\n");
|
||||
str+=String("[BitmapInfo::toString]height=")+String().fromInt(height())+String("\n");
|
||||
str+=String("[BitmapInfo::toString]bitCount=")+String().fromInt(bitCount())+String("\n");
|
||||
if(BiRGB==compression())strCompression="BI_RGB";
|
||||
else if(BiBitFields==compression())strCompression="BI_BITFIELDS";
|
||||
else if(BiRLE8==compression())strCompression="BI_RLE8";
|
||||
else if(BiRLE4==compression())strCompression="BI_RLE4";
|
||||
else strCompression=makeCompressionString();
|
||||
str+=String("[BitmapInfo::toString]compression=")+strCompression+String("\n");
|
||||
str+=String("[BitmapInfo::toString]sizeImage=")+String().fromInt(sizeImage())+String("\n");
|
||||
str+=String("[BitmapInfo::toString]xPelsPerMeter=")+String().fromInt(xPelsPerMeter())+String("\n");
|
||||
str+=String("[BitmapInfo::toString]yPelsPerMeter=")+String().fromInt(yPelsPerMeter())+String("\n");
|
||||
str+=String("[BitmapInfo::toString]colorUsed=")+String().fromInt(colorUsed())+String("\n");
|
||||
str+=String("[BitmapInfo::toString]colorImportant=")+String().fromInt(colorImportant())+String("\n");
|
||||
return str;
|
||||
}
|
||||
|
||||
String BitmapInfo::makeCompressionString(void)const
|
||||
{
|
||||
String strCompression;
|
||||
|
||||
strCompression.reserve(5);
|
||||
((char*)strCompression)[0]=(BYTE)(compression()&0xFF);
|
||||
((char*)strCompression)[1]=(BYTE)((compression()>>0x08)&0xFF);
|
||||
((char*)strCompression)[2]=(BYTE)((compression()>>0x10)&0xFF);
|
||||
((char*)strCompression)[3]=(BYTE)((compression()>>0x18)&0xFF);
|
||||
return strCompression;
|
||||
}
|
||||
|
||||
289
common/BMINFO.HPP
Normal file
289
common/BMINFO.HPP
Normal file
@@ -0,0 +1,289 @@
|
||||
#ifndef _COMMON_BITMAPINFO_HPP_
|
||||
#define _COMMON_BITMAPINFO_HPP_
|
||||
#ifndef _COMMON_EXCEPTION_HPP_
|
||||
#include <common/except.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_RGBQUAD_HPP_
|
||||
#include <common/rgbquad.hpp>
|
||||
#endif
|
||||
|
||||
class PurePalette;
|
||||
|
||||
class BitmapInfo
|
||||
{
|
||||
public:
|
||||
enum BitsPerPixel{Bit8=8,Bit16=16,Bit24=24,TrueColor=24,Bit32=32};
|
||||
enum BiCompression{BiRGB=BI_RGB,BiBitFields=BI_BITFIELDS,BiRLE8=BI_RLE8,BiRLE4=BI_RLE4};
|
||||
BitmapInfo(void);
|
||||
BitmapInfo(const BitmapInfo &someBitmapInfo);
|
||||
BitmapInfo(const BITMAPINFO &someBITMAPINFO);
|
||||
virtual ~BitmapInfo();
|
||||
BitmapInfo &operator=(const BitmapInfo &someBitmapInfo);
|
||||
BitmapInfo &operator=(const BITMAPINFO &someBITMAPINFO);
|
||||
BitmapInfo &operator=(const PurePalette &somePurePalette);
|
||||
WORD operator==(const BitmapInfo &someBitmapInfo)const;
|
||||
RGBQuad &operator[](int itemIndex);
|
||||
operator BITMAPINFO&(void);
|
||||
operator BITMAPINFO*(void);
|
||||
operator BITMAPINFOHEADER*(void);
|
||||
operator BITMAPINFOHEADER&(void);
|
||||
operator RGBQUAD*(void);
|
||||
WORD planes(void)const;
|
||||
void planes(WORD planes);
|
||||
LONG width(void)const;
|
||||
void width(LONG width);
|
||||
LONG height(void)const;
|
||||
void height(LONG height);
|
||||
BitsPerPixel bitCount(void)const;
|
||||
void bitCount(BitsPerPixel bitCount);
|
||||
BiCompression compression(void)const;
|
||||
void compression(BiCompression compression);
|
||||
void compression(DWORD compression);
|
||||
DWORD sizeImage(void)const;
|
||||
void sizeImage(DWORD sizeImage);
|
||||
LONG xPelsPerMeter(void)const;
|
||||
void xPelsPerMeter(LONG xPelsPerMeter);
|
||||
LONG yPelsPerMeter(void)const;
|
||||
void yPelsPerMeter(LONG yPelsPerMeter);
|
||||
DWORD colorUsed(void)const;
|
||||
void colorUsed(DWORD colorUsed);
|
||||
DWORD colorImportant(void)const;
|
||||
void colorImportant(DWORD colorImportant);
|
||||
DWORD rgbColors(void)const;
|
||||
void rgbColors(DWORD rgbColors);
|
||||
DWORD imageExtent(void)const;
|
||||
void verifyDimensions(void);
|
||||
String toString(void)const;
|
||||
BITMAPINFO &getBITMAPINFO(void);
|
||||
BITMAPINFOHEADER &getBITMAPINFOHEADER(void);
|
||||
private:
|
||||
enum {DefaultColors=0x100,DefaultCompression=BI_RGB,DefaultBitCount=Bit8,DefaultPlanes=0x01};
|
||||
void createInfo(DWORD rgbColors);
|
||||
void destroyInfo(void);
|
||||
String makeCompressionString(void)const;
|
||||
|
||||
BITMAPINFO *mlpBitmapInfo;
|
||||
HGLOBAL mhGlobalHandle;
|
||||
DWORD mRGBColors;
|
||||
};
|
||||
|
||||
inline
|
||||
BitmapInfo::BitmapInfo(void)
|
||||
: mlpBitmapInfo(0), mhGlobalHandle(0), mRGBColors(0)
|
||||
{
|
||||
createInfo(DefaultColors);
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::BitmapInfo(const BitmapInfo &someBitmapInfo)
|
||||
: mlpBitmapInfo(0), mhGlobalHandle(0), mRGBColors(0)
|
||||
{
|
||||
*this=someBitmapInfo;
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::BitmapInfo(const BITMAPINFO &someBITMAPINFO)
|
||||
: mlpBitmapInfo(0), mhGlobalHandle(0), mRGBColors(0)
|
||||
{
|
||||
*this=someBITMAPINFO;
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::~BitmapInfo()
|
||||
{
|
||||
destroyInfo();
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::operator BITMAPINFO&(void)
|
||||
{
|
||||
return *mlpBitmapInfo;
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::operator BITMAPINFO*(void)
|
||||
{
|
||||
return mlpBitmapInfo;
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::operator BITMAPINFOHEADER&(void)
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader;
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::operator BITMAPINFOHEADER*(void)
|
||||
{
|
||||
return &mlpBitmapInfo->bmiHeader;
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::operator RGBQUAD*(void)
|
||||
{
|
||||
return mlpBitmapInfo->bmiColors;
|
||||
}
|
||||
|
||||
inline
|
||||
RGBQuad &BitmapInfo::operator[](int itemIndex)
|
||||
{
|
||||
if(!(itemIndex<rgbColors()))throw(BoundaryError());
|
||||
return (RGBQuad&)mlpBitmapInfo->bmiColors[itemIndex];
|
||||
}
|
||||
|
||||
inline
|
||||
BITMAPINFO &BitmapInfo::getBITMAPINFO(void)
|
||||
{
|
||||
return *mlpBitmapInfo;
|
||||
}
|
||||
|
||||
inline
|
||||
BITMAPINFOHEADER &BitmapInfo::getBITMAPINFOHEADER(void)
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD BitmapInfo::planes(void)const
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader.biPlanes;
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::planes(WORD planes)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biPlanes=planes;
|
||||
}
|
||||
|
||||
inline
|
||||
LONG BitmapInfo::width(void)const
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader.biWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::width(LONG width)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biWidth=width;
|
||||
sizeImage(imageExtent());
|
||||
}
|
||||
|
||||
inline
|
||||
LONG BitmapInfo::height(void)const
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader.biHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::height(LONG height)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biHeight=height;
|
||||
sizeImage(imageExtent());
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::BitsPerPixel BitmapInfo::bitCount(void)const
|
||||
{
|
||||
return BitsPerPixel(mlpBitmapInfo->bmiHeader.biBitCount);
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::bitCount(BitsPerPixel bitCount)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biBitCount=int(bitCount);
|
||||
sizeImage(imageExtent());
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapInfo::BiCompression BitmapInfo::compression(void)const
|
||||
{
|
||||
return BiCompression(mlpBitmapInfo->bmiHeader.biCompression);
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::compression(BiCompression compression)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biCompression=compression;
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::compression(DWORD compression) // backward compatibility
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biCompression=compression;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD BitmapInfo::sizeImage(void)const
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader.biSizeImage;
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::sizeImage(DWORD sizeImage)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biSizeImage=sizeImage;
|
||||
}
|
||||
|
||||
inline
|
||||
LONG BitmapInfo::xPelsPerMeter(void)const
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader.biXPelsPerMeter;
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::xPelsPerMeter(LONG xPelsPerMeter)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biXPelsPerMeter=xPelsPerMeter;
|
||||
}
|
||||
|
||||
inline
|
||||
LONG BitmapInfo::yPelsPerMeter(void)const
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader.biYPelsPerMeter;
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::yPelsPerMeter(LONG yPelsPerMeter)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biYPelsPerMeter=yPelsPerMeter;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD BitmapInfo::colorUsed(void)const
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader.biClrUsed;
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::colorUsed(DWORD colorUsed)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biClrUsed=colorUsed;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD BitmapInfo::colorImportant(void)const
|
||||
{
|
||||
return mlpBitmapInfo->bmiHeader.biClrImportant;
|
||||
}
|
||||
|
||||
inline
|
||||
void BitmapInfo::colorImportant(DWORD colorImportant)
|
||||
{
|
||||
mlpBitmapInfo->bmiHeader.biClrImportant=colorImportant;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD BitmapInfo::rgbColors(void)const
|
||||
{
|
||||
return mRGBColors;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD BitmapInfo::imageExtent(void)const
|
||||
{
|
||||
return (((((width()*(long)bitCount())+31)&~31)>>3)*height());
|
||||
}
|
||||
#endif
|
||||
46
common/BMPLNK.CPP
Normal file
46
common/BMPLNK.CPP
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <common/bmplnk.hpp>
|
||||
|
||||
LinkedBitmap::LinkedBitmap(void)
|
||||
: mCtlID(0), mhBitmap(0), mReferenceCount(0), mhLibrary(0)
|
||||
{
|
||||
::memset(&mBitmapInfo,0,sizeof(BITMAP));
|
||||
}
|
||||
|
||||
LinkedBitmap::LinkedBitmap(int ctlID,String &bitmapName,HINSTANCE hLibrary)
|
||||
: mCtlID(ctlID), mReferenceCount(1), mhLibrary(hLibrary), mBitmapName(bitmapName)
|
||||
{
|
||||
::memset(&mBitmapInfo,0,sizeof(BITMAP));
|
||||
loadBitmap(bitmapName,hLibrary);
|
||||
}
|
||||
|
||||
LinkedBitmap::LinkedBitmap(const LinkedBitmap &someLinkedBitmap)
|
||||
: mCtlID(someLinkedBitmap.mCtlID), mReferenceCount(someLinkedBitmap.mReferenceCount),
|
||||
mhLibrary(someLinkedBitmap.mhLibrary), mBitmapName(someLinkedBitmap.mBitmapName)
|
||||
{
|
||||
::memset(&mBitmapInfo,0,sizeof(BITMAP));
|
||||
loadBitmap(someLinkedBitmap.mBitmapName,someLinkedBitmap.mhLibrary);
|
||||
}
|
||||
|
||||
LinkedBitmap::~LinkedBitmap()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void LinkedBitmap::destroy(void)
|
||||
{
|
||||
if(!isOkay())return;
|
||||
::DeleteObject(mhBitmap);
|
||||
mhBitmap=0;
|
||||
}
|
||||
|
||||
WORD LinkedBitmap::drawBitmap(HDC hDC,RECT locationRect)
|
||||
{
|
||||
DrawBitmap::drawBitmap(hDC,mhBitmap,locationRect);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD LinkedBitmap::drawBitmap(void)
|
||||
{
|
||||
DrawBitmap::drawBitmap(mhBitmap);
|
||||
return TRUE;
|
||||
}
|
||||
103
common/BMPLNK.HPP
Normal file
103
common/BMPLNK.HPP
Normal file
@@ -0,0 +1,103 @@
|
||||
#ifndef _COMMON_LINKEDBITMAP_HPP_
|
||||
#define _COMMON_LINKEDBITMAP_HPP_
|
||||
#ifndef _COMMON_DRAWBITMAP_HPP_
|
||||
#include <common/drawbmp.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class LinkedBitmap : public DrawBitmap
|
||||
{
|
||||
public:
|
||||
LinkedBitmap(void);
|
||||
LinkedBitmap(int ctlID,String &bitmapName,HINSTANCE hLibrary);
|
||||
LinkedBitmap(const LinkedBitmap &someLinkedBitmap);
|
||||
virtual ~LinkedBitmap();
|
||||
WORD drawBitmap(HDC hDC,RECT locationRect);
|
||||
WORD drawBitmap(void);
|
||||
int referenceCount(void)const;
|
||||
void referenceCount(int newCount);
|
||||
bool operator==(const LinkedBitmap &someLinkedBitmap)const;
|
||||
bool operator==(int ctlID)const;
|
||||
DWORD width(void)const;
|
||||
DWORD height(void)const;
|
||||
HBITMAP getHBITMAP(void)const;
|
||||
bool isOkay(void)const;
|
||||
bool loadBitmap(const String &strBitmapName,HINSTANCE hInstance=::GetModuleHandle(0));
|
||||
private:
|
||||
void getBitmapInfo(void);
|
||||
void destroy(void);
|
||||
|
||||
int mCtlID;
|
||||
HBITMAP mhBitmap;
|
||||
BITMAP mBitmapInfo;
|
||||
String mBitmapName;
|
||||
int mReferenceCount;
|
||||
HINSTANCE mhLibrary;
|
||||
};
|
||||
|
||||
inline
|
||||
int LinkedBitmap::referenceCount(void)const
|
||||
{
|
||||
return mReferenceCount;
|
||||
}
|
||||
|
||||
inline
|
||||
void LinkedBitmap::referenceCount(int newCount)
|
||||
{
|
||||
mReferenceCount=newCount;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LinkedBitmap::operator==(const LinkedBitmap &someLinkedBitmap)const
|
||||
{
|
||||
return (mCtlID==someLinkedBitmap.mCtlID);
|
||||
}
|
||||
|
||||
inline
|
||||
bool LinkedBitmap::operator==(int ctlID)const
|
||||
{
|
||||
return mCtlID==ctlID;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LinkedBitmap::loadBitmap(const String &strBitmapName,HINSTANCE hInstance)
|
||||
{
|
||||
destroy();
|
||||
mhBitmap=::LoadBitmap(hInstance,strBitmapName.str());
|
||||
if(!mhBitmap)return false;
|
||||
getBitmapInfo();
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
void LinkedBitmap::getBitmapInfo(void)
|
||||
{
|
||||
::GetObject(mhBitmap,sizeof(BITMAP),(LPSTR)&mBitmapInfo);
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD LinkedBitmap::width(void)const
|
||||
{
|
||||
return mBitmapInfo.bmWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD LinkedBitmap::height(void)const
|
||||
{
|
||||
return mBitmapInfo.bmHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
HBITMAP LinkedBitmap::getHBITMAP(void)const
|
||||
{
|
||||
return mhBitmap;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LinkedBitmap::isOkay(void)const
|
||||
{
|
||||
return mhBitmap?true:false;
|
||||
}
|
||||
#endif
|
||||
44
common/BOVERLAY.HPP
Normal file
44
common/BOVERLAY.HPP
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef _COMMON_BITMAPOVERLAY_HPP_
|
||||
#define _COMMON_BITMAPOVERLAY_HPP_
|
||||
#ifndef _COMMON_POINT_HPP_
|
||||
#include <common/point.hpp>
|
||||
#endif
|
||||
|
||||
class Bitmap;
|
||||
|
||||
class BitmapOverlay
|
||||
{
|
||||
public:
|
||||
BitmapOverlay(Bitmap &someBitmap,const Point &placementPoint);
|
||||
virtual ~BitmapOverlay();
|
||||
Bitmap &bitmap(void);
|
||||
const Point &placementPoint(void)const;
|
||||
private:
|
||||
Bitmap &mBitmap;
|
||||
Point mPlacementPoint;
|
||||
};
|
||||
|
||||
inline
|
||||
BitmapOverlay::BitmapOverlay(Bitmap &someBitmap,const Point &placementPoint)
|
||||
: mBitmap(someBitmap), mPlacementPoint(placementPoint)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
BitmapOverlay::~BitmapOverlay()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Bitmap &BitmapOverlay::bitmap(void)
|
||||
{
|
||||
return mBitmap;
|
||||
}
|
||||
|
||||
inline
|
||||
const Point &BitmapOverlay::placementPoint(void)const
|
||||
{
|
||||
return mPlacementPoint;
|
||||
}
|
||||
#endif
|
||||
|
||||
36
common/BRUSH.CPP
Normal file
36
common/BRUSH.CPP
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <common/brush.hpp>
|
||||
#include <common/purebmp.hpp>
|
||||
#include <common/resbmp.hpp>
|
||||
|
||||
Brush::Brush(PureBitmap &pureBitmap)
|
||||
: mhBrush(0)
|
||||
{
|
||||
if(!pureBitmap.isOkay())return;
|
||||
mhBrush=::CreatePatternBrush(pureBitmap);
|
||||
}
|
||||
|
||||
Brush::Brush(ResBitmap &resBitmap)
|
||||
: mhBrush(0)
|
||||
{
|
||||
if(!resBitmap.isOkay())return;
|
||||
mhBrush=::CreateDIBPatternBrushPt((BITMAPINFO*)(char*)(ResData<char>&)resBitmap,DIB_RGB_COLORS);
|
||||
}
|
||||
|
||||
bool Brush::createPatternBrush(PureBitmap &pureBitmap)
|
||||
{
|
||||
destroy();
|
||||
if(!pureBitmap.isOkay())return FALSE;
|
||||
mhBrush=::CreatePatternBrush(pureBitmap.getBitmap());
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
bool Brush::createHatchBrush(HatchStyle hatchStyle,const RGBColor &color)
|
||||
{
|
||||
destroy();
|
||||
mBrushColor=color;
|
||||
mhBrush=::CreateHatchBrush(int(hatchStyle),color.getCOLORREF());
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
128
common/BRUSH.HPP
Normal file
128
common/BRUSH.HPP
Normal file
@@ -0,0 +1,128 @@
|
||||
#ifndef _COMMON_BRUSH_HPP_
|
||||
#define _COMMON_BRUSH_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GDIOBJ_HPP_
|
||||
#include <common/gdiobj.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_RGBCOLOR_HPP_
|
||||
#include <common/rgbcolor.hpp>
|
||||
#endif
|
||||
|
||||
class PureBitmap;
|
||||
class ResBitmap;
|
||||
|
||||
class Brush
|
||||
{
|
||||
public:
|
||||
enum HatchStyle{HDiag=HS_BDIAGONAL,HCross=HS_CROSS,HDiagCross=HS_DIAGCROSS,HFDiag=HS_FDIAGONAL,HHoriz=HS_HORIZONTAL,HVert=HS_VERTICAL};
|
||||
Brush(void);
|
||||
Brush(RGBColor rgbColor);
|
||||
Brush(int red,int green,int blue);
|
||||
Brush(PureBitmap &pureBitmap);
|
||||
Brush(ResBitmap &resBitmap);
|
||||
virtual ~Brush();
|
||||
operator GDIObj(void);
|
||||
bool createBrush(const RGBColor &rgbColor);
|
||||
bool createNullBrush(void);
|
||||
bool createPatternBrush(PureBitmap &pureBitmap);
|
||||
bool createHatchBrush(HatchStyle hatchStyle,const RGBColor &rgbColor);
|
||||
bool isOkay(void)const;
|
||||
HBRUSH getBrush(void)const;
|
||||
const RGBColor &getColor(void)const;
|
||||
private:
|
||||
Brush(const Brush &someBrush);
|
||||
Brush &operator=(const Brush &someBrush);
|
||||
void destroy(void);
|
||||
HBRUSH mhBrush;
|
||||
RGBColor mBrushColor;
|
||||
};
|
||||
|
||||
inline
|
||||
Brush::Brush(void)
|
||||
: mhBrush(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Brush::Brush(const Brush &/*someBrush*/)
|
||||
: mhBrush(0)
|
||||
{ // private implementation
|
||||
}
|
||||
|
||||
inline
|
||||
Brush::Brush(int red,int green,int blue)
|
||||
: mhBrush(0)
|
||||
{
|
||||
mhBrush=::CreateSolidBrush((COLORREF)RGBColor(red,green,blue));
|
||||
}
|
||||
|
||||
inline
|
||||
Brush::Brush(RGBColor rgbColor)
|
||||
: mhBrush(0)
|
||||
{
|
||||
mBrushColor=rgbColor;
|
||||
mhBrush=::CreateSolidBrush((COLORREF)rgbColor);
|
||||
}
|
||||
|
||||
inline
|
||||
Brush::~Brush()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
inline
|
||||
Brush &Brush::operator=(const Brush &/*someBrush*/)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
Brush::operator GDIObj(void)
|
||||
{
|
||||
return (GDIObj)mhBrush;
|
||||
}
|
||||
|
||||
inline
|
||||
void Brush::destroy(void)
|
||||
{
|
||||
if(mhBrush){::DeleteObject(mhBrush);mhBrush=0;}
|
||||
}
|
||||
|
||||
inline
|
||||
bool Brush::createBrush(const RGBColor &rgbColor)
|
||||
{
|
||||
destroy();
|
||||
mBrushColor=rgbColor;
|
||||
mhBrush=::CreateSolidBrush((COLORREF)rgbColor);
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
inline
|
||||
bool Brush::createNullBrush(void)
|
||||
{
|
||||
destroy();
|
||||
mhBrush=(HBRUSH)::GetStockObject(NULL_BRUSH);
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
inline
|
||||
const RGBColor &Brush::getColor(void)const
|
||||
{
|
||||
return mBrushColor;
|
||||
}
|
||||
|
||||
inline
|
||||
HBRUSH Brush::getBrush(void)const
|
||||
{
|
||||
return mhBrush;
|
||||
}
|
||||
|
||||
inline
|
||||
bool Brush::isOkay(void)const
|
||||
{
|
||||
return (mhBrush?TRUE:FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
87
common/BTNLNK.CPP
Normal file
87
common/BTNLNK.CPP
Normal file
@@ -0,0 +1,87 @@
|
||||
#include <common/btnlnk.hpp>
|
||||
#include <common/purehdc.hpp>
|
||||
|
||||
LinkedButton::LinkedButton(void)
|
||||
: mCtlID(0), mFocus(Focus), mlpBitmapDefault(0), mReferenceCount(0), mhInstance(0)
|
||||
{
|
||||
}
|
||||
|
||||
LinkedButton::LinkedButton(int ctlID,String &focusUp,String &noFocusUp,String &focusDown,String &noFocusDisabled,HINSTANCE hInstance,FocusItem focusItem)
|
||||
: mCtlID(ctlID), mReferenceCount(1), mFocus(focusItem),
|
||||
mBitmapFocusUp(focusUp,hInstance), mBitmapNoFocusUp(noFocusUp,hInstance),
|
||||
mBitmapFocusDown(focusDown,hInstance), mBitmapDisabled(noFocusDisabled,hInstance),
|
||||
mFocusUpString(focusUp), mNoFocusUpString(noFocusUp), mFocusDownString(focusDown),
|
||||
mNoFocusDisabledString(noFocusDisabled), mhInstance(hInstance)
|
||||
{
|
||||
setBitmapDefault();
|
||||
}
|
||||
|
||||
LinkedButton::LinkedButton(int ctlID,String &focusUp,String &noFocusUp,String &focusDown,HINSTANCE hInstance,FocusItem focusItem)
|
||||
: mCtlID(ctlID), mReferenceCount(1), mFocus(focusItem),
|
||||
mBitmapFocusUp(focusUp,hInstance), mBitmapNoFocusUp(noFocusUp,hInstance),
|
||||
mBitmapFocusDown(focusDown,hInstance), mBitmapDisabled(noFocusUp,hInstance),
|
||||
mFocusUpString(focusUp), mNoFocusUpString(noFocusUp), mFocusDownString(focusDown),
|
||||
mNoFocusDisabledString(noFocusUp), mhInstance(hInstance)
|
||||
{
|
||||
setBitmapDefault();
|
||||
}
|
||||
|
||||
LinkedButton::LinkedButton(const LinkedButton &someLinkedButton)
|
||||
: mCtlID(someLinkedButton.mCtlID), mReferenceCount(someLinkedButton.mReferenceCount),
|
||||
mFocus(someLinkedButton.mFocus), mhInstance(someLinkedButton.instance()),
|
||||
mBitmapFocusUp(someLinkedButton.mFocusUpString,someLinkedButton.instance()),
|
||||
mBitmapNoFocusUp(someLinkedButton.mNoFocusUpString,someLinkedButton.instance()),
|
||||
mBitmapFocusDown(someLinkedButton.mFocusDownString,someLinkedButton.instance()),
|
||||
mBitmapDisabled(someLinkedButton.mNoFocusDisabledString,someLinkedButton.instance()),
|
||||
mFocusUpString(someLinkedButton.mFocusUpString),
|
||||
mNoFocusUpString(someLinkedButton.mNoFocusUpString),
|
||||
mFocusDownString(someLinkedButton.mFocusDownString),
|
||||
mNoFocusDisabledString(someLinkedButton.mNoFocusDisabledString)
|
||||
{
|
||||
setBitmapDefault();
|
||||
}
|
||||
|
||||
LinkedButton::~LinkedButton()
|
||||
{
|
||||
}
|
||||
|
||||
WORD LinkedButton::drawButton(LPDRAWITEMSTRUCT lpControlData)
|
||||
{
|
||||
int retCode(TRUE);
|
||||
|
||||
switch(lpControlData->itemAction)
|
||||
{
|
||||
case ODA_DRAWENTIRE :
|
||||
if(lpControlData->itemState&ODS_SELECTED)drawBitmap(lpControlData,mBitmapFocusDown);
|
||||
else if(lpControlData->itemState&ODS_FOCUS)drawBitmap(lpControlData,*mlpBitmapDefault);
|
||||
else if(lpControlData->itemState&ODS_DISABLED)drawBitmap(lpControlData,mBitmapDisabled);
|
||||
else drawBitmap(lpControlData,mBitmapNoFocusUp);
|
||||
break;
|
||||
case ODA_SELECT :
|
||||
if(lpControlData->itemState&ODS_SELECTED)drawBitmap(lpControlData,mBitmapFocusDown);
|
||||
else
|
||||
{
|
||||
drawBitmap(lpControlData,mBitmapFocusUp);
|
||||
retCode=FALSE;
|
||||
}
|
||||
break;
|
||||
case ODA_FOCUS :
|
||||
if(lpControlData->itemState&ODS_FOCUS)drawBitmap(lpControlData,mBitmapFocusUp);
|
||||
else drawBitmap(lpControlData,mBitmapNoFocusUp);
|
||||
break;
|
||||
}
|
||||
return retCode;
|
||||
}
|
||||
|
||||
void LinkedButton::drawBitmap(const LPDRAWITEMSTRUCT lpControlData,PureBitmap &pureBitmap)
|
||||
{
|
||||
RECT controlRect;
|
||||
|
||||
if(!pureBitmap.isOkay())return;
|
||||
PureDevice displayDevice(lpControlData->hDC);
|
||||
PureDevice memDevice(displayDevice);
|
||||
::GetClientRect(lpControlData->hwndItem,&controlRect);
|
||||
memDevice.select((HBITMAP)pureBitmap);
|
||||
displayDevice.stretchBlt(controlRect,memDevice,Rect(0,0,pureBitmap.width(),pureBitmap.height()),PureDevice::SourceCopy);
|
||||
memDevice.select((HBITMAP)pureBitmap,FALSE);
|
||||
}
|
||||
89
common/BTNLNK.HPP
Normal file
89
common/BTNLNK.HPP
Normal file
@@ -0,0 +1,89 @@
|
||||
#ifndef _COMMON_LINKEDBUTTON_HPP_
|
||||
#define _COMMON_LINKEDBUTTON_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PUREBITMAP_HPP_
|
||||
#include <common/purebmp.hpp>
|
||||
#endif
|
||||
|
||||
class LinkedButton
|
||||
{
|
||||
public:
|
||||
enum FocusItem{Focus,NoFocus};
|
||||
LinkedButton(void);
|
||||
LinkedButton(int ctlID,String &focusUp,String &noFocusUp,String &focusDown,HINSTANCE hLibrary,FocusItem focusItem=Focus);
|
||||
LinkedButton(int ctlID,String &focusUp,String &noFocusUp,String &focusDown,String &noFocusDisabled,HINSTANCE hLibrary,FocusItem focusItem=Focus);
|
||||
LinkedButton(const LinkedButton &someLinkedButton);
|
||||
virtual ~LinkedButton();
|
||||
WORD drawButton(LPDRAWITEMSTRUCT lpControlData);
|
||||
int referenceCount(void)const;
|
||||
void referenceCount(int newCount);
|
||||
WORD operator==(const LinkedButton &someLinkedButton)const;
|
||||
WORD operator==(int ctlID)const;
|
||||
HINSTANCE instance(void)const;
|
||||
private:
|
||||
void instance(HINSTANCE hInstance);
|
||||
void setBitmapDefault(void);
|
||||
void loadButtons(void);
|
||||
void drawBitmap(const LPDRAWITEMSTRUCT lpControlData,PureBitmap &pureBitmap);
|
||||
|
||||
int mCtlID;
|
||||
PureBitmap mBitmapFocusUp;
|
||||
PureBitmap mBitmapNoFocusUp;
|
||||
PureBitmap mBitmapFocusDown;
|
||||
PureBitmap mBitmapDisabled;
|
||||
PureBitmap *mlpBitmapDefault;
|
||||
String mFocusUpString;
|
||||
String mNoFocusUpString;
|
||||
String mFocusDownString;
|
||||
String mNoFocusDisabledString;
|
||||
int mReferenceCount;
|
||||
FocusItem mFocus;
|
||||
HINSTANCE mhInstance;
|
||||
};
|
||||
|
||||
inline
|
||||
int LinkedButton::referenceCount(void)const
|
||||
{
|
||||
return mReferenceCount;
|
||||
}
|
||||
|
||||
inline
|
||||
void LinkedButton::referenceCount(int newCount)
|
||||
{
|
||||
mReferenceCount=newCount;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD LinkedButton::operator==(const LinkedButton &someLinkedButton)const
|
||||
{
|
||||
return (mCtlID==someLinkedButton.mCtlID);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD LinkedButton::operator==(int ctlID)const
|
||||
{
|
||||
return mCtlID==ctlID;
|
||||
}
|
||||
|
||||
inline
|
||||
HINSTANCE LinkedButton::instance(void)const
|
||||
{
|
||||
return mhInstance;
|
||||
}
|
||||
|
||||
inline
|
||||
void LinkedButton::instance(HINSTANCE hInstance)
|
||||
{
|
||||
mhInstance=hInstance;
|
||||
}
|
||||
|
||||
inline
|
||||
void LinkedButton::setBitmapDefault(void)
|
||||
{
|
||||
if(Focus==mFocus)mlpBitmapDefault=&mBitmapFocusUp;
|
||||
else mlpBitmapDefault=&mBitmapNoFocusUp;
|
||||
}
|
||||
#endif
|
||||
|
||||
76
common/CALLBACK.TPP
Normal file
76
common/CALLBACK.TPP
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef _COMMON_CALLBACK_TPP_
|
||||
#define _COMMON_CALLBACK_TPP_
|
||||
|
||||
template <class T>
|
||||
Callback<T>::Callback(void)
|
||||
: mlpObject(0), mlpMethod(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Callback<T>::Callback(const Callback<T> &someCallback)
|
||||
: mlpObject(someCallback.mlpObject), mlpMethod(someCallback.mlpMethod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Callback<T>::Callback(T *lpObject,PFNMETHOD lpMethod)
|
||||
: mlpObject(lpObject), mlpMethod(lpMethod)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Callback<T>::~Callback()
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
WORD Callback<T>::operator==(const Callback<T> &someCallback)const
|
||||
{
|
||||
return (mlpObject==someCallback.mlpObject && mlpMethod==someCallback.mlpMethod);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Callback<T>::operator=(const Callback<T> &someCallback)
|
||||
{
|
||||
mlpObject=someCallback.mlpObject;
|
||||
mlpMethod=someCallback.mlpMethod;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Callback<T>::setObject(T *lpObject)
|
||||
{
|
||||
mlpObject=lpObject;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Callback<T>::setMethod(PFNMETHOD lpMethod)
|
||||
{
|
||||
mlpMethod=lpMethod;
|
||||
}
|
||||
|
||||
|
||||
//template <class T>
|
||||
//void Callback<T>::setMethod(CallbackData::ReturnType (T::*lpMethod)(CallbackData &someCallbackData))
|
||||
//{
|
||||
// mlpMethod=lpMethod;
|
||||
//}
|
||||
|
||||
template <class T>
|
||||
void Callback<T>::setCallback(T *lpObject,PFNMETHOD lpMethod)
|
||||
{
|
||||
mlpObject=lpObject;
|
||||
mlpMethod=lpMethod;
|
||||
}
|
||||
|
||||
//template <class T>
|
||||
//void Callback<T>::setCallback(T *lpObject,LONG (T::*lpMethod)(CallbackData &someCallbackData))
|
||||
//{
|
||||
// mlpObject=lpObject;
|
||||
// mlpMethod=lpMethod;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
66
common/CATMULL.CPP
Normal file
66
common/CATMULL.CPP
Normal file
@@ -0,0 +1,66 @@
|
||||
// SOURCE: CATMULL-ROM CUBIC SPLINE
|
||||
// AUTHOR: SEAN M. KESSLER
|
||||
// DATE: 12/28/1993
|
||||
#include <common/catmull.hpp>
|
||||
|
||||
WORD CatmullRom::performSpline(Array<FloatPairs> &sourcePairs,Array<FloatPairs> &destPairs)
|
||||
{
|
||||
double a0,a1,a2,a3;
|
||||
double dx,dx1,dx2;
|
||||
double dy,dy1,dy2;
|
||||
double endPointOne,endPointTwo,resamplingPos;
|
||||
double xPoint;
|
||||
short clampOne,clampTwo;
|
||||
short direction;
|
||||
short destSize((short)destPairs.size());
|
||||
short sourceSize((short)sourcePairs.size());
|
||||
short inputIndex,index;
|
||||
|
||||
if(sourceSize<2||destSize<2)return FALSE;
|
||||
if(sourcePairs[0].column()<sourcePairs[1].column())
|
||||
{
|
||||
if(destPairs[0].column()<sourcePairs[0].column()||
|
||||
destPairs[destSize-1].column()>sourcePairs[sourceSize-1].column())
|
||||
direction=0;
|
||||
else direction=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(destPairs[0].column()>sourcePairs[0].column()||
|
||||
destPairs[destSize-1].column()<sourcePairs[sourceSize-1].column())
|
||||
direction=0;
|
||||
else direction=-1;
|
||||
}
|
||||
if(!direction)return FALSE;
|
||||
if(1==direction)endPointTwo=destPairs[0].column()-1;
|
||||
else endPointTwo=destPairs[0].column()+1;
|
||||
for(index=0;index<destSize;index++)
|
||||
{
|
||||
resamplingPos=destPairs[index].column();
|
||||
if((1==direction&&resamplingPos>endPointTwo)||
|
||||
(-1==direction&&resamplingPos<endPointTwo))
|
||||
{
|
||||
for(inputIndex=0;inputIndex<sourceSize&&resamplingPos>sourcePairs[inputIndex].column();inputIndex++);
|
||||
if(resamplingPos<sourcePairs[inputIndex].column())inputIndex--;
|
||||
if(inputIndex<0)inputIndex=0;
|
||||
endPointOne=sourcePairs[inputIndex].column();
|
||||
endPointTwo=sourcePairs[inputIndex+1].column();
|
||||
clampOne=FloatPairs::fpmax(inputIndex-1,0);
|
||||
clampTwo=FloatPairs::fpmin(inputIndex+2,sourceSize-1);
|
||||
dx=1.0/(endPointTwo-endPointOne);
|
||||
dx1=1.0/(endPointTwo-sourcePairs[clampOne].column());
|
||||
dx2=1.0/(sourcePairs[clampTwo].column()-endPointOne);
|
||||
dy=(sourcePairs[inputIndex+1].row()-sourcePairs[inputIndex].row())*dx;
|
||||
dy1=(sourcePairs[inputIndex+1].row()-sourcePairs[clampOne].row())*dx1;
|
||||
dy2=(sourcePairs[clampTwo].row()-sourcePairs[inputIndex].row())*dx2;
|
||||
a0=sourcePairs[inputIndex].row();
|
||||
a1=dy1;
|
||||
a2=dx*(3*dy-2*dy1-dy2);
|
||||
a3=dx*dx*(-2*dy+dy1+dy2);
|
||||
}
|
||||
xPoint=resamplingPos-endPointOne;
|
||||
destPairs[index].row(((a3*xPoint+a2)*xPoint+a1)*xPoint+a0);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
164
common/CATMULL.HPP
Normal file
164
common/CATMULL.HPP
Normal file
@@ -0,0 +1,164 @@
|
||||
#ifndef _COMMON_CATMULL_HPP_
|
||||
#define _COMMON_CATMULL_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
|
||||
class FloatPairs
|
||||
{
|
||||
public:
|
||||
FloatPairs(void);
|
||||
FloatPairs(const FloatPairs &someFloatPairs);
|
||||
FloatPairs(double column,double row);
|
||||
virtual ~FloatPairs();
|
||||
FloatPairs &operator=(const FloatPairs &someFloatPairs);
|
||||
WORD operator==(const FloatPairs &someFloatPair)const;
|
||||
double column(void)const;
|
||||
void column(double newColumn);
|
||||
double row(void)const;
|
||||
void row(double newRow);
|
||||
void setPairs(double newColumn,double newRow);
|
||||
void setPairs(int newColumn,int newRow);
|
||||
static int fpmax(int firstVal,int secondVal);
|
||||
static int fpmin(int firstVal,int secondVal);
|
||||
private:
|
||||
double mColumn;
|
||||
double mRow;
|
||||
};
|
||||
|
||||
inline
|
||||
FloatPairs::FloatPairs(void)
|
||||
: mColumn(0.00), mRow(0.00)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
FloatPairs::FloatPairs(const FloatPairs &someFloatPairs)
|
||||
{
|
||||
*this=someFloatPairs;
|
||||
}
|
||||
|
||||
inline
|
||||
FloatPairs::FloatPairs(double column,double row)
|
||||
: mColumn(column), mRow(row)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
FloatPairs::~FloatPairs()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FloatPairs::operator==(const FloatPairs &someFloatPair)const
|
||||
{
|
||||
return (mColumn==someFloatPair.mColumn && mRow==someFloatPair.mRow);
|
||||
}
|
||||
|
||||
inline
|
||||
FloatPairs &FloatPairs::operator=(const FloatPairs &someFloatPairs)
|
||||
{
|
||||
column(someFloatPairs.column());
|
||||
row(someFloatPairs.row());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
double FloatPairs::column(void)const
|
||||
{
|
||||
return mColumn;
|
||||
}
|
||||
|
||||
inline
|
||||
void FloatPairs::column(double newColumn)
|
||||
{
|
||||
mColumn=newColumn;
|
||||
}
|
||||
|
||||
inline
|
||||
double FloatPairs::row(void)const
|
||||
{
|
||||
return mRow;
|
||||
}
|
||||
|
||||
inline
|
||||
void FloatPairs::row(double newRow)
|
||||
{
|
||||
mRow=newRow;
|
||||
}
|
||||
|
||||
inline
|
||||
void FloatPairs::setPairs(double newColumn,double newRow)
|
||||
{
|
||||
mColumn=newColumn;
|
||||
mRow=newRow;
|
||||
}
|
||||
|
||||
inline
|
||||
void FloatPairs::setPairs(int newColumn,int newRow)
|
||||
{
|
||||
mColumn=(double)newColumn;
|
||||
mRow=(double)newRow;
|
||||
}
|
||||
|
||||
inline
|
||||
int FloatPairs::fpmax(int firstVal,int secondVal)
|
||||
{
|
||||
return (firstVal>secondVal?firstVal:secondVal);
|
||||
}
|
||||
|
||||
inline
|
||||
int FloatPairs::fpmin(int firstVal,int secondVal)
|
||||
{
|
||||
return (firstVal<secondVal?firstVal:secondVal);
|
||||
}
|
||||
|
||||
// Sample usage of the spline generator...
|
||||
// CarmullRom splineGen;
|
||||
// Array<FloatPairs> srcPairs;
|
||||
// Array<FloatPairs> dstPairs;
|
||||
// srcPairs[0]=FloatPairs(1.00,25);
|
||||
// srcPairs[1]=FloatPairs(4.00,50);
|
||||
// dstPairs[0]=FloatPairs(1.00,0.00);
|
||||
// dstPairs[1]=FloatPairs(2.00,0.00);
|
||||
// dstPairs[2]=FloatPairs(3.00,0.00);
|
||||
// dstPairs[3]=FloatPairs(4.00,0.00);
|
||||
// splineGen.performSpline(srcPairs,dstPairs);
|
||||
// ... dstPairs contains interpolation of 25-50 across four points
|
||||
|
||||
class CatmullRom
|
||||
{
|
||||
public:
|
||||
CatmullRom(void);
|
||||
virtual ~CatmullRom();
|
||||
WORD performSpline(Array<FloatPairs> &sourcePoints,Array<FloatPairs> &destPoints);
|
||||
private:
|
||||
CatmullRom(const CatmullRom &someCatmullRom);
|
||||
CatmullRom &operator=(const CatmullRom &someCatmullRom);
|
||||
};
|
||||
|
||||
inline
|
||||
CatmullRom::CatmullRom(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CatmullRom::CatmullRom(const CatmullRom &someCatmullRom)
|
||||
{ // no implementation
|
||||
*this=someCatmullRom;
|
||||
}
|
||||
|
||||
inline
|
||||
CatmullRom::~CatmullRom()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CatmullRom &CatmullRom::operator=(const CatmullRom &/*someCatmullRom*/)
|
||||
{ // no implementation
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
19
common/CBDATA.CPP
Normal file
19
common/CBDATA.CPP
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <common/cbdata.hpp>
|
||||
#include <common/purehdc.hpp>
|
||||
|
||||
PaintInformation::PaintInformation(const PureDevice &paintDevice)
|
||||
: mlpPaintDevice(new PureDevice((HDC)paintDevice))
|
||||
{
|
||||
}
|
||||
|
||||
PaintInformation::~PaintInformation()
|
||||
{
|
||||
if(mlpPaintDevice)delete mlpPaintDevice;
|
||||
}
|
||||
|
||||
PaintInformation::operator PureDevice&(void)const
|
||||
{
|
||||
return *mlpPaintDevice;
|
||||
}
|
||||
|
||||
|
||||
42
common/CBDATAHK.CPP
Normal file
42
common/CBDATAHK.CPP
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <common/cbdatahk.hpp>
|
||||
|
||||
CallbackDataHook::CallbackDataHook(void)
|
||||
: mHookReturnCode((CallbackData::ReturnType)FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
CallbackDataHook::CallbackDataHook(const CallbackDataHook &someCallbackDataHook)
|
||||
{
|
||||
*this=someCallbackDataHook;
|
||||
}
|
||||
|
||||
CallbackDataHook::CallbackDataHook(const CallbackData &someCallbackData)
|
||||
: mHookReturnCode((CallbackData::ReturnType)FALSE), CallbackData(someCallbackData)
|
||||
{
|
||||
}
|
||||
|
||||
CallbackDataHook::CallbackDataHook(WPARAM wParam,LPARAM lParam,HWND hWndFrom)
|
||||
: mHookReturnCode((CallbackData::ReturnType)FALSE), CallbackData(wParam,lParam,hWndFrom)
|
||||
{
|
||||
}
|
||||
|
||||
CallbackDataHook::~CallbackDataHook()
|
||||
{
|
||||
}
|
||||
|
||||
CallbackDataHook &CallbackDataHook::operator=(const CallbackDataHook &someCallbackDataHook)
|
||||
{
|
||||
(CallbackData&)*this=(CallbackData&)someCallbackDataHook;
|
||||
hookReturnCode(someCallbackDataHook.hookReturnCode());
|
||||
return *this;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType CallbackDataHook::hookReturnCode(void)const
|
||||
{
|
||||
return mHookReturnCode;
|
||||
}
|
||||
|
||||
void CallbackDataHook::hookReturnCode(CallbackData::ReturnType hookReturnCode)
|
||||
{
|
||||
mHookReturnCode=hookReturnCode;
|
||||
}
|
||||
21
common/CBDATAHK.HPP
Normal file
21
common/CBDATAHK.HPP
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _COMMON_CALLBACKDATAHOOK_HPP_
|
||||
#define _COMMON_CALLBACKDATAHOOK_HPP_
|
||||
#ifndef _COMMON_CALLBACKDATA_HPP_
|
||||
#include <common/cbdata.hpp>
|
||||
#endif
|
||||
|
||||
class CallbackDataHook : public CallbackData
|
||||
{
|
||||
public:
|
||||
CallbackDataHook(void);
|
||||
CallbackDataHook(const CallbackDataHook &someCallbackDataHook);
|
||||
CallbackDataHook(const CallbackData &someCallbackData);
|
||||
CallbackDataHook(WPARAM wParam,LPARAM lParam,HWND hWndFrom=0);
|
||||
virtual ~CallbackDataHook();
|
||||
CallbackDataHook &operator=(const CallbackDataHook &someCallbackDataHook);
|
||||
CallbackData::ReturnType hookReturnCode(void)const;
|
||||
void hookReturnCode(CallbackData::ReturnType hookReturnCode);
|
||||
private:
|
||||
CallbackData::ReturnType mHookReturnCode;
|
||||
};
|
||||
#endif
|
||||
72
common/CBPTR.HPP
Normal file
72
common/CBPTR.HPP
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef _COMMON_CALLBACKPOINTER_HPP_
|
||||
#define _COMMON_CALLBACKPOINTER_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PURECALLBACK_HPP_
|
||||
#include <common/pcallbck.hpp>
|
||||
#endif
|
||||
|
||||
class CallbackPointer
|
||||
{
|
||||
public:
|
||||
CallbackPointer(void);
|
||||
CallbackPointer(PureCallback *lpCallback);
|
||||
CallbackPointer(const CallbackPointer &someCallbackPointer);
|
||||
virtual ~CallbackPointer();
|
||||
void operator=(CallbackPointer &someCallbackPointer);
|
||||
WORD operator==(const CallbackPointer &someCallbackPointer)const;
|
||||
CallbackData::ReturnType callback(CallbackData &someCallbackData);
|
||||
bool isOkay(void)const;
|
||||
private:
|
||||
PureCallback *mlpCallback;
|
||||
};
|
||||
|
||||
inline
|
||||
CallbackPointer::CallbackPointer(void)
|
||||
: mlpCallback(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CallbackPointer::CallbackPointer(PureCallback *lpCallback)
|
||||
: mlpCallback(lpCallback)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CallbackPointer::CallbackPointer(const CallbackPointer &someCallbackPointer)
|
||||
: mlpCallback(someCallbackPointer.mlpCallback)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CallbackPointer::~CallbackPointer()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void CallbackPointer::operator=(CallbackPointer &someCallbackPointer)
|
||||
{
|
||||
mlpCallback=someCallbackPointer.mlpCallback;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD CallbackPointer::operator==(const CallbackPointer &someCallbackPointer)const
|
||||
{
|
||||
return (mlpCallback==someCallbackPointer.mlpCallback);
|
||||
}
|
||||
|
||||
inline
|
||||
CallbackData::ReturnType CallbackPointer::callback(CallbackData &someCallbackData)
|
||||
{
|
||||
if(!mlpCallback)return (CallbackData::ReturnType)0;
|
||||
return mlpCallback->operator*(someCallbackData);
|
||||
}
|
||||
|
||||
inline
|
||||
bool CallbackPointer::isOkay(void)const
|
||||
{
|
||||
return mlpCallback?true:false;
|
||||
}
|
||||
#endif
|
||||
79
common/CFLAGS.HPP
Normal file
79
common/CFLAGS.HPP
Normal file
@@ -0,0 +1,79 @@
|
||||
#if defined(__FLAT__)
|
||||
#ifndef _COMMON_CREATIONFLAGS_HPP_
|
||||
#define _COMMON_CREATIONFLAGS_HPP_
|
||||
class CreationFlags
|
||||
{
|
||||
public:
|
||||
enum Flags{DefaultErrorMode=CREATE_DEFAULT_ERROR_MODE,
|
||||
NewConsole=CREATE_NEW_CONSOLE,
|
||||
NewProcessGroup=CREATE_NEW_PROCESS_GROUP,
|
||||
SeperateWOWVDM=CREATE_SEPARATE_WOW_VDM,
|
||||
Suspended=CREATE_SUSPENDED,
|
||||
UnicodeEnvironment=CREATE_UNICODE_ENVIRONMENT,
|
||||
DebugProcess=DEBUG_PROCESS,
|
||||
DebugOnlyThisProcess=DEBUG_ONLY_THIS_PROCESS,
|
||||
DetachedProcess=DETACHED_PROCESS,
|
||||
NormalPriorityClass=NORMAL_PRIORITY_CLASS,
|
||||
IdlePriorityClass=IDLE_PRIORITY_CLASS,
|
||||
HighPriorityClass=HIGH_PRIORITY_CLASS,
|
||||
RealtimePriorityClass=REALTIME_PRIORITY_CLASS};
|
||||
CreationFlags(Flags creationFlags=NormalPriorityClass);
|
||||
CreationFlags(const CreationFlags &someCreationFlags);
|
||||
virtual ~CreationFlags();
|
||||
CreationFlags &operator=(const CreationFlags &someCreationFlags);
|
||||
WORD operator==(const CreationFlags &someCreationFlags);
|
||||
CreationFlags &operator+=(Flags creationFlags);
|
||||
operator DWORD(void)const;
|
||||
private:
|
||||
DWORD mCreationFlags;
|
||||
};
|
||||
|
||||
inline
|
||||
CreationFlags::CreationFlags(Flags creationFlags)
|
||||
: mCreationFlags(creationFlags)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CreationFlags::CreationFlags(const CreationFlags &someCreationFlags)
|
||||
{
|
||||
*this=someCreationFlags;
|
||||
}
|
||||
|
||||
inline
|
||||
CreationFlags::~CreationFlags()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CreationFlags &CreationFlags::operator=(const CreationFlags &someCreationFlags)
|
||||
{
|
||||
mCreationFlags=someCreationFlags.mCreationFlags;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD CreationFlags::operator==(const CreationFlags &someCreationFlags)
|
||||
{
|
||||
return mCreationFlags==someCreationFlags.mCreationFlags;
|
||||
}
|
||||
|
||||
inline
|
||||
CreationFlags &CreationFlags::operator+=(Flags creationFlags)
|
||||
{
|
||||
mCreationFlags|=(DWORD)creationFlags;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
CreationFlags::operator DWORD(void)const
|
||||
{
|
||||
return mCreationFlags;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
220
common/CHARFORM.HPP
Normal file
220
common/CHARFORM.HPP
Normal file
@@ -0,0 +1,220 @@
|
||||
#ifndef _COMMON_CHARFORMAT_HPP_
|
||||
#define _COMMON_CHARFORMAT_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_RICHEDIT_HPP_
|
||||
#include <common/richedit.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_RGBCOLOR_HPP_
|
||||
#include <common/rgbcolor.hpp>
|
||||
#endif
|
||||
|
||||
class CharFormat : private CHARFORMAT
|
||||
{
|
||||
public:
|
||||
enum Mask{MaskBold=CFM_BOLD,MaskCharSet=CFM_CHARSET,MaskColor=CFM_COLOR,MaskFace=CFM_FACE,
|
||||
MaskItalic=CFM_ITALIC,MaskOffset=CFM_OFFSET,MaskProtected=CFM_PROTECTED,
|
||||
MaskSize=CFM_SIZE,MaskStrikeout=CFM_STRIKEOUT,MaskUnderline=CFM_UNDERLINE};
|
||||
enum Effects{EffectAutoColor=CFE_AUTOCOLOR,EffectBold=CFE_BOLD,EffectItalic=CFE_ITALIC,
|
||||
EffectStrikeout=CFE_STRIKEOUT,EffectUnderline=CFE_UNDERLINE,EffectProtected=CFE_PROTECTED};
|
||||
CharFormat(void);
|
||||
CharFormat(const CharFormat &someCharFormat);
|
||||
virtual ~CharFormat();
|
||||
CharFormat &operator=(const CharFormat &someCharFormat);
|
||||
BOOL operator==(const CharFormat &someCharFormat)const;
|
||||
operator CHARFORMAT &(void);
|
||||
DWORD mask(void)const;
|
||||
void mask(DWORD mask);
|
||||
DWORD effects(void)const;
|
||||
void effects(DWORD effects);
|
||||
LONG yHeight(void)const;
|
||||
void yHeight(LONG height);
|
||||
LONG yOffset(void)const;
|
||||
void yOffset(LONG offset);
|
||||
RGBColor textColor(void)const;
|
||||
void textColor(RGBColor textColor);
|
||||
BYTE charSet(void)const;
|
||||
void charSet(BYTE charSet);
|
||||
BYTE pitchAndFamily(void)const;
|
||||
void pitchAndFamily(BYTE pitchAndFamily);
|
||||
String faceName(void)const;
|
||||
void faceName(const String &faceName);
|
||||
private:
|
||||
void setZero(void);
|
||||
void initLength(void);
|
||||
};
|
||||
#endif
|
||||
|
||||
inline
|
||||
CharFormat::CharFormat(void)
|
||||
{
|
||||
setZero();
|
||||
}
|
||||
|
||||
inline
|
||||
CharFormat::CharFormat(const CharFormat &someCharFormat)
|
||||
{
|
||||
initLength();
|
||||
*this=someCharFormat;
|
||||
}
|
||||
|
||||
inline
|
||||
CharFormat::~CharFormat()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CharFormat &CharFormat::operator=(const CharFormat &someCharFormat)
|
||||
{
|
||||
mask(someCharFormat.mask());
|
||||
effects(someCharFormat.effects());
|
||||
yHeight(someCharFormat.yHeight());
|
||||
yOffset(someCharFormat.yOffset());
|
||||
textColor(someCharFormat.textColor());
|
||||
charSet(someCharFormat.charSet());
|
||||
pitchAndFamily(someCharFormat.pitchAndFamily());
|
||||
faceName(someCharFormat.faceName());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL CharFormat::operator==(const CharFormat &someCharFormat)const
|
||||
{
|
||||
return (mask()==someCharFormat.mask()&&
|
||||
effects()==someCharFormat.effects()&&
|
||||
yHeight()==someCharFormat.yHeight()&&
|
||||
yOffset()==someCharFormat.yOffset()&&
|
||||
textColor()==someCharFormat.textColor()&&
|
||||
charSet()==someCharFormat.charSet()&&
|
||||
pitchAndFamily()&&someCharFormat.pitchAndFamily()&&
|
||||
faceName()==someCharFormat.faceName());
|
||||
}
|
||||
|
||||
inline
|
||||
CharFormat::operator CHARFORMAT &(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD CharFormat::mask(void)const
|
||||
{
|
||||
return CHARFORMAT::dwMask;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::mask(DWORD mask)
|
||||
{
|
||||
CHARFORMAT::dwMask=mask;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD CharFormat::effects(void)const
|
||||
{
|
||||
return CHARFORMAT::dwEffects;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::effects(DWORD effects)
|
||||
{
|
||||
CHARFORMAT::dwEffects=effects;
|
||||
}
|
||||
|
||||
inline
|
||||
LONG CharFormat::yHeight(void)const
|
||||
{
|
||||
return CHARFORMAT::yHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::yHeight(LONG height)
|
||||
{
|
||||
CHARFORMAT::yHeight=height;
|
||||
}
|
||||
|
||||
inline
|
||||
LONG CharFormat::yOffset(void)const
|
||||
{
|
||||
return CHARFORMAT::yOffset;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::yOffset(LONG yOffset)
|
||||
{
|
||||
CHARFORMAT::yOffset=yOffset;
|
||||
}
|
||||
|
||||
inline
|
||||
RGBColor CharFormat::textColor(void)const
|
||||
{
|
||||
return CHARFORMAT::crTextColor;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::textColor(RGBColor textColor)
|
||||
{
|
||||
CHARFORMAT::crTextColor=(COLORREF)textColor;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE CharFormat::charSet(void)const
|
||||
{
|
||||
return CHARFORMAT::bCharSet;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::charSet(BYTE charSet)
|
||||
{
|
||||
CHARFORMAT::bCharSet=charSet;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE CharFormat::pitchAndFamily(void)const
|
||||
{
|
||||
return CHARFORMAT::bPitchAndFamily;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::pitchAndFamily(BYTE pitchAndFamily)
|
||||
{
|
||||
CHARFORMAT::bPitchAndFamily=pitchAndFamily;
|
||||
}
|
||||
|
||||
inline
|
||||
String CharFormat::faceName(void)const
|
||||
{
|
||||
return CHARFORMAT::szFaceName;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::faceName(const String &faceName)
|
||||
{
|
||||
WORD strLength(faceName.length());
|
||||
if(faceName.isNull()||strLength>=LF_FACESIZE)return;
|
||||
::memcpy(szFaceName,(char*)(String&)faceName,strLength);
|
||||
szFaceName[strLength]=0;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::setZero(void)
|
||||
{
|
||||
initLength();
|
||||
mask(0);
|
||||
effects(0);
|
||||
yHeight(0);
|
||||
yOffset(0);
|
||||
textColor(RGBColor(0,0,0));
|
||||
charSet(0);
|
||||
pitchAndFamily(0);
|
||||
faceName("Arial");
|
||||
}
|
||||
|
||||
inline
|
||||
void CharFormat::initLength(void)
|
||||
{
|
||||
CHARFORMAT::cbSize=sizeof(CHARFORMAT);
|
||||
}
|
||||
85
common/CHRRANGE.HPP
Normal file
85
common/CHRRANGE.HPP
Normal file
@@ -0,0 +1,85 @@
|
||||
#ifndef _COMMON_CHARRANGE_HPP_
|
||||
#define _COMMON_CHARRANGE_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class CharRange : private CHARRANGE
|
||||
{
|
||||
public:
|
||||
CharRange(void);
|
||||
CharRange(const CharRange &someCharRange);
|
||||
virtual ~CharRange();
|
||||
CharRange &operator=(const CharRange &someCharRange);
|
||||
BOOL operator==(const CharRange &someCharRange)const;
|
||||
LONG cpMin(void)const;
|
||||
void cpMin(LONG cpMin);
|
||||
LONG cpMax(void)const;
|
||||
void cpMax(LONG cpMax);
|
||||
CHARRANGE &getCHARRANGE(void);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
CharRange::CharRange(void)
|
||||
{
|
||||
cpMin(0);
|
||||
cpMax(0);
|
||||
}
|
||||
|
||||
inline
|
||||
CharRange::CharRange(const CharRange &someCharRange)
|
||||
{
|
||||
*this=someCharRange;
|
||||
}
|
||||
|
||||
inline
|
||||
CharRange::~CharRange()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CharRange &CharRange::operator=(const CharRange &someCharRange)
|
||||
{
|
||||
cpMin(someCharRange.cpMin());
|
||||
cpMax(someCharRange.cpMax());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL CharRange::operator==(const CharRange &someCharRange)const
|
||||
{
|
||||
return (cpMin()==someCharRange.cpMin()&&
|
||||
cpMax()==someCharRange.cpMax());
|
||||
}
|
||||
|
||||
inline
|
||||
LONG CharRange::cpMin(void)const
|
||||
{
|
||||
return CHARRANGE::cpMin;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharRange::cpMin(LONG cpMin)
|
||||
{
|
||||
CHARRANGE::cpMin=cpMin;
|
||||
}
|
||||
|
||||
inline
|
||||
LONG CharRange::cpMax(void)const
|
||||
{
|
||||
return CHARRANGE::cpMax;
|
||||
}
|
||||
|
||||
inline
|
||||
void CharRange::cpMax(LONG cpMax)
|
||||
{
|
||||
CHARRANGE::cpMax=cpMax;;
|
||||
}
|
||||
|
||||
inline
|
||||
CHARRANGE &CharRange::getCHARRANGE(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
156
common/CLIPBRD.CPP
Normal file
156
common/CLIPBRD.CPP
Normal file
@@ -0,0 +1,156 @@
|
||||
#include <common/clipbrd.hpp>
|
||||
#include <common/string.hpp>
|
||||
|
||||
Clipboard::Clipboard(GUIWindow &parentWindow)
|
||||
: mParentWindow(parentWindow), mhNextViewerWnd(0)
|
||||
{
|
||||
if(!parentWindow.isValid())return;
|
||||
mChangeCBChainHandler.setCallback(this,&Clipboard::changeCBChainHandler);
|
||||
mDrawClipboardHandler.setCallback(this,&Clipboard::drawClipboardHandler);
|
||||
mDestroyHandler.setCallback(this,&Clipboard::destroyHandler);
|
||||
mParentWindow.insertHandler(VectorHandler::ChangeCBChainHandler,&mChangeCBChainHandler);
|
||||
mParentWindow.insertHandler(VectorHandler::DrawClipboardHandler,&mDrawClipboardHandler);
|
||||
mParentWindow.insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
|
||||
mhNextViewerWnd=::SetClipboardViewer(mParentWindow);
|
||||
}
|
||||
|
||||
Clipboard::~Clipboard()
|
||||
{
|
||||
removeCBChain();
|
||||
mParentWindow.removeHandler(VectorHandler::DrawClipboardHandler,&mDrawClipboardHandler);
|
||||
mParentWindow.removeHandler(VectorHandler::ChangeCBChainHandler,&mChangeCBChainHandler);
|
||||
mParentWindow.removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
|
||||
}
|
||||
|
||||
void Clipboard::setDrawDataHandler(PureCallback *pCallback)
|
||||
{
|
||||
mDrawDataHandler=CallbackPointer(pCallback);
|
||||
}
|
||||
|
||||
bool Clipboard::isOkay(void)const
|
||||
{
|
||||
return mParentWindow.isValid();
|
||||
}
|
||||
|
||||
CallbackData::ReturnType Clipboard::destroyHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
removeCBChain();
|
||||
return (CallbackData::ReturnType)false;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType Clipboard::changeCBChainHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
if(!isOkay())return (CallbackData::ReturnType)false;
|
||||
if((HWND)someCallbackData.wParam()==mhNextViewerWnd)mhNextViewerWnd=(HWND)someCallbackData.loWord();
|
||||
else ::SendMessage(mhNextViewerWnd,WM_CHANGECBCHAIN,someCallbackData.wParam(),someCallbackData.lParam());
|
||||
return (CallbackData::ReturnType)false;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType Clipboard::drawClipboardHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
if(!isOkay())return (CallbackData::ReturnType)false;
|
||||
::SendMessage(mhNextViewerWnd,WM_DRAWCLIPBOARD,someCallbackData.wParam(),someCallbackData.lParam());
|
||||
if(::OpenClipboard(mParentWindow)){drawClipboard();::CloseClipboard();}
|
||||
return (CallbackData::ReturnType)false;
|
||||
}
|
||||
|
||||
void Clipboard::removeCBChain(void)
|
||||
{
|
||||
if(!isOkay())return;
|
||||
::ChangeClipboardChain(mParentWindow,mhNextViewerWnd);
|
||||
}
|
||||
|
||||
bool Clipboard::setClipboard(Format format,HANDLE hData)
|
||||
{
|
||||
bool returnCode(false);
|
||||
|
||||
if(!isOkay()||!hData)return returnCode;
|
||||
if(!::OpenClipboard(mParentWindow))return returnCode;
|
||||
emptyClipboard();
|
||||
returnCode=(hData==::SetClipboardData(format,hData));
|
||||
::CloseClipboard();
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
bool Clipboard::setClipboard(const String &strText)
|
||||
{
|
||||
bool returnCode(false);
|
||||
|
||||
if(!isOkay()||strText.isNull()||!::OpenClipboard(mParentWindow))return returnCode;
|
||||
emptyClipboard();
|
||||
int strLen(strText.length());
|
||||
char *ptrData=(char*)::GlobalAlloc(GMEM_FIXED,strLen+1);
|
||||
if(!ptrData){::CloseClipboard();return returnCode;}
|
||||
::memset(ptrData,0,strLen+1);
|
||||
::memcpy(ptrData,(char*)(String&)strText,strLen);
|
||||
returnCode=ptrData==::SetClipboardData(CF_TEXT,(HANDLE)ptrData);
|
||||
::CloseClipboard();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Clipboard::setClipboard(UINT format,const String &strText)
|
||||
{
|
||||
bool returnCode(false);
|
||||
|
||||
if(!isOkay()||strText.isNull()||!::OpenClipboard(mParentWindow))return returnCode;
|
||||
emptyClipboard();
|
||||
int strLen(strText.length());
|
||||
char *ptrData=(char*)::GlobalAlloc(GMEM_FIXED,strLen+1);
|
||||
if(!ptrData){::CloseClipboard();return returnCode;}
|
||||
::memset(ptrData,0,strLen+1);
|
||||
::memcpy(ptrData,(char*)(String&)strText,strLen);
|
||||
returnCode=ptrData==::SetClipboardData(format,(HANDLE)ptrData);
|
||||
::CloseClipboard();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Clipboard::getClipboard(String &strText)const
|
||||
{
|
||||
bool returnCode(false);
|
||||
HANDLE handle=0;
|
||||
|
||||
if(!isOkay()||!::OpenClipboard(mParentWindow))return returnCode;
|
||||
if(0==(handle=::GetClipboardData(CF_TEXT))){::CloseClipboard();return false;}
|
||||
strText=(LPSTR)::GlobalLock(handle);
|
||||
::GlobalUnlock(handle);
|
||||
::CloseClipboard();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Clipboard::getClipboard(UINT format,String &strText)const
|
||||
{
|
||||
bool returnCode(false);
|
||||
HANDLE handle=0;
|
||||
|
||||
if(!isOkay()||!::OpenClipboard(mParentWindow))return returnCode;
|
||||
if(0==(handle=::GetClipboardData(format))){::CloseClipboard();return false;}
|
||||
strText=(LPSTR)::GlobalLock(handle);
|
||||
::GlobalUnlock(handle);
|
||||
::CloseClipboard();
|
||||
return true;
|
||||
}
|
||||
|
||||
UINT Clipboard::registerClipboardFormat(const String &strFormatName)
|
||||
{
|
||||
return ::RegisterClipboardFormat(strFormatName.str());
|
||||
}
|
||||
|
||||
bool Clipboard::hasData(Format format)
|
||||
{
|
||||
return ::IsClipboardFormatAvailable(format);
|
||||
}
|
||||
|
||||
bool Clipboard::hasData(UINT format)
|
||||
{
|
||||
return ::IsClipboardFormatAvailable(format);
|
||||
}
|
||||
|
||||
// virtuals
|
||||
|
||||
void Clipboard::drawClipboard(void)
|
||||
{
|
||||
mDrawDataHandler.callback(CallbackData());
|
||||
}
|
||||
|
||||
// (ie) HANDLE hData=::GetClipboardData(CF_DIB);
|
||||
|
||||
52
common/CLIPBRD.HPP
Normal file
52
common/CLIPBRD.HPP
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef _COMMON_CLIPBOARD_HPP_
|
||||
#define _COMMON_CLIPBOARD_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GUIWINDOW_HPP_
|
||||
#include <common/guiwnd.hpp>
|
||||
#endif
|
||||
|
||||
class Clipboard
|
||||
{
|
||||
public:
|
||||
typedef enum Format{Bitmap=CF_BITMAP,Dib=CF_DIB,EnhMetaFile=CF_ENHMETAFILE,MetFilePict=CF_METAFILEPICT,
|
||||
OemText=CF_OEMTEXT,Text=CF_TEXT,UnicodeText=CF_UNICODETEXT};
|
||||
Clipboard(GUIWindow &parentWindow);
|
||||
virtual ~Clipboard();
|
||||
bool isOkay(void)const;
|
||||
bool emptyClipboard(void)const;
|
||||
bool setClipboard(Format format,HANDLE hData);
|
||||
bool setClipboard(const String &strText);
|
||||
bool setClipboard(UINT format,const String &strText);
|
||||
void setDrawDataHandler(PureCallback *pCallback);
|
||||
bool getClipboard(String &strText)const;
|
||||
bool getClipboard(UINT format,String &strText)const;
|
||||
static UINT registerClipboardFormat(const String &strFormatName);
|
||||
static bool hasData(Format format);
|
||||
static bool hasData(UINT format);
|
||||
protected:
|
||||
virtual void drawClipboard(void);
|
||||
private:
|
||||
CallbackData::ReturnType changeCBChainHandler(CallbackData &someCallbackData);
|
||||
CallbackData::ReturnType drawClipboardHandler(CallbackData &someCallbackData);
|
||||
CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData);
|
||||
void removeCBChain(void);
|
||||
|
||||
Callback<Clipboard> mChangeCBChainHandler;
|
||||
Callback<Clipboard> mDrawClipboardHandler;
|
||||
Callback<Clipboard> mDestroyHandler;
|
||||
|
||||
CallbackPointer mDrawDataHandler;
|
||||
GUIWindow &mParentWindow;
|
||||
HWND mhNextViewerWnd;
|
||||
};
|
||||
|
||||
inline
|
||||
bool Clipboard::emptyClipboard(void)const
|
||||
{
|
||||
return ::EmptyClipboard();
|
||||
}
|
||||
#endif // macro guards
|
||||
|
||||
|
||||
918
common/CODEGEN.HPP
Normal file
918
common/CODEGEN.HPP
Normal file
@@ -0,0 +1,918 @@
|
||||
#ifndef _COMMON_CODEGEN_HPP_
|
||||
#define _COMMON_CODEGEN_HPP_
|
||||
#include <common/stdio.hpp>
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FILEMAP_HPP_
|
||||
#include <common/filemap.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PUREVIEWOFFILE_HPP_
|
||||
#include <common/pview.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GLOBALDATA_HPP_
|
||||
#include <common/gdata.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable:4355)
|
||||
#endif
|
||||
|
||||
class CodeGen : public FileMap, public PureViewOfFile
|
||||
{
|
||||
public:
|
||||
CodeGen(DWORD maxExtent=100000L);
|
||||
virtual ~CodeGen();
|
||||
void breakPoint(void);
|
||||
void nop(void);
|
||||
void pushDS(void);
|
||||
void popDS(void);
|
||||
void pushCS(void);
|
||||
void movEAXOFFSETDS(int dsOffset);
|
||||
void movOFFSETDSEAX(int dsOffset);
|
||||
void pushad(void);
|
||||
void popad(void);
|
||||
void pushOFFSETCS(int csOffset);
|
||||
void pushEAX(void);
|
||||
void pushECX(void);
|
||||
void pushEBP(void);
|
||||
void pushESP(void);
|
||||
void pushEDI(void);
|
||||
void pushESI(void);
|
||||
void push(int value);
|
||||
void popEBP(void);
|
||||
void popESP(void);
|
||||
void popESI(void);
|
||||
void popEDI(void);
|
||||
void popAX(void);
|
||||
void popEAX(void);
|
||||
void popEBX(void);
|
||||
void popECX(void);
|
||||
void pushEBX(void);
|
||||
void subEDI(BYTE byteCount);
|
||||
void subESP(BYTE byteCount);
|
||||
void movDHDL(void);
|
||||
void movEDIDX(void);
|
||||
void movAXCS(void);
|
||||
void movEAXEBX(void);
|
||||
void movEBXEAX(void);
|
||||
void movEBPESP(void);
|
||||
void movECXESI(void);
|
||||
void movECXEDI(void);
|
||||
void movESIEBP(BYTE stackIndex);
|
||||
void movEDIEBP(BYTE stackIndex);
|
||||
void movEAXEBP(BYTE stackIndex);
|
||||
void movEAXESP(BYTE stackIndex);
|
||||
void movEAXEBP(void);
|
||||
void movEAXESP(void);
|
||||
void movAXEBP(BYTE stackIndex);
|
||||
void movBXEBP(BYTE stackIndex);
|
||||
void movCXEBP(BYTE stackIndex);
|
||||
void movDXEBP(BYTE stackIndex);
|
||||
void movALESI(LONG sourceIndex);
|
||||
void movESIAL(LONG sourceIndex);
|
||||
void movDLESI(DWORD sourceIndex);
|
||||
void movEDIDX(LONG offset);
|
||||
void movEDIDL(LONG offset);
|
||||
void movEDIAL(LONG offset);
|
||||
void movEDIDL(void);
|
||||
void movCLEBP(BYTE stackIndex);
|
||||
void movOFFSETESI(BYTE offset,BYTE charByte);
|
||||
void movEAXOFFSETCS(int csOffset);
|
||||
void movECXOFFSETCS(int csOffset);
|
||||
void movEAXOFFSETSS(int offset);
|
||||
void movOFFSETSSEAX(int offset);
|
||||
void movEAXESPOFFSET(int offset);
|
||||
void movEAXEBPOFFSET(int offset);
|
||||
void movESPOFFSETEAX(int offset);
|
||||
void movESPOFFSETEBX(int offset);
|
||||
void movDEREFEAXEBX(void);
|
||||
void leaESIEBP(BYTE offset);
|
||||
void addEDIEAX(void);
|
||||
void addEDIEBP(BYTE stackIndex);
|
||||
void addESP(int value);
|
||||
void addEAX(int value);
|
||||
void addEBP(int value);
|
||||
void subEAX(int value);
|
||||
void xorEAXEAX(void);
|
||||
void call(int offset);
|
||||
void callEBP(BYTE offset);
|
||||
void callEAX(void);
|
||||
void callEBX(void);
|
||||
void callECX(void);
|
||||
void je(BYTE jumpCount);
|
||||
void jmp(BYTE jumpBytes);
|
||||
void jnl(BYTE jumpCount);
|
||||
void cmpALCL(void);
|
||||
void decEDI(void);
|
||||
void movEAX(int value);
|
||||
void movECX(int value);
|
||||
void pushEBPEAXPLUS(int eaxAdditive);
|
||||
void decEAX(void);
|
||||
void cmpEAX(int value);
|
||||
void pushFSOFFSET(WORD offset);
|
||||
void movFSOFFSETESP(WORD offset);
|
||||
void movFSOFFSETEAX(int offset);
|
||||
void retn(void);
|
||||
void retn(short stackLength);
|
||||
void retf(void);
|
||||
void intno(BYTE intno);
|
||||
void encodeDD(int value=0);
|
||||
void encodeDB(BYTE value=0);
|
||||
void wait(void);
|
||||
void finit(void);
|
||||
void execute(void);
|
||||
void debugExecute(void);
|
||||
private:
|
||||
String entryName(void)const;
|
||||
};
|
||||
|
||||
inline
|
||||
CodeGen::CodeGen(DWORD maxExtent)
|
||||
: FileMap(entryName(),0L,1024), PureViewOfFile((FileMap&)*this)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CodeGen::~CodeGen()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::breakPoint(void)
|
||||
{
|
||||
write((BYTE)(0xCC));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushOFFSETCS(int csOffset)
|
||||
{
|
||||
write((BYTE)(0x2E));
|
||||
write((BYTE)(0xFF));
|
||||
write((BYTE)(0x35));
|
||||
write(csOffset);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushad(void)
|
||||
{
|
||||
write((BYTE)(0x60));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popad(void)
|
||||
{
|
||||
write((BYTE)(0x61));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushEAX(void)
|
||||
{
|
||||
write((BYTE)(0x50));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushECX(void)
|
||||
{
|
||||
write((BYTE)(0x51));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popECX(void)
|
||||
{
|
||||
write((BYTE)(0x59));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushEBP(void)
|
||||
{
|
||||
write((BYTE)(0x55));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushESP(void)
|
||||
{
|
||||
write((BYTE)(0x54));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushEDI(void)
|
||||
{
|
||||
write((BYTE)(0x57));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushESI(void)
|
||||
{
|
||||
write((BYTE)(0x56));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popEBP(void)
|
||||
{
|
||||
write((BYTE)(0x5D));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popESP(void)
|
||||
{
|
||||
write((BYTE)(0x5C));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popESI(void)
|
||||
{
|
||||
write((BYTE)(0x5E));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popEDI(void)
|
||||
{
|
||||
write((BYTE)(0x5F));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popAX(void)
|
||||
{
|
||||
write((BYTE)(0x66));
|
||||
write((BYTE)(0x58));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEBPESP(void)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0xEC));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movESIEBP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x75));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEDIEBP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x7D));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXEBP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x45));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXESP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x44));
|
||||
write((BYTE)(0x24));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXEBP(void)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0xC5));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEDIDL(void)
|
||||
{
|
||||
write((BYTE)(0x88));
|
||||
write((BYTE)(0x17));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::decEDI(void)
|
||||
{
|
||||
write((BYTE)(0x4F));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::addEDIEAX(void)
|
||||
{
|
||||
write((BYTE)(0x03));
|
||||
write((BYTE)(0xF8));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::addEDIEBP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x03));
|
||||
write((BYTE)(0x7D));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::retn(void)
|
||||
{
|
||||
write((BYTE)(0xC3));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::retn(short stackLength)
|
||||
{
|
||||
write((BYTE)(0xC2));
|
||||
write(stackLength);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::retf(void)
|
||||
{
|
||||
write((BYTE)(0xCB));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movDLESI(DWORD sourceIndex)
|
||||
{
|
||||
write((BYTE)(0x8A));
|
||||
write((BYTE)(0x96));
|
||||
write((BYTE)(sourceIndex&0x000000FF));
|
||||
write((BYTE)((sourceIndex&0x0000FF00)>>0x08));
|
||||
write((BYTE)((sourceIndex&0x00FF0000)>>0x10));
|
||||
write((BYTE)((sourceIndex&0xFF000000)>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movDHDL(void)
|
||||
{
|
||||
write((BYTE)(0x8A));
|
||||
write((BYTE)(0xF2));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movOFFSETESI(BYTE offset,BYTE charByte)
|
||||
{
|
||||
write((BYTE)(0xC6));
|
||||
write((BYTE)(0x46));
|
||||
write(offset);
|
||||
write(charByte);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::subEDI(BYTE byteCount)
|
||||
{
|
||||
write((BYTE)(0x83));
|
||||
write((BYTE)(0xEF));
|
||||
write(byteCount);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::subESP(BYTE byteCount)
|
||||
{
|
||||
write((BYTE)(0x83));
|
||||
write((BYTE)(0xEC));
|
||||
write(byteCount);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEDIDX(void)
|
||||
{
|
||||
write((BYTE)(0x66));
|
||||
write((BYTE)(0x89));
|
||||
write((BYTE)(0x17));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEDIDX(LONG sourceIndex)
|
||||
{
|
||||
write((BYTE)(0x66));
|
||||
write((BYTE)(0x89));
|
||||
write((BYTE)(0x97));
|
||||
write((BYTE)(sourceIndex&0x000000FF));
|
||||
write((BYTE)((sourceIndex&0x0000FF00)>>0x08));
|
||||
write((BYTE)((sourceIndex&0x00FF0000)>>0x10));
|
||||
write((BYTE)((sourceIndex&0xFF000000)>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEDIDL(LONG sourceIndex)
|
||||
{
|
||||
write((BYTE)(0x88));
|
||||
write((BYTE)(0x97));
|
||||
write((BYTE)(sourceIndex&0x000000FF));
|
||||
write((BYTE)((sourceIndex&0x0000FF00)>>0x08));
|
||||
write((BYTE)((sourceIndex&0x00FF0000)>>0x10));
|
||||
write((BYTE)((sourceIndex&0xFF000000)>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movALESI(LONG sourceIndex)
|
||||
{
|
||||
write((BYTE)(0x8A));
|
||||
write((BYTE)(0x86));
|
||||
write((BYTE)(sourceIndex&0x000000FF));
|
||||
write((BYTE)((sourceIndex&0x0000FF00)>>0x08));
|
||||
write((BYTE)((sourceIndex&0x00FF0000)>>0x10));
|
||||
write((BYTE)((sourceIndex&0xFF000000)>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movESIAL(LONG sourceIndex)
|
||||
{
|
||||
write((BYTE)(0x88));
|
||||
write((BYTE)(0x86));
|
||||
write((BYTE)(sourceIndex&0x000000FF));
|
||||
write((BYTE)((sourceIndex&0x0000FF00)>>0x08));
|
||||
write((BYTE)((sourceIndex&0x00FF0000)>>0x10));
|
||||
write((BYTE)((sourceIndex&0xFF000000)>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEDIAL(LONG sourceIndex)
|
||||
{
|
||||
write((BYTE)(0x88));
|
||||
write((BYTE)(0x87));
|
||||
write((BYTE)(sourceIndex&0x000000FF));
|
||||
write((BYTE)((sourceIndex&0x0000FF00)>>0x08));
|
||||
write((BYTE)((sourceIndex&0x00FF0000)>>0x10));
|
||||
write((BYTE)((sourceIndex&0xFF000000)>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movAXCS(void)
|
||||
{
|
||||
write((BYTE)(0x66));
|
||||
write((BYTE)(0x8C));
|
||||
write((BYTE)(0xC8));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movCLEBP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x8A));
|
||||
write((BYTE)(0x4D));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::leaESIEBP(BYTE offset)
|
||||
{
|
||||
write((BYTE)(0x8D));
|
||||
write((BYTE)(0x75));
|
||||
write(offset);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::cmpALCL(void)
|
||||
{
|
||||
write((BYTE)(0x3A));
|
||||
write((BYTE)(0xC1));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::call(int offset)
|
||||
{
|
||||
write((BYTE)(0xE8));
|
||||
write(offset);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::callEBP(BYTE offset)
|
||||
{
|
||||
write((BYTE)(0xFF));
|
||||
write((BYTE)(0x55));
|
||||
write(offset);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::callEAX(void)
|
||||
{
|
||||
write((BYTE)(0xFF));
|
||||
write((BYTE)(0xD0));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::callEBX(void)
|
||||
{
|
||||
write((BYTE)(0xFF));
|
||||
write((BYTE)(0xD3));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::callECX(void)
|
||||
{
|
||||
write((BYTE)(0xFF));
|
||||
write((BYTE)(0xD1));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::je(BYTE jumpCount)
|
||||
{
|
||||
write((BYTE)(0x74));
|
||||
write(jumpCount);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::jmp(BYTE jumpCount)
|
||||
{
|
||||
write((BYTE)(0xEB));
|
||||
write(jumpCount);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::jnl(BYTE jumpCount)
|
||||
{
|
||||
write((BYTE)(0x7D));
|
||||
write(jumpCount);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::intno(BYTE intno)
|
||||
{
|
||||
write((BYTE)(0xCD));
|
||||
write(intno);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movAXEBP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x66));
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x45));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movBXEBP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x66));
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x5D));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movCXEBP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x66));
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x4D));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movDXEBP(BYTE stackIndex)
|
||||
{
|
||||
write((BYTE)(0x66));
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x55));
|
||||
write(stackIndex);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::xorEAXEAX(void)
|
||||
{
|
||||
write((BYTE)(0x33));
|
||||
write((BYTE)(0xC0));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::push(int value)
|
||||
{
|
||||
write((BYTE)(0x68));
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popEAX(void)
|
||||
{
|
||||
write((BYTE)(0x58));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::addESP(int value)
|
||||
{
|
||||
write((BYTE)(0x81));
|
||||
write((BYTE)(0xC4));
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::addEAX(int value)
|
||||
{
|
||||
write((BYTE)(0x05));
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::subEAX(int value)
|
||||
{
|
||||
write((BYTE)(0x2D));
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::encodeDD(int value)
|
||||
{
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::encodeDB(BYTE value)
|
||||
{
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::execute(void)
|
||||
{
|
||||
(*((FARPROC)((BYTE*)base())))();
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::debugExecute(void)
|
||||
{
|
||||
GlobalData<BYTE> code;
|
||||
code.size(tell()+1);
|
||||
::memcpy((BYTE*)&code[0],(BYTE*)base(),tell()+1);
|
||||
(*((FARPROC)((BYTE*)&code[0])))();
|
||||
}
|
||||
|
||||
inline
|
||||
String CodeGen::entryName(void)const
|
||||
{
|
||||
String entryPointName;
|
||||
::sprintf(entryPointName,"CODE%08lx.BIN",(DWORD)this);
|
||||
return entryPointName;
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXOFFSETCS(int csOffset) // mov eax,cs:[csOffset]
|
||||
{
|
||||
write((BYTE)(0x2E));
|
||||
write((BYTE)(0xA1));
|
||||
write(csOffset);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movECXOFFSETCS(int csOffset) // mov ecx,cs:[csOffset]
|
||||
{
|
||||
write((BYTE)(0x2E));
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x0D));
|
||||
write(csOffset);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushDS(void)
|
||||
{
|
||||
write((BYTE)(0x1E));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popDS(void)
|
||||
{
|
||||
write((BYTE)(0x1F));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushCS(void)
|
||||
{
|
||||
write((BYTE)(0x0E));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXOFFSETDS(int dsOffset)
|
||||
{
|
||||
write((BYTE)(0xA1));
|
||||
write(dsOffset);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movOFFSETDSEAX(int dsOffset)
|
||||
{
|
||||
write((BYTE)(0xA3));
|
||||
write(dsOffset);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::nop(void)
|
||||
{
|
||||
write((BYTE)(0x90));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXEBX(void) // mov eax,ebx
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0xC3));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEBXEAX(void) // mov ebx,eax
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0xD8));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::popEBX(void)
|
||||
{
|
||||
write((BYTE)(0x5B));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushEBX(void)
|
||||
{
|
||||
write((BYTE)(0x53));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAX(int value)
|
||||
{
|
||||
write((BYTE)(0xB8));
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushEBPEAXPLUS(int eaxAdditive)
|
||||
{
|
||||
write((BYTE)(0xFF));
|
||||
write((BYTE)(0xB4));
|
||||
write((BYTE)(0x05));
|
||||
write(eaxAdditive);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::decEAX(void)
|
||||
{
|
||||
write((BYTE)(0x48));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::cmpEAX(int value)
|
||||
{
|
||||
write((BYTE)(0x3D));
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::addEBP(int value)
|
||||
{
|
||||
write((BYTE)(0x81));
|
||||
write((BYTE)(0xC5));
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movECXESI(void)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0xCE));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movECXEDI(void)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0xCF));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movECX(int value)
|
||||
{
|
||||
write((BYTE)(0xB9));
|
||||
write(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXESP(void)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0xC4));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::pushFSOFFSET(WORD offset)
|
||||
{
|
||||
write((BYTE)(0x64));
|
||||
write((BYTE)(0x67));
|
||||
write((BYTE)(0xFF));
|
||||
write((BYTE)(0X36));
|
||||
write((BYTE)(offset&0x00FF));
|
||||
write((BYTE)(offset>>0x08));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movFSOFFSETESP(WORD offset)
|
||||
{
|
||||
write((BYTE)(0x64));
|
||||
write((BYTE)(0x67));
|
||||
write((BYTE)(0x89));
|
||||
write((BYTE)(0x26));
|
||||
write((BYTE)(offset&0x00FF));
|
||||
write((BYTE)(offset>>0x08));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXOFFSETSS(int offset)
|
||||
{
|
||||
write((BYTE)(0x36));
|
||||
write((BYTE)(0xA1));
|
||||
write((BYTE)(offset));
|
||||
write((BYTE)(offset>>0x08));
|
||||
write((BYTE)(offset>>0x10));
|
||||
write((BYTE)(offset>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movOFFSETSSEAX(int offset)
|
||||
{
|
||||
write((BYTE)(0x36));
|
||||
write((BYTE)(0xA3));
|
||||
write((BYTE)(offset));
|
||||
write((BYTE)(offset>>0x08));
|
||||
write((BYTE)(offset>>0x10));
|
||||
write((BYTE)(offset>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXESPOFFSET(int offset)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x84));
|
||||
write((BYTE)(0x24));
|
||||
write((BYTE)(offset));
|
||||
write((BYTE)(offset>>0x08));
|
||||
write((BYTE)(offset>>0x10));
|
||||
write((BYTE)(offset>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movEAXEBPOFFSET(int offset)
|
||||
{
|
||||
write((BYTE)(0x8B));
|
||||
write((BYTE)(0x85));
|
||||
write((BYTE)(0x56));
|
||||
write((BYTE)(offset));
|
||||
write((BYTE)(offset>>0x08));
|
||||
write((BYTE)(offset>>0x10));
|
||||
write((BYTE)(offset>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movESPOFFSETEAX(int offset)
|
||||
{
|
||||
write((BYTE)(0x89));
|
||||
write((BYTE)(0x84));
|
||||
write((BYTE)(0x24));
|
||||
write((BYTE)(offset));
|
||||
write((BYTE)(offset>>0x08));
|
||||
write((BYTE)(offset>>0x10));
|
||||
write((BYTE)(offset>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movFSOFFSETEAX(int offset)
|
||||
{
|
||||
write((BYTE)(0x64));
|
||||
write((BYTE)(0xA3));
|
||||
write((BYTE)(offset));
|
||||
write((BYTE)(offset>>0x08));
|
||||
write((BYTE)(offset>>0x10));
|
||||
write((BYTE)(offset>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movESPOFFSETEBX(int offset)
|
||||
{
|
||||
write((BYTE)(0x89));
|
||||
write((BYTE)(0x9C));
|
||||
write((BYTE)(0x24));
|
||||
write((BYTE)(offset));
|
||||
write((BYTE)(offset>>0x08));
|
||||
write((BYTE)(offset>>0x10));
|
||||
write((BYTE)(offset>>0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::movDEREFEAXEBX(void)
|
||||
{
|
||||
write((BYTE)(0x89));
|
||||
write((BYTE)(0x18));
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::wait(void)
|
||||
{
|
||||
write((BYTE)0x9B);
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeGen::finit(void)
|
||||
{
|
||||
write((BYTE)0xDB);
|
||||
write((BYTE)0xE3);
|
||||
}
|
||||
#endif
|
||||
109
common/COMCTLEX.HPP
Normal file
109
common/COMCTLEX.HPP
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef _COMMON_COMMONCONTROLSEX_HPP_
|
||||
#define _COMMON_COMMONCONTROLSEX_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_COMMCTRL_HPP_
|
||||
#include <common/commctrl.hpp>
|
||||
#endif
|
||||
|
||||
class CommonControlsEx : private tagINITCOMMONCONTROLSEX
|
||||
{
|
||||
public:
|
||||
enum InitFlags{InitListView=ICC_LISTVIEW_CLASSES,InitTreeView=ICC_TREEVIEW_CLASSES,
|
||||
InitBar=ICC_BAR_CLASSES,InitTab=ICC_TAB_CLASSES,InitUpDown=ICC_UPDOWN_CLASS,
|
||||
InitProgress=ICC_PROGRESS_CLASS,InitHotKey=ICC_HOTKEY_CLASS,InitAnimate=ICC_ANIMATE_CLASS,
|
||||
InitWin95=ICC_WIN95_CLASSES,InitDate=ICC_DATE_CLASSES,InitUserEx=ICC_USEREX_CLASSES,
|
||||
InitCoolBar=ICC_COOL_CLASSES};
|
||||
CommonControlsEx(void);
|
||||
CommonControlsEx(const CommonControlsEx &someCommonControlsEx);
|
||||
CommonControlsEx(const tagINITCOMMONCONTROLSEX &sometagINITCOMMONCONTROLSEX);
|
||||
virtual ~CommonControlsEx();
|
||||
CommonControlsEx &operator=(const CommonControlsEx &someCommonControlsEx);
|
||||
CommonControlsEx &operator=(const tagINITCOMMONCONTROLSEX &sometagINITCOMMONCONTROLSEX);
|
||||
DWORD flags(void)const;
|
||||
void flags(DWORD flags);
|
||||
BOOL initCommonControlsEx(void);
|
||||
tagINITCOMMONCONTROLSEX &getINITCOMMONCONTROLSEX(void);
|
||||
private:
|
||||
DWORD size(void)const;
|
||||
void size(DWORD size);
|
||||
};
|
||||
|
||||
inline
|
||||
CommonControlsEx::CommonControlsEx(void)
|
||||
{
|
||||
size(sizeof(tagINITCOMMONCONTROLSEX));
|
||||
flags(0);
|
||||
}
|
||||
|
||||
inline
|
||||
CommonControlsEx::CommonControlsEx(const CommonControlsEx &someCommonControlsEx)
|
||||
{
|
||||
size(sizeof(tagINITCOMMONCONTROLSEX));
|
||||
*this=someCommonControlsEx;
|
||||
}
|
||||
|
||||
inline
|
||||
CommonControlsEx::CommonControlsEx(const tagINITCOMMONCONTROLSEX &sometagINITCOMMONCONTROLSEX)
|
||||
{
|
||||
size(sizeof(tagINITCOMMONCONTROLSEX));
|
||||
*this=sometagINITCOMMONCONTROLSEX;
|
||||
}
|
||||
|
||||
inline
|
||||
CommonControlsEx::~CommonControlsEx()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CommonControlsEx &CommonControlsEx::operator=(const CommonControlsEx &someCommonControlsEx)
|
||||
{
|
||||
flags(someCommonControlsEx.flags());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
CommonControlsEx &CommonControlsEx::operator=(const tagINITCOMMONCONTROLSEX &sometagINITCOMMONCONTROLSEX)
|
||||
{
|
||||
flags(sometagINITCOMMONCONTROLSEX.dwICC);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD CommonControlsEx::flags(void)const
|
||||
{
|
||||
return tagINITCOMMONCONTROLSEX::dwICC;
|
||||
}
|
||||
|
||||
inline
|
||||
void CommonControlsEx::flags(DWORD flags)
|
||||
{
|
||||
tagINITCOMMONCONTROLSEX::dwICC=flags;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD CommonControlsEx::size(void)const
|
||||
{
|
||||
return tagINITCOMMONCONTROLSEX::dwSize;
|
||||
}
|
||||
|
||||
inline
|
||||
void CommonControlsEx::size(DWORD size)
|
||||
{
|
||||
tagINITCOMMONCONTROLSEX::dwSize=size;
|
||||
}
|
||||
|
||||
inline
|
||||
tagINITCOMMONCONTROLSEX &CommonControlsEx::getINITCOMMONCONTROLSEX(void)
|
||||
{
|
||||
return (tagINITCOMMONCONTROLSEX&)*this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL CommonControlsEx::initCommonControlsEx(void)
|
||||
{
|
||||
if(!flags())return FALSE;
|
||||
return ::InitCommonControlsEx(&getINITCOMMONCONTROLSEX());
|
||||
}
|
||||
#endif
|
||||
4
common/COMMCTRL.HPP
Normal file
4
common/COMMCTRL.HPP
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef _COMMON_COMMCTRL_HPP_
|
||||
#define _COMMON_COMMCTRL_HPP_
|
||||
#include <commctrl.h>
|
||||
#endif
|
||||
5
common/COMMDLG.HPP
Normal file
5
common/COMMDLG.HPP
Normal file
@@ -0,0 +1,5 @@
|
||||
#ifndef _COMMON_COMMDLG_HPP_
|
||||
#define _COMMON_COMMDLG_HPP_
|
||||
#undef STDMETHOD
|
||||
#include <commdlg.h>
|
||||
#endif
|
||||
BIN
common/COMMON16.IDE
Normal file
BIN
common/COMMON16.IDE
Normal file
Binary file not shown.
BIN
common/COMMON16.OBR
Normal file
BIN
common/COMMON16.OBR
Normal file
Binary file not shown.
BIN
common/COMMON16.~DE
Normal file
BIN
common/COMMON16.~DE
Normal file
Binary file not shown.
BIN
common/COMMON32.IDE
Normal file
BIN
common/COMMON32.IDE
Normal file
Binary file not shown.
BIN
common/COMMON32.MBT
Normal file
BIN
common/COMMON32.MBT
Normal file
Binary file not shown.
BIN
common/COMMON32.MRT
Normal file
BIN
common/COMMON32.MRT
Normal file
Binary file not shown.
BIN
common/COMMON32.OBR
Normal file
BIN
common/COMMON32.OBR
Normal file
Binary file not shown.
BIN
common/COMMON32.~DE
Normal file
BIN
common/COMMON32.~DE
Normal file
Binary file not shown.
86
common/COMMONM.INC
Normal file
86
common/COMMONM.INC
Normal file
@@ -0,0 +1,86 @@
|
||||
; **************************************************************************
|
||||
; FILE:COMMON.INC
|
||||
; FUNCTION: COMMON ASSEMBLER INCLUDE FILE
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
;****************************************************************************
|
||||
INCLUDE WINDOWS.INC
|
||||
|
||||
LPDWORD TYPEDEF NEAR PTR DWORD
|
||||
NPDWORD TYPEDEF FAR PTR DWORD
|
||||
NPBYTE TYPEDEF PTR BYTE
|
||||
|
||||
String STRUC
|
||||
String@@mnpStr NPDWORD ?
|
||||
String@@mLengthBytes DD ?
|
||||
String ENDS
|
||||
|
||||
Point STRUC
|
||||
Point@@x DW ?
|
||||
Point@@y DW ?
|
||||
Point ENDS
|
||||
|
||||
Point3D STRUC
|
||||
Point3D@@xyPoint Point <>
|
||||
Point3D@@Point@@z DW ?
|
||||
Point3D ENDS
|
||||
|
||||
PurePalette STRUC
|
||||
PurePalette@@mhPalette HANDLE <>
|
||||
PurePalette@@mhOldPalette HANDLE <>
|
||||
PurePalette@@mPaletteData PALETTEENTRY 100h DUP (<>)
|
||||
PurePalette@@mIsInUse DW ?
|
||||
PurePalette ENDS
|
||||
|
||||
BitmapData STRUC
|
||||
BitmapData@@mhGlobalBitmapData HANDLE <>
|
||||
BitmapData@@mhGlobalBitmapInfo HANDLE <>
|
||||
BitmapData@@mlpBitmapData LPDWORD ?
|
||||
BitmapData@@mlpBitmapInfo PBITMAPINFO ?
|
||||
BitmapData@@mInfoDisposition DD ?
|
||||
BitmapData@@mDataDisposition DD ?
|
||||
BitmapData ENDS
|
||||
|
||||
Bitmap STRUC
|
||||
PBitmap TYPEDEF FAR PTR Bitmap
|
||||
PPBitmap TYPEDEF FAR PTR PBitmap
|
||||
Bitmap@@mBitmapData BitmapData <>
|
||||
Bitmap@@mFileName String <>
|
||||
Bitmap@@mMaxColors DW ?
|
||||
Bitmap@@mCurrentMode DD ?
|
||||
Bitmap@@mBitmapFileHeader BITMAPFILEHEADER <>
|
||||
Bitmap@@mPaletteData PurePalette <>
|
||||
Bitmap@@mBlockSize DD ?
|
||||
Bitmap@@mhFile HANDLE <>
|
||||
Bitmap@@mImageExtent DD ?
|
||||
Bitmap@@mWidth DD ?
|
||||
Bitmap@@mHeight DD ?
|
||||
Bitmap ENDS
|
||||
|
||||
PureVectorBitmap STRUC
|
||||
PPureVectorBitmap TYPEDEF FAR PTR PureVectorBitmap
|
||||
PureVectorBitmap@@mhGlobalMemPool DD ?
|
||||
PureVectorBitmap@@mhGlobalVectorTable DD ?
|
||||
PureVectorBitmap@@mEntries DD ?
|
||||
PureVectorBitmap@@mlpVectorTable PPBitmap ?
|
||||
PureVectorBitmap@@mlpMemPool PBitmap ?
|
||||
PureVectorBitmap ENDS
|
||||
|
||||
getBitmapPtr MACRO npPureVector,itemIndex
|
||||
LOCAL @@boundFail,@@return
|
||||
push edi ; save destination index register
|
||||
mov edi,npPureVector ; move npPureVector to edi register
|
||||
movzx eax,itemIndex ; move itemIndex to eax register
|
||||
cmp eax,[PureVectorBitmap ptr[edi]].PureVectorBitmap@@mEntries ; check index boundary
|
||||
jge @@boundFail ; handle out of bounds condition
|
||||
shl eax,02h ; multiply eax by sizeof(PTR)
|
||||
mov edi,[PureVectorBitmap ptr[edi]].PureVectorBitmap@@mlpVectorTable ; dereference vector table to edi
|
||||
add edi,eax ; add in itemIndex
|
||||
mov eax,[edi] ; dereference pointer to eax
|
||||
jmp @@return ; return
|
||||
@@boundFail: ; boundary error sync address
|
||||
xor eax,eax ; error clears eax register
|
||||
@@return: ; return sync address
|
||||
pop edi ; restore detination index register
|
||||
ENDM
|
||||
|
||||
|
||||
15
common/COMP.RSP
Normal file
15
common/COMP.RSP
Normal file
@@ -0,0 +1,15 @@
|
||||
/G4
|
||||
/YX
|
||||
/D__FLAT__
|
||||
/DSTRICT
|
||||
/G4
|
||||
/GA
|
||||
/J
|
||||
/Yd
|
||||
/Zi
|
||||
/IC:\PARTS\MSVC\INCLUDE
|
||||
/I..
|
||||
/I..\..\PARTS
|
||||
/c
|
||||
/FoMSVCOBJ\MATH.OBJ
|
||||
MATH.CPP
|
||||
90
common/CONSOLE.CPP
Normal file
90
common/CONSOLE.CPP
Normal file
@@ -0,0 +1,90 @@
|
||||
#if defined(__FLAT__)
|
||||
#include <common/console.hpp>
|
||||
#include <common/coord.hpp>
|
||||
#include <common/smrect.hpp>
|
||||
|
||||
Console::Console()
|
||||
: mhConsole(0), mHasConsole(FALSE), mIsSystemConsole(TRUE)
|
||||
{
|
||||
mhConsole=::GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if(mhConsole)mHasConsole=true;
|
||||
}
|
||||
|
||||
Console::Console(ConsoleType consoleType,bool forceCreate)
|
||||
: mhConsole(0), mHasConsole(FALSE), mIsSystemConsole(FALSE)
|
||||
{
|
||||
if(!mhConsole&&!::AllocConsole())
|
||||
{
|
||||
if(!forceCreate)return;
|
||||
::FreeConsole();
|
||||
if(!AllocConsole())return;
|
||||
}
|
||||
mHasConsole=TRUE;
|
||||
if(0==(mhConsole=::CreateConsoleScreenBuffer(consoleType,FILE_SHARE_READ|FILE_SHARE_WRITE,(LPSECURITY_ATTRIBUTES)0,CONSOLE_TEXTMODE_BUFFER,0)))
|
||||
{
|
||||
::FreeConsole();
|
||||
mHasConsole=FALSE;
|
||||
return;
|
||||
}
|
||||
::SetConsoleActiveScreenBuffer(mhConsole);
|
||||
::GetConsoleScreenBufferInfo(mhConsole,&((CONSOLE_SCREEN_BUFFER_INFO&)mConsoleScreenBufferInfo));
|
||||
setConsoleMode(ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT);
|
||||
}
|
||||
|
||||
Console::~Console()
|
||||
{
|
||||
if(mIsSystemConsole)return;
|
||||
if(mhConsole){::CloseHandle(mhConsole);mhConsole=0;}
|
||||
if(mHasConsole){::FreeConsole();mHasConsole=FALSE;}
|
||||
}
|
||||
|
||||
Console::operator HANDLE(void)
|
||||
{
|
||||
return mhConsole;
|
||||
}
|
||||
|
||||
WORD Console::read(void)
|
||||
{
|
||||
String consoleString;
|
||||
return read(consoleString);
|
||||
}
|
||||
|
||||
WORD Console::read(String &consoleString)
|
||||
{
|
||||
String consoleInputString;
|
||||
DWORD bytesRead;
|
||||
HANDLE mhConsoleInput;
|
||||
|
||||
if(!mhConsole)return FALSE;
|
||||
if(!::ReadConsole(::GetStdHandle(STD_INPUT_HANDLE),(LPSTR)consoleInputString,String::MaxString-1,&bytesRead,0))return FALSE;
|
||||
consoleString=consoleInputString;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Console::readBufferLine(int row,String &lineString)
|
||||
{
|
||||
Coord coord(0,row);
|
||||
DWORD bytesRead;
|
||||
|
||||
if(!mhConsole)return FALSE;
|
||||
const ConsoleScreenBufferInfo &consoleScreenBufferInfo=getConsoleScreenBufferInfo();
|
||||
lineString.reserve(consoleScreenBufferInfo.maxWinRect().x());
|
||||
return ::ReadConsoleOutputCharacter(*this,lineString,consoleScreenBufferInfo.maxWinRect().x(),(COORD&)coord,&bytesRead);
|
||||
}
|
||||
|
||||
WORD Console::fillConsoleOutputAttribute(WORD colorAttr,DWORD numChars,const Coord &writeCoord)
|
||||
{
|
||||
DWORD cellsWritten;
|
||||
|
||||
if(!mhConsole)return FALSE;
|
||||
return ::FillConsoleOutputAttribute(mhConsole,colorAttr,numChars,(COORD&)(Coord&)writeCoord,&cellsWritten);
|
||||
}
|
||||
|
||||
WORD Console::fillConsoleOutputCharacter(TCHAR outChar,DWORD nLength,const Coord &writeCoord)
|
||||
{
|
||||
DWORD cellsWritten;
|
||||
|
||||
if(!mhConsole)return FALSE;
|
||||
return ::FillConsoleOutputCharacter(mhConsole,outChar,nLength,(COORD&)(Coord&)writeCoord,&cellsWritten);
|
||||
}
|
||||
#endif
|
||||
89
common/CONSOLE.HPP
Normal file
89
common/CONSOLE.HPP
Normal file
@@ -0,0 +1,89 @@
|
||||
#if defined(__FLAT__)
|
||||
#ifndef _COMMON_CONSOLE_HPP_
|
||||
#define _COMMON_CONSOLE_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SCREENBUFFERINFO_HPP_
|
||||
#include <common/scrnbuff.hpp>
|
||||
#endif
|
||||
|
||||
class Coord;
|
||||
|
||||
class Console
|
||||
{
|
||||
public:
|
||||
enum Attribute{ForegroundBlue=FOREGROUND_BLUE,ForegroundGreen=FOREGROUND_GREEN,
|
||||
ForegroundRed=FOREGROUND_RED,ForegroundIntensity=FOREGROUND_INTENSITY,
|
||||
BackgroundBlue=BACKGROUND_BLUE,BackgroundGreen=BACKGROUND_GREEN,
|
||||
BackgroundRed=BACKGROUND_RED,BackgroundIntensity=BACKGROUND_INTENSITY};
|
||||
enum ConsoleType{Read=GENERIC_READ,Write=GENERIC_WRITE,ReadWrite=GENERIC_READ|GENERIC_WRITE};
|
||||
// Console(ConsoleType consoleType=(ConsoleType)((int)Write|(int)Read),bool forceCreate=false);
|
||||
Console();
|
||||
Console(ConsoleType consoleType,bool forceCreate);
|
||||
virtual ~Console();
|
||||
WORD write(const String &consoleString);
|
||||
WORD write(const BYTE consoleBYTE);
|
||||
WORD writeLine(const String &consoleString);
|
||||
WORD read(void);
|
||||
WORD read(String &consoleString);
|
||||
BOOL readBufferLine(int row,String &lineString);
|
||||
WORD setConsoleMode(DWORD consoleMode);
|
||||
WORD setConsoleAttribute(WORD consoleAttributes);
|
||||
WORD fillConsoleOutputAttribute(WORD colorAttr,DWORD numChars,const Coord &writeCoord);
|
||||
WORD fillConsoleOutputCharacter(TCHAR outChar,DWORD nLength,const Coord &writeCoord);
|
||||
const ConsoleScreenBufferInfo &getConsoleScreenBufferInfo(void)const;
|
||||
operator HANDLE(void);
|
||||
private:
|
||||
HANDLE mhConsole;
|
||||
WORD mHasConsole;
|
||||
DWORD mGenericResult;
|
||||
ConsoleScreenBufferInfo mConsoleScreenBufferInfo;
|
||||
bool mIsSystemConsole;
|
||||
};
|
||||
|
||||
inline
|
||||
WORD Console::write(const String &consoleString)
|
||||
{
|
||||
if(!mhConsole)return FALSE;
|
||||
if(consoleString.isNull())return FALSE;
|
||||
::WriteConsole(mhConsole,consoleString,consoleString.length(),&mGenericResult,0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Console::write(const BYTE consoleBYTE)
|
||||
{
|
||||
if(!mhConsole)return FALSE;
|
||||
::WriteConsole(mhConsole,&consoleBYTE,sizeof(consoleBYTE),&mGenericResult,0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Console::writeLine(const String &consoleString)
|
||||
{
|
||||
if(!write(consoleString))return FALSE;
|
||||
return write("\n");
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Console::setConsoleMode(DWORD consoleMode)
|
||||
{
|
||||
if(!mhConsole)return FALSE;
|
||||
return ::SetConsoleMode(mhConsole,consoleMode);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Console::setConsoleAttribute(WORD consoleAttributes)
|
||||
{
|
||||
if(!mhConsole)return FALSE;
|
||||
return ::SetConsoleTextAttribute(mhConsole,consoleAttributes);
|
||||
}
|
||||
|
||||
inline
|
||||
const ConsoleScreenBufferInfo &Console::getConsoleScreenBufferInfo(void)const
|
||||
{
|
||||
return mConsoleScreenBufferInfo;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
55
common/CONTROL.CPP
Normal file
55
common/CONTROL.CPP
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <common/control.hpp>
|
||||
|
||||
Control::~Control()
|
||||
{
|
||||
}
|
||||
|
||||
HWND Control::createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParentWnd,int controlID)
|
||||
{
|
||||
dwStyle|=WS_CHILD;
|
||||
if(isValid())return *this;
|
||||
this->controlID(controlID);
|
||||
createWindow(className,windowName,dwStyle,initRect,hParentWnd,(HMENU)controlID,(HINSTANCE)processInstance(),0);
|
||||
disposition(GUIWindow::AssumeAndDestroy);
|
||||
return *this;
|
||||
}
|
||||
|
||||
HWND Control::createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParentWnd,int controlID)
|
||||
{
|
||||
dwStyle|=WS_CHILD;
|
||||
if(isValid())return *this;
|
||||
this->controlID(controlID);
|
||||
createWindow(extendedStyle,className,windowName,dwStyle,initRect,hParentWnd,(HMENU)controlID,(HINSTANCE)processInstance(),0);
|
||||
disposition(GUIWindow::AssumeAndDestroy);
|
||||
return *this;
|
||||
}
|
||||
|
||||
HWND Control::createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,Window &parentWindow,int controlID)
|
||||
{
|
||||
dwStyle|=WS_CHILD;
|
||||
if(isValid())return *this;
|
||||
this->controlID(controlID);
|
||||
createWindow(className,windowName,dwStyle,initRect,parentWindow,(HMENU)controlID,parentWindow.processInstance(),0);
|
||||
disposition(GUIWindow::AssumeAndDestroy);
|
||||
return *this;
|
||||
}
|
||||
|
||||
HWND Control::createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,Window &parentWindow,int controlID)
|
||||
{
|
||||
dwStyle|=WS_CHILD;
|
||||
if(isValid())return *this;
|
||||
this->controlID(controlID);
|
||||
createWindow(extendedStyle,className,windowName,dwStyle,initRect,parentWindow,(HMENU)controlID,parentWindow.processInstance(),0);
|
||||
disposition(GUIWindow::AssumeAndDestroy);
|
||||
return *this;
|
||||
}
|
||||
|
||||
HWND Control::assumeControl(HWND hControlWnd,UINT controlID,BOOL destroyWindow)
|
||||
{
|
||||
if(isValid())return *this;
|
||||
this->controlID(controlID);
|
||||
setHandle(hControlWnd);
|
||||
disposition((destroyWindow?GUIWindow::AssumeAndDestroy:GUIWindow::Assume));
|
||||
return *this;
|
||||
}
|
||||
|
||||
115
common/CONTROL.HPP
Normal file
115
common/CONTROL.HPP
Normal file
@@ -0,0 +1,115 @@
|
||||
#ifndef _COMMON_CONTROL_HPP_
|
||||
#define _COMMON_CONTROL_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINDOW_HPP_
|
||||
#include <common/window.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_RECTANGLE_HPP_
|
||||
#include <common/rect.hpp>
|
||||
#endif
|
||||
|
||||
class Control : public Window
|
||||
{
|
||||
public:
|
||||
Control(void);
|
||||
Control(HWND hControlWnd,UINT controlID,BOOL destroyWindow=TRUE);
|
||||
virtual ~Control();
|
||||
BOOL operator==(const Control &someControl)const;
|
||||
WORD width(void)const;
|
||||
void width(WORD width);
|
||||
WORD height(void)const;
|
||||
void height(WORD height);
|
||||
UINT controlID(void)const;
|
||||
virtual HWND createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParentWnd,int controlID);
|
||||
virtual HWND createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParentWnd,int controlID);
|
||||
virtual HWND createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,Window &parentWindow,int controlID);
|
||||
virtual HWND createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,Window &parentWindow,int controlID);
|
||||
virtual HWND assumeControl(HWND hControlWnd,UINT controlID,BOOL destroyWindow=FALSE);
|
||||
private:
|
||||
Control(const Control &someControl);
|
||||
Control &operator=(const GUIWindow &someGUIWindow);
|
||||
Control &operator=(const Control &someControl);
|
||||
void controlID(UINT controlID);
|
||||
UINT mControlID;
|
||||
};
|
||||
|
||||
inline
|
||||
Control::Control(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Control::Control(HWND hControlWnd,UINT controlID,BOOL destroyWindow)
|
||||
{
|
||||
assumeControl(hControlWnd,controlID,destroyWindow);
|
||||
}
|
||||
|
||||
inline
|
||||
Control::Control(const Control &someControl)
|
||||
{ // private implementation
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Control::operator==(const Control &someControl)const
|
||||
{
|
||||
return ((HWND)*this==(HWND)someControl);
|
||||
}
|
||||
|
||||
inline
|
||||
Control &Control::operator=(const Control &someControl)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
Control &Control::operator=(const GUIWindow &someGUIWindow)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
UINT Control::controlID(void)const
|
||||
{
|
||||
return mControlID;
|
||||
}
|
||||
|
||||
inline
|
||||
void Control::controlID(UINT controlID)
|
||||
{
|
||||
mControlID=controlID;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Control::width(void)const
|
||||
{
|
||||
Rect winRect;
|
||||
windowRect(winRect);
|
||||
return winRect.right()-winRect.left();
|
||||
}
|
||||
|
||||
inline
|
||||
void Control::width(WORD width)
|
||||
{
|
||||
Rect winRect;
|
||||
windowRect(winRect);
|
||||
::SetWindowPos(*this,HWND_BOTTOM,0,0,width,winRect.bottom()-winRect.top(),SWP_NOMOVE|SWP_NOZORDER);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Control::height(void)const
|
||||
{
|
||||
Rect winRect;
|
||||
windowRect(winRect);
|
||||
return winRect.bottom()-winRect.top();
|
||||
}
|
||||
|
||||
inline
|
||||
void Control::height(WORD height)
|
||||
{
|
||||
Rect winRect;
|
||||
windowRect(winRect);
|
||||
::SetWindowPos(*this,HWND_BOTTOM,0,0,winRect.right()-winRect.left(),height,SWP_NOMOVE|SWP_NOZORDER);
|
||||
}
|
||||
#endif
|
||||
93
common/COORD.HPP
Normal file
93
common/COORD.HPP
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _COMMON_COORD_HPP_
|
||||
#define _COMMON_COORD_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class Coord : private COORD
|
||||
{
|
||||
public:
|
||||
Coord(void);
|
||||
Coord(const Coord &someCoord);
|
||||
Coord(short x,short y);
|
||||
virtual ~Coord();
|
||||
Coord &operator=(const Coord &someCoord);
|
||||
WORD operator==(const Coord &someCoord)const;
|
||||
operator COORD&(void);
|
||||
short x(void)const;
|
||||
void x(short x);
|
||||
short y(void)const;
|
||||
void y(short y);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
Coord::Coord(void)
|
||||
{
|
||||
COORD::X=0;
|
||||
COORD::Y=0;
|
||||
}
|
||||
|
||||
inline
|
||||
Coord::Coord(const Coord &someCoord)
|
||||
{
|
||||
*this=someCoord;
|
||||
}
|
||||
|
||||
inline
|
||||
Coord::Coord(short x,short y)
|
||||
{
|
||||
COORD::X=x;
|
||||
COORD::Y=y;
|
||||
}
|
||||
|
||||
inline
|
||||
Coord::~Coord()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Coord &Coord::operator=(const Coord &someCoord)
|
||||
{
|
||||
x(someCoord.x());
|
||||
y(someCoord.y());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Coord::operator==(const Coord &someCoord)const
|
||||
{
|
||||
return (x()==someCoord.x()&&
|
||||
y()==someCoord.y());
|
||||
}
|
||||
|
||||
inline
|
||||
Coord::operator COORD&(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
short Coord::x(void)const
|
||||
{
|
||||
return COORD::X;
|
||||
}
|
||||
|
||||
inline
|
||||
void Coord::x(short x)
|
||||
{
|
||||
COORD::X=x;
|
||||
}
|
||||
|
||||
inline
|
||||
short Coord::y(void)const
|
||||
{
|
||||
return COORD::Y;
|
||||
}
|
||||
|
||||
inline
|
||||
void Coord::y(short y)
|
||||
{
|
||||
COORD::Y=y;
|
||||
}
|
||||
#endif
|
||||
20
common/CRSCTRL.CPP
Normal file
20
common/CRSCTRL.CPP
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <common/crsctrl.hpp>
|
||||
|
||||
void CursorControl::setCursor(int setState,CursorID cursorID)
|
||||
{
|
||||
if(setState)
|
||||
{
|
||||
if(!mhCursor)mhCursor=::SetCursor(::LoadCursor(NULL,(const char*)(int)cursorID));
|
||||
::ShowCursor(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mhCursor)
|
||||
{
|
||||
::ShowCursor(FALSE);
|
||||
::SetCursor(mhCursor);
|
||||
::ShowCursor(TRUE);
|
||||
mhCursor=FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
common/CRSCTRL.HPP
Normal file
46
common/CRSCTRL.HPP
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef _COMMON_CURSORCONTROL_HPP_
|
||||
#define _COMMON_CURSORCONTROL_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class CursorControl
|
||||
{
|
||||
public:
|
||||
enum CursorID{Arrow=IDC_ARROW,IBeam=IDC_IBEAM,Wait=IDC_WAIT,Cross=IDC_CROSS,
|
||||
UpArrow=IDC_UPARROW,Size=IDC_SIZE,Icon=IDC_ICON,SizeNWSE=IDC_SIZENWSE,
|
||||
SizeNESW=IDC_SIZENESW,SizeWE=IDC_SIZEWE,SizeNS=IDC_SIZENS,
|
||||
SizeAll=IDC_SIZEALL,No=IDC_NO,AppStarting=IDC_APPSTARTING,Help=IDC_HELP};
|
||||
CursorControl(void);
|
||||
virtual ~CursorControl();
|
||||
void waitCursor(int setState);
|
||||
void setCursor(int setState,CursorID cursorID=Wait);
|
||||
static int showCursor(BOOL show);
|
||||
private:
|
||||
HCURSOR mhCursor;
|
||||
};
|
||||
|
||||
inline
|
||||
CursorControl::CursorControl(void)
|
||||
: mhCursor(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CursorControl::~CursorControl()
|
||||
{
|
||||
waitCursor(FALSE);
|
||||
}
|
||||
|
||||
inline
|
||||
void CursorControl::waitCursor(int setState)
|
||||
{
|
||||
setCursor(setState,Wait);
|
||||
}
|
||||
|
||||
inline
|
||||
int CursorControl::showCursor(BOOL show)
|
||||
{
|
||||
return ::ShowCursor(show);
|
||||
}
|
||||
#endif
|
||||
58
common/Callback.hpp
Normal file
58
common/Callback.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef _COMMON_CALLBACK_HPP_
|
||||
#define _COMMON_CALLBACK_HPP_
|
||||
#ifndef _COMMON_CALLBACKDATA_HPP_
|
||||
#include <common/cbdata.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PURECALLBACK_HPP_
|
||||
#include <common/pcallbck.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_CALLBACKPOINTER_HPP_
|
||||
#include <common/cbptr.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable:4355)
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class Callback : public PureCallback
|
||||
{
|
||||
public:
|
||||
typedef CallbackData::ReturnType (T::*PFNMETHOD)(CallbackData &callbackData);
|
||||
Callback(void);
|
||||
Callback(const Callback<T> &someCallback);
|
||||
Callback(T *lpObject,PFNMETHOD lpMethod);
|
||||
virtual ~Callback();
|
||||
void setObject(T *lpObject);
|
||||
void setMethod(PFNMETHOD lpMethod);
|
||||
void setCallback(T *lpObject,PFNMETHOD lpMethod);
|
||||
WORD operator==(const Callback<T> &someCallback)const;
|
||||
void operator=(const Callback<T> &someCallback);
|
||||
CallbackData::ReturnType operator*(CallbackData &someCallbackData);
|
||||
private:
|
||||
T *mlpObject;
|
||||
CallbackData::ReturnType (T::*mlpMethod)(CallbackData &someCallbackData);
|
||||
};
|
||||
|
||||
#ifndef _MSC_VER
|
||||
template <class T>
|
||||
inline
|
||||
CallbackData::ReturnType Callback<T>::operator*(CallbackData &someCallbackData)
|
||||
{
|
||||
if((!mlpObject)||(!mlpMethod))return (CallbackData::ReturnType)0;
|
||||
return (mlpObject->*mlpMethod)(someCallbackData);
|
||||
}
|
||||
#else // the rocket scientists at microsoft have problems compiling the preceeding, must do the following...
|
||||
template <class T>
|
||||
inline
|
||||
CallbackData::ReturnType Callback<T>::operator*(CallbackData &someCallbackData)
|
||||
{
|
||||
CallbackData::ReturnType (T::*lpMethod)(CallbackData &someCallbackData)=0;
|
||||
if((lpMethod==mlpMethod)||!mlpObject)return (CallbackData::ReturnType)0;
|
||||
return (mlpObject->*mlpMethod)(someCallbackData);
|
||||
}
|
||||
#endif
|
||||
#if defined(_MSC_VER) // the rocket scientists at microsoft have trouble expanding templates
|
||||
#include <common/callback.tpp>
|
||||
#endif
|
||||
#endif
|
||||
242
common/Cbdata.hpp
Normal file
242
common/Cbdata.hpp
Normal file
@@ -0,0 +1,242 @@
|
||||
#ifndef _COMMON_CALLBACKDATA_HPP_
|
||||
#define _COMMON_CALLBACKDATA_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINDOWSX_HPP_
|
||||
#include <common/windowsx.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_RECTANGLE_HPP_
|
||||
#include <common/rect.hpp>
|
||||
#endif
|
||||
|
||||
class PureDevice;
|
||||
|
||||
class PaintInformation : public PAINTSTRUCT
|
||||
{
|
||||
public:
|
||||
PaintInformation(const PureDevice &somePureDevice);
|
||||
~PaintInformation();
|
||||
operator PureDevice&(void)const;
|
||||
Rect paintRect(void)const;
|
||||
private:
|
||||
PureDevice *mlpPaintDevice;
|
||||
};
|
||||
|
||||
inline
|
||||
Rect PaintInformation::paintRect(void)const
|
||||
{
|
||||
return Rect(PAINTSTRUCT::rcPaint.left,PAINTSTRUCT::rcPaint.top,PAINTSTRUCT::rcPaint.right,PAINTSTRUCT::rcPaint.bottom);
|
||||
}
|
||||
|
||||
class CallbackData
|
||||
{
|
||||
public:
|
||||
typedef LONG ReturnType;
|
||||
CallbackData(void);
|
||||
CallbackData(const CallbackData &someCallbackData);
|
||||
CallbackData(WPARAM wParam,LPARAM lParam,HWND hWndFrom=0);
|
||||
virtual ~CallbackData();
|
||||
CallbackData &operator=(const CallbackData &someCallbackData);
|
||||
WORD operator==(const CallbackData &someCallbackData)const;
|
||||
HWND hwndFrom(void)const;
|
||||
void hwndFrom(HWND hwndFrom);
|
||||
WPARAM wParam(void)const;
|
||||
void wParam(WPARAM wParam);
|
||||
LPARAM lParam(void)const;
|
||||
void lParam(LPARAM lParam);
|
||||
WORD loWord(void)const;
|
||||
WORD hiWord(void)const;
|
||||
WPARAM wmCommandID(void)const; // specialized WM_COMMAND interpreter
|
||||
HWND wmCommandWindow(void)const; // ""
|
||||
WORD wmCommandCommand(void)const; // ""
|
||||
WPARAM menuSelectID(void)const; // specialized WM_MENUSELECT interpreter
|
||||
WPARAM menuSelectFlags(void)const; // ""
|
||||
HMENU menuSelectMenu(void)const; // ""
|
||||
HMENU menuSelectIDPopup(void)const; // ""
|
||||
UINT controlID(void)const; // specialized control handling
|
||||
HWND controlWindow(void)const; // ""
|
||||
WORD controlNotification(void)const; // ""
|
||||
private:
|
||||
WPARAM mwParam;
|
||||
LPARAM mlParam;
|
||||
HWND mhWndFrom;
|
||||
};
|
||||
|
||||
inline
|
||||
CallbackData::CallbackData(void)
|
||||
: mwParam(0), mlParam(0), mhWndFrom(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CallbackData::CallbackData(WPARAM wParam,LPARAM lParam,HWND hWndFrom)
|
||||
: mwParam(wParam), mlParam(lParam), mhWndFrom(hWndFrom)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CallbackData::CallbackData(const CallbackData &someCallbackData)
|
||||
{
|
||||
*this=someCallbackData;
|
||||
}
|
||||
|
||||
inline
|
||||
CallbackData::~CallbackData()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CallbackData &CallbackData::operator=(const CallbackData &someCallbackData)
|
||||
{
|
||||
wParam(someCallbackData.wParam());
|
||||
lParam(someCallbackData.lParam());
|
||||
hwndFrom(someCallbackData.hwndFrom());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD CallbackData::operator==(const CallbackData &someCallbackData)const
|
||||
{
|
||||
return (wParam()==someCallbackData.wParam()&&
|
||||
lParam()==someCallbackData.lParam()&&
|
||||
hwndFrom()==someCallbackData.hwndFrom());
|
||||
}
|
||||
|
||||
inline
|
||||
WPARAM CallbackData::wmCommandID(void)const
|
||||
{
|
||||
return (WPARAM)(GET_WM_COMMAND_ID(mwParam,mlParam));
|
||||
}
|
||||
|
||||
inline
|
||||
HWND CallbackData::wmCommandWindow(void)const
|
||||
{
|
||||
return GET_WM_COMMAND_HWND(mwParam,mlParam);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD CallbackData::wmCommandCommand(void)const
|
||||
{
|
||||
return GET_WM_COMMAND_CMD(mwParam,mlParam);
|
||||
}
|
||||
|
||||
inline
|
||||
WPARAM CallbackData::menuSelectID(void)const
|
||||
{
|
||||
#ifdef __FLAT__
|
||||
return LOWORD(mwParam);
|
||||
#else
|
||||
return mwParam;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
WPARAM CallbackData::menuSelectFlags(void)const
|
||||
{
|
||||
#ifdef __FLAT__
|
||||
return HIWORD(mwParam);
|
||||
#else
|
||||
return LOWORD(mlParam);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
HMENU CallbackData::menuSelectMenu(void)const
|
||||
{
|
||||
#ifdef __FLAT__
|
||||
return (HMENU)mlParam;
|
||||
#else
|
||||
return (HMENU)HIWORD(mlParam);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
HMENU CallbackData::menuSelectIDPopup(void)const
|
||||
{
|
||||
if(!(menuSelectFlags()&MF_POPUP))return (HMENU)0;
|
||||
#ifdef __FLAT__
|
||||
return ::GetSubMenu(menuSelectMenu(),menuSelectID());
|
||||
#else
|
||||
return (HMENU)menuSelectID();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
UINT CallbackData::controlID(void)const
|
||||
{
|
||||
#ifdef __FLAT__
|
||||
return LOWORD(mwParam);
|
||||
#else
|
||||
return mwParam;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
HWND CallbackData::controlWindow(void)const
|
||||
{
|
||||
#ifdef __FLAT__
|
||||
return (HWND)mlParam;
|
||||
#else
|
||||
return (HWND)LOWORD(mlParam);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
WORD CallbackData::controlNotification(void)const
|
||||
{
|
||||
#ifdef __FLAT__
|
||||
return HIWORD(mwParam);
|
||||
#else
|
||||
return HIWORD(mlParam);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
HWND CallbackData::hwndFrom(void)const
|
||||
{
|
||||
return mhWndFrom;
|
||||
}
|
||||
|
||||
inline
|
||||
void CallbackData::hwndFrom(HWND hwndFrom)
|
||||
{
|
||||
mhWndFrom=hwndFrom;
|
||||
}
|
||||
|
||||
inline
|
||||
WPARAM CallbackData::wParam(void)const
|
||||
{
|
||||
return mwParam;
|
||||
}
|
||||
|
||||
inline
|
||||
void CallbackData::wParam(WPARAM wParam)
|
||||
{
|
||||
mwParam=wParam;
|
||||
}
|
||||
|
||||
inline
|
||||
LPARAM CallbackData::lParam(void)const
|
||||
{
|
||||
return mlParam;
|
||||
}
|
||||
|
||||
inline
|
||||
void CallbackData::lParam(LPARAM lParam)
|
||||
{
|
||||
mlParam=lParam;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD CallbackData::loWord(void)const
|
||||
{
|
||||
return LOWORD(mlParam);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD CallbackData::hiWord(void)const
|
||||
{
|
||||
return HIWORD(mlParam);
|
||||
}
|
||||
#endif
|
||||
80
common/Common.inc
Normal file
80
common/Common.inc
Normal file
@@ -0,0 +1,80 @@
|
||||
; **************************************************************************
|
||||
; FILE:COMMON.INC
|
||||
; FUNCTION: COMMON ASSEMBLER INCLUDE FILE
|
||||
; AUTHOR: SEAN M. KESSLER
|
||||
;****************************************************************************
|
||||
INCLUDE ..\COMMON\WINDOWS.INC
|
||||
|
||||
LPDWORD TYPEDEF NEAR PTR DWORD
|
||||
NPDWORD TYPEDEF FAR PTR DWORD
|
||||
NPBYTE TYPEDEF PTR BYTE
|
||||
|
||||
String STRUC
|
||||
String@@mnpStr NPDWORD ?
|
||||
String@@mLengthBytes DD ?
|
||||
String ENDS
|
||||
|
||||
Point STRUC
|
||||
Point@@x DW ?
|
||||
Point@@y DW ?
|
||||
Point ENDS
|
||||
|
||||
PurePalette STRUC
|
||||
PurePalette@@mhPalette HANDLE <>
|
||||
PurePalette@@mhOldPalette HANDLE <>
|
||||
PurePalette@@mPaletteData PALETTEENTRY 100h DUP (<>)
|
||||
PurePalette@@mIsInUse DW ?
|
||||
PurePalette ENDS
|
||||
|
||||
BitmapData STRUC
|
||||
BitmapData@@mhGlobalBitmapData HANDLE <>
|
||||
BitmapData@@mhGlobalBitmapInfo HANDLE <>
|
||||
BitmapData@@mlpBitmapData LPDWORD ?
|
||||
BitmapData@@mlpBitmapInfo PBITMAPINFO ?
|
||||
BitmapData@@mInfoDisposition DD ?
|
||||
BitmapData@@mDataDisposition DD ?
|
||||
BitmapData ENDS
|
||||
|
||||
Bitmap STRUC
|
||||
PBitmap TYPEDEF NEAR PTR Bitmap
|
||||
PPBitmap TYPEDEF NEAR PTR PBitmap
|
||||
Bitmap@@mBitmapData BitmapData <>
|
||||
Bitmap@@mFileName String <>
|
||||
Bitmap@@mMaxColors DW ?
|
||||
Bitmap@@mCurrentMode DD ?
|
||||
Bitmap@@mBitmapFileHeader BITMAPFILEHEADER <>
|
||||
Bitmap@@mPaletteData PurePalette <>
|
||||
Bitmap@@mBlockSize DD ?
|
||||
Bitmap@@mhFile HANDLE <>
|
||||
Bitmap@@mImageExtent DD ?
|
||||
Bitmap@@mWidth DD ?
|
||||
Bitmap@@mHeight DD ?
|
||||
Bitmap ENDS
|
||||
|
||||
PureVectorBitmap STRUC
|
||||
PPureVectorBitmap TYPEDEF FAR PTR PureVectorBitmap
|
||||
PureVectorBitmap@@mhGlobalMemPool DD ?
|
||||
PureVectorBitmap@@mhGlobalVectorTable DD ?
|
||||
PureVectorBitmap@@mEntries DD ?
|
||||
PureVectorBitmap@@mlpVectorTable PPBitmap ?
|
||||
PureVectorBitmap@@mlpMemPool PBitmap ?
|
||||
PureVectorBitmap ENDS
|
||||
|
||||
getBitmapPtr MACRO npPureVector,itemIndex
|
||||
LOCAL @@boundFail,@@return
|
||||
push edi ; save destination index register
|
||||
mov edi,npPureVector ; move npPureVector to edi register
|
||||
movzx eax,itemIndex ; move itemIndex to eax register
|
||||
cmp eax,[edi].PureVectorBitmap@@mEntries ; check index boundary
|
||||
jge @@boundFail ; handle out of bounds condition
|
||||
shl eax,02h ; multiply eax by sizeof(PTR)
|
||||
mov edi,[edi].PureVectorBitmap@@mlpVectorTable ; dereference vector table to edi
|
||||
add edi,eax ; add in itemIndex
|
||||
mov eax,[edi] ; dereference pointer to eax
|
||||
jmp @@return ; return
|
||||
@@boundFail: ; boundary error sync address
|
||||
xor eax,eax ; error clears eax register
|
||||
@@return: ; return sync address
|
||||
pop edi ; restore detination index register
|
||||
ENDM
|
||||
|
||||
4
common/DDE.HPP
Normal file
4
common/DDE.HPP
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef _COMMON_DDE_HPP_
|
||||
#define _COMMON_DDE_HPP_
|
||||
#include <dde.h>
|
||||
#endif
|
||||
111
common/DDEACK.HPP
Normal file
111
common/DDEACK.HPP
Normal file
@@ -0,0 +1,111 @@
|
||||
#ifndef _COMMON_DDEACK_HPP_
|
||||
#define _COMMON_DDEACK_HPP_
|
||||
#ifndef _COMMON_DDE_HPP_
|
||||
#include <common/dde.hpp>
|
||||
#endif
|
||||
|
||||
class DDEAck : private DDEACK
|
||||
{
|
||||
public:
|
||||
DDEAck(void);
|
||||
DDEAck(WORD appReturnCode,WORD busy,WORD ack);
|
||||
DDEAck(const DDEAck &someDDEAck);
|
||||
~DDEAck();
|
||||
DDEAck &operator=(const DDEAck &someDDEAck);
|
||||
WORD operator==(const DDEAck &someDDEAck);
|
||||
WORD returnCode(void)const;
|
||||
void returnCode(WORD returnCode);
|
||||
WORD busy(void)const;
|
||||
void busy(WORD busy);
|
||||
WORD ack(void)const;
|
||||
void ack(WORD ack);
|
||||
operator WORD(void)const;
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
DDEAck::DDEAck(void)
|
||||
{
|
||||
returnCode(FALSE);
|
||||
busy(FALSE);
|
||||
ack(TRUE);
|
||||
}
|
||||
|
||||
inline
|
||||
DDEAck::DDEAck(WORD appReturnCode,WORD busyFlag,WORD ackFlag)
|
||||
{
|
||||
returnCode(appReturnCode);
|
||||
busy(busyFlag);
|
||||
ack(ackFlag);
|
||||
}
|
||||
|
||||
inline
|
||||
DDEAck::DDEAck(const DDEAck &someDDEAck)
|
||||
{
|
||||
*this=someDDEAck;
|
||||
}
|
||||
|
||||
inline
|
||||
DDEAck::~DDEAck()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DDEAck &DDEAck::operator=(const DDEAck &someDDEAck)
|
||||
{
|
||||
returnCode(someDDEAck.returnCode());
|
||||
busy(someDDEAck.busy());
|
||||
ack(someDDEAck.ack());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEAck::operator==(const DDEAck &someDDEAck)
|
||||
{
|
||||
return(returnCode()==someDDEAck.returnCode()&&
|
||||
busy()==someDDEAck.busy()&&
|
||||
ack()==someDDEAck.ack());
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEAck::returnCode(void)const
|
||||
{
|
||||
return DDEACK::bAppReturnCode;
|
||||
}
|
||||
|
||||
inline
|
||||
void DDEAck::returnCode(WORD returnCode)
|
||||
{
|
||||
DDEACK::bAppReturnCode=returnCode;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEAck::busy(void)const
|
||||
{
|
||||
return DDEACK::fBusy;
|
||||
}
|
||||
|
||||
inline
|
||||
void DDEAck::busy(WORD busy)
|
||||
{
|
||||
DDEACK::fBusy=busy;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEAck::ack(void)const
|
||||
{
|
||||
return DDEACK::fAck;
|
||||
}
|
||||
|
||||
inline
|
||||
void DDEAck::ack(WORD ack)
|
||||
{
|
||||
DDEACK::fAck=ack;
|
||||
}
|
||||
|
||||
inline
|
||||
DDEAck::operator WORD(void)const
|
||||
{
|
||||
return *((WORD*)((DDEACK*)this));
|
||||
}
|
||||
#endif
|
||||
105
common/DDEDATA.HPP
Normal file
105
common/DDEDATA.HPP
Normal file
@@ -0,0 +1,105 @@
|
||||
#ifndef _COMMON_DDEDATA_HPP_
|
||||
#define _COMMON_DDEDATA_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_DDE_HPP_
|
||||
#include <common/dde.hpp>
|
||||
#endif
|
||||
|
||||
class DDEData : public DDEDATA
|
||||
{
|
||||
public:
|
||||
DDEData(void);
|
||||
~DDEData();
|
||||
WORD mustRespond(void)const;
|
||||
void mustRespond(WORD mustRespond);
|
||||
WORD mustRelease(void)const;
|
||||
void mustRelease(WORD mustRelease);
|
||||
WORD isResponseForRequest(void)const;
|
||||
void isResponseForRequest(WORD isResponseForRequest);
|
||||
short getFormat(void)const;
|
||||
void setFormat(short format);
|
||||
WORD setData(char FAR *npDDEData,DWORD sizeData);
|
||||
char FAR *getData(void);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
DDEData::DDEData(void)
|
||||
{
|
||||
DDEDATA::fResponse=0;
|
||||
DDEDATA::fRelease=0;
|
||||
DDEDATA::fAckReq=0;
|
||||
DDEDATA::cfFormat=0;
|
||||
DDEDATA::Value[0]=0;
|
||||
}
|
||||
|
||||
inline
|
||||
DDEData::~DDEData()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEData::mustRespond(void)const
|
||||
{
|
||||
return DDEDATA::fResponse;
|
||||
}
|
||||
|
||||
inline
|
||||
void DDEData::mustRespond(WORD mustRespond)
|
||||
{
|
||||
DDEDATA::fResponse=mustRespond;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEData::mustRelease(void)const
|
||||
{
|
||||
return DDEDATA::fRelease;
|
||||
}
|
||||
|
||||
inline
|
||||
void DDEData::mustRelease(WORD mustRelease)
|
||||
{
|
||||
DDEDATA::fRelease=mustRelease;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEData::isResponseForRequest(void)const
|
||||
{
|
||||
return DDEDATA::fAckReq;
|
||||
}
|
||||
|
||||
inline
|
||||
void DDEData::isResponseForRequest(WORD isResponseForRequest)
|
||||
{
|
||||
DDEDATA::fAckReq=isResponseForRequest;
|
||||
}
|
||||
|
||||
inline
|
||||
short DDEData::getFormat(void)const
|
||||
{
|
||||
return DDEDATA::cfFormat;
|
||||
}
|
||||
|
||||
inline
|
||||
void DDEData::setFormat(short format)
|
||||
{
|
||||
DDEDATA::cfFormat=format;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEData::setData(char FAR *npLinkData,DWORD sizeData)
|
||||
{
|
||||
if(!npLinkData)return FALSE;
|
||||
::memcpy(DDEDATA::Value,npLinkData,sizeData);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
char FAR *DDEData::getData(void)
|
||||
{
|
||||
return (char FAR *)DDEData::Value;
|
||||
}
|
||||
#endif
|
||||
|
||||
274
common/DDEMSG.CPP
Normal file
274
common/DDEMSG.CPP
Normal file
@@ -0,0 +1,274 @@
|
||||
#include <stdio.h>
|
||||
#include <common\ddemsg.hpp>
|
||||
|
||||
HGLOBAL DDEMessage::buildDDEDataHandle(HGLOBAL hGlobalData)
|
||||
{
|
||||
DDEData *npDDEData;
|
||||
DWORD sizeData(::GlobalSize(hGlobalData));
|
||||
char *npLinkData;
|
||||
|
||||
HGLOBAL hGlobalDDEData=::GlobalAlloc(GMEM_DDESHARE|GHND,sizeof(DDEData)+sizeData-1L);
|
||||
npDDEData=(DDEData FAR*)::GlobalLock(hGlobalDDEData);
|
||||
npLinkData=(char FAR*)::GlobalLock(hGlobalData);
|
||||
npDDEData->mustRespond(TRUE);
|
||||
npDDEData->mustRelease(FALSE);
|
||||
npDDEData->isResponseForRequest(TRUE);
|
||||
npDDEData->setFormat(TextFormat);
|
||||
npDDEData->setData(npLinkData,sizeData);
|
||||
::GlobalUnlock(hGlobalData);
|
||||
::GlobalFree(hGlobalData);
|
||||
::GlobalUnlock(hGlobalDDEData);
|
||||
return hGlobalDDEData;
|
||||
}
|
||||
|
||||
HGLOBAL DDEMessage::copyDDEDataHandle(HGLOBAL hGlobalDDEData)
|
||||
{
|
||||
int sizeData;
|
||||
HGLOBAL hGlobalData;
|
||||
DDEData FAR *npDDEData;
|
||||
char *pReturnData;
|
||||
|
||||
if(!hGlobalDDEData)return (HGLOBAL)FALSE;
|
||||
npDDEData=(DDEData FAR*)::GlobalLock(hGlobalDDEData);
|
||||
if(!npDDEData)return (HGLOBAL)FALSE;
|
||||
sizeData=::GlobalSize(hGlobalDDEData)-(sizeof(DDEDATA)-1);
|
||||
if(sizeData<=0)return (HGLOBAL)FALSE;
|
||||
hGlobalData=::GlobalAlloc(GMEM_FIXED,sizeData);
|
||||
pReturnData=(char FAR*)::GlobalLock(hGlobalData);
|
||||
::memcpy(pReturnData,npDDEData->getData(),sizeData);
|
||||
::GlobalUnlock(hGlobalDDEData);
|
||||
::GlobalUnlock(hGlobalData);
|
||||
return hGlobalData;
|
||||
}
|
||||
|
||||
WORD DDEMessage::sendInitiate(String applicationString,String topicString)
|
||||
{
|
||||
LRESULT returnCode(FALSE);
|
||||
|
||||
if(applicationString.isNull()||topicString.isNull())return returnCode;
|
||||
ATOM atomApplication(::GlobalAddAtom(applicationString));
|
||||
ATOM atomTopic(::GlobalAddAtom(topicString));
|
||||
mLastDDEMessage=WM_DDE_INITIATE;
|
||||
returnCode=::SendMessage(HWND_BROADCAST,WM_DDE_INITIATE,(WPARAM)mhClientWnd,MAKELPARAM(atomApplication,atomTopic));
|
||||
::GlobalDeleteAtom(atomApplication);
|
||||
::GlobalDeleteAtom(atomTopic);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
WORD DDEMessage::acceptInitiate(String applicationString,String topicString)
|
||||
{
|
||||
if(applicationString.isNull())return FALSE;
|
||||
if(topicString.isNull())return FALSE;
|
||||
ATOM atomApplication(::GlobalAddAtom(applicationString));
|
||||
ATOM atomTopic(::GlobalAddAtom(topicString));
|
||||
mLastDDEMessage=WM_DDE_ACK;
|
||||
return ::SendMessage(mhServerWnd,WM_DDE_ACK,(WPARAM)mhClientWnd,MAKELPARAM(atomApplication,atomTopic));
|
||||
}
|
||||
|
||||
void DDEMessage::cleanup(void)
|
||||
{
|
||||
if(!mhGlobalLastDDEData)return;
|
||||
::GlobalUnlock(mhGlobalLastDDEData);
|
||||
::GlobalFree(mhGlobalLastDDEData);
|
||||
mhGlobalLastDDEData=0;
|
||||
}
|
||||
|
||||
#if defined(__FLAT__)
|
||||
WORD DDEMessage::postRequest(String requestString)
|
||||
{
|
||||
if(requestString.isNull()||!isValid())return FALSE;
|
||||
ATOM atomDescription(::GlobalAddAtom(requestString));
|
||||
mLastDDEMessage=WM_DDE_REQUEST;
|
||||
return ::PostMessage(mhServerWnd,WM_DDE_REQUEST,(WPARAM)mhClientWnd,MAKELPARAM(TextFormat,atomDescription));
|
||||
}
|
||||
|
||||
WORD DDEMessage::receiveRequest(CallbackData &someCallbackData,String &receiveString)
|
||||
{
|
||||
WORD returnCode(FALSE);
|
||||
|
||||
mLastCallbackData=someCallbackData;
|
||||
if(!someCallbackData.hiWord())receiveString=mStringUnset;
|
||||
else
|
||||
{
|
||||
receiveString.reserve(MaxLength);
|
||||
::GlobalGetAtomName(someCallbackData.hiWord(),receiveString,MaxLength-1);
|
||||
::GlobalDeleteAtom(someCallbackData.hiWord());
|
||||
returnCode=TRUE;
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
WORD DDEMessage::postAcknowledge(void)
|
||||
{
|
||||
String ackDescription(mStringUnset);
|
||||
DDEAck ddeAck;
|
||||
|
||||
return postAcknowledge(ddeAck,ackDescription);
|
||||
}
|
||||
|
||||
WORD DDEMessage::postAcknowledge(DDEAck someDDEAck,String ackDescription)
|
||||
{
|
||||
if(ackDescription.isNull()||!isValid())return FALSE;
|
||||
ATOM atomDescription(::GlobalAddAtom(ackDescription));
|
||||
LONG packedParam(::PackDDElParam(WM_DDE_ACK,(WORD)someDDEAck,atomDescription));
|
||||
if(!packedParam){::GlobalDeleteAtom(atomDescription);return FALSE;}
|
||||
mLastDDEMessage=WM_DDE_ACK;
|
||||
return ::PostMessage(mhServerWnd,WM_DDE_ACK,(WPARAM)mhClientWnd,(LPARAM)packedParam);
|
||||
}
|
||||
|
||||
WORD DDEMessage::receiveAcknowledge(CallbackData &someCallbackData)
|
||||
{
|
||||
UINT packedParamLo(0);
|
||||
UINT packedParamHi(0);
|
||||
String stringOne;
|
||||
String stringTwo;
|
||||
|
||||
mLastCallbackData=someCallbackData;
|
||||
if(WM_DDE_INITIATE==lastDDEMessage())
|
||||
{
|
||||
if(someCallbackData.loWord())::GlobalDeleteAtom(someCallbackData.loWord());
|
||||
if(someCallbackData.hiWord())::GlobalDeleteAtom(someCallbackData.hiWord());
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
stringOne.reserve(MaxLength);
|
||||
stringTwo.reserve(MaxLength);
|
||||
::UnpackDDElParam(WM_DDE_ACK,someCallbackData.lParam(),&packedParamLo,&packedParamHi);
|
||||
if(packedParamHi)
|
||||
{
|
||||
::GlobalGetAtomName(packedParamHi,stringTwo,MaxLength-1);
|
||||
if(!stringTwo.isNull())::GlobalDeleteAtom(packedParamHi);
|
||||
}
|
||||
::FreeDDElParam(WM_DDE_ACK,someCallbackData.lParam());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD DDEMessage::postData(HGLOBAL hGlobalData,String stringDescription)
|
||||
{
|
||||
if(!hGlobalData||!isValid())return FALSE;
|
||||
if(stringDescription.isNull())stringDescription=mStringUnset;
|
||||
cleanup();
|
||||
mhGlobalLastDDEData=buildDDEDataHandle(hGlobalData);
|
||||
if(!mhGlobalLastDDEData)return FALSE;
|
||||
ATOM atomDescription(::GlobalAddAtom(stringDescription));
|
||||
LPARAM packedParam(::PackDDElParam(WM_DDE_DATA,(UINT)mhGlobalLastDDEData,atomDescription));
|
||||
if(!packedParam){::GlobalDeleteAtom(atomDescription);return FALSE;}
|
||||
mLastDDEMessage=WM_DDE_DATA;
|
||||
return ::PostMessage(mhServerWnd,WM_DDE_DATA,(WPARAM)mhClientWnd,packedParam);
|
||||
}
|
||||
|
||||
HGLOBAL DDEMessage::receiveData(CallbackData &someCallbackData)
|
||||
{
|
||||
UINT packedParamLo;
|
||||
UINT packedParamHi;
|
||||
HGLOBAL hGlobalDDEData;
|
||||
|
||||
mLastCallbackData=someCallbackData;
|
||||
::UnpackDDElParam(WM_DDE_DATA,someCallbackData.lParam(),&packedParamLo,&packedParamHi);
|
||||
if(packedParamHi)::GlobalDeleteAtom(packedParamHi);
|
||||
if(packedParamLo)hGlobalDDEData=(HGLOBAL)packedParamLo;
|
||||
else hGlobalDDEData=(HGLOBAL)FALSE;
|
||||
::FreeDDElParam(WM_DDE_DATA,someCallbackData.lParam());
|
||||
if(hGlobalDDEData)mhGlobalLastDDEData=copyDDEDataHandle(hGlobalDDEData);
|
||||
return mhGlobalLastDDEData;
|
||||
}
|
||||
#else
|
||||
WORD DDEMessage::postRequest(String requestorString)
|
||||
{
|
||||
if(requestorString.isNull()||!isValid())return FALSE;
|
||||
ATOM atomDescription(::GlobalAddAtom(requestorString));
|
||||
mLastDDEMessage=WM_DDE_REQUEST;
|
||||
return ::PostMessage(mhServerWnd,WM_DDE_REQUEST,(WPARAM)mhClientWnd,MAKELPARAM(TextFormat,atomDescription));
|
||||
}
|
||||
|
||||
WORD DDEMessage::receiveRequest(CallbackData &someCallbackData,String &receiveString)
|
||||
{
|
||||
WORD returnCode(FALSE);
|
||||
|
||||
mLastCallbackData=someCallbackData;
|
||||
if(!someCallbackData.hiWord())receiveString=mStringUnset;
|
||||
else
|
||||
{
|
||||
receiveString.reserve(MaxLength);
|
||||
::GlobalGetAtomName(someCallbackData.hiWord(),receiveString,MaxLength-1);
|
||||
::GlobalDeleteAtom(someCallbackData.hiWord());
|
||||
returnCode=TRUE;
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
WORD DDEMessage::postAcknowledge(void)
|
||||
{
|
||||
String ackDescription(mStringUnset);
|
||||
DDEAck ddeAck;
|
||||
|
||||
return postAcknowledge(ddeAck,ackDescription);
|
||||
}
|
||||
|
||||
WORD DDEMessage::postAcknowledge(DDEAck someDDEAck,String ackDescription)
|
||||
{
|
||||
if(ackDescription.isNull())ackDescription=mStringUnset;
|
||||
ATOM ackAtom(::GlobalAddAtom(ackDescription));
|
||||
mLastDDEMessage=WM_DDE_ACK;
|
||||
return ::PostMessage(mhServerWnd,WM_DDE_ACK,(WPARAM)mhClientWnd,MAKELPARAM((WORD)someDDEAck,ackAtom));
|
||||
}
|
||||
|
||||
WORD DDEMessage::receiveAcknowledge(CallbackData &someCallbackData)
|
||||
{
|
||||
String stringOne;
|
||||
String stringTwo;
|
||||
UINT packedParamLo;
|
||||
UINT packedParamHi;
|
||||
|
||||
if(!isValid())return FALSE;
|
||||
mLastCallbackData=someCallbackData;
|
||||
if(WM_DDE_INITIATE==lastDDEMessage())
|
||||
{
|
||||
if(someCallbackData.loWord())::GlobalDeleteAtom(someCallbackData.loWord());
|
||||
if(someCallbackData.hiWord())::GlobalDeleteAtom(someCallbackData.hiWord());
|
||||
return TRUE;
|
||||
}
|
||||
stringOne.reserve(MaxLength);
|
||||
stringTwo.reserve(MaxLength);
|
||||
if(someCallbackData.loWord())
|
||||
{
|
||||
::GlobalGetAtomName(someCallbackData.loWord(),stringOne,MaxLength-1);
|
||||
if(!stringOne.isNull())::GlobalDeleteAtom(someCallbackData.loWord());
|
||||
}
|
||||
if(someCallbackData.hiWord())
|
||||
{
|
||||
::GlobalGetAtomName(someCallbackData.hiWord(),stringTwo,MaxLength-1);
|
||||
if(!stringTwo.isNull())::GlobalDeleteAtom(someCallbackData.hiWord());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD DDEMessage::postData(HGLOBAL hGlobalData,String stringDescription)
|
||||
{
|
||||
cleanup();
|
||||
if(!hGlobalData||!isValid())return FALSE;
|
||||
if(stringDescription.isNull())stringDescription=mStringUnset;
|
||||
cleanup();
|
||||
mhGlobalLastDDEData=buildDDEDataHandle(hGlobalData);
|
||||
if(!mhGlobalLastDDEData)return FALSE;
|
||||
ATOM atomDescription(::GlobalAddAtom(stringDescription));
|
||||
mLastDDEMessage=WM_DDE_DATA;
|
||||
return ::PostMessage(mhServerWnd,WM_DDE_DATA,(WPARAM)mhClientWnd,MAKELPARAM(mhGlobalLastDDEData,atomDescription));
|
||||
}
|
||||
|
||||
HGLOBAL DDEMessage::receiveData(CallbackData &someCallbackData)
|
||||
{
|
||||
HGLOBAL hGlobalDDEData;
|
||||
|
||||
cleanup();
|
||||
mLastCallbackData=someCallbackData;
|
||||
if(someCallbackData.hiWord())::GlobalDeleteAtom(someCallbackData.hiWord());
|
||||
if(someCallbackData.loWord())hGlobalDDEData=(HGLOBAL)someCallbackData.loWord();
|
||||
else hGlobalDDEData=(HGLOBAL)FALSE;
|
||||
if(!hGlobalDDEData)return hGlobalDDEData;
|
||||
return copyDDEDataHandle(hGlobalDDEData);
|
||||
}
|
||||
#endif
|
||||
|
||||
131
common/DDEMSG.HPP
Normal file
131
common/DDEMSG.HPP
Normal file
@@ -0,0 +1,131 @@
|
||||
#ifndef _COMMON_DDEMESSAGE_HPP_
|
||||
#define _COMMON_DDEMESSAGE_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_DDE_HPP_
|
||||
#include <common/dde.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_DDEACK_HPP_
|
||||
#include <common/ddeack.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_DDEDATA_HPP_
|
||||
#include <common/ddedata.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_CALLBACK_HPP_
|
||||
#include <common/callback.hpp>
|
||||
#endif
|
||||
|
||||
class DDEMessage
|
||||
{
|
||||
public:
|
||||
DDEMessage(void);
|
||||
DDEMessage(HWND hClientWnd,HWND hServerWnd);
|
||||
~DDEMessage();
|
||||
void setClient(HWND hClientWnd);
|
||||
void setServer(HWND hServerWnd);
|
||||
WORD postTerminate(void);
|
||||
WORD receiveTerminate(CallbackData &someCallbackData);
|
||||
WORD sendInitiate(String applicationString,String topicString);
|
||||
WORD acceptInitiate(String applicationString,String topicString);
|
||||
WORD postRequest(String requestString);
|
||||
WORD receiveRequest(CallbackData &someCallbackData,String &requestString);
|
||||
WORD postAcknowledge(void);
|
||||
WORD postAcknowledge(DDEAck someDDEAck,String ackDescription);
|
||||
WORD receiveAcknowledge(CallbackData &someCallbackData);
|
||||
WORD postData(HGLOBAL hGlobalData,String stringDescription=String());
|
||||
HGLOBAL receiveData(CallbackData &someCallbackData);
|
||||
DWORD lastDDEMessage(void)const;
|
||||
CallbackData lastCallbackData(void)const;
|
||||
private:
|
||||
enum {MaxLength=250};
|
||||
enum Format{TextFormat=CF_TEXT};
|
||||
enum Mode{Receive,Send,Post};
|
||||
DDEMessage(const DDEMessage &someDDEMessage);
|
||||
void cleanup(void);
|
||||
WORD isValid(void)const;
|
||||
HGLOBAL buildDDEDataHandle(HGLOBAL hGlobalData);
|
||||
HGLOBAL copyDDEDataHandle(HGLOBAL hGlobalDDEData);
|
||||
void examineDDEData(HGLOBAL hGlobalDDEData);
|
||||
|
||||
String mStringUnset;
|
||||
HWND mhServerWnd;
|
||||
HWND mhClientWnd;
|
||||
DWORD mLastDDEMessage;
|
||||
HGLOBAL mhGlobalLastDDEData;
|
||||
CallbackData mLastCallbackData;
|
||||
};
|
||||
|
||||
inline
|
||||
DDEMessage::DDEMessage(void)
|
||||
: mhServerWnd(0), mhClientWnd(0), mLastDDEMessage(0L), mhGlobalLastDDEData(0),
|
||||
mStringUnset("UNSET")
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DDEMessage::DDEMessage(HWND hServerWnd,HWND hClientWnd)
|
||||
: mhServerWnd(hServerWnd), mhClientWnd(hClientWnd), mLastDDEMessage(0L),
|
||||
mhGlobalLastDDEData(0), mStringUnset("UNSET")
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DDEMessage::DDEMessage(const DDEMessage &/*someDDEMessage*/)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DDEMessage::~DDEMessage()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEMessage::isValid(void)const
|
||||
{
|
||||
if(!::IsWindow(mhClientWnd))return FALSE;
|
||||
if(!::IsWindow(mhServerWnd))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
void DDEMessage::setClient(HWND hClientWnd)
|
||||
{
|
||||
mhClientWnd=hClientWnd;
|
||||
}
|
||||
|
||||
inline
|
||||
void DDEMessage::setServer(HWND hServerWnd)
|
||||
{
|
||||
mhServerWnd=hServerWnd;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD DDEMessage::lastDDEMessage(void)const
|
||||
{
|
||||
return mLastDDEMessage;
|
||||
}
|
||||
|
||||
inline
|
||||
CallbackData DDEMessage::lastCallbackData(void)const
|
||||
{
|
||||
return mLastCallbackData;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEMessage::postTerminate(void)
|
||||
{
|
||||
mLastDDEMessage=WM_DDE_TERMINATE;
|
||||
return ::PostMessage(mhServerWnd,WM_DDE_TERMINATE,(WPARAM)mhClientWnd,0L);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DDEMessage::receiveTerminate(CallbackData &/*someCallbackData*/)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
69
common/DISKINFO.CPP
Normal file
69
common/DISKINFO.CPP
Normal file
@@ -0,0 +1,69 @@
|
||||
#include <common/diskinfo.hpp>
|
||||
|
||||
WORD DiskInfo::getLogicalDrives(Block<String> &driveStrings)const
|
||||
{
|
||||
DWORD driveMask(::GetLogicalDrives());
|
||||
BYTE driveChar('A');
|
||||
DWORD maskValue(1);
|
||||
|
||||
driveStrings.remove();
|
||||
if(!driveMask)return driveMask;
|
||||
for(DWORD itemIndex=0;itemIndex<sizeof(DWORD)*8;itemIndex++)
|
||||
{
|
||||
if(maskValue&driveMask)
|
||||
{
|
||||
String driveString((char)driveChar);
|
||||
driveString+=":\\";
|
||||
driveStrings.insert(&driveString);
|
||||
}
|
||||
maskValue<<=1;
|
||||
driveChar++;
|
||||
}
|
||||
return driveStrings.size();
|
||||
}
|
||||
|
||||
WORD DiskInfo::getFixedLogicalDrives(Block<String> &driveStrings)const
|
||||
{
|
||||
DWORD driveMask(::GetLogicalDrives());
|
||||
BYTE driveChar('A');
|
||||
DWORD maskValue(1);
|
||||
|
||||
driveStrings.remove();
|
||||
if(!driveMask)return driveMask;
|
||||
for(DWORD itemIndex=0;itemIndex<sizeof(DWORD)*8;itemIndex++)
|
||||
{
|
||||
if(maskValue&driveMask)
|
||||
{
|
||||
String driveString((char)driveChar);
|
||||
driveString+=":\\";
|
||||
if(DriveFixed==getDriveType())driveStrings.insert(&driveString);
|
||||
}
|
||||
maskValue<<=1;
|
||||
driveChar++;
|
||||
}
|
||||
return driveStrings.size();
|
||||
}
|
||||
|
||||
DWORD DiskInfo::getCurrentDirectory(String ¤tDirectory)const
|
||||
{
|
||||
String currDir;
|
||||
DWORD returnCode;
|
||||
|
||||
returnCode=::GetCurrentDirectory(String::MaxString,(LPSTR)currDir);
|
||||
currentDirectory=currDir;
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
BOOL DiskInfo::copyFile(const String &strExistingFile,const String &strNewFile,BOOL overwrite)
|
||||
{
|
||||
if(strExistingFile.isNull()||strNewFile.isNull())return FALSE;
|
||||
return ::CopyFile((String&)strExistingFile,(String&)strNewFile,!overwrite);
|
||||
}
|
||||
|
||||
BOOL DiskInfo::rename(const String &strExistingFileName,const String &strNewFile)
|
||||
{
|
||||
return ::MoveFile(strExistingFileName,strNewFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
6
common/DOS.HPP
Normal file
6
common/DOS.HPP
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef _COMMON_DOS_HPP_
|
||||
#define _COMMON_DOS_HPP_
|
||||
#include <dos.h>
|
||||
#undef enable
|
||||
#endif
|
||||
|
||||
68
common/DRAWBMP.CPP
Normal file
68
common/DRAWBMP.CPP
Normal file
@@ -0,0 +1,68 @@
|
||||
#include <common/drawbmp.hpp>
|
||||
|
||||
DrawBitmap::DrawBitmap(void)
|
||||
{
|
||||
}
|
||||
|
||||
DrawBitmap::~DrawBitmap()
|
||||
{
|
||||
}
|
||||
|
||||
void DrawBitmap::drawBitmap(HBITMAP hBitmap)const
|
||||
{
|
||||
if(!hBitmap)return;
|
||||
HWND hFocusWnd(::GetDesktopWindow());
|
||||
drawBitmap(hFocusWnd,hBitmap);
|
||||
}
|
||||
|
||||
void DrawBitmap::drawBitmap(HWND hDrawWindow,HBITMAP hBitmap)const
|
||||
{
|
||||
HDC hDC;
|
||||
RECT windowRect;
|
||||
BITMAP bm;
|
||||
|
||||
if(!hBitmap||!hDrawWindow)return;
|
||||
hDC=::GetDC(hDrawWindow);
|
||||
::GetObject(hBitmap,sizeof(BITMAP),(LPSTR)&bm);
|
||||
::GetWindowRect(hDrawWindow,(RECT FAR *)&windowRect);
|
||||
windowRect.left=(((windowRect.right-windowRect.left))/2)-(bm.bmWidth/2)-1;
|
||||
windowRect.top=(((windowRect.bottom-windowRect.top))/2)-(bm.bmHeight/2)-1;
|
||||
windowRect.right=bm.bmWidth;
|
||||
windowRect.bottom=bm.bmHeight;
|
||||
drawBitmap(hDC,hBitmap,windowRect,FALSE);
|
||||
::ReleaseDC(hDrawWindow,hDC);
|
||||
}
|
||||
|
||||
void DrawBitmap::drawBitmap(HDC hDC,HBITMAP hBitmap,RECT &drawRect,int initRect)const
|
||||
{
|
||||
HDC hMemDC;
|
||||
|
||||
if(!hBitmap)return;
|
||||
if(initRect)
|
||||
{
|
||||
BITMAP bm;
|
||||
::GetObject(hBitmap,sizeof(BITMAP),(LPSTR)&bm);
|
||||
drawRect.left=0;
|
||||
drawRect.top=0;
|
||||
drawRect.right=bm.bmWidth;
|
||||
drawRect.bottom=bm.bmHeight;
|
||||
}
|
||||
hMemDC=::CreateCompatibleDC(hDC);
|
||||
::SelectObject(hMemDC,hBitmap);
|
||||
::BitBlt(hDC,drawRect.left,drawRect.top,drawRect.right,drawRect.bottom,hMemDC,0,0,SRCCOPY);
|
||||
::DeleteDC(hMemDC);
|
||||
return;
|
||||
}
|
||||
|
||||
void DrawBitmap::centerRect(HBITMAP hBitmap,RECT &windowRect)const
|
||||
{
|
||||
BITMAP bm;
|
||||
|
||||
if(!hBitmap)return;
|
||||
::GetObject(hBitmap,sizeof(bm),(LPSTR)&bm);
|
||||
::GetWindowRect(::GetDesktopWindow(),(RECT FAR *)&windowRect);
|
||||
windowRect.left=(((windowRect.right-windowRect.left))/2)-(bm.bmWidth/2)-1;
|
||||
windowRect.top=(((windowRect.bottom-windowRect.top))/2)-(bm.bmHeight/2)-1;
|
||||
windowRect.right=bm.bmWidth+2;
|
||||
windowRect.bottom=bm.bmHeight+2;
|
||||
}
|
||||
18
common/DRAWBMP.HPP
Normal file
18
common/DRAWBMP.HPP
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _COMMON_DRAWBITMAP_HPP_
|
||||
#define _COMMON_DRAWBITMAP_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class DrawBitmap
|
||||
{
|
||||
public:
|
||||
DrawBitmap(void);
|
||||
virtual ~DrawBitmap();
|
||||
void drawBitmap(HBITMAP hBitmap)const;
|
||||
void drawBitmap(HWND hWnd,HBITMAP hBitmap)const;
|
||||
void drawBitmap(HDC hDC,HBITMAP hBitmap,RECT &drawRect,int initRect=TRUE)const;
|
||||
void centerRect(HBITMAP hBitmap,RECT &bitmapRect)const;
|
||||
private:
|
||||
};
|
||||
#endif
|
||||
227
common/DRAWITEM.HPP
Normal file
227
common/DRAWITEM.HPP
Normal file
@@ -0,0 +1,227 @@
|
||||
#ifndef _COMMON_DRAWITEM_HPP_
|
||||
#define _COMMON_DRAWITEM_HPP_
|
||||
#ifndef _COMMON_STDLIB_HPP_
|
||||
#include <common/stdlib.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_COMMCTRL_HPP_
|
||||
#include <common/commctrl.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_RECTANGLE_HPP_
|
||||
#include <common/rect.hpp>
|
||||
#endif
|
||||
|
||||
class DrawItem : private DRAWITEMSTRUCT
|
||||
{
|
||||
public:
|
||||
enum ItemAction{Select=ODA_SELECT,DrawEntire=ODA_DRAWENTIRE,Focus=ODA_FOCUS};
|
||||
enum ControlType{Button=ODT_BUTTON,ComboBox=ODT_COMBOBOX,ListBox=ODT_LISTBOX,ListView=ODT_LISTVIEW,Menu=ODT_MENU,Static=ODT_STATIC,Tab=ODT_TAB};
|
||||
DrawItem(void);
|
||||
DrawItem(const DrawItem &someDrawItem);
|
||||
DrawItem(const DRAWITEMSTRUCT &someDRAWITEMSTRUCT);
|
||||
virtual ~DrawItem();
|
||||
DrawItem &operator=(const DrawItem &someDrawItem);
|
||||
DrawItem &operator=(const DRAWITEMSTRUCT &someDRAWITEMSTRUCT);
|
||||
WORD operator==(const DrawItem &someDrawItem);
|
||||
ControlType controlType(void)const;
|
||||
void controlType(ControlType controlType);
|
||||
UINT controlID(void)const;
|
||||
void controlID(UINT controlID);
|
||||
UINT itemID(void)const;
|
||||
void itemID(UINT itemID);
|
||||
ItemAction itemAction(void)const;
|
||||
void itemAction(ItemAction itemAction);
|
||||
UINT itemState(void)const;
|
||||
void itemState(UINT itemState);
|
||||
HWND hwndItem(void)const;
|
||||
void hwndItem(HWND hwndItem);
|
||||
HDC deviceContext(void)const;
|
||||
void deviceContext(HDC hDeviceContext);
|
||||
Rect rectItem(void)const;
|
||||
void rectItem(const Rect &rectItem);
|
||||
DWORD itemData(void)const;
|
||||
void itemData(DWORD itemData);
|
||||
private:
|
||||
void setZero(void);
|
||||
};
|
||||
|
||||
inline
|
||||
DrawItem::DrawItem(void)
|
||||
{
|
||||
setZero();
|
||||
}
|
||||
|
||||
inline
|
||||
DrawItem::DrawItem(const DrawItem &someDrawItem)
|
||||
{
|
||||
*this=someDrawItem;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
DrawItem::DrawItem(const DRAWITEMSTRUCT &someDRAWITEMSTRUCT)
|
||||
{
|
||||
*this=someDRAWITEMSTRUCT;
|
||||
}
|
||||
|
||||
inline
|
||||
DrawItem::~DrawItem()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DrawItem &DrawItem::operator=(const DrawItem &someDrawItem)
|
||||
{
|
||||
controlType(someDrawItem.controlType());
|
||||
controlID(someDrawItem.controlID());
|
||||
itemID(someDrawItem.itemID());
|
||||
itemAction(someDrawItem.itemAction());
|
||||
itemState(someDrawItem.itemState());
|
||||
hwndItem(someDrawItem.hwndItem());
|
||||
deviceContext(someDrawItem.deviceContext());
|
||||
rectItem(someDrawItem.rectItem());
|
||||
itemData(someDrawItem.itemData());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
DrawItem &DrawItem::operator=(const DRAWITEMSTRUCT &someDRAWITEMSTRUCT)
|
||||
{
|
||||
::memcpy(&((DRAWITEMSTRUCT&)*this),&someDRAWITEMSTRUCT,sizeof(DRAWITEMSTRUCT));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DrawItem::operator==(const DrawItem &someDrawItem)
|
||||
{
|
||||
return (controlType()==someDrawItem.controlType()&&
|
||||
controlID()==someDrawItem.controlID()&&
|
||||
itemID()==someDrawItem.itemID()&&
|
||||
itemAction()==someDrawItem.itemAction()&&
|
||||
itemState()==someDrawItem.itemState()&&
|
||||
hwndItem()==someDrawItem.hwndItem()&&
|
||||
deviceContext()==someDrawItem.deviceContext()&&
|
||||
rectItem()==someDrawItem.rectItem()&&
|
||||
itemData()==someDrawItem.itemData());
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
DrawItem::ControlType DrawItem::controlType(void)const
|
||||
{
|
||||
return (ControlType)DRAWITEMSTRUCT::CtlType;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::controlType(ControlType controlType)
|
||||
{
|
||||
DRAWITEMSTRUCT::CtlType=(ControlType)controlType;
|
||||
}
|
||||
|
||||
inline
|
||||
UINT DrawItem::controlID(void)const
|
||||
{
|
||||
return DRAWITEMSTRUCT::CtlID;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::controlID(UINT controlID)
|
||||
{
|
||||
DRAWITEMSTRUCT::CtlID=controlID;
|
||||
}
|
||||
|
||||
inline
|
||||
UINT DrawItem::itemID(void)const
|
||||
{
|
||||
return DRAWITEMSTRUCT::itemID;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::itemID(UINT itemID)
|
||||
{
|
||||
DRAWITEMSTRUCT::itemID;
|
||||
}
|
||||
|
||||
inline
|
||||
DrawItem::ItemAction DrawItem::itemAction(void)const
|
||||
{
|
||||
return (ItemAction)DRAWITEMSTRUCT::itemAction;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::itemAction(ItemAction itemAction)
|
||||
{
|
||||
DRAWITEMSTRUCT::itemAction=(UINT)itemAction;
|
||||
}
|
||||
|
||||
inline
|
||||
UINT DrawItem::itemState(void)const
|
||||
{
|
||||
return DRAWITEMSTRUCT::itemState;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::itemState(UINT itemState)
|
||||
{
|
||||
DRAWITEMSTRUCT::itemState=itemState;
|
||||
}
|
||||
|
||||
inline
|
||||
HWND DrawItem::hwndItem(void)const
|
||||
{
|
||||
return DRAWITEMSTRUCT::hwndItem;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::hwndItem(HWND hwndItem)
|
||||
{
|
||||
DRAWITEMSTRUCT::hwndItem=hwndItem;
|
||||
}
|
||||
|
||||
inline
|
||||
HDC DrawItem::deviceContext(void)const
|
||||
{
|
||||
return DRAWITEMSTRUCT::hDC;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::deviceContext(HDC hDeviceContext)
|
||||
{
|
||||
DRAWITEMSTRUCT::hDC=hDeviceContext;
|
||||
}
|
||||
|
||||
inline
|
||||
Rect DrawItem::rectItem(void)const
|
||||
{
|
||||
return DRAWITEMSTRUCT::rcItem;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::rectItem(const Rect &rectItem)
|
||||
{
|
||||
DRAWITEMSTRUCT::rcItem.left=rectItem.left();
|
||||
DRAWITEMSTRUCT::rcItem.top=rectItem.top();
|
||||
DRAWITEMSTRUCT::rcItem.right=rectItem.right();
|
||||
DRAWITEMSTRUCT::rcItem.bottom=rectItem.bottom();
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD DrawItem::itemData(void)const
|
||||
{
|
||||
return DRAWITEMSTRUCT::itemData;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::itemData(DWORD itemData)
|
||||
{
|
||||
DRAWITEMSTRUCT::itemData=itemData;
|
||||
}
|
||||
|
||||
inline
|
||||
void DrawItem::setZero(void)
|
||||
{
|
||||
::memset(&(DRAWITEMSTRUCT&)*this,0,sizeof(DRAWITEMSTRUCT));
|
||||
}
|
||||
#endif
|
||||
209
common/DWINDOW.CPP
Normal file
209
common/DWINDOW.CPP
Normal file
@@ -0,0 +1,209 @@
|
||||
#include <common/dwindow.hpp>
|
||||
#include <common/string.hpp>
|
||||
#include <common/mmsystem.hpp>
|
||||
#include <common/instance.hpp>
|
||||
#include <common/dde.hpp>
|
||||
|
||||
DWindow::~DWindow()
|
||||
{
|
||||
}
|
||||
|
||||
bool DWindow::createDialogParam(GUIWindow &frameWindow,GUIWindow &parentWindow,const String &strTemplate,LPARAM param)
|
||||
{
|
||||
if(isValid()||!frameWindow.isValid()||!parentWindow.isValid()||strTemplate.isNull())return false;
|
||||
mFrameWindow=&frameWindow;
|
||||
mFrameWindow.disposition(PointerDisposition::Assume);
|
||||
setHandle(::CreateDialogParam(parentWindow.processInstance(),(LPSTR)(String&)strTemplate,parentWindow,DWindow::DlgProc,param));
|
||||
if(!isValid())return false;
|
||||
mFrameWindow->insertModelessDialog(*this);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DWindow::createDialogParam(GUIWindow &parentWindow,const String &strTemplate,LPARAM param)
|
||||
{
|
||||
if(isValid()||!parentWindow.isValid()||strTemplate.isNull())return false;
|
||||
mFrameWindow=&parentWindow;
|
||||
mFrameWindow.disposition(PointerDisposition::Assume);
|
||||
setHandle(::CreateDialogParam(parentWindow.processInstance(),(LPSTR)(String&)strTemplate,parentWindow,DWindow::DlgProc,param));
|
||||
if(!isValid())return false;
|
||||
mFrameWindow->insertModelessDialog(*this);
|
||||
return true;
|
||||
}
|
||||
|
||||
String DWindow::getText(UINT controlID)const
|
||||
{
|
||||
String strText;
|
||||
getText(controlID,strText);
|
||||
return strText;
|
||||
}
|
||||
|
||||
WORD DWindow::getText(UINT controlID,String &textString)const
|
||||
{
|
||||
WORD returnCode(FALSE);
|
||||
String workString;
|
||||
|
||||
if(!isValid())return returnCode;
|
||||
returnCode=::GetDlgItemText(*this,controlID,workString,String::MaxString);
|
||||
textString=workString;
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
void DWindow::setText(UINT controlID,const String &setText)const
|
||||
{
|
||||
if(!isValid())return;
|
||||
::SetDlgItemText(*this,controlID,(LPCTSTR)(LPSTR)((String&)setText));
|
||||
}
|
||||
|
||||
BOOL DWindow::setInt(UINT controlID,int value)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::SetDlgItemInt(*this,controlID,value,TRUE);
|
||||
}
|
||||
|
||||
BOOL DWindow::getInt(UINT controlID,int &value)const
|
||||
{
|
||||
BOOL returnCode(FALSE);
|
||||
|
||||
if(!isValid())return returnCode;
|
||||
value=::GetDlgItemInt(*this,controlID,&returnCode,TRUE);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
int DWindow::windowProcedure(HWND hWnd,WORD message,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
if(message>=WM_USER&&message<=0x7FFF)return (int)callHandlers(VectorHandler::UserHandler,CallbackData(message,lParam,hWnd));
|
||||
switch(message)
|
||||
{
|
||||
case WM_CLOSE :
|
||||
return (int)callHandlers(VectorHandler::CloseHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_TIMER :
|
||||
return (int)callHandlers(VectorHandler::TimerHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CHANGECBCHAIN :
|
||||
return (int)callHandlers(VectorHandler::ChangeCBChainHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DRAWCLIPBOARD :
|
||||
return (int)callHandlers(VectorHandler::DrawClipboardHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_COMMAND :
|
||||
return callHandlers(VectorHandler::CommandHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_COMPACTING :
|
||||
return callHandlers(VectorHandler::CompactingHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_ERASEBKGND :
|
||||
return callHandlers(VectorHandler::EraseBackgroundHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_WININICHANGE :
|
||||
return callHandlers(VectorHandler::WinIniChangeHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_SYSCOLORCHANGE :
|
||||
return callHandlers(VectorHandler::SysColorChangeHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_LBUTTONDBLCLK :
|
||||
return callHandlers(VectorHandler::LeftButtonDoubleHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_LBUTTONDOWN :
|
||||
return callHandlers(VectorHandler::LeftButtonDownHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_LBUTTONUP :
|
||||
return callHandlers(VectorHandler::LeftButtonUpHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_RBUTTONDBLCLK :
|
||||
return callHandlers(VectorHandler::RightButtonDoubleHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_RBUTTONDOWN :
|
||||
return callHandlers(VectorHandler::RightButtonDownHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_RBUTTONUP :
|
||||
return callHandlers(VectorHandler::RightButtonUpHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_NCLBUTTONUP :
|
||||
return callHandlers(VectorHandler::NCLeftButtonUpHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_NCLBUTTONDOWN :
|
||||
return callHandlers(VectorHandler::NCLeftButtonDownHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_NCRBUTTONUP :
|
||||
return callHandlers(VectorHandler::NCRightButtonUpHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_NCRBUTTONDOWN :
|
||||
return callHandlers(VectorHandler::NCRightButtonDownHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_SETFOCUS :
|
||||
return callHandlers(VectorHandler::SetFocusHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_SETFONT :
|
||||
return callHandlers(VectorHandler::SetFontHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_KILLFOCUS :
|
||||
return callHandlers(VectorHandler::KillFocusHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CTLCOLOR :
|
||||
return callHandlers(VectorHandler::ControlColorHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CTLCOLORMSGBOX :
|
||||
return callHandlers(VectorHandler::ControlColorHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CTLCOLOREDIT :
|
||||
return callHandlers(VectorHandler::ControlColorHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CTLCOLORLISTBOX :
|
||||
return callHandlers(VectorHandler::ControlColorHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CTLCOLORBTN :
|
||||
return callHandlers(VectorHandler::ControlColorHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CTLCOLORDLG :
|
||||
return callHandlers(VectorHandler::ControlColorHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CTLCOLORSCROLLBAR :
|
||||
return callHandlers(VectorHandler::ControlColorHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CTLCOLORSTATIC :
|
||||
return callHandlers(VectorHandler::ControlColorHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_KEYUP :
|
||||
return callHandlers(VectorHandler::KeyUpHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_KEYDOWN :
|
||||
return callHandlers(VectorHandler::KeyDownHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_GETMINMAXINFO :
|
||||
return callHandlers(VectorHandler::MinMaxHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_ENTERIDLE :
|
||||
return callHandlers(VectorHandler::EnterIdleHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_MENUSELECT :
|
||||
return callHandlers(VectorHandler::MenuSelectHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_ACTIVATEAPP :
|
||||
return callHandlers(VectorHandler::ActivateAppHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DISPLAYCHANGE :
|
||||
return callHandlers(VectorHandler::DisplayChangeHandler,CallbackData(wParam,lParam,hWnd));
|
||||
#if defined(__FLAT__)
|
||||
case WM_NOTIFY :
|
||||
return callHandlers(VectorHandler::NotifyHandler,CallbackData(wParam,lParam,hWnd));
|
||||
#endif
|
||||
case WM_SIZE :
|
||||
return callHandlers(VectorHandler::SizeHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_PAINT :
|
||||
return handlePaintMessage(hWnd,message,wParam,lParam);
|
||||
case WM_DRAWITEM :
|
||||
return callHandlers(VectorHandler::DrawItemHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CHAR :
|
||||
return callHandlers(VectorHandler::CharHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DDE_INITIATE :
|
||||
return callHandlers(VectorHandler::DDEInitiateHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DDE_ACK :
|
||||
return callHandlers(VectorHandler::DDEAckHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DDE_REQUEST :
|
||||
return callHandlers(VectorHandler::DDERequestHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DDE_TERMINATE :
|
||||
return callHandlers(VectorHandler::DDETerminateHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DDE_DATA :
|
||||
return callHandlers(VectorHandler::DDEDataHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case MM_WOM_OPEN :
|
||||
return callHandlers(VectorHandler::MMOpenHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case MM_WOM_CLOSE :
|
||||
return callHandlers(VectorHandler::MMCloseHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case MM_WOM_DONE :
|
||||
return callHandlers(VectorHandler::MMDoneHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_MOUSEMOVE :
|
||||
return callHandlers(VectorHandler::MouseMoveHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_GETDLGCODE :
|
||||
return callHandlers(VectorHandler::DialogCodeHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_MEASUREITEM :
|
||||
return callHandlers(VectorHandler::MeasureItemHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_HSCROLL :
|
||||
return callHandlers(VectorHandler::HorizontalScrollHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_VSCROLL :
|
||||
return callHandlers(VectorHandler::VerticalScrollHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DROPFILES :
|
||||
return callHandlers(VectorHandler::DropFilesHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_MDIACTIVATE :
|
||||
return callHandlers(VectorHandler::MDIActivateHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_SHOWWINDOW :
|
||||
return callHandlers(VectorHandler::ShowWindowHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_CAPTURECHANGED :
|
||||
return callHandlers(VectorHandler::CaptureChangedHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DEVICECHANGE :
|
||||
return callHandlers(VectorHandler::DeviceChangeHandler,CallbackData(wParam,lParam,hWnd));
|
||||
case WM_DESTROY :
|
||||
callHandlers(VectorHandler::DestroyHandler,CallbackData(wParam,lParam,hWnd));
|
||||
InstanceData::removeInstanceData(hWnd);
|
||||
if(mFrameWindow.isOkay())mFrameWindow->removeModelessDialog(*this);
|
||||
setHandle(0);
|
||||
return FALSE;
|
||||
case WM_NCDESTROY :
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
310
common/Dib.cpp
Normal file
310
common/Dib.cpp
Normal file
@@ -0,0 +1,310 @@
|
||||
#include <common/dib.hpp>
|
||||
#include <common/vector2d.hpp>
|
||||
#include <common/bitmap.hpp>
|
||||
#include <common/boverlay.hpp>
|
||||
#include <common/resbmp.hpp>
|
||||
#include <common/math.hpp>
|
||||
|
||||
void DIBitmap::createBitmap(const PureDevice &somePureDevice)
|
||||
{
|
||||
destroyBitmap();
|
||||
mhBitmap=::CreateDIBSection(somePureDevice,(BITMAPINFO*)(static_cast<BitmapInfo&>(*this)),DIB_RGB_COLORS,&mlpBmBits,(HANDLE)0,0L);
|
||||
if(!mhBitmap)::GetLastError();
|
||||
if(mhBitmap)mImageExtent=BitmapInfo::imageExtent();
|
||||
}
|
||||
|
||||
void DIBitmap::createBitmap(void)
|
||||
{
|
||||
destroyBitmap();
|
||||
mhBitmap=::CreateDIBSection((HDC)0,(BITMAPINFO*)(static_cast<BitmapInfo&>(*this)),DIB_RGB_COLORS,&mlpBmBits,(HANDLE)0,0L);
|
||||
if(mhBitmap)mImageExtent=BitmapInfo::imageExtent();
|
||||
}
|
||||
|
||||
WORD DIBitmap::size(DWORD newWidth,DWORD newHeight)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
verifyDimensions(newWidth,newHeight);
|
||||
width(newWidth);
|
||||
height(newHeight);
|
||||
createBitmap(mBitmapDevice);
|
||||
mBitmapDevice.select(mhBitmap);
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
void DIBitmap::verifyDimensions(DWORD &desiredWidth,DWORD desiredHeight)const
|
||||
{
|
||||
DWORD imageExtent;
|
||||
|
||||
imageExtent=(((((LONG)desiredWidth*8)+31)&~31)>>3)*(LONG)desiredHeight;
|
||||
if(imageExtent==(LONG)desiredWidth*(LONG)desiredHeight)return;
|
||||
desiredWidth=(WORD)(imageExtent/(LONG)desiredHeight);
|
||||
}
|
||||
|
||||
void DIBitmap::setBits(BYTE charByte)
|
||||
{
|
||||
if(!charByte)clearBits();
|
||||
BYTE *lpImagePtr=(BYTE*)mlpBmBits;
|
||||
for(DWORD ptrIndex=0;ptrIndex<imageExtent();ptrIndex++)*lpImagePtr++=charByte;
|
||||
}
|
||||
|
||||
void DIBitmap::clearBits(void)
|
||||
{
|
||||
DWORD *lpImagePtr=(DWORD*)mlpBmBits;
|
||||
DWORD extent(imageExtent()/sizeof(DWORD));
|
||||
for(unsigned long ptrIndex=0;ptrIndex<extent;ptrIndex++)*lpImagePtr++=0L;
|
||||
}
|
||||
|
||||
bool DIBitmap::copyBits(unsigned char *ptrDataChar,DWORD length)
|
||||
{
|
||||
DWORD writeExtent=length<=imageExtent()?length:imageExtent();
|
||||
DWORD numDWORDS=writeExtent>>2;
|
||||
DWORD numBytes=0;
|
||||
int *ptrSrcDataInt=0;
|
||||
int *ptrDstDataInt=0;
|
||||
char *ptrSrcDataChar;
|
||||
char *ptrDstDataChar;
|
||||
|
||||
if(!writeExtent)return false;
|
||||
numBytes=(writeExtent%writeExtent);
|
||||
ptrSrcDataInt=(int*)ptrDataChar;
|
||||
ptrDstDataInt=(int*)mlpBmBits;
|
||||
for(DWORD count=0;count<numDWORDS;count++)*ptrDstDataInt++=*ptrSrcDataInt++;
|
||||
ptrSrcDataChar=(char*)ptrSrcDataInt;
|
||||
ptrDstDataChar=(char*)ptrDstDataInt;
|
||||
for(count=0;count<numBytes;count++)*ptrDstDataChar++=*ptrSrcDataChar++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void DIBitmap::copyBits(unsigned char *lpDstPtr,unsigned char *lpSrcPtr,DWORD length)const
|
||||
{
|
||||
for(DWORD count=0;count<length;count++)*lpDstPtr++=*lpSrcPtr++;
|
||||
}
|
||||
|
||||
DIBitmap &DIBitmap::operator+=(BitmapOverlay &someBitmapOverlay)
|
||||
{
|
||||
overlay(someBitmapOverlay.placementPoint(),someBitmapOverlay.bitmap().width(),someBitmapOverlay.bitmap().height(),someBitmapOverlay.bitmap().getDataPtr());
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool DIBitmap::getAt(SmartPointer<DIBitmap> &bitmap,const Rect &areaRect)
|
||||
{
|
||||
bitmap.destroy();
|
||||
bitmap=::new DIBitmap(getDevice(),areaRect.width(),areaRect.height(),getPalette());
|
||||
bitmap.disposition(PointerDisposition::Delete);
|
||||
for(int col=areaRect.left(),dstCol=0;col<=areaRect.right();col++,dstCol++)
|
||||
{
|
||||
for(int row=areaRect.top(),dstRow=0;row<=areaRect.bottom();row++,dstRow++)
|
||||
{
|
||||
bitmap->setByte(dstRow,dstCol,getByte(row,col));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DIBitmap::overlay(Bitmap &bitmap,const Point &placementPoint)
|
||||
{
|
||||
return overlay(placementPoint,bitmap.width(),bitmap.height(),bitmap.getDataPtr());
|
||||
}
|
||||
|
||||
bool DIBitmap::overlay(ResBitmap &resBitmap,const Point &placementPoint)
|
||||
{
|
||||
return overlay(placementPoint,resBitmap.width(),resBitmap.height(),resBitmap.ptrData());
|
||||
}
|
||||
|
||||
bool DIBitmap::overlay(DIBitmap &bitmap,const Point &placementPoint)
|
||||
{
|
||||
return overlay(placementPoint,bitmap.width(),bitmap.height(),(unsigned char*)bitmap.ptrData());
|
||||
}
|
||||
|
||||
bool DIBitmap::overlay(const Point &placementPoint,int srcWidth,int srcHeight,UCHAR *pBmBits)
|
||||
{
|
||||
DWORD newSrcY;
|
||||
DWORD newDstY;
|
||||
DWORD srcIndex;
|
||||
DWORD dstIndex;
|
||||
UINT srcRow;
|
||||
UINT srcCol;
|
||||
|
||||
if(!isOkay())return false;
|
||||
if(srcWidth>width())srcWidth=width();
|
||||
if(srcHeight>height())srcHeight=height();
|
||||
for(srcRow=0;srcRow<srcHeight;srcRow++)
|
||||
{
|
||||
for(srcCol=0;srcCol<srcWidth;srcCol++)
|
||||
{
|
||||
newSrcY=srcRow;
|
||||
srcIndex=newSrcY*srcWidth+srcCol;
|
||||
newDstY=height()-srcHeight-placementPoint.y()+srcRow;
|
||||
dstIndex=newDstY*width()+srcCol+placementPoint.x();
|
||||
*((char*)mlpBmBits+dstIndex)=*(pBmBits+srcIndex);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DIBitmap::colorRect(const Rect &rect,BYTE byteValue)
|
||||
{
|
||||
int bmHeight=rect.height();
|
||||
for(int row=0;row<bmHeight;row++)
|
||||
{
|
||||
line(Point(rect.left(),rect.top()+row),Point(rect.right(),rect.top()+row),byteValue);
|
||||
}
|
||||
}
|
||||
|
||||
void DIBitmap::outlineRect(const Rect &outlineRect,BYTE byteValue)
|
||||
{
|
||||
Point p1;
|
||||
Point p2;
|
||||
|
||||
p1.x(outlineRect.left());
|
||||
p1.y(outlineRect.top());
|
||||
p2.x(outlineRect.right());
|
||||
p2.y(outlineRect.top());
|
||||
line(p1,p2,byteValue);
|
||||
p1.x(outlineRect.right());
|
||||
p1.y(outlineRect.top());
|
||||
p2.x(outlineRect.right());
|
||||
p2.y(outlineRect.bottom());
|
||||
line(p1,p2,byteValue);
|
||||
p1.x(outlineRect.left());
|
||||
p1.y(outlineRect.bottom());
|
||||
p2.x(outlineRect.right());
|
||||
p2.y(outlineRect.bottom());
|
||||
line(p1,p2,byteValue);
|
||||
p1.x(outlineRect.left());
|
||||
p1.y(outlineRect.top());
|
||||
p2.x(outlineRect.left());
|
||||
p2.y(outlineRect.bottom());
|
||||
line(p1,p2,byteValue);
|
||||
}
|
||||
|
||||
void DIBitmap::line(const Point &firstPoint,const Point &secondPoint,BYTE byteValue)
|
||||
{
|
||||
int xRunning((LONG)firstPoint.x()<<0x10);
|
||||
int yRunning((LONG)firstPoint.y()<<0x10);
|
||||
int xDelta;
|
||||
int yDelta;
|
||||
short xDir(1);
|
||||
short yDir(1);
|
||||
short steps;
|
||||
|
||||
if(secondPoint.x()<firstPoint.x())xDir=-1;
|
||||
if(secondPoint.y()<firstPoint.y())yDir=-1;
|
||||
xDelta=(int)secondPoint.x()-(int)firstPoint.x();
|
||||
yDelta=(int)secondPoint.y()-(int)firstPoint.y();
|
||||
if(xDelta<0)xDelta=-xDelta;
|
||||
if(yDelta<0)yDelta=-yDelta;
|
||||
if(xDelta<yDelta)
|
||||
{
|
||||
xDelta<<=0x10;
|
||||
if(yDelta)xDelta/=yDelta;
|
||||
else xDelta=1L;
|
||||
steps=yDelta;
|
||||
yDelta=0x10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
yDelta<<=0x10;
|
||||
if(xDelta)yDelta/=xDelta;
|
||||
else yDelta=1L;
|
||||
steps=xDelta;
|
||||
xDelta=0x10000;
|
||||
}
|
||||
if(-1==xDir&&-1==yDir)
|
||||
{
|
||||
for(short stepIndex=0;stepIndex<steps;stepIndex++)
|
||||
{
|
||||
setByte(yRunning>>0x10,xRunning>>0x10,byteValue);
|
||||
xRunning-=xDelta;
|
||||
yRunning-=yDelta;
|
||||
}
|
||||
}
|
||||
else if(-1==xDir&&1==yDir)
|
||||
{
|
||||
for(short stepIndex=0;stepIndex<steps;stepIndex++)
|
||||
{
|
||||
setByte(yRunning>>0x10,xRunning>>0x10,byteValue);
|
||||
xRunning-=xDelta;
|
||||
yRunning+=yDelta;
|
||||
}
|
||||
}
|
||||
else if(1==xDir&&-1==yDir)
|
||||
{
|
||||
for(short itemIndex=0;itemIndex<steps;itemIndex++)
|
||||
{
|
||||
setByte(yRunning>>0x10,xRunning>>0x10,byteValue);
|
||||
xRunning+=xDelta;
|
||||
yRunning-=yDelta;
|
||||
}
|
||||
}
|
||||
else if(1==xDir&&1==yDir)
|
||||
{
|
||||
for(short itemIndex=0;itemIndex<steps;itemIndex++)
|
||||
{
|
||||
setByte(yRunning>>0x10,xRunning>>0x10,byteValue);
|
||||
xRunning+=xDelta;
|
||||
yRunning+=yDelta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WORD DIBitmap::square(const Point ¢erPoint,WORD lineLength,BYTE palIndex)
|
||||
{
|
||||
WORD halfLength(lineLength>>0x01);
|
||||
Point topLeft;
|
||||
Point topRight;
|
||||
Point bottomLeft;
|
||||
Point bottomRight;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
topLeft.x(centerPoint.x()-halfLength);
|
||||
topLeft.y(centerPoint.y()-halfLength);
|
||||
topRight.x(centerPoint.x()+halfLength);
|
||||
topRight.y(centerPoint.y()-halfLength);
|
||||
bottomRight.x(centerPoint.x()+halfLength);
|
||||
bottomRight.y(centerPoint.y()+halfLength);
|
||||
bottomLeft.x(centerPoint.x()-halfLength);
|
||||
bottomLeft.y(centerPoint.y()+halfLength);
|
||||
line(topLeft,topRight,palIndex);
|
||||
line(topRight,bottomRight,palIndex);
|
||||
line(bottomRight,bottomLeft,palIndex);
|
||||
line(bottomLeft,topLeft,palIndex);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD DIBitmap::circle(WORD aspectValue,const Point &xyPoint,WORD radius,WORD palIndex)
|
||||
{
|
||||
int a(radius);
|
||||
int af;
|
||||
int bf;
|
||||
int b(0);
|
||||
int target(1);
|
||||
int radiusSquared(radius*radius);
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
while(a>=b)
|
||||
{
|
||||
b=(int)(Math::sqrt(radiusSquared-(a*a))+.50);
|
||||
int temp(target);
|
||||
target=b;
|
||||
b=temp;
|
||||
while(b<target)
|
||||
{
|
||||
if(100.00!=aspectValue)af=(aspectValue*a)/100.00,bf=(aspectValue*b)/100.00;
|
||||
else af=a,bf=b;
|
||||
setByte(xyPoint.x()+af,xyPoint.y()+b,palIndex);
|
||||
setByte(xyPoint.x()+bf,xyPoint.y()+a,palIndex);
|
||||
setByte(xyPoint.x()-af,xyPoint.y()+b,palIndex);
|
||||
setByte(xyPoint.x()-bf,xyPoint.y()+a,palIndex);
|
||||
setByte(xyPoint.x()-af,xyPoint.y()-b,palIndex);
|
||||
setByte(xyPoint.x()-bf,xyPoint.y()-a,palIndex);
|
||||
setByte(xyPoint.x()+af,xyPoint.y()-b,palIndex);
|
||||
setByte(xyPoint.x()+bf,xyPoint.y()-a,palIndex);
|
||||
++b;
|
||||
}
|
||||
--a;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
264
common/Dib.hpp
Normal file
264
common/Dib.hpp
Normal file
@@ -0,0 +1,264 @@
|
||||
#ifndef _COMMON_DIBITMAP_HPP_
|
||||
#define _COMMON_DIBITMAP_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BITMAPINFO_HPP_
|
||||
#include <common/bminfo.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PUREPALETTE_HPP_
|
||||
#include <common/purepal.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_EXCEPTION_HPP_
|
||||
#include <common/except.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SMARTPOINTER_HPP_
|
||||
#include <common/pointer.hpp>
|
||||
#endif
|
||||
|
||||
class BitmapOverlay;
|
||||
class Bitmap;
|
||||
class ResBitmap;
|
||||
class Vector2D;
|
||||
class Point;
|
||||
|
||||
class DIBitmap : public BitmapInfo
|
||||
{
|
||||
public:
|
||||
DIBitmap(const PureDevice &pureDevice,DWORD bmWidth,DWORD bmHeight,const PurePalette &purePalette);
|
||||
DIBitmap(const PureDevice &pureDevice,const BitmapInfo &someBitmapInfo,const PurePalette &purePalette);
|
||||
DIBitmap(const BitmapInfo &someBitmapInfo);
|
||||
DIBitmap(const DIBitmap &someDIBitmap);
|
||||
virtual ~DIBitmap();
|
||||
DIBitmap &operator=(const DIBitmap &someDIBitmap);
|
||||
DIBitmap &operator+=(BitmapOverlay &someBitmapOverlay);
|
||||
bool overlay(Bitmap &bitmap,const Point &placementPoint);
|
||||
bool overlay(ResBitmap &resBitmap,const Point &placementPoint);
|
||||
bool overlay(DIBitmap &bitmap,const Point &placementPoint);
|
||||
bool getAt(SmartPointer<DIBitmap> &bitmap,const Rect &areaRect);
|
||||
void setByte(WORD row,WORD col,BYTE byteValue);
|
||||
BYTE getByte(WORD row,WORD col)const;
|
||||
void line(const Point &firstPoint,const Point &secondPoint,BYTE byteValue);
|
||||
void outlineRect(const Rect &outlineRect,BYTE byteValue=0);
|
||||
void colorRect(const Rect &rect,BYTE byteValue=0);
|
||||
WORD square(const Point ¢erPoint,WORD lineLength,const RGBColor &lineColor);
|
||||
WORD square(const Point ¢erPoint,WORD lineLength,BYTE indexColor);
|
||||
WORD circle(WORD aspectValue,const Point &xyPoint,WORD radius,WORD palIndex);
|
||||
WORD bitBlt(PureDevice &displayDevice,PureDevice::BltMode ropCode=PureDevice::SourceCopy);
|
||||
WORD bitBlt(PureDevice &displayDevice,const Rect &dstRect,const Point &srcPoint,PureDevice::BltMode ropCode=PureDevice::SourceCopy);
|
||||
WORD bitBlt(PureDevice &displayDevice,const Point &srcPoint,PureDevice::BltMode ropCode=PureDevice::SourceCopy);
|
||||
BOOL stretchBlt(PureDevice &displayDevice,const Rect &dstRect,PureDevice::BltMode ropCode=PureDevice::SourceCopy);
|
||||
void setBits(BYTE charByte);
|
||||
bool copyBits(unsigned char *ptrData,DWORD length);
|
||||
void clearBits(void);
|
||||
WORD size(DWORD newWidth,DWORD newHeight);
|
||||
void *ptrData(void);
|
||||
DWORD imageExtent(void)const;
|
||||
BOOL usePalette(BOOL usage);
|
||||
BOOL usePalette(PureDevice &pureDevice,BOOL usage);
|
||||
WORD isOkay(void)const;
|
||||
PurePalette &getPalette(void);
|
||||
PureDevice &getDevice(void);
|
||||
HBITMAP getBitmap(void);
|
||||
private:
|
||||
bool overlay(const Point &placementPoint,int srcWidth,int srcHeight,UCHAR *pBmBits);
|
||||
void copyBits(unsigned char *lpDstPtr,unsigned char *lpSrcPtr,DWORD length)const;
|
||||
void createBitmap(const PureDevice &somePureDevice);
|
||||
void createBitmap(void);
|
||||
void destroyBitmap(void);
|
||||
void verifyDimensions(DWORD &desiredWidth,DWORD desiredHeight)const;
|
||||
|
||||
HBITMAP mhBitmap;
|
||||
void *mlpBmBits;
|
||||
DWORD mImageExtent;
|
||||
PureDevice mBitmapDevice;
|
||||
PurePalette mBitmapPalette;
|
||||
};
|
||||
|
||||
inline
|
||||
DIBitmap::DIBitmap(const DIBitmap &someDIBitmap)
|
||||
: mhBitmap(0), mImageExtent(0), mlpBmBits(0)
|
||||
{
|
||||
*this=someDIBitmap;
|
||||
}
|
||||
|
||||
inline
|
||||
DIBitmap::DIBitmap(const PureDevice &somePureDevice,DWORD bmWidth,DWORD bmHeight,const PurePalette &purePalette)
|
||||
: mhBitmap(0), mImageExtent(0), mlpBmBits(0)
|
||||
{
|
||||
verifyDimensions(bmWidth,bmHeight);
|
||||
width(bmWidth);
|
||||
height(bmHeight);
|
||||
static_cast<BitmapInfo&>(*this)=purePalette;
|
||||
mBitmapPalette=purePalette;
|
||||
createBitmap(somePureDevice);
|
||||
if(!isOkay())return;
|
||||
mBitmapDevice.compatibleDevice(somePureDevice);
|
||||
mBitmapDevice.select(mhBitmap);
|
||||
}
|
||||
|
||||
inline
|
||||
DIBitmap::DIBitmap(const PureDevice &somePureDevice,const BitmapInfo &someBitmapInfo,const PurePalette &purePalette)
|
||||
: mhBitmap(0), mImageExtent(0), mlpBmBits(0), BitmapInfo(someBitmapInfo)
|
||||
{
|
||||
DWORD bmWidth(width());
|
||||
DWORD bmHeight(height());
|
||||
verifyDimensions(bmWidth,bmHeight);
|
||||
width(bmWidth);
|
||||
height(bmHeight);
|
||||
static_cast<BitmapInfo&>(*this)=purePalette;
|
||||
mBitmapPalette=purePalette;
|
||||
createBitmap(somePureDevice);
|
||||
if(!isOkay())return;
|
||||
mBitmapDevice.compatibleDevice(somePureDevice);
|
||||
mBitmapDevice.select(mhBitmap);
|
||||
}
|
||||
|
||||
inline
|
||||
DIBitmap::DIBitmap(const BitmapInfo &someBitmapInfo)
|
||||
: mhBitmap(0), mImageExtent(0), mlpBmBits(0), BitmapInfo(someBitmapInfo)
|
||||
{
|
||||
DWORD bmWidth(width());
|
||||
DWORD bmHeight(height());
|
||||
verifyDimensions(bmWidth,bmHeight);
|
||||
width(bmWidth);
|
||||
height(bmHeight);
|
||||
createBitmap();
|
||||
if(!isOkay())return;
|
||||
}
|
||||
|
||||
inline
|
||||
DIBitmap::~DIBitmap()
|
||||
{
|
||||
if(isOkay())mBitmapDevice.select(mhBitmap,FALSE);
|
||||
destroyBitmap();
|
||||
}
|
||||
|
||||
inline
|
||||
DIBitmap &DIBitmap::operator=(const DIBitmap &someDIBitmap)
|
||||
{
|
||||
destroyBitmap();
|
||||
(BitmapInfo&)*this=(BitmapInfo&)someDIBitmap;
|
||||
mBitmapPalette=((DIBitmap&)someDIBitmap).getPalette();
|
||||
createBitmap(someDIBitmap.mBitmapDevice);
|
||||
if(!isOkay())return *this;
|
||||
copyBits((unsigned char*)ptrData(),(unsigned char*)((DIBitmap&)someDIBitmap).ptrData(),imageExtent());
|
||||
mBitmapDevice.compatibleDevice(someDIBitmap.mBitmapDevice);
|
||||
mBitmapDevice.select(mhBitmap);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void DIBitmap::destroyBitmap(void)
|
||||
{
|
||||
if(!mhBitmap)return;
|
||||
mBitmapDevice.select(mhBitmap,FALSE);
|
||||
::DeleteObject(mhBitmap);
|
||||
mhBitmap=0;
|
||||
mlpBmBits=0;
|
||||
mImageExtent=0;
|
||||
}
|
||||
|
||||
inline
|
||||
void DIBitmap::setByte(WORD row,WORD col,BYTE byteValue)
|
||||
{
|
||||
if(!isOkay()||row>=height()||col>=width())return;
|
||||
BYTE *lpImage=(BYTE*)mlpBmBits+width()*height();
|
||||
*((lpImage-((LONG)row*width()+width()))+(LONG)col)=byteValue;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE DIBitmap::getByte(WORD row,WORD col)const
|
||||
{
|
||||
if(!isOkay()||row>=height()||col>=width())return (BYTE)FALSE;
|
||||
BYTE *lpImage=(BYTE*)mlpBmBits+width()*height();
|
||||
return *((lpImage-((LONG)row*width()+width()))+(LONG)col);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DIBitmap::bitBlt(PureDevice &displayDevice,PureDevice::BltMode ropCode)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
return ::BitBlt(displayDevice,0,0,width(),height(),mBitmapDevice,0,0,ropCode);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DIBitmap::bitBlt(PureDevice &displayDevice,const Point &srcPoint,PureDevice::BltMode ropCode)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
return ::BitBlt(displayDevice,0,0,width(),height(),mBitmapDevice,srcPoint.x(),srcPoint.y(),ropCode);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DIBitmap::bitBlt(PureDevice &displayDevice,const Rect &dstRect,const Point &srcPoint,PureDevice::BltMode ropCode)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
return ::BitBlt(displayDevice,dstRect.left(),dstRect.top(),dstRect.right(),dstRect.bottom(),mBitmapDevice,srcPoint.x(),srcPoint.y(),ropCode);
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL DIBitmap::stretchBlt(PureDevice &displayDevice,const Rect &dstRect,PureDevice::BltMode ropCode)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
return ::StretchBlt(displayDevice,dstRect.left(),dstRect.top(),dstRect.right(),dstRect.bottom(),mBitmapDevice,0,0,width(),height(),ropCode);
|
||||
}
|
||||
|
||||
inline
|
||||
void *DIBitmap::ptrData(void)
|
||||
{
|
||||
if(!mlpBmBits)throw(NullError());
|
||||
return mlpBmBits;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD DIBitmap::imageExtent(void)const
|
||||
{
|
||||
return mImageExtent;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DIBitmap::square(const Point ¢erPoint,WORD lineLength,const RGBColor &lineColor)
|
||||
{
|
||||
return square(centerPoint,lineLength,mBitmapPalette.paletteIndex(lineColor));
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DIBitmap::isOkay(void)const
|
||||
{
|
||||
return (mhBitmap?TRUE:FALSE);
|
||||
}
|
||||
|
||||
inline
|
||||
PurePalette &DIBitmap::getPalette(void)
|
||||
{
|
||||
return mBitmapPalette;
|
||||
}
|
||||
|
||||
inline
|
||||
PureDevice &DIBitmap::getDevice(void)
|
||||
{
|
||||
return mBitmapDevice;
|
||||
}
|
||||
|
||||
inline
|
||||
HBITMAP DIBitmap::getBitmap(void)
|
||||
{
|
||||
return mhBitmap;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL DIBitmap::usePalette(BOOL usage)
|
||||
{
|
||||
if(!isOkay()||!mBitmapDevice.isOkay())return FALSE;
|
||||
mBitmapPalette.usePalette(mBitmapDevice,usage);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL DIBitmap::usePalette(PureDevice &pureDevice,BOOL usage)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
mBitmapPalette.usePalette(pureDevice,usage);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
112
common/Diskinfo.hpp
Normal file
112
common/Diskinfo.hpp
Normal file
@@ -0,0 +1,112 @@
|
||||
#ifndef _COMMON_DISKINFO_HPP_
|
||||
#define _COMMON_DISKINFO_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FINDDATA_HPP_
|
||||
#include <common/finddata.hpp>
|
||||
#endif
|
||||
|
||||
class DiskInfo : public FindData
|
||||
{
|
||||
public:
|
||||
enum DriveType{DriveUnknown=0,DriveNoRoot=1,DriveRemovable=DRIVE_REMOVABLE,DriveFixed=DRIVE_FIXED,DriveRemote=DRIVE_REMOTE,DriveCDROM=DRIVE_CDROM,DriveRamDisk=DRIVE_RAMDISK};
|
||||
DiskInfo(void);
|
||||
virtual ~DiskInfo();
|
||||
DWORD getDiskFreeSpace(String pathFileName=String())const;
|
||||
DWORD getDiskUsage(String pathFileName=String())const;
|
||||
DWORD getCurrentDirectory(String ¤tDirectory)const;
|
||||
DWORD setCurrentDirectory(const String ¤tDirectory)const;
|
||||
WORD createDirectory(const String &pathDirectoryName)const;
|
||||
WORD getLogicalDrives(Block<String> &driveStrings)const;
|
||||
WORD getFixedLogicalDrives(Block<String> &driveStrings)const;
|
||||
DriveType getDriveType(String pathFileName=String())const;
|
||||
bool unlink(const String &pathFileName)const;
|
||||
BOOL copyFile(const String &strExistingFile,const String &strNewFile,BOOL overwrite=TRUE);
|
||||
BOOL rename(const String &strExistingFileName,const String &strNewFile);
|
||||
private:
|
||||
String rootPath(String pathFileName)const;
|
||||
};
|
||||
|
||||
inline
|
||||
DiskInfo::DiskInfo(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DiskInfo::~DiskInfo()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD DiskInfo::getDiskFreeSpace(String pathFileName)const
|
||||
{
|
||||
DWORD sectorsPerCluster;
|
||||
DWORD bytesPerSector;
|
||||
DWORD freeClusters;
|
||||
DWORD totalClusters;
|
||||
|
||||
pathFileName=rootPath(pathFileName);
|
||||
if(!::GetDiskFreeSpace((pathFileName.isNull()?(LPSTR)0:(LPSTR)pathFileName),§orsPerCluster,&bytesPerSector,&freeClusters,&totalClusters))return FALSE;
|
||||
return freeClusters*sectorsPerCluster*bytesPerSector;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD DiskInfo::getDiskUsage(String pathFileName)const
|
||||
{
|
||||
DWORD sectorsPerCluster;
|
||||
DWORD bytesPerSector;
|
||||
DWORD freeClusters;
|
||||
DWORD totalClusters;
|
||||
|
||||
pathFileName=rootPath(pathFileName);
|
||||
if(!::GetDiskFreeSpace((pathFileName.isNull()?(LPSTR)0:(LPSTR)pathFileName),§orsPerCluster,&bytesPerSector,&freeClusters,&totalClusters))return FALSE;
|
||||
return (totalClusters*sectorsPerCluster*bytesPerSector)-(freeClusters*sectorsPerCluster*bytesPerSector);
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD DiskInfo::setCurrentDirectory(const String ¤tDirectory)const
|
||||
{
|
||||
if(currentDirectory.isNull())return FALSE;
|
||||
return ::SetCurrentDirectory((LPSTR)currentDirectory);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DiskInfo::createDirectory(const String &pathDirectoryName)const
|
||||
{
|
||||
if(pathDirectoryName.isNull())return FALSE;
|
||||
return ::CreateDirectory(pathDirectoryName,(LPSECURITY_ATTRIBUTES)0);
|
||||
}
|
||||
|
||||
inline
|
||||
String DiskInfo::rootPath(String pathFileName)const
|
||||
{
|
||||
String rootPath;
|
||||
|
||||
if(pathFileName.isNull())return rootPath;
|
||||
rootPath=pathFileName.betweenString(0,'\\');
|
||||
rootPath+="\\";
|
||||
return rootPath;
|
||||
}
|
||||
|
||||
inline
|
||||
DiskInfo::DriveType DiskInfo::getDriveType(String pathFileName)const
|
||||
{
|
||||
pathFileName=rootPath(pathFileName);
|
||||
return (DriveType)::GetDriveType((pathFileName.isNull()?(LPSTR)0:(LPSTR)pathFileName));
|
||||
}
|
||||
|
||||
inline
|
||||
bool DiskInfo::unlink(const String &pathFileName)const
|
||||
{
|
||||
if(pathFileName.isNull())return false;
|
||||
if(DriveCDROM==getDriveType(pathFileName))return false;
|
||||
return ::DeleteFile(pathFileName);
|
||||
}
|
||||
#endif
|
||||
106
common/Dwindow.hpp
Normal file
106
common/Dwindow.hpp
Normal file
@@ -0,0 +1,106 @@
|
||||
#ifndef _COMMON_DWINDOW_HPP_
|
||||
#define _COMMON_DWINDOW_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SMARTPOINTER_HPP_
|
||||
#include <common/pointer.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GUIWINDOW_HPP_
|
||||
#include <common/guiwnd.hpp>
|
||||
#endif
|
||||
|
||||
class Rect;
|
||||
class String;
|
||||
|
||||
class DWindow : public GUIWindow
|
||||
{
|
||||
public:
|
||||
DWindow(void);
|
||||
virtual ~DWindow();
|
||||
bool createDialogParam(GUIWindow &frameWindow,GUIWindow &parentWindow,const String &strTemplate,LPARAM param);
|
||||
bool createDialogParam(GUIWindow &parentWindow,const String &strTemplate,LPARAM param);
|
||||
HWND getItem(int controlID)const;
|
||||
LRESULT sendMessage(DWORD controlID,UINT message,WPARAM wParam,LPARAM lParam)const;
|
||||
LRESULT postMessage(DWORD controlID,UINT message,WPARAM wParam,LPARAM lParam)const;
|
||||
void setText(UINT controlID,const String &setText)const;
|
||||
WORD getText(UINT controlID,String &textString)const;
|
||||
String getText(UINT controlID)const;
|
||||
BOOL setInt(UINT controlID,int value)const;
|
||||
BOOL getInt(UINT controlID,int &value)const;
|
||||
WORD enable(UINT controlID,WORD isEnabled)const;
|
||||
void setFocus(UINT controlID)const;
|
||||
bool show(UINT controlID,int nCmdShow=SW_SHOW)const;
|
||||
protected:
|
||||
void endDialog(WORD returnCode);
|
||||
virtual int windowProcedure(HWND hWnd,WORD message,WPARAM wParam,LPARAM lParam);
|
||||
private:
|
||||
DWindow(const DWindow &someDWindow);
|
||||
DWindow &operator=(const DWindow &someDWindow);
|
||||
|
||||
SmartPointer<GUIWindow> mFrameWindow;
|
||||
};
|
||||
|
||||
inline
|
||||
DWindow::DWindow(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DWindow::DWindow(const DWindow &someDWindow)
|
||||
: GUIWindow(someDWindow) // private implementation
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DWindow &DWindow::operator=(const DWindow &someDWindow)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
HWND DWindow::getItem(int controlID)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::GetDlgItem(*this,controlID);
|
||||
}
|
||||
|
||||
inline
|
||||
void DWindow::setFocus(UINT controlID)const
|
||||
{
|
||||
::SetFocus(getItem(controlID));
|
||||
}
|
||||
|
||||
inline
|
||||
bool DWindow::show(UINT controlID,int nCmdShow)const
|
||||
{
|
||||
return ::ShowWindow(getItem(controlID),nCmdShow);
|
||||
}
|
||||
|
||||
inline
|
||||
LRESULT DWindow::sendMessage(DWORD controlID,UINT message,WPARAM wParam,LPARAM lParam)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::SendMessage(getItem(controlID),message,wParam,lParam);
|
||||
}
|
||||
|
||||
inline
|
||||
LRESULT DWindow::postMessage(DWORD controlID,UINT message,WPARAM wParam,LPARAM lParam)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::PostMessage(::GetDlgItem(*this,controlID),message,wParam,lParam);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD DWindow::enable(UINT controlID,WORD isEnabled)const
|
||||
{
|
||||
return ::EnableWindow(::GetDlgItem(*this,controlID),isEnabled);
|
||||
}
|
||||
|
||||
inline
|
||||
void DWindow::endDialog(WORD returnCode)
|
||||
{
|
||||
if(isValid())::EndDialog((HWND)*this,returnCode);
|
||||
}
|
||||
#endif
|
||||
|
||||
47
common/ELASTIC.CPP
Normal file
47
common/ELASTIC.CPP
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <common/elastic.hpp>
|
||||
|
||||
GUIWindow &ElasticControl::controlWindow(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
HWND ElasticControl::createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,GUIWindow &parentWindow,int controlID)
|
||||
{
|
||||
ElasticControl::createControl(0,className,windowName,dwStyle,initRect,parentWindow,controlID);
|
||||
return *this;
|
||||
}
|
||||
|
||||
HWND ElasticControl::createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,GUIWindow &parentWindow,int controlID)
|
||||
{
|
||||
mlpParentWindow=&parentWindow;
|
||||
parentWindow.insertHandler(VectorHandler::SizeHandler,&mSizeHandler);
|
||||
Control::createControl(extendedStyle,className,windowName,dwStyle,initRect,parentWindow,controlID);
|
||||
initControl(parentWindow);
|
||||
return *this;
|
||||
}
|
||||
|
||||
HWND ElasticControl::assumeControl(GUIWindow &parentWindow,HWND hControlWnd,UINT controlID)
|
||||
{
|
||||
mlpParentWindow=&parentWindow;
|
||||
parentWindow.insertHandler(VectorHandler::SizeHandler,&mSizeHandler);
|
||||
Control::assumeControl(hControlWnd,controlID);
|
||||
initControl(parentWindow);
|
||||
return *this;
|
||||
}
|
||||
|
||||
HWND ElasticControl::createControl(DWORD /*extendedStyle*/,const String &/*className*/,const String &/*windowName*/,DWORD /*dwStyle*/,const Rect &/*initRect*/,HWND /*hParent*/,int /*controlID*/)
|
||||
{ // no implementation
|
||||
return (HWND)0;
|
||||
}
|
||||
|
||||
HWND ElasticControl::createControl(const String &/*className*/,const String &/*windowName*/,DWORD /*dwStyle*/,const Rect &/*initRect*/,HWND /*hParentWnd*/,int /*controlID*/)
|
||||
{ // no implementation
|
||||
return (HWND)0;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType ElasticControl::sizeHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
if(!mlpParentWindow)return (CallbackData::ReturnType)FALSE;
|
||||
moveControl(*mlpParentWindow,someCallbackData.loWord(),someCallbackData.hiWord());
|
||||
return (CallbackData::ReturnType)FALSE;
|
||||
}
|
||||
53
common/ELASTIC.HPP
Normal file
53
common/ELASTIC.HPP
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef _COMMON_ELASTICCONTROL_HPP_
|
||||
#define _COMMON_ELASTICCONTROL_HPP_
|
||||
#ifndef _COMMON_RUBBERCONTROL_HPP_
|
||||
#include <common/rubber.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_CONTROL_HPP_
|
||||
#include <common/control.hpp>
|
||||
#endif
|
||||
|
||||
class ElasticControl : public Control, private RubberControl
|
||||
{
|
||||
public:
|
||||
ElasticControl(void);
|
||||
virtual ~ElasticControl();
|
||||
virtual HWND createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,GUIWindow &parentWindow,int controlID);
|
||||
virtual HWND createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,GUIWindow &parentWindow,int controlID);
|
||||
virtual HWND assumeControl(GUIWindow &parentWindow,HWND hControlWnd,UINT controlID);
|
||||
protected:
|
||||
virtual GUIWindow &controlWindow(void);
|
||||
private:
|
||||
ElasticControl(const ElasticControl &someElasticControl);
|
||||
ElasticControl &operator=(const ElasticControl &someElasticControl);
|
||||
HWND createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParentWnd,int controlID);
|
||||
HWND createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParent,int controlID);
|
||||
CallbackData::ReturnType sizeHandler(CallbackData &someCallbackData);
|
||||
|
||||
Callback<ElasticControl> mSizeHandler;
|
||||
GUIWindow *mlpParentWindow;
|
||||
};
|
||||
|
||||
inline
|
||||
ElasticControl::ElasticControl(void)
|
||||
: mlpParentWindow(0)
|
||||
{
|
||||
mSizeHandler.setCallback(this,&ElasticControl::sizeHandler);
|
||||
}
|
||||
|
||||
inline
|
||||
ElasticControl::ElasticControl(const ElasticControl &/*someElasticControl*/)
|
||||
{ // no implementation
|
||||
}
|
||||
|
||||
inline
|
||||
ElasticControl::~ElasticControl()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ElasticControl &ElasticControl::operator=(const ElasticControl &/*someElasticControl*/)
|
||||
{ // no implementation
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
16
common/ENUM.TXT
Normal file
16
common/ENUM.TXT
Normal file
@@ -0,0 +1,16 @@
|
||||
inline
|
||||
WORD RegKey::enumValue(DWORD index,const String &valueName,DWORD &longData)
|
||||
{
|
||||
LONG keyResult;
|
||||
DWORD nameLength;
|
||||
DWORD valueLength;
|
||||
DWORD typeCode(REG_DWORD);
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
valueName.GetBufferSetLength(MaxDataLength);
|
||||
nameLength=MaxDataLength;
|
||||
valueLength=sizeof(DWORD);
|
||||
keyResult=::RegEnumValue((HKEY)*this,index,(LPSTR)(LPCTSTR)nameValue,&nameLength,0,&typeCode,(LPBYTE)&longData,&valueLength);
|
||||
if(ERROR_SUCCESS!=keyReturn||REG_DWORD!=valueType)return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
50
common/EXCEPT.HPP
Normal file
50
common/EXCEPT.HPP
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef _COMMON_EXCEPTION_HPP_
|
||||
#define _COMMON_EXCEPTION_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class Exception
|
||||
{
|
||||
public:
|
||||
Exception(){mReason="";}
|
||||
Exception(const String &reason){mReason=reason;}
|
||||
virtual ~Exception(){;}
|
||||
virtual String toString(){return mReason;}
|
||||
const String &getReason(void)const{return mReason;};
|
||||
private:
|
||||
String mReason;
|
||||
};
|
||||
|
||||
class BoundaryError : public Exception
|
||||
{
|
||||
public :
|
||||
String toString(){return "BoundaryError";}
|
||||
};
|
||||
|
||||
class NullError : public Exception
|
||||
{
|
||||
public :
|
||||
String toString(){return "NullError";}
|
||||
};
|
||||
|
||||
class ArrayIndexOutOfBoundsException : public Exception
|
||||
{
|
||||
public :
|
||||
String toString(){return "ArrayIndexOutOfBounds";}
|
||||
};
|
||||
|
||||
class LibraryNotFoundException : public Exception
|
||||
{
|
||||
public:
|
||||
LibraryNotFoundException(const String &reason="LibraryNotFoundException"):Exception(reason){;}
|
||||
String toString(){return getReason();}
|
||||
};
|
||||
|
||||
class InvalidStateException : public Exception
|
||||
{
|
||||
public:
|
||||
InvalidStateException(const String &reason="InvalidStateException"):Exception(reason){;}
|
||||
String toString(){return getReason();}
|
||||
};
|
||||
#endif
|
||||
4
common/EXCPT.HPP
Normal file
4
common/EXCPT.HPP
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef _COMMON_EXCEPTION_HPP_
|
||||
#define _COMMON_EXCEPTION_HPP_
|
||||
#include <excpt.h>
|
||||
#endif
|
||||
309
common/FILE.CPP
Normal file
309
common/FILE.CPP
Normal file
@@ -0,0 +1,309 @@
|
||||
#include <common/file.hpp>
|
||||
|
||||
File::File(void)
|
||||
: mpFilePointer(0)
|
||||
{
|
||||
}
|
||||
|
||||
File::File(String pathFileName,String access)
|
||||
: mpFilePointer(0)
|
||||
{
|
||||
open(pathFileName,access);
|
||||
}
|
||||
|
||||
File::File(const File &someFile)
|
||||
: mpFilePointer(0)
|
||||
{
|
||||
*this=someFile;
|
||||
}
|
||||
|
||||
File::~File()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
File &File::operator=(const File &someFile)
|
||||
{
|
||||
open(someFile.pathFileName(),someFile.access());
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool File::operator==(const File &someFile)
|
||||
{
|
||||
return (pathFileName()==someFile.pathFileName());
|
||||
}
|
||||
|
||||
bool File::open(String pathFileName,String access)
|
||||
{
|
||||
close();
|
||||
if(pathFileName.isNull())return false;
|
||||
mpFilePointer=::fopen(pathFileName,access);
|
||||
if(!mpFilePointer)return FALSE;
|
||||
mPathFileName=pathFileName;
|
||||
mAccess=access;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool File::close(void)
|
||||
{
|
||||
if(!mpFilePointer)return FALSE;
|
||||
::fclose(mpFilePointer);
|
||||
mpFilePointer=0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const String &File::pathFileName(void)const
|
||||
{
|
||||
return mPathFileName;
|
||||
}
|
||||
|
||||
const String &File::access(void)const
|
||||
{
|
||||
return mAccess;
|
||||
}
|
||||
|
||||
bool File::isOkay(void)const
|
||||
{
|
||||
return (mpFilePointer?TRUE:FALSE);
|
||||
}
|
||||
|
||||
bool File::write(const String &string)
|
||||
{
|
||||
return write(string.str(),string.length());
|
||||
}
|
||||
|
||||
bool File::write(void *pData,DWORD extent)
|
||||
{
|
||||
if(!isOkay()||!pData||!extent)return FALSE;
|
||||
if(!::fwrite(pData,extent,1,mpFilePointer))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD File::write(BYTE value)
|
||||
{
|
||||
return write((void*)&value,sizeof(value));
|
||||
}
|
||||
|
||||
DWORD File::write(WORD value)
|
||||
{
|
||||
return write((void*)&value,sizeof(value));
|
||||
}
|
||||
|
||||
DWORD File::write(DWORD value)
|
||||
{
|
||||
return write((void*)&value,sizeof(value));
|
||||
}
|
||||
|
||||
DWORD File::write(int value)
|
||||
{
|
||||
return write((void*)&value,sizeof(value));
|
||||
}
|
||||
|
||||
DWORD File::write(double value)
|
||||
{
|
||||
return write((void*)&value,sizeof(value));
|
||||
}
|
||||
|
||||
DWORD File::write(const void *lpBuffer,DWORD lengthData)
|
||||
{
|
||||
return write((void*)lpBuffer,lengthData);
|
||||
}
|
||||
|
||||
bool File::writeLine(const String &lineString)
|
||||
{
|
||||
char crlf[2]={'\r','\n'};
|
||||
if(!isOkay()||lineString.isNull())return FALSE;
|
||||
if(!::fwrite((char*)((String&)lineString),lineString.length(),1,mpFilePointer))return FALSE;
|
||||
if(!::fwrite(crlf,sizeof(crlf),1,mpFilePointer))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool File::flush(void)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
::fflush(mpFilePointer);
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD File::length(void)const
|
||||
{
|
||||
DWORD currentPosition;
|
||||
DWORD length;
|
||||
|
||||
if(!isOkay())return 0;
|
||||
currentPosition=tell();
|
||||
seek(0,SeekEnd);
|
||||
length=tell();
|
||||
seek(currentPosition,SeekSet);
|
||||
return length;
|
||||
}
|
||||
|
||||
DWORD File::tell(void)const
|
||||
{
|
||||
fpos_t pos;
|
||||
if(!isOkay())return FALSE;
|
||||
if(::fgetpos(mpFilePointer,&pos))return FALSE;
|
||||
return pos;
|
||||
}
|
||||
|
||||
bool File::eof(void)const
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
return feof(mpFilePointer);
|
||||
}
|
||||
|
||||
bool File::rewind(void)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
::rewind(mpFilePointer);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool File::seek(long pos,SeekMethod seekMethod)const
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
if(-1==::fseek(mpFilePointer,pos,seekMethod))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD File::read(int &value)
|
||||
{
|
||||
return read((void*)&value,sizeof(int));
|
||||
}
|
||||
|
||||
DWORD File::read(double &value)
|
||||
{
|
||||
return read((void*)&value,sizeof(double));
|
||||
}
|
||||
|
||||
DWORD File::read(void *pData,int extent)
|
||||
{
|
||||
if(!isOkay()||!pData||!extent)return 0;
|
||||
return ::fread((char*)pData,1,extent,mpFilePointer);
|
||||
}
|
||||
|
||||
DWORD File::read(BYTE &value)
|
||||
{
|
||||
return read((void*)&value,sizeof(BYTE));
|
||||
}
|
||||
|
||||
DWORD File::read(WORD &value)
|
||||
{
|
||||
return read((void*)&value,sizeof(WORD));
|
||||
}
|
||||
|
||||
DWORD File::read(DWORD &value)
|
||||
{
|
||||
return read((void*)&value,sizeof(DWORD));
|
||||
}
|
||||
|
||||
DWORD File::read(char *lpBuffer,WORD lengthData,int stopChar)
|
||||
{
|
||||
BYTE tempChar;
|
||||
|
||||
for(int bytesRead=0;bytesRead<lengthData-1;bytesRead++)
|
||||
{
|
||||
if(!read(tempChar))return FALSE;
|
||||
if(tempChar==stopChar)break;
|
||||
*(lpBuffer++)=tempChar;
|
||||
}
|
||||
*(lpBuffer)=0;
|
||||
if(!bytesRead)return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD File::readLine(String &lineString)
|
||||
{
|
||||
int granularity(1024);
|
||||
int blockLength(granularity);
|
||||
BYTE charByte;
|
||||
BYTE *ptrLine;
|
||||
WORD bytesRead(0);
|
||||
|
||||
lineString.reserve(blockLength);
|
||||
ptrLine=(BYTE*)(char*)lineString;
|
||||
while(TRUE)
|
||||
{
|
||||
if(!read(charByte))break;
|
||||
if(bytesRead>=blockLength-1)
|
||||
{
|
||||
*ptrLine=0;
|
||||
String tmpString(lineString);
|
||||
int nextIndex(ptrLine-(BYTE*)(char*)lineString);
|
||||
lineString.reserve(blockLength+granularity);
|
||||
::memcpy((char*)lineString,(char*)tmpString,blockLength);
|
||||
blockLength+=granularity;
|
||||
ptrLine=(BYTE*)(char*)lineString+nextIndex;
|
||||
}
|
||||
if(CarriageReturn==charByte)
|
||||
{
|
||||
if(!read(charByte))break;
|
||||
if(LineFeed==charByte)
|
||||
{
|
||||
*ptrLine=0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if(LineFeed==charByte)
|
||||
{
|
||||
*ptrLine=0;
|
||||
return TRUE;
|
||||
}
|
||||
else if(NullChar==charByte)
|
||||
{
|
||||
*ptrLine++=0;
|
||||
return bytesRead;
|
||||
}
|
||||
else if(TabChar==charByte)
|
||||
{
|
||||
*ptrLine++=' ';
|
||||
bytesRead++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptrLine++=charByte;
|
||||
bytesRead++;
|
||||
}
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
bool File::operator+=(DWORD sizeIncrement)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return seek(sizeIncrement,SeekCur);
|
||||
}
|
||||
|
||||
bool File::operator++(void)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return seek(1,SeekCur);
|
||||
}
|
||||
|
||||
bool File::operator++(int postFixDummy) // postfix works the same as prefix
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return seek(1,SeekCur);
|
||||
}
|
||||
|
||||
bool File::operator-=(DWORD sizeDecrement)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return seek(-((int)sizeDecrement),SeekCur);
|
||||
}
|
||||
|
||||
bool File::operator--(void)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return seek(-1,SeekCur);
|
||||
}
|
||||
|
||||
bool File::operator--(int postFixDummy) // postfix works the same as prefix
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return seek(-1,SeekCur);
|
||||
}
|
||||
|
||||
|
||||
|
||||
102
common/FILE.HPP
Normal file
102
common/FILE.HPP
Normal file
@@ -0,0 +1,102 @@
|
||||
#ifndef _COMMON_FILE_HPP_
|
||||
#define _COMMON_FILE_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STDIO_HPP_
|
||||
#include <common/stdio.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
enum SeekMethod{SeekSet=SEEK_SET,SeekCur=SEEK_CUR,SeekEnd=SEEK_END};
|
||||
File(void);
|
||||
File(String pathFileName,String access="rb");
|
||||
File(const File &someFile);
|
||||
virtual ~File();
|
||||
File &operator=(const File &someFile);
|
||||
bool operator==(const File &someFile);
|
||||
bool open(String pathFileName,String access="rb");
|
||||
bool close(void);
|
||||
bool rewind(void);
|
||||
bool seek(long pos,SeekMethod seekMethod=SeekSet)const;
|
||||
DWORD tell(void)const;
|
||||
DWORD length(void)const;
|
||||
const String &pathFileName(void)const;
|
||||
const String &access(void)const;
|
||||
DWORD readLine(String &lineString);
|
||||
DWORD read(void *pData,int extent);
|
||||
DWORD read(BYTE &value);
|
||||
DWORD read(WORD &value);
|
||||
DWORD read(DWORD &value);
|
||||
DWORD read(int &value);
|
||||
DWORD read(double &value);
|
||||
DWORD read(char *lpBuffer,WORD lengthData,int stopChar);
|
||||
DWORD write(int value);
|
||||
DWORD write(double value);
|
||||
DWORD write(BYTE value);
|
||||
DWORD write(WORD value);
|
||||
DWORD write(DWORD value);
|
||||
bool write(const String &string);
|
||||
DWORD write(const void *lpBuffer,DWORD lengthData);
|
||||
bool write(void *pData,DWORD extent);
|
||||
bool writeLine(const String &lineString);
|
||||
bool operator+=(DWORD sizeIncrement);
|
||||
bool operator++(void);
|
||||
bool operator++(int postFixDummy);
|
||||
bool operator-=(DWORD sizeDecrement);
|
||||
bool operator--(void);
|
||||
bool operator--(int postFixDummy);
|
||||
bool flush(void);
|
||||
bool eof(void)const;
|
||||
bool isOkay(void)const;
|
||||
FILE *getFile(void);
|
||||
private:
|
||||
enum {CarriageReturn=0x0D,LineFeed=0x0A,TabChar=0x09,NullChar=0x00};
|
||||
FILE *mpFilePointer;
|
||||
String mPathFileName;
|
||||
String mAccess;
|
||||
};
|
||||
|
||||
inline
|
||||
FILE *File::getFile(void)
|
||||
{
|
||||
return mpFilePointer;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
64
common/FILEMAP.CPP
Normal file
64
common/FILEMAP.CPP
Normal file
@@ -0,0 +1,64 @@
|
||||
#if defined(__FLAT__)
|
||||
#include <common/filemap.hpp>
|
||||
#include <common/openfile.hpp>
|
||||
|
||||
FileMap::FileMap(void)
|
||||
: mMaxExtentHigh(0L), mMaxExtentLow(0L),
|
||||
mPaging(ReadOnly), mProtection(Image), mhFileHandle(0)
|
||||
{
|
||||
}
|
||||
|
||||
FileMap::FileMap(const FileMap &/*someFileMap*/)
|
||||
: mMaxExtentHigh(0L), mMaxExtentLow(0L),
|
||||
mPaging(ReadOnly), mProtection(Image), mhFileHandle(0)
|
||||
{
|
||||
}
|
||||
|
||||
FileMap::FileMap(String mapName,DWORD maxExtentHigh,DWORD maxExtentLow,Paging paging,Protection protection)
|
||||
: mMaxExtentHigh(maxExtentHigh), mMaxExtentLow(maxExtentLow), mPaging(paging),
|
||||
mProtection(protection), mhFileHandle(0)
|
||||
{
|
||||
create(mapName,maxExtentHigh,maxExtentLow,paging,protection);
|
||||
}
|
||||
|
||||
FileMap::FileMap(const FileHandle &someFileHandle)
|
||||
: mMaxExtentHigh(0L), mMaxExtentLow(0), mhFileHandle(0)
|
||||
{
|
||||
maxExtentHigh(0L);
|
||||
maxExtentLow(someFileHandle.size());
|
||||
create(someFileHandle);
|
||||
}
|
||||
|
||||
WORD FileMap::create(const FileHandle &someFileHandle)
|
||||
{
|
||||
if(FileHandle::Read==someFileHandle.access())mPaging=ReadOnly;
|
||||
else if(FileHandle::Write==someFileHandle.access())mPaging=WriteCopy;
|
||||
else if(FileHandle::ReadWrite==someFileHandle.access())mPaging=ReadWrite;
|
||||
else mPaging=ReadOnly;
|
||||
mProtection=Commit;
|
||||
return create(String(""),0L,someFileHandle.size(),mPaging,mProtection,(HANDLE)someFileHandle);
|
||||
}
|
||||
|
||||
WORD FileMap::create(String mapName,DWORD maxExtentHigh,DWORD maxExtentLow,Paging paging,Protection protection,HANDLE hMapFile)
|
||||
{
|
||||
mMaxExtentHigh=maxExtentHigh;
|
||||
mMaxExtentLow=maxExtentLow;
|
||||
mPaging=paging;
|
||||
mProtection=protection;
|
||||
destroyMap();
|
||||
mhFileHandle=::CreateFileMapping((HANDLE)hMapFile,(LPSECURITY_ATTRIBUTES)0,paging|protection,maxExtentHigh,maxExtentLow,mapName);
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
BOOL FileMap::open(const String &strName,DWORD maxExtentHigh,DWORD maxExtentLow,Paging paging,Protection protection,DWORD access,BOOL inherit)
|
||||
{
|
||||
destroyMap();
|
||||
if(strName.isNull())return FALSE;
|
||||
mhFileHandle=::OpenFileMapping(access,inherit,(LPSTR)(String&)strName);
|
||||
mMaxExtentHigh=maxExtentHigh;
|
||||
mMaxExtentLow=maxExtentLow;
|
||||
mPaging=paging;
|
||||
mProtection=protection;
|
||||
return isOkay();
|
||||
}
|
||||
#endif
|
||||
112
common/FILEMAP.HPP
Normal file
112
common/FILEMAP.HPP
Normal file
@@ -0,0 +1,112 @@
|
||||
#if defined(__FLAT__)
|
||||
#ifndef _COMMON_FILEMAP_HPP_
|
||||
#define _COMMON_FILEMAP_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class FileHandle;
|
||||
|
||||
class FileMap
|
||||
{
|
||||
public:
|
||||
friend class PureViewOfFile;
|
||||
enum MapMessage{ShutDown=0x02};
|
||||
enum Paging{ReadOnly=PAGE_READONLY,ReadWrite=PAGE_READWRITE,WriteCopy=PAGE_WRITECOPY};
|
||||
enum Protection{Commit=SEC_COMMIT,Image=SEC_IMAGE,NoCache=SEC_NOCACHE,Reserve=SEC_RESERVE};
|
||||
FileMap(void);
|
||||
FileMap(String mapFileName,DWORD maxExtentHigh,DWORD maxExtentLow,Paging paging=ReadWrite,Protection protection=Commit);
|
||||
FileMap(const FileHandle &someFileHandle);
|
||||
virtual ~FileMap();
|
||||
WORD create(const FileHandle &someFileHandle);
|
||||
WORD create(String mapName,DWORD maxExtentHigh,DWORD maxExtentLow,Paging paging,Protection protection,HANDLE hMapFile=(HANDLE)0xFFFFFFFF);
|
||||
BOOL open(const String &strName,DWORD maxExtentHigh,DWORD maxExtentLow,Paging paging=ReadWrite,Protection protection=Commit,DWORD access=FILE_MAP_ALL_ACCESS,BOOL inherit=TRUE);
|
||||
DWORD maxExtentLow(void)const;
|
||||
DWORD maxExtentHigh(void)const;
|
||||
Paging paging(void)const;
|
||||
Protection protection(void)const;
|
||||
HANDLE getHandle(void)const;
|
||||
WORD isOkay(void)const;
|
||||
private:
|
||||
FileMap(const FileMap &someFileMap);
|
||||
operator HANDLE(void)const;
|
||||
void destroyMap(void);
|
||||
void maxExtentLow(DWORD maxExtentLow);
|
||||
void maxExtentHigh(DWORD maxExtentHigh);
|
||||
|
||||
Paging mPaging;
|
||||
Protection mProtection;
|
||||
DWORD mMaxExtentHigh;
|
||||
DWORD mMaxExtentLow;
|
||||
HANDLE mhFileHandle;
|
||||
};
|
||||
|
||||
inline
|
||||
WORD FileMap::isOkay(void)const
|
||||
{
|
||||
return (mhFileHandle?TRUE:FALSE);
|
||||
}
|
||||
|
||||
inline
|
||||
FileMap::operator HANDLE(void)const
|
||||
{
|
||||
return mhFileHandle;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FileMap::maxExtentLow(void)const
|
||||
{
|
||||
return mMaxExtentLow;
|
||||
}
|
||||
|
||||
inline
|
||||
void FileMap::maxExtentLow(DWORD maxExtentLow)
|
||||
{
|
||||
mMaxExtentLow=maxExtentLow;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FileMap::maxExtentHigh(void)const
|
||||
{
|
||||
return mMaxExtentHigh;
|
||||
}
|
||||
|
||||
inline
|
||||
void FileMap::maxExtentHigh(DWORD maxExtentHigh)
|
||||
{
|
||||
mMaxExtentHigh=maxExtentHigh;
|
||||
}
|
||||
|
||||
inline
|
||||
FileMap::Paging FileMap::paging(void)const
|
||||
{
|
||||
return mPaging;
|
||||
}
|
||||
|
||||
inline
|
||||
FileMap::Protection FileMap::protection(void)const
|
||||
{
|
||||
return mProtection;
|
||||
}
|
||||
|
||||
inline
|
||||
FileMap::~FileMap()
|
||||
{
|
||||
destroyMap();
|
||||
}
|
||||
|
||||
inline
|
||||
HANDLE FileMap::getHandle(void)const
|
||||
{
|
||||
return mhFileHandle;
|
||||
}
|
||||
|
||||
inline
|
||||
void FileMap::destroyMap(void)
|
||||
{
|
||||
if(!mhFileHandle)return;
|
||||
::CloseHandle(mhFileHandle);
|
||||
mhFileHandle=0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
140
common/FILETIME.HPP
Normal file
140
common/FILETIME.HPP
Normal file
@@ -0,0 +1,140 @@
|
||||
#if defined(_WIN32)
|
||||
#ifndef _COMMON_FILETIME_HPP_
|
||||
#define _COMMON_FILETIME_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class SystemTime;
|
||||
|
||||
class FileTime : private FILETIME
|
||||
{
|
||||
public:
|
||||
FileTime(void);
|
||||
FileTime(const FileTime &someFileTime);
|
||||
FileTime(const SystemTime &someSystemTime);
|
||||
FileTime(const FILETIME &fileTime);
|
||||
virtual ~FileTime();
|
||||
FileTime &operator=(const FileTime &someFileTime);
|
||||
FileTime &operator=(const SystemTime &someSystemTime);
|
||||
FileTime &operator=(const FILETIME &someFileTime);
|
||||
WORD operator==(const FileTime &someFileTime)const;
|
||||
WORD operator>(const FileTime &someFileTime)const;
|
||||
WORD operator<(const FileTime &someFileTime)const;
|
||||
DWORD lowDateTime(void)const;
|
||||
void lowDateTime(DWORD lowDateTime);
|
||||
DWORD highDateTime(void)const;
|
||||
void highDateTime(DWORD highDateTime);
|
||||
FILETIME &getFILETIME(void);
|
||||
private:
|
||||
void zeroInit(void);
|
||||
};
|
||||
|
||||
inline
|
||||
FileTime::FileTime(void)
|
||||
{
|
||||
zeroInit();
|
||||
}
|
||||
|
||||
inline
|
||||
FileTime::FileTime(const FileTime &someFileTime)
|
||||
{
|
||||
*this=someFileTime;
|
||||
}
|
||||
|
||||
inline
|
||||
FileTime::FileTime(const SystemTime &someSystemTime)
|
||||
{
|
||||
*this=someSystemTime;
|
||||
}
|
||||
|
||||
inline
|
||||
FileTime::FileTime(const FILETIME &fileTime)
|
||||
{
|
||||
*this=fileTime;
|
||||
}
|
||||
|
||||
inline
|
||||
FileTime::~FileTime()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
FILETIME &FileTime::getFILETIME(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
FileTime &FileTime::operator=(const FileTime &someFileTime)
|
||||
{
|
||||
lowDateTime(someFileTime.lowDateTime());
|
||||
highDateTime(someFileTime.highDateTime());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
FileTime &FileTime::operator=(const SystemTime &someSystemTime)
|
||||
{
|
||||
::SystemTimeToFileTime(&((SYSTEMTIME&)((SystemTime&)someSystemTime)),&((FILETIME&)*this));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
FileTime &FileTime::operator=(const FILETIME &someFileTime)
|
||||
{
|
||||
FILETIME::dwLowDateTime=someFileTime.dwLowDateTime;
|
||||
FILETIME::dwHighDateTime=someFileTime.dwHighDateTime;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FileTime::operator==(const FileTime &someFileTime)const
|
||||
{
|
||||
return (0==::CompareFileTime(&((FILETIME&)*this),&((FILETIME&)someFileTime)));
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FileTime::operator>(const FileTime &someFileTime)const
|
||||
{
|
||||
return (1==::CompareFileTime(&((FILETIME&)*this),&((FILETIME&)someFileTime)));
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FileTime::operator<(const FileTime &someFileTime)const
|
||||
{
|
||||
return (-1==::CompareFileTime(&((FILETIME&)*this),&((FILETIME&)someFileTime)));
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FileTime::lowDateTime(void)const
|
||||
{
|
||||
return FILETIME::dwLowDateTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void FileTime::lowDateTime(DWORD lowDateTime)
|
||||
{
|
||||
FILETIME::dwLowDateTime=lowDateTime;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FileTime::highDateTime(void)const
|
||||
{
|
||||
return FILETIME::dwHighDateTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void FileTime::highDateTime(DWORD highDateTime)
|
||||
{
|
||||
FILETIME::dwHighDateTime=highDateTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void FileTime::zeroInit(void)
|
||||
{
|
||||
FILETIME::dwLowDateTime=0L;
|
||||
FILETIME::dwHighDateTime=0L;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
55
common/FINDDATA.CPP
Normal file
55
common/FINDDATA.CPP
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <common/finddata.hpp>
|
||||
|
||||
void FindData::destroyFind(void)
|
||||
{
|
||||
if(INVALID_HANDLE_VALUE==mhFindHandle)return;
|
||||
::FindClose(mhFindHandle);
|
||||
mhFindHandle=INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
WORD FindData::findFirst(const String &searchFileName,DWORD searchAttributes)
|
||||
{
|
||||
destroyFind();
|
||||
zeroInit();
|
||||
if(searchFileName.isNull())return FALSE;
|
||||
fileName(searchFileName);
|
||||
attributes(searchAttributes);
|
||||
if(INVALID_HANDLE_VALUE==(mhFindHandle=::FindFirstFile((LPSTR)searchFileName,&((WIN32_FIND_DATA&)*this))))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void FindData::altFileName(String altFileName)
|
||||
{
|
||||
WORD nameLength(altFileName.length());
|
||||
|
||||
if(altFileName.isNull())return;
|
||||
if(nameLength>=sizeof(WIN32_FIND_DATA::cAlternateFileName))altFileName.length(sizeof(WIN32_FIND_DATA::cAlternateFileName)-1);
|
||||
::strcpy(WIN32_FIND_DATA::cAlternateFileName,(LPSTR)altFileName);
|
||||
}
|
||||
|
||||
FindData &FindData::operator=(const FindData &someFindData)
|
||||
{
|
||||
attributes(someFindData.attributes());
|
||||
creationTime(someFindData.creationTime());
|
||||
lastAccessTime(someFindData.lastAccessTime());
|
||||
lastModifyTime(someFindData.lastModifyTime());
|
||||
sizeHigh(someFindData.sizeHigh());
|
||||
sizeLow(someFindData.sizeLow());
|
||||
fileName(someFindData.fileName());
|
||||
altFileName(someFindData.altFileName());
|
||||
return *this;
|
||||
}
|
||||
|
||||
WORD FindData::operator==(const FindData &someFindData)const
|
||||
{
|
||||
return (attributes()==someFindData.attributes()&&
|
||||
creationTime()==someFindData.creationTime()&&
|
||||
lastAccessTime()==someFindData.lastAccessTime()&&
|
||||
sizeHigh()==someFindData.sizeHigh()&&
|
||||
fileName()==someFindData.fileName()&&
|
||||
altFileName()==someFindData.altFileName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
185
common/FINDDATA.HPP
Normal file
185
common/FINDDATA.HPP
Normal file
@@ -0,0 +1,185 @@
|
||||
#ifndef _COMMON_FINDDATA_HPP_
|
||||
#define _COMMON_FINDDATA_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SYSTEMTIME_HPP_
|
||||
#include <common/systime.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FILETIME_HPP_
|
||||
#include <common/filetime.hpp>
|
||||
#endif
|
||||
|
||||
class FindData : private WIN32_FIND_DATA
|
||||
{
|
||||
public:
|
||||
enum FileAttributes{FileArchive=FILE_ATTRIBUTE_ARCHIVE,FileDirectory=FILE_ATTRIBUTE_DIRECTORY,
|
||||
FileHidden=FILE_ATTRIBUTE_HIDDEN,FileNormal=FILE_ATTRIBUTE_NORMAL,
|
||||
FileReadOnly=FILE_ATTRIBUTE_READONLY,FileSystem=FILE_ATTRIBUTE_SYSTEM,
|
||||
FileTemporary=FILE_ATTRIBUTE_TEMPORARY};
|
||||
FindData(void);
|
||||
FindData(const FindData &someFindData);
|
||||
virtual ~FindData();
|
||||
WORD findFirst(const String &searchFileName,DWORD attributes=(DWORD)FileArchive);
|
||||
WORD findNext(void);
|
||||
FindData &operator=(const FindData &someFindData);
|
||||
WORD operator==(const FindData &someFindData)const;
|
||||
operator WIN32_FIND_DATA &(void);
|
||||
DWORD attributes(void)const;
|
||||
void attributes(DWORD attributes);
|
||||
SystemTime creationTime(void)const;
|
||||
void creationTime(const SystemTime &creationTime);
|
||||
SystemTime lastAccessTime(void)const;
|
||||
void lastAccessTime(const SystemTime &lastAccessTime);
|
||||
SystemTime lastModifyTime(void)const;
|
||||
void lastModifyTime(const SystemTime &lastModifyTime);
|
||||
DWORD sizeHigh(void)const;
|
||||
void sizeHigh(DWORD sizeHigh);
|
||||
DWORD sizeLow(void)const;
|
||||
void sizeLow(DWORD sizeLow);
|
||||
String fileName(void)const;
|
||||
void fileName(String fileName);
|
||||
String altFileName(void)const;
|
||||
void altFileName(String altFileName);
|
||||
private:
|
||||
void zeroInit(void);
|
||||
void destroyFind(void);
|
||||
HANDLE mhFindHandle;
|
||||
};
|
||||
|
||||
inline
|
||||
FindData::FindData(void)
|
||||
: mhFindHandle(INVALID_HANDLE_VALUE)
|
||||
{
|
||||
zeroInit();
|
||||
}
|
||||
|
||||
inline
|
||||
FindData::FindData(const FindData &someFindData)
|
||||
: mhFindHandle(INVALID_HANDLE_VALUE)
|
||||
{
|
||||
*this=someFindData;
|
||||
}
|
||||
|
||||
inline
|
||||
FindData::~FindData()
|
||||
{
|
||||
destroyFind();
|
||||
}
|
||||
|
||||
inline
|
||||
FindData::operator WIN32_FIND_DATA &(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FindData::attributes(void)const
|
||||
{
|
||||
return WIN32_FIND_DATA::dwFileAttributes;
|
||||
}
|
||||
|
||||
inline
|
||||
void FindData::attributes(DWORD attributes)
|
||||
{
|
||||
WIN32_FIND_DATA::dwFileAttributes=attributes;
|
||||
}
|
||||
|
||||
inline
|
||||
SystemTime FindData::creationTime(void)const
|
||||
{
|
||||
return (FileTime&)WIN32_FIND_DATA::ftCreationTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void FindData::creationTime(const SystemTime &creationTime)
|
||||
{
|
||||
(FileTime&)WIN32_FIND_DATA::ftCreationTime=creationTime;
|
||||
}
|
||||
|
||||
inline
|
||||
SystemTime FindData::lastAccessTime(void)const
|
||||
{
|
||||
return (FileTime&)WIN32_FIND_DATA::ftLastAccessTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void FindData::lastAccessTime(const SystemTime &lastAccessTime)
|
||||
{
|
||||
(FileTime&)WIN32_FIND_DATA::ftLastAccessTime=lastAccessTime;
|
||||
}
|
||||
|
||||
inline
|
||||
SystemTime FindData::lastModifyTime(void)const
|
||||
{
|
||||
return (FileTime&)WIN32_FIND_DATA::ftLastWriteTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void FindData::lastModifyTime(const SystemTime &lastModifyTime)
|
||||
{
|
||||
(FileTime&)WIN32_FIND_DATA::ftLastWriteTime=lastModifyTime;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FindData::sizeHigh(void)const
|
||||
{
|
||||
return WIN32_FIND_DATA::nFileSizeHigh;
|
||||
}
|
||||
|
||||
inline
|
||||
void FindData::sizeHigh(DWORD sizeHigh)
|
||||
{
|
||||
WIN32_FIND_DATA::nFileSizeHigh=sizeHigh;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FindData::sizeLow(void)const
|
||||
{
|
||||
return WIN32_FIND_DATA::nFileSizeLow;
|
||||
}
|
||||
|
||||
inline
|
||||
void FindData::sizeLow(DWORD sizeLow)
|
||||
{
|
||||
WIN32_FIND_DATA::nFileSizeLow=sizeLow;
|
||||
}
|
||||
|
||||
inline
|
||||
String FindData::fileName(void)const
|
||||
{
|
||||
return WIN32_FIND_DATA::cFileName;
|
||||
}
|
||||
|
||||
inline
|
||||
void FindData::fileName(String fileName)
|
||||
{
|
||||
WORD nameLength(fileName.length());
|
||||
|
||||
if(fileName.isNull())return;
|
||||
if(nameLength>=sizeof(WIN32_FIND_DATA::cFileName))fileName.length(sizeof(WIN32_FIND_DATA::cFileName)-1);
|
||||
::strcpy(WIN32_FIND_DATA::cFileName,(LPSTR)fileName);
|
||||
}
|
||||
|
||||
inline
|
||||
String FindData::altFileName(void)const
|
||||
{
|
||||
return WIN32_FIND_DATA::cAlternateFileName;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FindData::findNext(void)
|
||||
{
|
||||
if(INVALID_HANDLE_VALUE==mhFindHandle)return FALSE;
|
||||
return ::FindNextFile(mhFindHandle,&((WIN32_FIND_DATA&)*this));
|
||||
}
|
||||
|
||||
inline
|
||||
void FindData::zeroInit(void)
|
||||
{
|
||||
::memset(&((WIN32_FIND_DATA&)*this),0,sizeof(WIN32_FIND_DATA));
|
||||
}
|
||||
#endif
|
||||
8
common/FIXUP.HPP
Normal file
8
common/FIXUP.HPP
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef _COMMON_FIXUP_HPP_
|
||||
#define _COMMON_FIXUP_HPP_
|
||||
extern "C"
|
||||
{
|
||||
extern void push0002(void);
|
||||
extern void pop0002(void);
|
||||
}
|
||||
#endif
|
||||
125
common/FNDTEXTX.HPP
Normal file
125
common/FNDTEXTX.HPP
Normal file
@@ -0,0 +1,125 @@
|
||||
#ifndef _COMMON_FINDTEXTEX_HPP_
|
||||
#define _COMMON_FINDTEXTEX_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_CHARRANGE_HPP_
|
||||
#include <common/range.hpp>
|
||||
#endif
|
||||
|
||||
class FindTextEx : private FINDTEXTEX
|
||||
{
|
||||
public:
|
||||
FindTextEx(void);
|
||||
FindTextEx(const FindTextEx &findTextEx);
|
||||
FindTextEx(const CharRange &charRange,const String &strFind);
|
||||
virtual ~FindTextEx();
|
||||
FindTextEx &operator=(const FindTextEx &findTextEx);
|
||||
BOOL operator==(const FindTextEx &findTextEx)const;
|
||||
CharRange searchRange(void)const;
|
||||
void searchRange(const CharRange &searchRange);
|
||||
const String &strFind(void)const;
|
||||
void strFind(const String &strFind);
|
||||
CharRange foundRange(void)const;
|
||||
void foundRange(const CharRange &foundRange);
|
||||
FINDTEXTEX &findTextEx(void);
|
||||
private:
|
||||
String mStrInternal;
|
||||
};
|
||||
|
||||
inline
|
||||
FindTextEx::FindTextEx(void)
|
||||
{
|
||||
FINDTEXTEX::chrg.cpMin=0;
|
||||
FINDTEXTEX::chrg.cpMax=0;
|
||||
FINDTEXTEX::lpstrText=0;
|
||||
FINDTEXTEX::chrgText.cpMin=0;
|
||||
FINDTEXTEX::chrgText.cpMax=0;
|
||||
}
|
||||
|
||||
inline
|
||||
FindTextEx::FindTextEx(const FindTextEx &findTextEx)
|
||||
{
|
||||
*this=findTextEx;
|
||||
}
|
||||
|
||||
inline
|
||||
FindTextEx::FindTextEx(const CharRange &charRange,const String &strFind)
|
||||
{
|
||||
mStrInternal=strFind;
|
||||
FINDTEXTEX::chrg.cpMin=charRange.posMin();
|
||||
FINDTEXTEX::chrg.cpMax=charRange.posMax();
|
||||
FINDTEXTEX::lpstrText=(char*)mStrInternal;
|
||||
}
|
||||
|
||||
inline
|
||||
FindTextEx::~FindTextEx()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
FindTextEx &FindTextEx::operator=(const FindTextEx &findTextEx)
|
||||
{
|
||||
searchRange(findTextEx.searchRange());
|
||||
strFind(findTextEx.strFind());
|
||||
foundRange(findTextEx.foundRange());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL FindTextEx::operator==(const FindTextEx &findTextEx)const
|
||||
{
|
||||
return (searchRange()==findTextEx.searchRange()&&
|
||||
foundRange()==findTextEx.foundRange()&&
|
||||
strFind()==findTextEx.strFind());
|
||||
}
|
||||
|
||||
inline
|
||||
CharRange FindTextEx::searchRange(void)const
|
||||
{
|
||||
return CharRange(FINDTEXTEX::chrg.cpMin,FINDTEXTEX::chrg.cpMax);
|
||||
}
|
||||
|
||||
inline
|
||||
void FindTextEx::searchRange(const CharRange &searchRange)
|
||||
{
|
||||
FINDTEXTEX::chrg.cpMin=searchRange.posMin();
|
||||
FINDTEXTEX::chrg.cpMax=searchRange.posMax();
|
||||
}
|
||||
|
||||
inline
|
||||
const String &FindTextEx::strFind(void)const
|
||||
{
|
||||
return mStrInternal;
|
||||
}
|
||||
|
||||
inline
|
||||
void FindTextEx::strFind(const String &strFind)
|
||||
{
|
||||
mStrInternal=strFind;
|
||||
FINDTEXTEX::lpstrText=(char*)mStrInternal;
|
||||
}
|
||||
|
||||
inline
|
||||
CharRange FindTextEx::foundRange(void)const
|
||||
{
|
||||
return CharRange(FINDTEXTEX::chrgText.cpMin,FINDTEXTEX::chrgText.cpMax);
|
||||
}
|
||||
|
||||
inline
|
||||
void FindTextEx::foundRange(const CharRange &foundRange)
|
||||
{
|
||||
FINDTEXTEX::chrgText.cpMin=foundRange.posMin();
|
||||
FINDTEXTEX::chrgText.cpMax=foundRange.posMax();
|
||||
}
|
||||
|
||||
inline
|
||||
FINDTEXTEX &FindTextEx::findTextEx(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
37
common/FONT.CPP
Normal file
37
common/FONT.CPP
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <common/font.hpp>
|
||||
#include <common/purehdc.hpp>
|
||||
|
||||
Font &Font::operator=(const Font &someFont)
|
||||
{
|
||||
if(someFont.isOkay())
|
||||
{
|
||||
mPitchAndFamily=someFont.mPitchAndFamily;
|
||||
mWeight=someFont.mWeight;
|
||||
mFontStyle=someFont.mFontStyle;
|
||||
mFontSize=someFont.mFontSize;
|
||||
mCharSet=someFont.mCharSet;
|
||||
createFont();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Font::createFont(void)
|
||||
{
|
||||
PureDevice screenDevice;
|
||||
TEXTMETRIC tm;
|
||||
int fontHeight;
|
||||
|
||||
destroyFont();
|
||||
screenDevice.screenDevice();
|
||||
fontHeight=::MulDiv(((short)mFontSize),::GetDeviceCaps(screenDevice,LOGPIXELSY),72);
|
||||
mhFont=::CreateFont(fontHeight,0,0,0,mWeight,0,0,0,
|
||||
mCharSet,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,mPitchAndFamily,mFontStyle.str());
|
||||
screenDevice.select(mhFont);
|
||||
::GetTextMetrics(screenDevice,&tm);
|
||||
charHeight(tm.tmHeight+tm.tmExternalLeading);
|
||||
pureHeight(tm.tmHeight);
|
||||
avgCharWidth(tm.tmAveCharWidth);
|
||||
maxCharWidth(tm.tmMaxCharWidth);
|
||||
}
|
||||
|
||||
249
common/FONT.HPP
Normal file
249
common/FONT.HPP
Normal file
@@ -0,0 +1,249 @@
|
||||
#ifndef _COMMON_FONT_HPP_
|
||||
#define _COMMON_FONT_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GDIOBJ_HPP_
|
||||
#include <common/gdiobj.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class Font
|
||||
{
|
||||
public:
|
||||
enum{PitchDefault=DEFAULT_PITCH,PitchFixed=FIXED_PITCH,PitchVariable=VARIABLE_PITCH};
|
||||
enum{FamilyDecorative=FF_DECORATIVE,FamilyDontCare=FF_DONTCARE,
|
||||
FamilyModern=FF_MODERN,FamilyRoman=FF_ROMAN,FamilyScript=FF_SCRIPT,
|
||||
FamilySwiss=FF_SWISS};
|
||||
enum{WeightDontCare=FW_DONTCARE,WeightThin=FW_THIN,WeightExtraLight=FW_EXTRALIGHT,
|
||||
WeightUltraLight=FW_ULTRALIGHT,WeightLight=FW_LIGHT,WeightNormal=FW_NORMAL,
|
||||
WeightRegular=FW_REGULAR,WeightMedium=FW_MEDIUM,WeightSemiBold=FW_SEMIBOLD,
|
||||
WeightDemiBold=FW_DEMIBOLD,WeightBold=FW_BOLD,WeightExtraBold=FW_EXTRABOLD,
|
||||
WeightUltraBold=FW_ULTRABOLD,WeightHeavy=FW_HEAVY,WeightBlack=FW_BLACK};
|
||||
enum CharSet{AnsiCharSet=ANSI_CHARSET,OemCharSet=OEM_CHARSET,DefaultCharSet=DEFAULT_CHARSET,
|
||||
SymbolCharSet=SYMBOL_CHARSET,RussianCharSet=RUSSIAN_CHARSET};
|
||||
Font(void);
|
||||
Font(const Font &someFont);
|
||||
Font(const String &fontStyle,WORD sizeFont=8,DWORD pitchAndFamily=PitchVariable|FamilySwiss,DWORD weight=WeightNormal,CharSet charSet=AnsiCharSet);
|
||||
virtual ~Font();
|
||||
operator HFONT(void)const;
|
||||
operator GDIObj(void)const;
|
||||
Font &operator=(const Font &someFont);
|
||||
WORD operator==(const Font &someFont)const;
|
||||
String fontStyle(void)const;
|
||||
void fontStyle(const String &someFontStyle);
|
||||
DWORD pitchAndFamily(void)const;
|
||||
void pitchAndFamily(DWORD pitchAndFamily);
|
||||
DWORD weight(void)const;
|
||||
void weight(DWORD weight);
|
||||
WORD sizeFont(void)const;
|
||||
void sizeFont(WORD sizeFont);
|
||||
WORD charHeight(void)const;
|
||||
WORD avgCharWidth(void)const;
|
||||
WORD maxCharWidth(void)const;
|
||||
WORD pureHeight(void)const;
|
||||
CharSet charSet(void)const;
|
||||
void charSet(CharSet charSet);
|
||||
WORD isOkay(void)const;
|
||||
private:
|
||||
void pureHeight(WORD pureHeight);
|
||||
void charHeight(WORD charHeight);
|
||||
void avgCharWidth(WORD avgCharWidth);
|
||||
void maxCharWidth(WORD maxCharWidth);
|
||||
void createFont(void);
|
||||
void destroyFont(void);
|
||||
|
||||
HFONT mhFont;
|
||||
WORD mPureHeight;
|
||||
WORD mCharHeight;
|
||||
WORD mAvgCharWidth;
|
||||
WORD mMaxCharWidth;
|
||||
WORD mFontSize;
|
||||
CharSet mCharSet;
|
||||
String mFontStyle;
|
||||
DWORD mPitchAndFamily;
|
||||
DWORD mWeight;
|
||||
};
|
||||
|
||||
inline
|
||||
Font::Font(void)
|
||||
: mCharHeight(0), mhFont(0), mFontStyle("Arial"),
|
||||
mPitchAndFamily(PitchVariable|FamilySwiss), mFontSize(8), mPureHeight(0),
|
||||
mWeight(WeightNormal), mCharSet(AnsiCharSet)
|
||||
{
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
Font::Font(const String &fontStyle,WORD sizeFont,DWORD pitchAndFamily,DWORD weight,CharSet charSet)
|
||||
: mCharHeight(0), mhFont(0), mFontStyle(fontStyle), mPitchAndFamily(pitchAndFamily),
|
||||
mFontSize(sizeFont), mPureHeight(0), mWeight(weight), mCharSet(charSet)
|
||||
{
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
Font::Font(const Font &someFont)
|
||||
{
|
||||
*this=someFont;
|
||||
}
|
||||
|
||||
inline
|
||||
Font::~Font()
|
||||
{
|
||||
destroyFont();
|
||||
}
|
||||
|
||||
inline
|
||||
Font::operator GDIObj(void)const
|
||||
{
|
||||
return (GDIObj)mhFont;
|
||||
}
|
||||
|
||||
inline
|
||||
Font::operator HFONT(void)const
|
||||
{
|
||||
return mhFont;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::operator==(const Font &someFont)const
|
||||
{
|
||||
return (fontStyle()==someFont.fontStyle()&&
|
||||
pitchAndFamily()==someFont.pitchAndFamily()&&
|
||||
weight()==someFont.weight()&&
|
||||
sizeFont()==someFont.sizeFont()&&
|
||||
charHeight()==someFont.charHeight()&&
|
||||
avgCharWidth()==someFont.avgCharWidth()&&
|
||||
maxCharWidth()==someFont.maxCharWidth()&&
|
||||
charSet()==someFont.charSet());
|
||||
}
|
||||
|
||||
inline
|
||||
String Font::fontStyle(void)const
|
||||
{
|
||||
return mFontStyle;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::fontStyle(const String &someFontStyle)
|
||||
{
|
||||
mFontStyle=someFontStyle;
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::charHeight(void)const
|
||||
{
|
||||
return mCharHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::charHeight(WORD charHeight)
|
||||
{
|
||||
mCharHeight=charHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::avgCharWidth(void)const
|
||||
{
|
||||
return mAvgCharWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::avgCharWidth(WORD avgCharWidth)
|
||||
{
|
||||
mAvgCharWidth=avgCharWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::maxCharWidth(void)const
|
||||
{
|
||||
return mMaxCharWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::maxCharWidth(WORD maxCharWidth)
|
||||
{
|
||||
mMaxCharWidth=maxCharWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Font::pitchAndFamily(void)const
|
||||
{
|
||||
return mPitchAndFamily;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::pitchAndFamily(DWORD pitchAndFamily)
|
||||
{
|
||||
mPitchAndFamily=pitchAndFamily;
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Font::weight(void)const
|
||||
{
|
||||
return mWeight;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::weight(DWORD weight)
|
||||
{
|
||||
mWeight=weight;
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::sizeFont(void)const
|
||||
{
|
||||
return mFontSize;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::sizeFont(WORD sizeFont)
|
||||
{
|
||||
mFontSize=sizeFont;
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::pureHeight(WORD pureHeight)
|
||||
{
|
||||
mPureHeight=pureHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::pureHeight(void)const
|
||||
{
|
||||
return mPureHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
Font::CharSet Font::charSet(void)const
|
||||
{
|
||||
return mCharSet;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::charSet(CharSet charSet)
|
||||
{
|
||||
mCharSet=charSet;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::destroyFont(void)
|
||||
{
|
||||
if(!mhFont)return;
|
||||
::DeleteObject(mhFont);
|
||||
mhFont=0;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::isOkay(void)const
|
||||
{
|
||||
return (mhFont?TRUE:FALSE);
|
||||
}
|
||||
#endif
|
||||
226
common/Fileio.cpp
Normal file
226
common/Fileio.cpp
Normal file
@@ -0,0 +1,226 @@
|
||||
#include <common/fileio.hpp>
|
||||
|
||||
FileIO::FileIO(void)
|
||||
: mlpFilePointer(0), mByteOrder(LittleEndian)
|
||||
{
|
||||
}
|
||||
|
||||
FileIO::FileIO(String pathFileName,ByteOrder byteOrder,Mode openMode,CreationFlags creationFlags)
|
||||
: mlpFilePointer(0) , mByteOrder(byteOrder)
|
||||
{
|
||||
open(pathFileName,byteOrder,openMode,creationFlags);
|
||||
}
|
||||
|
||||
FileIO::~FileIO()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
bool FileIO::close(void)
|
||||
{
|
||||
if(!mlpFilePointer)return false;
|
||||
::fclose(mlpFilePointer);
|
||||
mlpFilePointer=0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileIO::open(String pathFileName,ByteOrder byteOrder,Mode openMode,CreationFlags creationFlags)
|
||||
{
|
||||
close();
|
||||
if(pathFileName.isNull())return false;
|
||||
mByteOrder=byteOrder;
|
||||
if(ReadOnly==openMode)mlpFilePointer=::fopen(pathFileName,"rb");
|
||||
else
|
||||
{
|
||||
if(CreateAlways==creationFlags)mlpFilePointer=::fopen(pathFileName,"w+b");
|
||||
else if(Create==creationFlags)mlpFilePointer=::fopen(pathFileName,"a+b");
|
||||
else mlpFilePointer=::fopen(pathFileName,"r+b");
|
||||
}
|
||||
if(!mlpFilePointer)return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileIO::peek(BYTE &value)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
read(value);
|
||||
seek(tell()-1,SeekCurrent);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileIO::read(BYTE &value)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return (sizeof(value)==::fread(&value,1,1,mlpFilePointer)?true:false);
|
||||
}
|
||||
|
||||
bool FileIO::read(WORD &value)
|
||||
{
|
||||
BYTE byteValue;
|
||||
|
||||
if(!isOkay())return false;
|
||||
if(!read(byteValue))return false;
|
||||
value=byteValue;
|
||||
if(!read(byteValue))return false;
|
||||
value|=((WORD)byteValue)<<8;
|
||||
if(BigEndian==mByteOrder)value=Intel::intelData(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileIO::read(DWORD &value)
|
||||
{
|
||||
WORD wordValue;
|
||||
|
||||
if(!isOkay())return false;
|
||||
if(!read(wordValue))return false;
|
||||
value=wordValue;
|
||||
if(!read(wordValue))return false;
|
||||
value|=((DWORD)wordValue)<<16;
|
||||
if(BigEndian==mByteOrder)value=Intel::intelData(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileIO::read(char *lpBuffer,DWORD lengthData)
|
||||
{
|
||||
BYTE byteValue;
|
||||
|
||||
if(!isOkay()||!lpBuffer)return false;
|
||||
return (1==::fread(lpBuffer,lengthData,1,mlpFilePointer));
|
||||
}
|
||||
|
||||
bool FileIO::read(char *lpBuffer,DWORD lengthData,int stopChar)
|
||||
{
|
||||
BYTE tempChar;
|
||||
int bytesRead;
|
||||
|
||||
if(!isOkay()||!lpBuffer||!lengthData)return false;
|
||||
for(bytesRead=0;bytesRead<lengthData-1;bytesRead++)
|
||||
{
|
||||
if(!read(tempChar))return false;
|
||||
if(tempChar==stopChar)break;
|
||||
*(lpBuffer++)=tempChar;
|
||||
}
|
||||
*(lpBuffer)=0;
|
||||
if(!bytesRead)return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD FileIO::readLine(String &lineString)
|
||||
{
|
||||
int granularity(1024);
|
||||
int blockLength(granularity);
|
||||
BYTE charByte;
|
||||
BYTE *ptrLine;
|
||||
DWORD bytesRead(0);
|
||||
|
||||
lineString.reserve(blockLength);
|
||||
ptrLine=(BYTE*)(char*)lineString;
|
||||
while(TRUE)
|
||||
{
|
||||
if(!read(charByte))break;
|
||||
if(bytesRead>=blockLength-1)
|
||||
{
|
||||
*ptrLine=0;
|
||||
String tmpString(lineString);
|
||||
int nextIndex(ptrLine-(BYTE*)(char*)lineString);
|
||||
lineString.reserve(blockLength+granularity);
|
||||
::memcpy((char*)lineString,(char*)tmpString,blockLength);
|
||||
blockLength+=granularity;
|
||||
ptrLine=(BYTE*)(char*)lineString+nextIndex;
|
||||
}
|
||||
if(CarriageReturn==charByte)
|
||||
{
|
||||
if(!read(charByte))break;
|
||||
if(LineFeed==charByte)
|
||||
{
|
||||
*ptrLine=0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(NullChar==charByte)
|
||||
{
|
||||
*ptrLine++=0;
|
||||
return bytesRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptrLine++=charByte;
|
||||
bytesRead++;
|
||||
}
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
bool FileIO::write(WORD value)
|
||||
{
|
||||
BYTE byteValue;
|
||||
|
||||
if(!isOkay())return false;
|
||||
if(BigEndian==mByteOrder)value=Intel::intelData(value);
|
||||
byteValue=(BYTE)(value&0x00FF);
|
||||
if(!write(byteValue))return false;
|
||||
byteValue=(BYTE)(value>>8);
|
||||
if(!write(byteValue))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileIO::write(DWORD value)
|
||||
{
|
||||
WORD wordValue;
|
||||
|
||||
if(!isOkay())return false;
|
||||
if(BigEndian==mByteOrder)
|
||||
{
|
||||
WORD hiWord(HIWORD(value));
|
||||
WORD loWord(LOWORD(value));
|
||||
|
||||
value=((DWORD)Intel::intelData(loWord))<<16;
|
||||
value|=Intel::intelData(hiWord);
|
||||
if(!write((char*)&value,sizeof(value)))return false;
|
||||
return true;
|
||||
}
|
||||
wordValue=(WORD)(value&0xFFFF);
|
||||
if(!write(wordValue))return false;
|
||||
wordValue=(WORD)(value>>16);
|
||||
if(!write(wordValue))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileIO::writeLine(const String &strLine)
|
||||
{
|
||||
if(!isOkay()||strLine.isNull())return false;
|
||||
if(!write((char*)(String&)strLine,strLine.length()))return false;
|
||||
return write("\r\n",2);
|
||||
}
|
||||
|
||||
bool FileIO::write(char *lpBuffer,DWORD lengthData)
|
||||
{
|
||||
if(!isOkay()||!lpBuffer||!lengthData)return false;
|
||||
if(1!=::fwrite(lpBuffer,1,lengthData,mlpFilePointer))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileIO::rewind(void)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return (!::fseek(mlpFilePointer,0,SEEK_SET));
|
||||
}
|
||||
|
||||
FileIO &FileIO::operator++(void)
|
||||
{
|
||||
seek(1L,SeekCurrent);
|
||||
return *this;
|
||||
}
|
||||
|
||||
FileIO &FileIO::operator--(void)
|
||||
{
|
||||
seek(-1L,SeekCurrent);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool FileIO::seek(LONG seekOffset,SeekFrom seekFrom)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return 0==::fseek(mlpFilePointer,seekOffset,seekFrom)?true:false;
|
||||
}
|
||||
|
||||
93
common/Fileio.hpp
Normal file
93
common/Fileio.hpp
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _COMMON_FILEIO_HPP_
|
||||
#define _COMMON_FILEIO_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STDIO_HPP_
|
||||
#include <common/stdio.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_INTEL_HPP_
|
||||
#include <common/intel.hpp>
|
||||
#endif
|
||||
|
||||
class FileIO
|
||||
{
|
||||
public:
|
||||
enum Mode{ReadOnly,ReadWrite};
|
||||
enum ByteOrder{BigEndian,LittleEndian};
|
||||
enum SeekFrom{SeekCurrent=SEEK_CUR,SeekEnd=SEEK_END,SeekBeginning=SEEK_SET};
|
||||
enum CreationFlags{Create,CreateAlways,None};
|
||||
FileIO(void);
|
||||
FileIO(String pathFileName,ByteOrder byteOrder=LittleEndian,Mode openMode=ReadOnly,CreationFlags creationFlags=None);
|
||||
virtual ~FileIO();
|
||||
bool open(String pathFileName,ByteOrder byteOrder=LittleEndian,Mode openMode=ReadOnly,CreationFlags creationFlags=None);
|
||||
bool close(void);
|
||||
bool rewind(void);
|
||||
bool peek(BYTE &value);
|
||||
bool read(BYTE &value);
|
||||
bool read(WORD &value);
|
||||
bool read(DWORD &value);
|
||||
bool read(char *lpBuffer,DWORD lengthData);
|
||||
bool read(BYTE *lpBuffer,DWORD lengthData);
|
||||
bool read(char *lpBuffer,DWORD lengthData,int stopChar);
|
||||
bool write(BYTE value);
|
||||
bool write(WORD value);
|
||||
bool write(DWORD value);
|
||||
bool write(char *lpBuffer,DWORD lengthData);
|
||||
FileIO &operator++(void);
|
||||
FileIO &operator--(void);
|
||||
bool seek(LONG seekOffset,SeekFrom seekFrom);
|
||||
DWORD readLine(String &lineString);
|
||||
bool writeLine(const String &strLine);
|
||||
bool isOkay(void)const;
|
||||
DWORD tell(void)const;
|
||||
ByteOrder getByteOrder(void)const;
|
||||
void setByteOrder(ByteOrder byteOrder);
|
||||
private:
|
||||
enum {CarriageReturn=0x0D,LineFeed=0x0A,NullChar=0x00};
|
||||
FILE *mlpFilePointer;
|
||||
ByteOrder mByteOrder;
|
||||
};
|
||||
|
||||
inline
|
||||
bool FileIO::isOkay(void)const
|
||||
{
|
||||
return (mlpFilePointer?true:false);
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FileIO::tell(void)const
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
return ::ftell(mlpFilePointer);
|
||||
}
|
||||
|
||||
inline
|
||||
bool FileIO::read(BYTE *lpBuffer,DWORD lengthData)
|
||||
{
|
||||
return read((char*)lpBuffer,lengthData);
|
||||
}
|
||||
|
||||
inline
|
||||
bool FileIO::write(BYTE value)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
if(1!=::fwrite(&value,1,1,mlpFilePointer))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
FileIO::ByteOrder FileIO::getByteOrder(void)const
|
||||
{
|
||||
return mByteOrder;
|
||||
}
|
||||
|
||||
inline
|
||||
void FileIO::setByteOrder(ByteOrder byteOrder)
|
||||
{
|
||||
mByteOrder=byteOrder;
|
||||
}
|
||||
#endif
|
||||
151
common/GDATA.HPP
Normal file
151
common/GDATA.HPP
Normal file
@@ -0,0 +1,151 @@
|
||||
#ifndef _COMMON_GLOBALDATA_HPP_
|
||||
#define _COMMON_GLOBALDATA_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_TYPES_HPP_
|
||||
#include <common/types.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_EXCEPTION_HPP_
|
||||
#include <common/except.hpp>
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class GlobalData
|
||||
{
|
||||
public:
|
||||
GlobalData(void);
|
||||
GlobalData(const GlobalData<T> &someGlobalData);
|
||||
GlobalData(DWORD sizeData,UINT globalFlags=GMEM_FIXED);
|
||||
virtual ~GlobalData();
|
||||
DWORD size(void)const;
|
||||
WORD size(DWORD sizeData,UINT globalFlags=GMEM_FIXED);
|
||||
UINT globalFlags(void)const;
|
||||
void globalFlags(UINT globalFlags);
|
||||
T &operator[](DWORD itemIndex);
|
||||
WORD operator==(const GlobalData<T> &someGlobalData)const;
|
||||
GlobalData<T> &operator=(const GlobalData<T> &someGlobalData);
|
||||
bool setZero(void);
|
||||
HANDLE getHandle(void)const;
|
||||
WORD isOkay(void)const;
|
||||
private:
|
||||
void destroyGlobalData(void);
|
||||
WORD createGlobalData(void);
|
||||
T HUGE *mlpGlobalData;
|
||||
HGLOBAL mhGlobalData;
|
||||
UINT mGlobalFlags;
|
||||
DWORD mSizeData;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
GlobalData<T>::GlobalData(void)
|
||||
: mlpGlobalData(0), mGlobalFlags(GMEM_FIXED), mSizeData(0), mhGlobalData(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
GlobalData<T>::GlobalData(const GlobalData<T> &someGlobalData)
|
||||
: mlpGlobalData(0), mGlobalFlags(GMEM_FIXED), mSizeData(0), mhGlobalData(0)
|
||||
{
|
||||
*this=someGlobalData;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
GlobalData<T>::GlobalData(DWORD sizeData,UINT globalFlags)
|
||||
: mlpGlobalData(0), mGlobalFlags(globalFlags), mSizeData(sizeData), mhGlobalData(0)
|
||||
{
|
||||
createGlobalData();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
GlobalData<T>::~GlobalData()
|
||||
{
|
||||
destroyGlobalData();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
DWORD GlobalData<T>::size(void)const
|
||||
{
|
||||
return mSizeData;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
WORD GlobalData<T>::size(DWORD sizeData,UINT globalFlags)
|
||||
{
|
||||
mGlobalFlags=globalFlags;
|
||||
mSizeData=sizeData;
|
||||
if(createGlobalData())return TRUE;
|
||||
mSizeData=0;
|
||||
mGlobalFlags=GMEM_FIXED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
UINT GlobalData<T>::globalFlags(void)const
|
||||
{
|
||||
return mGlobalFlags;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
void GlobalData<T>::globalFlags(UINT globalFlags)
|
||||
{
|
||||
mGlobalFlags=globalFlags;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
T &GlobalData<T>::operator[](DWORD itemIndex)
|
||||
{
|
||||
if(itemIndex>=mSizeData)throw(BoundaryError());
|
||||
return *(mlpGlobalData+itemIndex);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
WORD GlobalData<T>::createGlobalData(void)
|
||||
{
|
||||
destroyGlobalData();
|
||||
if(!mSizeData)return FALSE;
|
||||
mhGlobalData=::GlobalAlloc(mGlobalFlags,mSizeData*sizeof(T));
|
||||
if(!mhGlobalData)return FALSE;
|
||||
mlpGlobalData=(T HUGE*)::GlobalLock(mhGlobalData);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
void GlobalData<T>::destroyGlobalData(void)
|
||||
{
|
||||
if(!mlpGlobalData)return;
|
||||
::GlobalUnlock(mhGlobalData);
|
||||
::GlobalFree(mhGlobalData);
|
||||
mhGlobalData=0;
|
||||
mlpGlobalData=0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
HANDLE GlobalData<T>::getHandle(void)const
|
||||
{
|
||||
return ::GlobalHandle(mlpGlobalData);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
WORD GlobalData<T>::isOkay(void)const
|
||||
{
|
||||
return (mlpGlobalData?TRUE:FALSE);
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
#include <common/gdata.tpp>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
34
common/GDATA.TPP
Normal file
34
common/GDATA.TPP
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _COMMON_GLOBALDATA_TPP_
|
||||
#define _COMMON_GLOBALDATA_TPP_
|
||||
|
||||
template <class T>
|
||||
WORD GlobalData<T>::operator==(const GlobalData<T> &someGlobalData)const
|
||||
{
|
||||
DWORD itemCount(size());
|
||||
|
||||
if(itemCount!=someGlobalData.size())return FALSE;
|
||||
for(DWORD itemIndex=0;itemIndex<itemCount;itemIndex++)
|
||||
if(!(((GlobalData<T>&)*this).operator[](itemIndex)==((GlobalData<T>&)someGlobalData)[itemIndex]))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
GlobalData<T> &GlobalData<T>::operator=(const GlobalData<T> &someGlobalData)
|
||||
{
|
||||
DWORD itemCount(someGlobalData.size());
|
||||
|
||||
size(someGlobalData.size());
|
||||
if(!size())return *this;
|
||||
for(DWORD itemIndex=0;itemIndex<itemCount;itemIndex++)
|
||||
operator[](itemIndex)=((GlobalData<T>&)someGlobalData)[itemIndex];
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool GlobalData<T>::setZero(void)
|
||||
{
|
||||
if(!isOkay())return false;
|
||||
::memset(mlpGlobalData,0,size()*sizeof(T));
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
7
common/GDIOBJ.HPP
Normal file
7
common/GDIOBJ.HPP
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef _COMMON_GDIOBJ_HPP_
|
||||
#define _COMMON_GDIOBJ_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
typedef HGDIOBJ GDIObj;
|
||||
#endif
|
||||
30
common/GDIPOINT.CPP
Normal file
30
common/GDIPOINT.CPP
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <common/gdipoint.hpp>
|
||||
|
||||
GDIPoint &GDIPoint::operator--(void)
|
||||
{
|
||||
x(x()-1);
|
||||
y(y()-1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
GDIPoint GDIPoint::operator--(int /*prefixDummy*/)
|
||||
{
|
||||
GDIPoint prePoint(*this);
|
||||
--(*this);
|
||||
return prePoint;
|
||||
}
|
||||
|
||||
GDIPoint GDIPoint::operator++(int /*prefixDummy*/)
|
||||
{
|
||||
GDIPoint prePoint(*this);
|
||||
++(*this);
|
||||
return prePoint;
|
||||
}
|
||||
|
||||
GDIPoint GDIPoint::operator+(const GDIPoint &someGDIPoint)const
|
||||
{
|
||||
GDIPoint tmpPoint(*this);
|
||||
tmpPoint+=someGDIPoint;
|
||||
return tmpPoint;
|
||||
}
|
||||
|
||||
149
common/GDIPOINT.HPP
Normal file
149
common/GDIPOINT.HPP
Normal file
@@ -0,0 +1,149 @@
|
||||
#ifndef _COMMON_GDIPOINT_HPP_
|
||||
#define _COMMON_GDIPOINT_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class GDIPoint : private POINT
|
||||
{
|
||||
public:
|
||||
GDIPoint(void);
|
||||
GDIPoint(int x,int y);
|
||||
GDIPoint(const GDIPoint &someGDIPoint);
|
||||
virtual ~GDIPoint();
|
||||
WORD operator==(const GDIPoint &someGDIPoint)const;
|
||||
GDIPoint operator+(const GDIPoint &someGDIPoint)const;
|
||||
GDIPoint &operator=(const GDIPoint &someGDIPoint);
|
||||
GDIPoint &operator-=(const GDIPoint &someGDIPoint);
|
||||
GDIPoint &operator+=(const GDIPoint &someGDIPoint);
|
||||
GDIPoint &operator++(void);
|
||||
GDIPoint operator++(int prefixDummy);
|
||||
GDIPoint &operator--(void);
|
||||
GDIPoint operator--(int prefixDummy);
|
||||
operator POINT&(void);
|
||||
int x(void)const;
|
||||
void x(int newx);
|
||||
int y(void)const;
|
||||
void y(int newy);
|
||||
void setPoint(int newx,int newy);
|
||||
int distance(const GDIPoint &someGDIPoint)const;
|
||||
POINT &getPOINT(void);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
GDIPoint::GDIPoint(void)
|
||||
{
|
||||
POINT::x=0;
|
||||
POINT::y=0;
|
||||
}
|
||||
|
||||
inline
|
||||
GDIPoint::GDIPoint(int x,int y)
|
||||
{
|
||||
POINT::x=x;
|
||||
POINT::y=y;
|
||||
}
|
||||
|
||||
inline
|
||||
GDIPoint::GDIPoint(const GDIPoint &someGDIPoint)
|
||||
{
|
||||
*this=someGDIPoint;
|
||||
}
|
||||
|
||||
inline
|
||||
GDIPoint::~GDIPoint()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
int GDIPoint::x(void)const
|
||||
{
|
||||
return POINT::x;
|
||||
}
|
||||
|
||||
inline
|
||||
void GDIPoint::x(int newx)
|
||||
{
|
||||
POINT::x=newx;
|
||||
}
|
||||
|
||||
inline
|
||||
int GDIPoint::y(void)const
|
||||
{
|
||||
return POINT::y;
|
||||
}
|
||||
|
||||
inline
|
||||
void GDIPoint::y(int newy)
|
||||
{
|
||||
POINT::y=newy;
|
||||
}
|
||||
|
||||
inline
|
||||
void GDIPoint::setPoint(int newx,int newy)
|
||||
{
|
||||
POINT::x=newx;
|
||||
POINT::y=newy;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD GDIPoint::operator==(const GDIPoint &someGDIPoint)const
|
||||
{
|
||||
return (x()==someGDIPoint.x()&&
|
||||
y()==someGDIPoint.y());
|
||||
}
|
||||
|
||||
inline
|
||||
GDIPoint &GDIPoint::operator=(const GDIPoint &someGDIPoint)
|
||||
{
|
||||
x(someGDIPoint.x());
|
||||
y(someGDIPoint.y());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
GDIPoint &GDIPoint::operator-=(const GDIPoint &someGDIPoint)
|
||||
{
|
||||
x(x()-someGDIPoint.x());
|
||||
y(y()-someGDIPoint.y());
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
GDIPoint &GDIPoint::operator+=(const GDIPoint &someGDIPoint)
|
||||
{
|
||||
x(x()+someGDIPoint.x());
|
||||
y(y()+someGDIPoint.y());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
GDIPoint &GDIPoint::operator++(void)
|
||||
{
|
||||
x(x()+1);
|
||||
y(y()+1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
GDIPoint::operator POINT&(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
int GDIPoint::distance(const GDIPoint &someGDIPoint)const
|
||||
{
|
||||
int xDiff(someGDIPoint.x()-x());
|
||||
int yDiff(someGDIPoint.y()-y());
|
||||
return (xDiff*xDiff)+(yDiff*yDiff);
|
||||
}
|
||||
|
||||
inline
|
||||
POINT &GDIPoint::getPOINT(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
4
common/GL.HPP
Normal file
4
common/GL.HPP
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef _COMMON_GL_HPP_
|
||||
#define _COMMON_GL_HPP_
|
||||
#include <gl/gl.h>
|
||||
#endif
|
||||
501
common/GUIWND.CPP
Normal file
501
common/GUIWND.CPP
Normal file
@@ -0,0 +1,501 @@
|
||||
#include <common/guiwnd.hpp>
|
||||
#include <common/commdlg.hpp>
|
||||
#include <common/purehdc.hpp>
|
||||
#include <common/instance.hpp>
|
||||
#include <common/string.hpp>
|
||||
#include <common/rect.hpp>
|
||||
#include <common/point.hpp>
|
||||
#include <common/gdipoint.hpp>
|
||||
#include <common/puremenu.hpp>
|
||||
#include <common/font.hpp>
|
||||
|
||||
GUIWindow::~GUIWindow()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
bool GUIWindow::insertModelessDialog(GUIWindow &modelessDialog)
|
||||
{
|
||||
if(!isValid()||!modelessDialog.isValid())return false;
|
||||
mModelessDialogs.insert(&WindowPointer(&modelessDialog));
|
||||
return true;
|
||||
}
|
||||
|
||||
void GUIWindow::removeModelessDialog(GUIWindow &modelessDialog)
|
||||
{
|
||||
if(!isValid())return;
|
||||
mModelessDialogs.remove(&WindowPointer(&modelessDialog));
|
||||
}
|
||||
|
||||
GUIWindow &GUIWindow::operator=(const GUIWindow &/*someGUIWindow*/)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
GUIWindow &GUIWindow::operator=(HWND /*hWnd*/)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOL GUIWindow::validate(const Rect &validRect)
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::ValidateRect(mhWnd,(RECT*)((Rect&)validRect));
|
||||
}
|
||||
|
||||
WORD GUIWindow::width(void)const
|
||||
{
|
||||
Rect winRect;
|
||||
clientRect(winRect);
|
||||
return winRect.right();
|
||||
}
|
||||
|
||||
WORD GUIWindow::height(void)const
|
||||
{
|
||||
Rect winRect;
|
||||
clientRect(winRect);
|
||||
return winRect.bottom();
|
||||
}
|
||||
|
||||
void GUIWindow::windowRect(Rect &windowRect)const
|
||||
{
|
||||
if(!isValid())return;
|
||||
::GetWindowRect(*this,(RECT FAR*)windowRect);
|
||||
}
|
||||
|
||||
void GUIWindow::clientRect(Rect &clientRect)const
|
||||
{
|
||||
if(!isValid())return;
|
||||
::GetClientRect(*this,(RECT FAR*)clientRect);
|
||||
}
|
||||
|
||||
void GUIWindow::setFont(const Font &someFont,BOOL redraw)const
|
||||
{
|
||||
if(!isValid())return;
|
||||
sendMessage(WM_SETFONT,(WPARAM)(HFONT)someFont,MAKELPARAM(redraw,0));
|
||||
}
|
||||
|
||||
WORD GUIWindow::moveWindow(const Rect &winRect,WORD repaint)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::MoveWindow(mhWnd,winRect.left(),winRect.top(),(winRect.right()-winRect.left())+1,(winRect.bottom()-winRect.top())+1,repaint);
|
||||
}
|
||||
|
||||
WORD GUIWindow::moveWindow(int left,int top,int right,int bottom,WORD repaint)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::MoveWindow(mhWnd,left,top,right,bottom,repaint);
|
||||
}
|
||||
|
||||
void GUIWindow::move(const GDIPoint &topLeftPoint,bool repaint)
|
||||
{
|
||||
move(Point(topLeftPoint.x(),topLeftPoint.y()),repaint);
|
||||
}
|
||||
|
||||
void GUIWindow::move(const Point &topLeftPoint,bool repaint)
|
||||
{
|
||||
RECT windowRect;
|
||||
|
||||
if(!(HWND)*this)return;
|
||||
::GetWindowRect(*this,&windowRect);
|
||||
WORD windowWidth((windowRect.right-windowRect.left));
|
||||
WORD windowHeight((windowRect.bottom-windowRect.top));
|
||||
::MoveWindow(*this,topLeftPoint.x(),topLeftPoint.y(),windowWidth,windowHeight,TRUE);
|
||||
if(repaint)::UpdateWindow(*this);
|
||||
}
|
||||
|
||||
void GUIWindow::size(const Point &dimensionPoint)
|
||||
{
|
||||
Rect windowRect;
|
||||
|
||||
if(!isValid())return;
|
||||
::GetWindowRect(*this,(RECT FAR *)windowRect);
|
||||
::MoveWindow(*this,windowRect.left(),windowRect.top(),dimensionPoint.x(),dimensionPoint.y(),FALSE);
|
||||
}
|
||||
|
||||
BOOL GUIWindow::setCaption(const String &captionString)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::SetWindowText(*this,(LPSTR)captionString);
|
||||
}
|
||||
|
||||
BOOL GUIWindow::setWindowPos(const GDIPoint &startPos,int width,int height)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::SetWindowPos(*this,HWND_BOTTOM,startPos.x(),startPos.y(),width,height,SWP_NOZORDER);
|
||||
}
|
||||
|
||||
int GUIWindow::windowText(String &strText)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
strText.reserve(String::MaxString*2);
|
||||
return ::GetWindowText(*this,strText,String::MaxString*2);
|
||||
}
|
||||
|
||||
WORD GUIWindow::clientToScreen(Rect &clientRect)const
|
||||
{
|
||||
GDIPoint screenPoint;
|
||||
|
||||
if(!isValid())return FALSE;
|
||||
screenPoint.x(clientRect.left());
|
||||
screenPoint.y(clientRect.top());
|
||||
::ClientToScreen(mhWnd,&((POINT&)screenPoint));
|
||||
clientRect.left(screenPoint.x());
|
||||
clientRect.top(screenPoint.y());
|
||||
screenPoint.x(clientRect.right());
|
||||
screenPoint.y(clientRect.bottom());
|
||||
::ClientToScreen(mhWnd,&((POINT&)screenPoint));
|
||||
clientRect.right(screenPoint.x());
|
||||
clientRect.bottom(screenPoint.y());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD GUIWindow::screenToClient(Rect &clientRect)const
|
||||
{
|
||||
GDIPoint screenPoint;
|
||||
|
||||
if(!isValid())return FALSE;
|
||||
screenPoint.x(clientRect.left());
|
||||
screenPoint.y(clientRect.top());
|
||||
::ScreenToClient(mhWnd,&((POINT&)screenPoint));
|
||||
clientRect.left(screenPoint.x());
|
||||
clientRect.top(screenPoint.y());
|
||||
screenPoint.x(clientRect.right());
|
||||
screenPoint.y(clientRect.bottom());
|
||||
::ScreenToClient(mhWnd,&((POINT&)screenPoint));
|
||||
clientRect.right(screenPoint.x());
|
||||
clientRect.bottom(screenPoint.y());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL GUIWindow::screenToClient(GDIPoint &somePoint)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::ScreenToClient(mhWnd,&((POINT&)somePoint));
|
||||
}
|
||||
|
||||
BOOL GUIWindow::clientToScreen(GDIPoint &somePoint)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::ClientToScreen(mhWnd,&((POINT&)somePoint));
|
||||
}
|
||||
|
||||
WORD GUIWindow::killTimer(WORD timerIdentifier)
|
||||
{
|
||||
if(!isValidHandler(VectorHandler::TimerHandler,timerIdentifier))return FALSE;
|
||||
::KillTimer((HWND)*this,timerIdentifier);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void GUIWindow::destroy(void)
|
||||
{
|
||||
if(!isValid())return;
|
||||
if(disposition()&Destroy)::DestroyWindow((HWND)*this);
|
||||
setHandle(0);
|
||||
}
|
||||
|
||||
void GUIWindow::postQuitMessage(int exitCode)const
|
||||
{
|
||||
::PostQuitMessage(exitCode);
|
||||
}
|
||||
|
||||
void GUIWindow::yieldTask(void)const
|
||||
{
|
||||
bool isDialogMessage;
|
||||
MSG msg;
|
||||
|
||||
if(::PeekMessage(&msg,0,0,0,PM_REMOVE))
|
||||
{
|
||||
isDialogMessage=false;
|
||||
for(int mindex=0;mindex<mModelessDialogs.size()&&!isDialogMessage;mindex++)
|
||||
if(::IsDialogMessage(*((((GUIWindow&)*this).mModelessDialogs)[mindex]),&msg))
|
||||
isDialogMessage=true;
|
||||
if(!isDialogMessage)
|
||||
{
|
||||
if(mAccelerator.isOkay()&&mAccelerator.translate(*this,msg))
|
||||
{
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int GUIWindow::messageLoop(void)const
|
||||
{
|
||||
bool isDialogMessage;
|
||||
MSG msg;
|
||||
|
||||
while(::GetMessage(&msg,NULL,0,0))
|
||||
{
|
||||
isDialogMessage=false;
|
||||
for(int mindex=0;mindex<mModelessDialogs.size()&&!isDialogMessage;mindex++)
|
||||
if(::IsDialogMessage(*((((GUIWindow&)*this).mModelessDialogs)[mindex]),&msg))isDialogMessage=true;
|
||||
if(isDialogMessage)continue;
|
||||
if(!mAccelerator.translateMDISysAccelerator(*this,msg)&&!mAccelerator.translate(*this,msg))
|
||||
{
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LONG GUIWindow::handlePaintMessage(HWND hWnd,WORD /*message*/,WPARAM wParam,LPARAM /*lParam*/)
|
||||
{
|
||||
PAINTSTRUCT paintStruct;
|
||||
LONG returnCode;
|
||||
|
||||
::BeginPaint(hWnd,(PAINTSTRUCT FAR *)&paintStruct);
|
||||
PaintInformation *lpPaintInformation=new PaintInformation(PureDevice(paintStruct.hdc));
|
||||
(PAINTSTRUCT&)*lpPaintInformation=paintStruct;
|
||||
returnCode=callHandlers(VectorHandler::PaintHandler,CallbackData(wParam,(LPARAM)(LONG)lpPaintInformation));
|
||||
delete lpPaintInformation;
|
||||
::EndPaint(hWnd,(PAINTSTRUCT FAR*)&paintStruct);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
HWND GUIWindow::findWindow(const String &strWindowName)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::FindWindowEx(mhWnd,0,0,(char*)(String&)strWindowName);
|
||||
}
|
||||
|
||||
HWND GUIWindow::createWindow(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParentWnd,HMENU hMenu,HINSTANCE hInstance,void FAR *lpInstanceData)
|
||||
{
|
||||
destroy();
|
||||
if(!hInstance)hInstance=processInstance();
|
||||
mhWnd=::CreateWindow((LPSTR)className,(LPSTR)windowName,dwStyle,initRect.left(),initRect.top(),
|
||||
initRect.right(),initRect.bottom(),hParentWnd,hMenu,hInstance,lpInstanceData);
|
||||
return mhWnd;
|
||||
}
|
||||
|
||||
HWND GUIWindow::createWindow(DWORD dwExStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,HWND hParentWnd,HMENU hMenu,HINSTANCE hInstance,void FAR *lpInstanceData)
|
||||
{
|
||||
destroy();
|
||||
if(!hInstance)hInstance=processInstance();
|
||||
mhWnd=::CreateWindowEx(dwExStyle,(LPSTR)className,(LPSTR)windowName,dwStyle,initRect.left(),initRect.top(),initRect.right(),initRect.bottom(),hParentWnd,hMenu,hInstance,lpInstanceData);
|
||||
return mhWnd;
|
||||
}
|
||||
|
||||
LRESULT GUIWindow::postMessage(HWND hPostWindow,UINT message,WPARAM wParam,LPARAM lParam)const
|
||||
{
|
||||
if(HWND_BROADCAST!=hPostWindow&&!::IsWindow(hPostWindow))return FALSE;
|
||||
return ::PostMessage(hPostWindow,message,wParam,lParam);
|
||||
}
|
||||
|
||||
LRESULT GUIWindow::sendMessage(HWND hPostWindow,UINT message,WPARAM wParam,LPARAM lParam)const
|
||||
{
|
||||
if(HWND_BROADCAST!=hPostWindow&&!::IsWindow(hPostWindow))return FALSE;
|
||||
return ::SendMessage(hPostWindow,message,wParam,lParam);
|
||||
}
|
||||
|
||||
LRESULT GUIWindow::sendMessage(UINT message,WPARAM wParam,LPARAM lParam)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return sendMessage(mhWnd,message,wParam,lParam);
|
||||
}
|
||||
|
||||
BOOL GUIWindow::setMenu(const PureMenu &somePureMenu)const
|
||||
{
|
||||
if(!isValid()||!somePureMenu.isOkay())return FALSE;
|
||||
return ::SetMenu(mhWnd,(HMENU)somePureMenu);
|
||||
}
|
||||
|
||||
BOOL GUIWindow::setIcon(const String &strIcon)
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return (::SetClassLong(mhWnd,GCL_HICON,(LPARAM)::LoadIcon(processInstance(),(LPSTR)(String&)strIcon))?TRUE:FALSE);
|
||||
}
|
||||
|
||||
BOOL GUIWindow::drawMenuBar(void)const
|
||||
{
|
||||
if(!isValid())return FALSE;
|
||||
return ::DrawMenuBar(mhWnd);
|
||||
}
|
||||
|
||||
String GUIWindow::getClassName(void)const
|
||||
{
|
||||
String strClassName;
|
||||
if(!isValid())return strClassName;
|
||||
::GetClassName(mhWnd,strClassName.str(),String::MaxString);
|
||||
return strClassName;
|
||||
}
|
||||
|
||||
#if defined(__FLAT__)
|
||||
HINSTANCE GUIWindow::processInstance(void)const
|
||||
{
|
||||
if(!isValid())return ::GetModuleHandle(0);
|
||||
return (HINSTANCE)::GetWindowLong(mhWnd,GWL_HINSTANCE);
|
||||
}
|
||||
#else
|
||||
HINSTANCE GUIWindow::processInstance(void)const
|
||||
{
|
||||
if(!isValid())return (HINSTANCE)0;
|
||||
return (HINSTANCE)::GetWindowWord(mhWnd,GWW_HINSTANCE);
|
||||
}
|
||||
#endif
|
||||
|
||||
// *** virtuals
|
||||
|
||||
int GUIWindow::windowProcedure(HWND /*hWnd*/,WORD /*message*/,WPARAM /*wParam*/,LPARAM /*lParam*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// *** statics
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
long FAR PASCAL GUIWindow::WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#else
|
||||
long FAR PASCAL _export GUIWindow::WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#endif
|
||||
{
|
||||
GUIWindow FAR *lpGUIWindow=(GUIWindow FAR*)InstanceData::getInstanceData(hWnd);
|
||||
if(0==lpGUIWindow)
|
||||
{
|
||||
if(WM_NCCREATE==message)
|
||||
{
|
||||
::DefWindowProc(hWnd,message,wParam,lParam);
|
||||
LPCREATESTRUCT lpcs((LPCREATESTRUCT)lParam);
|
||||
lpGUIWindow=(GUIWindow *)lpcs->lpCreateParams;
|
||||
if(!lpGUIWindow)return ::DefWindowProc(hWnd,message,wParam,lParam);
|
||||
InstanceData::setInstanceData(hWnd,(void FAR*)lpGUIWindow);
|
||||
lpGUIWindow->setHandle(hWnd);
|
||||
lpGUIWindow->disposition(Destroy);
|
||||
return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
}
|
||||
else if(WM_INITDIALOG==message)
|
||||
{
|
||||
lpGUIWindow=(GUIWindow*)lParam;
|
||||
if(!lpGUIWindow)return FALSE;
|
||||
InstanceData::setInstanceData(hWnd,(void FAR*)lpGUIWindow);
|
||||
lpGUIWindow->setHandle(hWnd);
|
||||
lpGUIWindow->disposition(Destroy);
|
||||
return (int)lpGUIWindow->callHandlers(VectorHandler::InitDialogHandler,CallbackData(wParam,lParam,hWnd));
|
||||
}
|
||||
else if(WM_NCDESTROY==message)return ::DefWindowProc(hWnd,message,wParam,lParam);
|
||||
else return ::DefWindowProc(hWnd,message,wParam,lParam);
|
||||
}
|
||||
switch(message)
|
||||
{
|
||||
case WM_CREATE :
|
||||
{
|
||||
Rect sizeRect;
|
||||
lpGUIWindow->clientRect(sizeRect);
|
||||
}
|
||||
break;
|
||||
case WM_SIZE :
|
||||
break;
|
||||
}
|
||||
return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
int FAR PASCAL GUIWindow::DlgProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#else
|
||||
int FAR PASCAL _export GUIWindow::DlgProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#endif
|
||||
{
|
||||
GUIWindow *lpGUIWindow=(GUIWindow*)InstanceData::getInstanceData(hWnd);
|
||||
if(0==lpGUIWindow)
|
||||
{
|
||||
if(WM_INITDIALOG==message)
|
||||
{
|
||||
lpGUIWindow=(GUIWindow*)lParam;
|
||||
if(!lpGUIWindow)return FALSE;
|
||||
InstanceData::setInstanceData(hWnd,(void FAR*)lpGUIWindow);
|
||||
lpGUIWindow->setHandle(hWnd);
|
||||
lpGUIWindow->disposition(Destroy);
|
||||
return (int)lpGUIWindow->callHandlers(VectorHandler::InitDialogHandler,CallbackData(wParam,lParam,hWnd));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
UINT FAR PASCAL GUIWindow::OFHookProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#else
|
||||
UINT FAR PASCAL _export GUIWindow::OFHookProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#endif
|
||||
{
|
||||
GUIWindow *lpGUIWindow=(GUIWindow*)InstanceData::getInstanceData(hWnd);
|
||||
if(0==lpGUIWindow)
|
||||
{
|
||||
if(WM_INITDIALOG==message)
|
||||
{
|
||||
OPENFILENAME *lpOPENFILENAME=(OPENFILENAME*)lParam;
|
||||
if(!lpOPENFILENAME)return FALSE;
|
||||
lpGUIWindow=(GUIWindow*)lpOPENFILENAME->lCustData;
|
||||
if(!lpGUIWindow)return FALSE;
|
||||
InstanceData::setInstanceData(hWnd,(void FAR*)lpGUIWindow);
|
||||
lpGUIWindow->setHandle(hWnd);
|
||||
lpGUIWindow->disposition(Destroy);
|
||||
return (int)lpGUIWindow->callHandlers(VectorHandler::InitDialogHandler,CallbackData(wParam,lParam,hWnd));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
LONG FAR PASCAL GUIWindow::FrameProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#else
|
||||
LONG FAR PASCAL _export GUIWindow::FrameProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#endif
|
||||
{
|
||||
GUIWindow *lpGUIWindow=(GUIWindow*)InstanceData::getInstanceData(hWnd);
|
||||
if(lpGUIWindow==0)
|
||||
{
|
||||
if(WM_CREATE==message)
|
||||
{
|
||||
::DefFrameProc(hWnd,(HWND)0,message,wParam,lParam);
|
||||
LPCREATESTRUCT lpcs=(LPCREATESTRUCT)lParam;
|
||||
lpGUIWindow=(GUIWindow *)lpcs->lpCreateParams;
|
||||
InstanceData::setInstanceData(hWnd,(void FAR*)lpGUIWindow);
|
||||
lpGUIWindow->setHandle(hWnd);
|
||||
lpGUIWindow->disposition(Destroy);
|
||||
return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
}
|
||||
else if(WM_CREATE==message)return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
else return ::DefFrameProc(hWnd,(HWND)0,message,wParam,lParam);
|
||||
}
|
||||
else return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
LONG FAR PASCAL GUIWindow::MDIProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#else
|
||||
LONG FAR PASCAL _export GUIWindow::MDIProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
|
||||
#endif
|
||||
{
|
||||
GUIWindow *lpGUIWindow=(GUIWindow*)InstanceData::getInstanceData(hWnd);
|
||||
|
||||
if(lpGUIWindow==0)
|
||||
{
|
||||
if(WM_NCCREATE==message)
|
||||
{
|
||||
::DefMDIChildProc(hWnd,message,wParam,lParam);
|
||||
LPCREATESTRUCT lpcs=(LPCREATESTRUCT)lParam;
|
||||
LPMDICREATESTRUCT lpcm=(LPMDICREATESTRUCT)lpcs->lpCreateParams;
|
||||
lpGUIWindow=(GUIWindow *)lpcm->lParam;
|
||||
if(!lpGUIWindow)return FALSE;
|
||||
InstanceData::setInstanceData(hWnd,(void FAR*)lpGUIWindow);
|
||||
lpGUIWindow->setHandle(hWnd);
|
||||
lpGUIWindow->disposition(Destroy);
|
||||
return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
}
|
||||
else if(WM_CREATE==message)return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
else return ::DefMDIChildProc(hWnd,message,wParam,lParam);
|
||||
}
|
||||
else return lpGUIWindow->windowProcedure(hWnd,message,wParam,lParam);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user