|
From: andrew7 <bd...@us...> - 2006-11-30 01:03:37
|
Update of /cvsroot/smartwin/SmartWin/tests/sw_mdi In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31948/tests/sw_mdi Modified Files: MdiDraw.h MdiEdit.h MdiFrame.h MdiGrid.h MdiTree.h MdiWidg.h Log Message: Unicode support and update Menus to be raised reasonably. Index: MdiTree.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/sw_mdi/MdiTree.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- MdiTree.h 17 Jul 2006 18:52:02 -0000 1.10 +++ MdiTree.h 30 Nov 2006 01:03:33 -0000 1.11 @@ -121,20 +121,12 @@ void PopupMenuViaRightClick( const SmartWin::MouseEventResult & mouse ) { - SmartWin::Rectangle possize = this->getBounds(); - int x = possize.pos.x + mouse.pos.x; - int y = possize.pos.y + mouse.pos.y; - - ::TrackPopupMenu( reinterpret_cast< HMENU >( itsPopmenu->handle() ), - TPM_CENTERALIGN | TPM_VCENTERALIGN, - x, y, 0, this->handle(), 0 ); + itsPopmenu->trackPopupMenu( this ); } void PopupMenuViaButton( typename MdiTree< parent, MdiParent >::WidgetButtonPtr btn ) { - SmartWin::Rectangle btn_possize = btn->getBounds(); - - itsPopmenu->trackPopupMenu( this, btn_possize.pos.x, btn_possize.pos.y + btn_possize.size.y, TPM_LEFTALIGN | TPM_TOPALIGN ); + itsPopmenu->trackPopupMenu( this ); } void addNode( typename MdiTree< parent, MdiParent >::WidgetButtonPtr btn ) @@ -235,7 +227,11 @@ SmartUtil::tstring filePath; HtmlFilenameFromUser( filePath ); +#ifdef UNICODE + wfstream file( filePath.c_str(), ios_base::in ); +#else fstream file( filePath.c_str(), ios_base::in ); +#endif if ( ! file.good() ) return; itsCurrentFilename = filePath; this->setText( itsCurrentFilename + _T( " - Grid" ) ); @@ -272,7 +268,11 @@ void FileSave( SmartUtil::tstring & filePath ) { +#ifdef UNICODE + wfstream file( filePath.c_str(), ios_base::out ); +#else fstream file( filePath.c_str(), ios_base::out ); +#endif if ( ! file.good() ) return; html_put hp( file ); @@ -325,7 +325,7 @@ layout( sz.newSize ); } - void OnTextReady( const string & newtext ) + void OnTextReady( const SmartUtil::tstring & newtext ) {} bool KeyPressed( typename MdiTree< parent, MdiParent >::WidgetTextBoxPtr textField, int key ) @@ -334,12 +334,12 @@ { case VK_RETURN : OnTextReady( itsInputBox->getText() ); - itsInputBox->setText( "" ); + itsInputBox->setText( _T("") ); return true; case VK_ESCAPE : // itsAddBut->setText( "" ); - itsInputBox->setText( "" ); + itsInputBox->setText( _T("") ); return true; default: return false; } @@ -403,7 +403,7 @@ // Configure the prompt and input text box. itsMenuBut = this->createButton(); - itsMenuBut->setText( "menu" ); + itsMenuBut->setText( _T("menu") ); itsMenuBut->onClicked( & MdiTree< parent, MdiParent >::PopupMenuViaButton ); itsAddBut = this->createButton(); Index: MdiFrame.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/sw_mdi/MdiFrame.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- MdiFrame.h 15 Oct 2006 14:30:11 -0000 1.4 +++ MdiFrame.h 30 Nov 2006 01:03:33 -0000 1.5 @@ -329,7 +329,7 @@ ( this, itsMdiParent, & MdiFrame::editClosed, uniquebase() ); itsEdits.push_back( me ); itsHands.push_back( me->handle() ); - me->setText( "Edit Widget" ); + me->setText( _T("Edit Widget") ); wantResized(); } @@ -342,7 +342,7 @@ ( this, itsMdiParent, & MdiFrame::treeClosed, uniquebase() ); itsTrees.push_back( me ); itsHands.push_back( me->handle() ); - me->setText( "Tree Widget" ); + me->setText( _T("Tree Widget") ); wantResized(); } @@ -354,7 +354,7 @@ me = new MdiGrid< MdiFrame, WidgetMDIParent > ( this, itsMdiParent, & MdiFrame::gridClosed, uniquebase() ); - me->setText( "Grid Widget" ); + me->setText( _T("Grid Widget") ); itsGrids.push_back( me ); itsHands.push_back( me->handle() ); wantResized(); @@ -367,7 +367,7 @@ me = new MdiDraw< MdiFrame, WidgetMDIParent > ( this, itsMdiParent, & MdiFrame::drawClosed, uniquebase() ); - me->setText( "Draw Widget" ); + me->setText( _T("Draw Widget") ); itsDraws.push_back( me ); itsHands.push_back( me->handle() ); wantResized(); @@ -380,7 +380,7 @@ me = new MdiWidg< MdiFrame, WidgetMDIParent > ( this, itsMdiParent, & MdiFrame::widgClosed, uniquebase() ); - me->setText( "Widget" ); + me->setText( _T("Widget") ); itsWidgs.push_back( me ); itsHands.push_back( me->handle() ); wantResized(); Index: MdiWidg.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/sw_mdi/MdiWidg.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- MdiWidg.h 17 Jul 2006 18:52:02 -0000 1.9 +++ MdiWidg.h 30 Nov 2006 01:03:33 -0000 1.10 @@ -93,23 +93,12 @@ void PopupMenuViaRightClick( const SmartWin::MouseEventResult & mouse ) { - SmartWin::Rectangle possize = this->getBounds(); - int x = possize.pos.x + mouse.pos.x; - int y = possize.pos.y + mouse.pos.y; - - ::TrackPopupMenu( reinterpret_cast< HMENU >( itsPopmenu->handle() ), - TPM_CENTERALIGN | TPM_VCENTERALIGN, - x, y, 0, this->handle(), 0 ); + itsPopmenu->trackPopupMenu( this ); } void PopupMenuViaButton( typename MdiWidg< parent, MdiParent >::WidgetButtonPtr btn ) { - SmartWin::Rectangle btn_possize( btn->getSize() ); - - ::TrackPopupMenu( reinterpret_cast< HMENU >( itsPopmenu->handle() ), - TPM_LEFTALIGN | TPM_TOPALIGN, - btn_possize.pos.x, btn_possize.pos.y + btn_possize.size.y, - 0, this->handle(), 0 ); + itsPopmenu->trackPopupMenu( this ); } void new_tab( typename MdiWidg< parent, MdiParent >::WidgetTabSheetPtr sheet ) @@ -172,12 +161,12 @@ { case VK_RETURN : // OnTextReady( InputBox->getText() ); - itsInputBox->setText( "" ); + itsInputBox->setText( _T("") ); return true; case VK_ESCAPE : - itsPrompt->setText( "" ); - itsInputBox->setText( "" ); + itsPrompt->setText( _T("") ); + itsInputBox->setText( _T("") ); return true; default: return false; } @@ -212,11 +201,11 @@ this->createMDIChild( seedMdiChild ); itsTabSheet = this->createTabSheet(); - itsTabSheet->addPage( "buttons", 0 ); + itsTabSheet->addPage( _T("buttons"), 0 ); itsButtonPage = this->createWidgetChildWindow(); - itsTabSheet->addPage( "combolists", 1 ); + itsTabSheet->addPage( _T("combolists"), 1 ); itsComboPage = this->createWidgetChildWindow(); - itsTabSheet->addPage( "textboxes", 2 ); + itsTabSheet->addPage( _T("textboxes"), 2 ); itsTextBoxPage = this->createWidgetChildWindow(); itsTabSheet->onSelectionChanged( & MdiWidg< parent, MdiParent >::new_tab ); itsTabSheet->setHotTrack(); @@ -245,7 +234,7 @@ // Configure the itsPrompt and input text box. itsMenuBut = this->createButton(); - itsMenuBut->setText( "menu" ); + itsMenuBut->setText( _T("menu") ); itsMenuBut->onClicked( & MdiWidg< parent, MdiParent >::PopupMenuViaButton ); typename MdiWidg< parent, MdiParent >::WidgetStatic::Seed seedStatic; Index: MdiDraw.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/sw_mdi/MdiDraw.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- MdiDraw.h 9 Jul 2006 03:42:01 -0000 1.6 +++ MdiDraw.h 30 Nov 2006 01:03:33 -0000 1.7 @@ -70,13 +70,7 @@ void PopupMenuViaRightClick( const SmartWin::MouseEventResult & mouse ) { - SmartWin::Rectangle possize = this->getBounds(); - int x = possize.pos.x + mouse.pos.x; - int y = possize.pos.y + mouse.pos.y; - - ::TrackPopupMenu( reinterpret_cast< HMENU >( itsPopmenu->handle() ), - TPM_CENTERALIGN | TPM_VCENTERALIGN, - x, y, 0, this->handle(), 0 ); + itsPopmenu->trackPopupMenu( this ); } void painting( SmartWin::Canvas & canvas ) @@ -150,7 +144,7 @@ CreateCannedEmf( filePath.c_str() ); } - void CreateCannedEmf( const char * filename ) + void CreateCannedEmf( const TCHAR * filename ) { SmartWin::Rectangle rc = sw::Rectangle( this->getClientAreaSize() ); RECT r; @@ -161,7 +155,7 @@ UpdateCanvas uc( this ); map10um( uc.getDc(), r ); - HDC enhhdc = CreateEnhMetaFile( uc.getDc(), filename, & r, "description" ); + HDC enhhdc = CreateEnhMetaFile( uc.getDc(), filename, & r, _T("description") ); paint( enhhdc, xlim, ylim ); itsHEmf = CloseEnhMetaFile( enhhdc ); } Index: MdiGrid.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/sw_mdi/MdiGrid.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- MdiGrid.h 17 Jul 2006 18:52:01 -0000 1.10 +++ MdiGrid.h 30 Nov 2006 01:03:33 -0000 1.11 @@ -11,6 +11,8 @@ #include "SmartWin.h" using namespace SmartWin; #include <string> +#include <fstream> + using namespace std; #include "io/iolib.h" #include "io/html_get.h" @@ -129,20 +131,12 @@ void PopupMenuViaRightClick( const SmartWin::MouseEventResult & mouse ) { - SmartWin::Rectangle possize = this->getBounds(); - int x = possize.pos.x + mouse.pos.x; - int y = possize.pos.y + mouse.pos.y; - - ::TrackPopupMenu( reinterpret_cast< HMENU >( itsPopmenu->handle() ), - TPM_CENTERALIGN | TPM_VCENTERALIGN, - x, y, 0, this->handle(), 0 ); + itsPopmenu->trackPopupMenu( this ); } void PopupMenuViaButton( typename MdiGrid::WidgetButtonPtr btn ) { - SmartWin::Rectangle btn_possize = btn->getBounds(); - - itsPopmenu->trackPopupMenu( this, btn_possize.pos.x, btn_possize.pos.y + btn_possize.size.y, TPM_LEFTALIGN | TPM_TOPALIGN ); + itsPopmenu->trackPopupMenu( this ); } void HtmlFilenameFromUser( SmartUtil::tstring & txtfilename ) @@ -222,8 +216,11 @@ { SmartUtil::tstring filePath; HtmlFilenameFromUser( filePath ); - +#ifdef UNICODE + wfstream file( filePath.c_str(), ios_base::in ); +#else fstream file( filePath.c_str(), ios_base::in ); +#endif if ( ! file.good() ) return; itsCurrentFilename = filePath; this->setText( itsCurrentFilename + _T( " - Grid" ) ); @@ -260,7 +257,11 @@ void FileSave( SmartUtil::tstring & filePath ) { +#ifdef UNICODE + wfstream file( filePath.c_str(), ios_base::out ); +#else fstream file( filePath.c_str(), ios_base::out ); +#endif if ( ! file.good() ) return; html_put hp( file ); @@ -349,15 +350,15 @@ void add_col_menu() { - itsPrompt->setText( "Add column named : " ); + itsPrompt->setText( _T("Add column named : ") ); itsInputMode = COL_NAME; itsInputBox->setFocus(); } - void add_col( const string & column_name ) + void add_col( const SmartUtil::tstring & column_name ) { - vector< vector< string > > data; - vector< string > row; + vector< vector< SmartUtil::tstring > > data; + vector< SmartUtil::tstring > row; int colcount = ( int ) itsGrid->getColumnCount(); int rowcount = ( int ) itsGrid->getRowCount(); @@ -369,7 +370,7 @@ { data[ r ].push_back( itsGrid->getCellText( c, r ) ); } - data[ r ].push_back( "" ); // Extra unused column + data[ r ].push_back( _T("") ); // Extra unused column } itsColnames.push_back( column_name ); colcount++; @@ -420,7 +421,7 @@ return ( true ); } - void OnTextReady( const string & newtext ) + void OnTextReady( const SmartUtil::tstring & newtext ) { switch ( itsInputMode ) { @@ -432,7 +433,7 @@ if ( itsGrid->getRowCount() > 0 ) { itsInputMode = COL_DATA; - itsPrompt->setText( "Column data: " ); + itsPrompt->setText( _T("Column data: ") ); itsRow = 0; } break; @@ -442,7 +443,7 @@ if ( itsRow >= itsGrid->getRowCount() ) { itsInputMode = NO_INPUT; - itsPrompt->setText( "" ); + itsPrompt->setText( _T("") ); itsGrid->setFocus(); } break; @@ -452,7 +453,7 @@ if ( itsCol >= itsGrid->getColumnCount() ) { itsInputMode = NO_INPUT; - itsPrompt->setText( "" ); + itsPrompt->setText( _T("") ); itsGrid->setFocus(); } else @@ -469,12 +470,12 @@ { case VK_RETURN : OnTextReady( itsInputBox->getText() ); - itsInputBox->setText( "" ); + itsInputBox->setText( _T("") ); return true; case VK_ESCAPE : - itsPrompt->setText( "" ); - itsInputBox->setText( "" ); + itsPrompt->setText( _T("") ); + itsInputBox->setText( _T("") ); itsInputMode = NO_INPUT; return true; default: return false; @@ -483,32 +484,32 @@ return true; } - void sim_entry( char txt[] ) + void sim_entry( TCHAR txt[] ) { itsInputBox->setText( txt ); KeyPressed( itsInputBox, VK_RETURN ); } void canned_table() { - add_col( string( "Year" ) ); - add_col( string( "Sales" ) ); - add_col( string( "Profits" ) ); + add_col( SmartUtil::tstring( _T("Year") ) ); + add_col( SmartUtil::tstring( _T("Sales") ) ); + add_col( SmartUtil::tstring( _T("Profits") ) ); add_row(); - sim_entry( "2000" ); sim_entry( "1020" ); sim_entry( "210" ); + sim_entry( _T("2000") ); sim_entry( _T("1020") ); sim_entry( _T("210") ); add_row(); - sim_entry( "2001" ); sim_entry( "1120" ); sim_entry( "250" ); + sim_entry( _T("2001") ); sim_entry( _T("1120") ); sim_entry( _T("250") ); add_row(); - sim_entry( "2002" ); sim_entry( "1280" ); sim_entry( "290" ); + sim_entry( _T("2002") ); sim_entry( _T("1280") ); sim_entry( _T("290") ); itsGrid->setSelectedIndex( 1 ); del_row(); add_col_menu(); - sim_entry( "Dividends" ); - sim_entry( "75" ); - sim_entry( "77" ); + sim_entry( _T("Dividends") ); + sim_entry( _T("75") ); + sim_entry( _T("77") ); } /* @@ -552,7 +553,7 @@ // The menu button itsMenuBut = this->createButton(); - itsMenuBut->setText( "menu" ); + itsMenuBut->setText( _T("menu") ); itsMenuBut->onClicked( & MdiGrid::PopupMenuViaButton ); // The prompt for element input. Index: MdiEdit.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/sw_mdi/MdiEdit.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- MdiEdit.h 17 Jul 2006 18:52:01 -0000 1.10 +++ MdiEdit.h 30 Nov 2006 01:03:33 -0000 1.11 @@ -70,14 +70,14 @@ case EMAIL : { - string emailtext = string( itsTextField->getText() ); + SmartUtil::tstring emailtext = itsTextField->getText(); itsIo.FileEmailFile( emailtext ); } break; case PRINT : { - string printtext = string( itsTextField->getText() ); + SmartUtil::tstring printtext = itsTextField->getText(); itsIo.print( printtext ); } break; @@ -136,20 +136,12 @@ void PopupMenuViaRightClick( const SmartWin::MouseEventResult & mouse ) { - SmartWin::Rectangle possize = this->getBounds(); - int x = possize.pos.x + mouse.pos.x; - int y = possize.pos.y + mouse.pos.y; - - ::TrackPopupMenu( reinterpret_cast< HMENU >( itsPopmenu->handle() ), - TPM_CENTERALIGN | TPM_VCENTERALIGN, - x, y, 0, this->handle(), 0 ); + itsPopmenu->trackPopupMenu( this ); } void PopupMenuViaButton( typename MdiEdit< parent, MdiParent >::WidgetButton * btn ) { - SmartWin::Rectangle btn_possize = btn->getBounds(); - - itsPopmenu->trackPopupMenu( this, btn_possize.pos.x, btn_possize.pos.y + btn_possize.size.y, TPM_LEFTALIGN | TPM_TOPALIGN ); + itsPopmenu->trackPopupMenu( this ); } bool KeyPressed( typename MdiEdit< parent, MdiParent >::WidgetTextBox * textField, int key ) @@ -234,18 +226,18 @@ SmartUtil::tstring title; if ( readfile ) { - title = "Read file using Ftp parameters of:"; + title = _T("Read file using Ftp parameters of:"); } else { - title = "Write file using Ftp parameters of: "; + title = _T("Write file using Ftp parameters of: "); } InDialog sd( this, title ); - sd.add( "Ftp server: ", & itsFtpServer ) - .add( "Filename: ", & itsFtpFilename ) - .add( "Username: ", & itsFtpUsername ) - .add( "Password: ", & itsFtpPassword ); + sd.add( _T("Ftp server: "), & itsFtpServer ) + .add( _T("Filename: "), & itsFtpFilename ) + .add( _T("Username: "), & itsFtpUsername ) + .add( _T("Password: "), & itsFtpPassword ); if ( IDOK == sd.createDialog() ) { @@ -253,7 +245,7 @@ if ( readfile ) { // Read a FTP file and make it the current text. - string ftptext; + SmartUtil::tstring ftptext; if ( itsIo.FtpReadFile( itsFtpServer, itsFtpFilename, itsFtpUsername, itsFtpPassword.itsString, ftptext ) ) @@ -262,13 +254,13 @@ } else { - this->createMessageBox().show( "Ftp read failed", "FtpError" ); + this->createMessageBox().show( _T("Ftp read failed"), _T("FtpError") ); } } else { // Write the current text to a FTP file. - string ftptext = string( itsTextField->getText() ); + SmartUtil::tstring ftptext = itsTextField->getText(); itsIo.FtpWriteFile( ftptext, itsFtpServer, itsFtpFilename, itsFtpUsername, itsFtpPassword.itsString ); @@ -297,8 +289,8 @@ void find_input_text() { - InDialog findDlg( this, "Find text" ); - findDlg.add( "Find what: ", & itsFindText ); + InDialog findDlg( this, _T("Find text") ); + findDlg.add( _T("Find what: "), & itsFindText ); if ( IDOK == findDlg.createDialog() ) { // Blocks until the dialog is finished. @@ -440,7 +432,7 @@ onClosing( & MdiEdit< parent, MdiParent >::closeMdi ); itsMenuBut = this->createButton(); - itsMenuBut->setText( "menu" ); + itsMenuBut->setText( _T("menu") ); itsMenuBut->onClicked( & MdiEdit< parent, MdiParent >::PopupMenuViaButton ); // See documentation for Edit Control Styles from CreateWindow(). @@ -458,9 +450,9 @@ init_font(); init_menu( base ); - itsFtpServer = "upload.comcast.net"; - itsFtpFilename = "ftp.txt"; - itsFtpUsername = "andrew7webb"; + itsFtpServer = _T("upload.comcast.net"); + itsFtpFilename = _T("ftp.txt"); + itsFtpUsername = _T("andrew7webb"); } ~MdiEdit() |