[Gcblue-commits] gcb_wx/src/common tcOptions.cpp,1.10,1.11 tcOptionsView.cpp,1.9,1.10
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-10-02 22:42:15
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13659/src/common Modified Files: tcOptions.cpp tcOptionsView.cpp Log Message: Changes related to GDI+ replacement Index: tcOptionsView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcOptionsView.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcOptionsView.cpp 5 Sep 2004 01:02:01 -0000 1.9 --- tcOptionsView.cpp 2 Oct 2004 22:41:33 -0000 1.10 *************** *** 1,6 **** ! /* ! ** tcOptionsView.cpp ! ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcOptionsView.cpp ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 26,139 **** #include "tcString.h" #include "wxcommands.h" - using namespace Gdiplus; /*******************************************************************************/ ! bool tcOptionsView::Init() { ! char zBuff[96]; ! strcpy(zBuff,IMAGE_PATH); ! strcat(zBuff,"options_bk.jpg"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! mpiBackground = new Image(mzwchar,false); ! strcpy(zBuff,IMAGE_PATH); ! strcat(zBuff,"options_bon.bmp"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! mpiButtonOn = new Image(mzwchar,false); ! strcpy(zBuff,IMAGE_PATH); ! strcat(zBuff,"options_boff.bmp"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! mpiButtonOff = new Image(mzwchar,false); ! if (mpiBackground == NULL) { ! WTL("tcOptions - background bitmap (options_bk.jpg) load error"); ! return false; ! } ! if (mpiButtonOn == NULL) { ! WTL("tcOptions - background bitmap (options_bon.bmp) load error"); ! return false; ! } ! if (mpiButtonOff == NULL) { ! WTL("tcOptions - background bitmap (options_boff.bmp) load error"); ! return false; ! } ! FontFamily ff(L"Arial"); ! mpFont = new Font(&ff,12,FontStyleBold,UnitPixel); ! if (mpFont == NULL) { ! WTL("tcOptionsView - mpFont creation failed\n"); ! return false; ! } ! mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB ! if (mpBrush == NULL) { ! WTL("tcOptionsView - mpBrush creation failed\n"); ! return false; } ! mpPen = new Pen(Color(255,200,200,200),2); ! if (mpPen == NULL) { ! WTL("tcTOptionsView - mpPen creation failed\n"); ! return false; } - - - // Get dimensions and limit to window dimensions - // mpiButtonOn dimensions are used for all buttons - mnBackgroundWidth = mpiBackground->GetWidth(); - if (mnBackgroundWidth > mnWidth) {mnBackgroundWidth = mnWidth;} - mnBackgroundHeight = mpiBackground->GetHeight(); - if (mnBackgroundHeight > mnHeight) {mnBackgroundHeight = mnHeight;} - mnButtonWidth = mpiButtonOn->GetWidth(); - if (mnButtonWidth > mnWidth) {mnButtonWidth = mnWidth;} //limit dimensions to window - mnButtonHeight = mpiButtonOn->GetHeight(); - if (mnButtonHeight > mnHeight) {mnButtonHeight = mnHeight;} - return true; } ! /*******************************************************************************/ ! int tcOptionsView::Draw() { static nTestCount = 0; - static WCHAR szwchar[256]; // wide char array buffer for string conversion - Graphics *pGraphics; - Erase(); - if (!GetGraphics(pGraphics)) { - return false; - } - if (mpiBackground == NULL) {return false;} - if (mpOptions == NULL) {return false;} - - pGraphics->DrawImage(mpiBackground,0,0,mnWidth,mnHeight); ! mpBrush->SetColor(Color(0xFEFFFFFF)); ! ! ! /*** Draw test text **/ tcString sText; ! ! int xpos,ypos; ypos = mnYStart; ! RectF rstring; ! for(int i=0;i<mpOptions->mnNumOptions;i++) { xpos = mnXStart; int nBoxWidth = maButtonPosition[i][mpOptions->maOptionInfo[i].mnStateCount-1].mnButtonX - maButtonPosition[i][0].mnTextX + 2*mnButtonWidth; ! mpBrush->SetColor(Color(0x60FFFFFF)); ! pGraphics->FillRectangle(mpBrush, ! maButtonPosition[i][0].mnTextX - mnButtonHeight/2, ypos - 3*mnButtonHeight/2, ! nBoxWidth, 2*mnButtonHeight); ! mpBrush->SetColor(Color(255,255,220,220)); ! for(int j=0;j<mpOptions->maOptionInfo[i].mnStateCount;j++) { sText = mpOptions->maOptionInfo[i].mzCaption[j]; ! MultiByteToWideChar(CP_ACP, 0, sText.GetBuffer(), -1, szwchar, 255); ! pGraphics->MeasureString(szwchar,-1,mpFont,PointF(0,0),&rstring); maButtonPosition[i][j].mnTextX = xpos; maButtonPosition[i][j].mnTextY = ypos-mnButtonHeight+2; ! xpos += (int)(rstring.Width) + 1; maButtonPosition[i][j].mnButtonX = xpos; maButtonPosition[i][j].mnButtonY = ypos-mnButtonHeight-mnButtonHeight/6; --- 26,95 ---- #include "tcString.h" #include "wxcommands.h" + #include "tcOptions.h" + #include "tcSound.h" + + #include <osg/Texture2D> + #include <osg/Vec4> /*******************************************************************************/ ! void tcOptionsView::Init() { ! wxString s; ! LoadBackgroundImage("options_bk.jpg"); ! mpiButtonOn = LoadTexture("options_bon.bmp"); ! mpiButtonOff = LoadTexture("options_boff.bmp"); ! ! wxASSERT(mpiButtonOn.valid()); ! wxASSERT(mpiButtonOn->getImage()); ! if (mpiButtonOn.valid() && mpiButtonOn->getImage()) ! { ! mnButtonWidth = mpiButtonOn->getImage()->s(); ! mnButtonHeight = mpiButtonOn->getImage()->t(); } ! else ! { ! fprintf(stderr, "tcOptionsView::Init - error loading button images\n"); } } ! /** ! * ! */ ! void tcOptionsView::Draw() { static nTestCount = 0; ! wxASSERT(mpOptions); tcString sText; ! int xpos, ypos; ypos = mnYStart; ! wxSize rstring; ! ! for(int i=0; i<mpOptions->mnNumOptions; i++) ! { xpos = mnXStart; int nBoxWidth = maButtonPosition[i][mpOptions->maOptionInfo[i].mnStateCount-1].mnButtonX - maButtonPosition[i][0].mnTextX + 2*mnButtonWidth; ! ! DrawRectangle(maButtonPosition[i][0].mnTextX - mnButtonHeight/2, ! ypos - 3*mnButtonHeight/2, ! nBoxWidth, 2*mnButtonHeight, osg::Vec4(1, 1, 1, 0.5), FILL_OFF); ! for(int j=0; j<mpOptions->maOptionInfo[i].mnStateCount; j++) ! { sText = mpOptions->maOptionInfo[i].mzCaption[j]; ! ! MeasureText(defaultFont.get(), fontSize, sText.c_str(), rstring); maButtonPosition[i][j].mnTextX = xpos; maButtonPosition[i][j].mnTextY = ypos-mnButtonHeight+2; ! xpos += (int)(rstring.GetWidth()) + 1; maButtonPosition[i][j].mnButtonX = xpos; maButtonPosition[i][j].mnButtonY = ypos-mnButtonHeight-mnButtonHeight/6; *************** *** 142,186 **** } ! pGraphics->DrawRectangle(mpPen, ! maButtonPosition[i][0].mnTextX - mnButtonHeight/2, ypos - 3*mnButtonHeight/2, ! nBoxWidth, 2*mnButtonHeight); ypos += 3*mnButtonHeight; } ! for(i=0;i<mpOptions->mnNumOptions;i++) { ! for(int j=0;j<mpOptions->maOptionInfo[i].mnStateCount;j++) { sText = mpOptions->maOptionInfo[i].mzCaption[j]; ! MultiByteToWideChar(CP_ACP, 0, sText.GetBuffer(), -1, szwchar, 255); ! pGraphics->DrawString(szwchar, -1, mpFont, ! PointF((float)maButtonPosition[i][j].mnTextX, (float)maButtonPosition[i][j].mnTextY), ! mpBrush); ! if (mpOptions->maOptionInfo[i].mnValue == j) { ! DrawButton(pGraphics,maButtonPosition[i][j].mnButtonX, ! maButtonPosition[i][j].mnButtonY,1); } ! else { ! DrawButton(pGraphics,maButtonPosition[i][j].mnButtonX, ! maButtonPosition[i][j].mnButtonY,0); } } } ! DrawChildren(pGraphics); - ReleaseGraphics(pGraphics); DrawBorder(); ! return true; } - /*******************************************************************************/ - void tcOptionsView::DrawButton(Graphics *apGraphics, int x, int y, int abOn) { - Image *pButton; ! if (apGraphics == NULL) {return;} ! pButton = (abOn == 1) ? mpiButtonOn : mpiButtonOff; ! if (pButton == NULL) {return;} ! apGraphics->DrawImage(pButton,x,y); } /******************************************************************************/ --- 98,151 ---- } ! DrawRectangle(maButtonPosition[i][0].mnTextX - mnButtonHeight/2, ! ypos - 3*mnButtonHeight/2, ! nBoxWidth, 2*mnButtonHeight, osg::Vec4(1, 1, 1, 0.5), FILL_OFF); ypos += 3*mnButtonHeight; } ! for(i=0; i<mpOptions->mnNumOptions; i++) ! { ! for(int j=0; j<mpOptions->maOptionInfo[i].mnStateCount; j++) ! { sText = mpOptions->maOptionInfo[i].mzCaption[j]; ! ! float x = (float)maButtonPosition[i][j].mnTextX; ! float y = (float)maButtonPosition[i][j].mnTextY; ! DrawText(sText.c_str(), x, y, defaultFont.get(), ! osg::Vec4(0.86f, 0.86f, 1.0f, 1.0f), fontSize, LEFT_BASE_LINE); ! if (mpOptions->maOptionInfo[i].mnValue == j) ! { ! DrawButton(maButtonPosition[i][j].mnButtonX, ! maButtonPosition[i][j].mnButtonY, 1); } ! else ! { ! DrawButton(maButtonPosition[i][j].mnButtonX, ! maButtonPosition[i][j].mnButtonY, 0); } } } ! DrawChildren(); DrawBorder(); ! ! HideUnusedObjects(); } ! /** ! * ! */ ! void tcOptionsView::DrawButton(int x, int y, int abOn) ! { ! osg::Texture2D* pButton; ! ! pButton = (abOn == 1) ? mpiButtonOn.get() : mpiButtonOff.get(); ! ! DrawImage(pButton, x, y, float(mnButtonWidth), float(mnButtonHeight), ! ALIGN_BOTTOM_LEFT); } /******************************************************************************/ *************** *** 198,209 **** // TranslatePoint(point); // adjust for flipped up/down bButtonClicked = ButtonContainingPoint(event.GetPosition(), nOption, nValue); ! if (bButtonClicked) { if ((nOption >= mpOptions->mnNumOptions)|| ! (nValue >= mpOptions->maOptionInfo[nOption].mnStateCount)) { WTL("tcOptionsView::OnLButtonDown error"); return; } mpOptions->maOptionInfo[nOption].mnValue = nValue; ! if (mpOptions->maOptionInfo[nOption].mpAssociated != NULL) { *mpOptions->maOptionInfo[nOption].mpAssociated = nValue; } --- 163,177 ---- // TranslatePoint(point); // adjust for flipped up/down bButtonClicked = ButtonContainingPoint(event.GetPosition(), nOption, nValue); ! if (bButtonClicked) ! { if ((nOption >= mpOptions->mnNumOptions)|| ! (nValue >= mpOptions->maOptionInfo[nOption].mnStateCount)) ! { WTL("tcOptionsView::OnLButtonDown error"); return; } mpOptions->maOptionInfo[nOption].mnValue = nValue; ! if (mpOptions->maOptionInfo[nOption].mpAssociated != NULL) ! { *mpOptions->maOptionInfo[nOption].mpAssociated = nValue; } *************** *** 229,238 **** int nx, ny; ! for(i=0;i<mpOptions->mnNumOptions;i++) { ! for(j=0;j<mpOptions->maOptionInfo[i].mnStateCount;j++) { nx = maButtonPosition[i][j].mnButtonX; ny = maButtonPosition[i][j].mnButtonY; ! wxRect cr(nx,ny,mnButtonWidth,mnButtonHeight); ! if (cr.Inside(point)) { rnOption = i; rnValue = j; --- 197,211 ---- int nx, ny; ! point.y = mnHeight - point.y; ! ! for(i=0; i<mpOptions->mnNumOptions; i++) ! { ! for(j=0; j<mpOptions->maOptionInfo[i].mnStateCount; j++) ! { nx = maButtonPosition[i][j].mnButtonX; ny = maButtonPosition[i][j].mnButtonY; ! wxRect cr(nx, ny, mnButtonWidth, mnButtonHeight); ! if (cr.Inside(point)) ! { rnOption = i; rnValue = j; *************** *** 248,257 **** ////////////////////////////////////////////////////////////////////// ! tcOptionsView::tcOptionsView(wxWindow *parent, tcWindow *surfaceHost, ! const wxPoint& pos, const wxSize& size, const wxString& name) : ! tcXmlWindow(parent, pos, size, "xml/options_view.xml", name, surfaceHost) { - wxASSERT(surfaceHost); if (config) --- 221,230 ---- ////////////////////////////////////////////////////////////////////// ! tcOptionsView::tcOptionsView(wxWindow *parent, const wxPoint& pos, ! const wxSize& size, const wxString& name) : ! tcXmlWindow(parent, pos, size, "xml/options_view.xml", name), ! fontSize(16.0f) { if (config) *************** *** 265,279 **** } ! mpiBackground = NULL; ! mpiButtonOn = NULL; ! mpiButtonOff = NULL; ! mpOptions = NULL; ! mpFont = NULL; ! mpBrush = NULL; mnXStart = 100; mnYStart = 150; ! for(int i=0;i<N_OPTIONS;i++) { ! for(int k=0;k<N_OPTION_VALUES;k++) { maButtonPosition[i][k].mnButtonX = -100; --- 238,250 ---- } ! ! mpOptions = tcOptions::Get(); ! mnXStart = 100; mnYStart = 150; ! ! for(int i=0; i<tcOptions::N_OPTIONS; i++) { ! for(int k=0; k<tcOptions::N_OPTION_VALUES; k++) { maButtonPosition[i][k].mnButtonX = -100; *************** *** 287,295 **** tcOptionsView::~tcOptionsView() { - if (mpiBackground != NULL) {delete mpiBackground;} - if (mpiButtonOn != NULL) {delete mpiButtonOn;} - if (mpiButtonOff != NULL) {delete mpiButtonOff;} - if (mpFont != NULL) {delete mpFont;} - if (mpBrush != NULL) {delete mpBrush;} - if (mpPen != NULL) {delete mpPen;} } --- 258,260 ---- Index: tcOptions.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcOptions.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcOptions.cpp 19 Jun 2004 22:00:27 -0000 1.10 --- tcOptions.cpp 2 Oct 2004 22:41:33 -0000 1.11 *************** *** 1,6 **** /** ** @file tcOptions.cpp ! ** ! ** Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- /** ** @file tcOptions.cpp ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. |