/*****************************************************************************/
/* SOURCE FILE */
/*****************************************************************************/
/*
$Archive: $
$Revision: $
Last Checkin:
$Date: $
By:
$Author: $
Last Modification:
$ModTime: $
Description: Implementation of the XML Style decoder methods.
TOOL And XML FORMS License
==========================
Except where otherwise noted, all of the documentation
and software included in the TOOL package is
copyrighted by Michael Swartzendruber.
Copyright (C) 2005 Michael John Swartzendruber.
All rights reserved.
Access to this code, whether intentional or accidental,
does NOT IMPLY any transfer of rights.
This software is provided "as-is," without any express
or implied warranty. In no event shall the author be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for
any purpose, including commercial applications, and to
alter and redistribute it, provided that the following
conditions are met:
1. All redistributions of source code files must retain
all copyright notices that are currently in place,
and this list of conditions without modification.
2. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
3. If you use this software in another product, an acknowledgment
in the product documentation would be appreciated but is
not required.
4. Modified versions in source or binary form must be plainly
marked as such, and must not be misrepresented as being
the original software.
*/
static char OBJECT_ID[] = "$Revision: $ : $JustDate: $";
/*****************************************************************************/
#include "stdafx.h"
#include "XMLFormBMPImage.h"
#include "XMLStyleDecoder.h"
#pragma warning( disable : 4786 )
/*****************************************************************************/
/*
FUNCTION NAME: CXMLStyleDecoder::DecodeFrameStyle
DESCRIPTION: decodes a string containing frame style and converts it
into a style value
INPUT: oStyle - string containing style info
OUTPUT: none
RETURNS: DWORD value for style string
*/
DWORD CXMLStyleDecoder::DecodeFrameStyle( std::string oStyle )
{
bool bIsNumericAlready = true;
const char* pchIsDigits = oStyle.c_str();
for ( unsigned int iDigitCheckLoop = 0; iDigitCheckLoop < strlen( pchIsDigits ); iDigitCheckLoop++ ) // 2b|!2b==?
{
if ( !isdigit( *( pchIsDigits + iDigitCheckLoop ) ) )
{
bIsNumericAlready = false;
break;
}
}
if ( bIsNumericAlready )
{
return atol( pchIsDigits );
}
// controls and frames share some common style values, so get common values
// first
//
DWORD dwResult = DecodeCtrlStyle( oStyle );
// get style string into a buffer and up case it
//
char* pchStyle = const_cast<char*>( oStyle.c_str() );
int iLength = strlen( pchStyle );
for ( int iLoop = 0; iLoop < iLength; iLoop++ )
{
*( pchStyle + iLoop ) = toupper( *( pchStyle + iLoop ) );
}
// now search the style string for each supported style
//
if ( NULL != strstr( pchStyle, ccWS_DLGFRAME ) )
{
dwResult |= WS_DLGFRAME;
}
if ( NULL != strstr( pchStyle, ccWS_MAXIMIZEBOX ) )
{
dwResult |= WS_MAXIMIZEBOX;
}
if ( NULL != strstr( pchStyle, ccWS_MINIMIZEBOX ) )
{
dwResult |= WS_MINIMIZEBOX;
}
if ( NULL != strstr( pchStyle, ccWS_SYSMENU ) )
{
dwResult |= WS_SYSMENU;
}
if ( NULL != strstr( pchStyle, ccWS_CAPTION ) )
{
dwResult |= WS_CAPTION;
}
if ( NULL != strstr( pchStyle, ccWS_MAXIMIZE ) )
{
dwResult |= WS_MAXIMIZE;
}
if ( NULL != strstr( pchStyle, ccWS_MINIMIZE ) )
{
dwResult |= WS_MINIMIZE;
}
return dwResult;
}
/* End of function "CXMLStyleDecoder::DecodeFrameStyle"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: CXMLStyleDecoder::DecodeCtrlStyle
DESCRIPTION: decodes a string containing control style and converts it
into a style value
INPUT: oStyle - string containing style info
OUTPUT: none
RETURNS: DWORD value for style string
*/
DWORD CXMLStyleDecoder::DecodeCtrlStyle( std::string oStyle, P_FORM_CONTROL pxCtrl )
{
bool bIsNumericAlready = true;
const char* pchIsDigits = oStyle.c_str();
for ( unsigned int iDigitCheckLoop = 0; iDigitCheckLoop < strlen( pchIsDigits ); iDigitCheckLoop++ ) // 2b|!2b==?
{
if ( !isdigit( *( pchIsDigits + iDigitCheckLoop ) ) )
{
bIsNumericAlready = false;
break;
}
}
if ( bIsNumericAlready )
{
return atol( pchIsDigits );
}
// these styles are stamped on all frames/ctrls created
//
DWORD dwResult = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
// get style string into a buffer and up case it
//
char* pchStyle = const_cast<char*>( oStyle.c_str() );
int iLength = strlen( pchStyle );
for ( int iLoop = 0; iLoop < iLength; iLoop++ )
{
*( pchStyle + iLoop ) = toupper( *( pchStyle + iLoop ) );
}
// now search the style string for each supported style
//
if ( NULL != strstr( pchStyle, ccWS_HSCROLL ) )
{
dwResult |= WS_HSCROLL;
}
if ( NULL != strstr( pchStyle, ccWS_VSCROLL ) )
{
dwResult |= WS_VSCROLL;
}
if ( NULL != pxCtrl )
{
switch( pxCtrl->m_eCtrlType )
{
case eImage:
{
dwResult = XMLFORM_IMAGE_AUTODELETE + XMLFORM_IMAGE_STRETCHED + XMLFORM_IMAGE_CENTERED;
}
break;
case eButton:
case eRadioButton:
case eCheckBox:
case eColorPicker:
{
//
// decode any button control styles in the style string
//
if ( NULL != strstr( pchStyle, ccBS_AUTOCHECKBOX ) )
{
dwResult |= BS_AUTOCHECKBOX;
}
if ( NULL != strstr( pchStyle, ccBS_CHECKBOX ) )
{
// promote check box to auto check box
//
dwResult |= BS_AUTOCHECKBOX;
}
if ( NULL != strstr( pchStyle, ccBS_AUTORADIOBUTTON ) )
{
dwResult |= BS_AUTORADIOBUTTON;
}
if ( NULL != strstr( pchStyle, ccBS_RADIOBUTTON ) )
{
// promote radio button to auto radio button
//
dwResult |= BS_AUTORADIOBUTTON;
}
if ( NULL != strstr( pchStyle, ccBS_GROUPBOX ) )
{
dwResult |= BS_GROUPBOX;
}
if ( NULL != strstr( pchStyle, ccBS_PUSHBUTTON ) )
{
dwResult |= BS_PUSHBUTTON;
}
if ( NULL != strstr( pchStyle, ccBS_DEFPUSHBUTTON ) )
{
dwResult &= ~BS_PUSHBUTTON;
dwResult |= BS_DEFPUSHBUTTON;
}
// the following are specialized owner drawn buttons
// that are supported in xml forms
//
if ( eColorPicker == pxCtrl->m_eCtrlType )
{
dwResult |= BS_OWNERDRAW;
}
}
break;
case eCardTrackDataCtrl:
case eEditCtrl:
{
//
// decode any edit control styles in the style string
//
if ( NULL != strstr( pchStyle, ccES_AUTOHSCROLL ) )
{
dwResult |= ES_AUTOHSCROLL;
}
if ( NULL != strstr( pchStyle, ccES_AUTOVSCROLL ) )
{
dwResult |= ES_AUTOVSCROLL;
}
if ( NULL != strstr( pchStyle, ccES_CENTER ) )
{
dwResult &= ~( ES_LEFT | ES_RIGHT );
dwResult |= ES_CENTER;
}
if ( NULL != strstr( pchStyle, ccES_LEFT ) )
{
dwResult &= ~( ES_CENTER | ES_RIGHT );
dwResult |= ES_LEFT;
}
if ( NULL != strstr( pchStyle, ccES_RIGHT ) )
{
dwResult &= ~( ES_CENTER | ES_LEFT );
dwResult |= ES_RIGHT;
}
if ( NULL != strstr( pchStyle, ccES_LOWERCASE ) )
{
dwResult &= ~ES_UPPERCASE;
dwResult |= ES_LOWERCASE;
}
if ( NULL != strstr( pchStyle, ccES_UPPERCASE ) )
{
dwResult &= ~ES_LOWERCASE;
dwResult |= ES_UPPERCASE;
}
if ( NULL != strstr( pchStyle, ccES_MULTILINE ) )
{
dwResult |= ES_MULTILINE;
}
if ( NULL != strstr( pchStyle, ccES_NOHIDESEL ) )
{
dwResult |= ES_NOHIDESEL;
}
if ( NULL != strstr( pchStyle, ccES_OEMCONVERT ) )
{
dwResult |= ES_OEMCONVERT;
}
if ( NULL != strstr( pchStyle, ccES_PASSWORD ) )
{
dwResult |= ES_PASSWORD;
}
if ( NULL != strstr( pchStyle, ccES_READONLY ) )
{
dwResult |= ES_READONLY;
}
if ( NULL != strstr( pchStyle, ccES_WANTRETURN ) )
{
dwResult |= ES_WANTRETURN;
}
// stamp these styles on all card swipe controls
//
if ( pxCtrl->m_eCtrlType == eCardTrackDataCtrl )
{
dwResult |= ES_READONLY;
dwResult |= ES_WANTRETURN;
}
}
break;
case eStaticText:
{
//
// decode any static control styles in the style string
//
if ( NULL != strstr( pchStyle, ccSS_BLACKFRAME ) )
{
dwResult &= ~( SS_GRAYFRAME | SS_WHITEFRAME );
dwResult |= SS_BLACKFRAME;
}
if ( NULL != strstr( pchStyle, ccSS_WHITEFRAME ) )
{
dwResult &= ~( SS_GRAYFRAME | SS_BLACKFRAME );
dwResult |= SS_WHITEFRAME;
}
if ( NULL != strstr( pchStyle, ccSS_GRAYFRAME ) )
{
dwResult &= ~( SS_WHITEFRAME | SS_BLACKFRAME );
dwResult |= SS_GRAYFRAME;
}
if ( NULL != strstr( pchStyle, ccSS_BLACKRECT ) )
{
dwResult &= ~( SS_GRAYRECT | SS_WHITERECT );
dwResult |= SS_BLACKRECT;
}
if ( NULL != strstr( pchStyle, ccSS_WHITERECT ) )
{
dwResult &= ~( SS_GRAYRECT | SS_BLACKRECT );
dwResult |= SS_WHITERECT;
}
if ( NULL != strstr( pchStyle, ccSS_GRAYRECT ) )
{
dwResult &= ~( SS_WHITERECT | SS_BLACKRECT );
dwResult |= SS_GRAYRECT;
}
if ( NULL != strstr( pchStyle, ccSS_CENTER ) )
{
dwResult &= ~( SS_RIGHT | SS_LEFT );
dwResult |= SS_CENTER;
}
if ( NULL != strstr( pchStyle, ccSS_LEFT ) )
{
dwResult &= ~( SS_RIGHT | SS_CENTER );
dwResult |= SS_LEFT;
}
if ( NULL != strstr( pchStyle, ccSS_RIGHT ) )
{
dwResult &= ~( SS_CENTER | SS_LEFT );
dwResult |= SS_RIGHT;
}
if ( NULL != strstr( pchStyle, ccSS_LEFTNOWORDWRAP ) )
{
dwResult |= SS_LEFTNOWORDWRAP;
}
if ( NULL != strstr( pchStyle, ccSS_LEFTNOWORDWRAP ) )
{
dwResult |= SS_LEFTNOWORDWRAP;
}
if ( NULL != strstr( pchStyle, ccSS_SIMPLE ) )
{
dwResult |= SS_SIMPLE;
}
}
break;
case eListBox:
{
if ( NULL != strstr( pchStyle, ccLBS_HASSTRINGS ) )
{
dwResult |= LBS_HASSTRINGS;
}
if ( NULL != strstr( pchStyle, ccLBS_MULTIPLESEL ) )
{
dwResult |= LBS_MULTIPLESEL;
}
if ( NULL != strstr( pchStyle, ccLBS_NOINTEGRALHEIGHT ) )
{
dwResult |= LBS_NOINTEGRALHEIGHT;
}
if ( NULL != strstr( pchStyle, ccLBS_SORT ) )
{
dwResult |= LBS_SORT;
}
if ( NULL != strstr( pchStyle, ccLBS_STANDARD ) )
{
dwResult |= LBS_STANDARD;
}
if ( NULL != strstr( pchStyle, ccLBS_DISABLENOSCROLL ) )
{
dwResult |= LBS_DISABLENOSCROLL;
}
}
break;
case eTreeCtrl:
{
//
// decode any tree control styles in the style string
//
if ( NULL != strstr( pchStyle, ccTVS_HASLINES ) )
{
dwResult |= TVS_HASLINES;
}
if ( NULL != strstr( pchStyle, ccTVS_LINESATROOT ) )
{
dwResult |= TVS_HASLINES | TVS_LINESATROOT;
}
if ( NULL != strstr( pchStyle, ccTVS_HASBUTTONS ) )
{
dwResult |= TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS;
}
if ( NULL != strstr( pchStyle, ccTVS_SHOWSELALWAYS ) )
{
dwResult |= TVS_SHOWSELALWAYS;
}
if ( NULL != strstr( pchStyle, ccTVS_SINGLEEXPAND ) )
{
dwResult |= TVS_SINGLEEXPAND;
}
}
break;
case eListCtrl:
{
if ( NULL != strstr( pchStyle, ccLVS_LIST ) )
{
dwResult &= ~LVS_REPORT;
dwResult |= LVS_LIST;
}
if ( NULL != strstr( pchStyle, ccLVS_REPORT ) )
{
dwResult &= ~LVS_LIST;
dwResult |= LVS_REPORT;
}
if ( NULL != strstr( pchStyle, ccLVS_NOCOLUMNHEADER ) )
{
dwResult |= LVS_NOCOLUMNHEADER;
}
if ( NULL != strstr( pchStyle, ccLVS_NOSORTHEADER ) )
{
dwResult |= LVS_NOSORTHEADER;
}
if ( NULL != strstr( pchStyle, ccLVS_SHOWSELALWAYS ) )
{
dwResult |= LVS_SHOWSELALWAYS;
}
if ( NULL != strstr( pchStyle, ccLVS_SINGLESEL ) )
{
dwResult |= LVS_SINGLESEL;
}
if ( NULL != strstr( pchStyle, ccLVS_SORTASCENDING ) )
{
dwResult &= ~LVS_SORTDESCENDING;
dwResult |= LVS_SORTASCENDING;
}
if ( NULL != strstr( pchStyle, ccLVS_SORTDESCENDING ) )
{
dwResult &= ~LVS_SORTASCENDING;
dwResult |= LVS_SORTDESCENDING;
}
}
break;
case eSlideCtrl:
{
if ( NULL != strstr( pchStyle, ccTBS_HORZ ) )
{
dwResult &= ~TBS_VERT;
dwResult |= TBS_HORZ;
}
if ( NULL != strstr( pchStyle, ccTBS_VERT ) )
{
dwResult &= ~TBS_HORZ;
dwResult |= TBS_VERT;
}
if ( NULL != strstr( pchStyle, ccTBS_AUTOTICKS ) )
{
dwResult &= ~TBS_NOTICKS;
dwResult |= TBS_AUTOTICKS;
}
if ( NULL != strstr( pchStyle, ccTBS_NOTICKS ) )
{
dwResult &= ~TBS_AUTOTICKS;
dwResult |= TBS_NOTICKS;
}
if ( NULL != strstr( pchStyle, ccTBS_BOTTOM ) )
{
dwResult &= ~( TBS_TOP | TBS_LEFT | TBS_RIGHT );
dwResult |= TBS_BOTTOM;
}
if ( NULL != strstr( pchStyle, ccTBS_TOP ) )
{
dwResult &= ~( TBS_BOTTOM | TBS_LEFT | TBS_RIGHT );
dwResult |= TBS_TOP;
}
if ( NULL != strstr( pchStyle, ccTBS_RIGHT ) )
{
dwResult &= ~( TBS_LEFT | TBS_TOP | TBS_BOTTOM );
dwResult |= TBS_RIGHT;
}
if ( NULL != strstr( pchStyle, ccTBS_LEFT ) )
{
dwResult &= ~( TBS_RIGHT | TBS_TOP | TBS_BOTTOM );
dwResult |= TBS_LEFT;
}
if ( NULL != strstr( pchStyle, ccTBS_BOTH ) )
{
dwResult &= ~( TBS_LEFT | TBS_RIGHT | TBS_TOP | TBS_BOTTOM );
dwResult |= TBS_BOTH;
}
if ( NULL != strstr( pchStyle, ccTBS_ENABLESELRANGE ) )
{
dwResult |= TBS_ENABLESELRANGE;
}
}
break;
case eSpinButton:
{
if ( NULL != strstr( pchStyle, ccUDS_HORZ ) )
{
dwResult |= UDS_HORZ;
}
if ( NULL != strstr( pchStyle, ccUDS_ALIGNLEFT ) )
{
dwResult &= ~UDS_ALIGNRIGHT;
dwResult |= UDS_ALIGNLEFT;
}
if ( NULL != strstr( pchStyle, ccUDS_ALIGNRIGHT ) )
{
dwResult &= ~UDS_ALIGNLEFT;
dwResult |= UDS_ALIGNRIGHT;
}
if ( NULL != strstr( pchStyle, ccUDS_SETBUDDYINT ) )
{
dwResult |= UDS_SETBUDDYINT;
}
if ( NULL != strstr( pchStyle, ccUDS_NOTHOUSANDS ) )
{
dwResult |= UDS_NOTHOUSANDS;
}
if ( NULL != strstr( pchStyle, ccUDS_NOTHOUSANDS ) )
{
dwResult |= UDS_NOTHOUSANDS;
}
if ( NULL != strstr( pchStyle, ccUDS_WRAP ) )
{
dwResult |= UDS_WRAP;
}
if ( NULL != strstr( pchStyle, ccUDS_ARROWKEYS ) )
{
dwResult |= UDS_ARROWKEYS;
}
}
break;
case eDateTimePicker:
{
}
break;
case eMonthCalender:
{
}
break;
}
}
return dwResult;
}
/* End of function "CXMLStyleDecoder::DecodeCtrlStyle"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: CXMLStyleDecoder::DecodeFrameExStyle
DESCRIPTION: decodes a string containing frame's ex-style and converts it
into a style value
INPUT: oStyle - string containing style info
OUTPUT: none
RETURNS: DWORD value for style string
*/
DWORD CXMLStyleDecoder::DecodeFrameExStyle( std::string oStyle )
{
bool bIsNumericAlready = true;
const char* pchIsDigits = oStyle.c_str();
for ( unsigned int iDigitCheckLoop = 0; iDigitCheckLoop < strlen( pchIsDigits ); iDigitCheckLoop++ ) // 2b|!2b==?
{
if ( !isdigit( *( pchIsDigits + iDigitCheckLoop ) ) )
{
bIsNumericAlready = false;
break;
}
}
if ( bIsNumericAlready )
{
return atol( pchIsDigits );
}
// controls and frames share some common style values, so get common values
// first
//
DWORD dwResult = DecodeCtrlExStyle( oStyle );
// get style string into a buffer and up case it
//
char* pchStyle = const_cast<char*>( oStyle.c_str() );
int iLength = strlen( pchStyle );
for ( int iLoop = 0; iLoop < iLength; iLoop++ )
{
*( pchStyle + iLoop ) = toupper( *( pchStyle + iLoop ) );
}
// now search the style string for each supported style
// since windows docs says that they don't like WS_EX_STATICEDGE
// for input fields, that value is only supported for frames....
// sorry, take it up with bill and friends
//
if ( NULL != strstr( pchStyle, ccWS_EX_STATICEDGE ) )
{
dwResult |= WS_EX_STATICEDGE;
}
// these ex style values are applied against all frames
//
dwResult |= WS_EX_CONTROLPARENT | WS_EX_DLGMODALFRAME | WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
return dwResult;
}
/* End of function "CXMLStyleDecoder::DecodeFrameExStyle"
/*****************************************************************************/
/*****************************************************************************/
/*
FUNCTION NAME: CXMLStyleDecoder::DecodeCtrlExStyle
DESCRIPTION: decodes a string containing ctrl's ex-style and converts it
into a style value
INPUT: oStyle - string containing style info
OUTPUT: none
RETURNS: DWORD value for style string
*/
DWORD CXMLStyleDecoder::DecodeCtrlExStyle( std::string oStyle )
{
bool bIsNumericAlready = true;
const char* pchIsDigits = oStyle.c_str();
for ( unsigned int iDigitCheckLoop = 0; iDigitCheckLoop < strlen( pchIsDigits ); iDigitCheckLoop++ ) // 2b|!2b==?
{
if ( !isdigit( *( pchIsDigits + iDigitCheckLoop ) ) )
{
bIsNumericAlready = false;
break;
}
}
if ( bIsNumericAlready )
{
return atol( pchIsDigits );
}
DWORD dwResult = 0L;
// get style string into a buffer and up case it
//
char* pchStyle = const_cast<char*>( oStyle.c_str() );
int iLength = strlen( pchStyle );
for ( int iLoop = 0; iLoop < iLength; iLoop++ )
{
*( pchStyle + iLoop ) = toupper( *( pchStyle + iLoop ) );
}
if ( NULL != strstr( pchStyle, ccWS_EX_CLIENTEDGE ) )
{
dwResult |= WS_EX_CLIENTEDGE;
}
if ( NULL != strstr( pchStyle, ccWS_EX_WINDOWEDGE ) )
{
dwResult |= WS_EX_WINDOWEDGE;
}
return dwResult;
}
/* End of function "CXMLStyleDecoder::DecodeCtrlExStyle"
/*****************************************************************************/
/*****************************************************************************/
/* Check-in history
$WorkFile: $
$Archive: $
*$Log: $
*/
/*****************************************************************************/