2000-09-26 17:59:37 -04:00
|
|
|
// rc2wxr.cpp: implementation of the rc2wxr class.
|
2000-09-17 15:17:13 -04:00
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2000-09-26 17:59:37 -04:00
|
|
|
//Author: Brian Gavin 9/24/00
|
|
|
|
//License: wxWindows License
|
|
|
|
/*
|
|
|
|
WARNING- I know this code has some bugs to work out but
|
|
|
|
I don't plan to fix them since I feel that wxr files will
|
|
|
|
not be used much longer.
|
|
|
|
This code was used as a starting point for my rc2xml converter
|
|
|
|
*/
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation "rc2wxr.cpp"
|
|
|
|
#pragma interface "rc2wxr.cpp"
|
|
|
|
#endif
|
|
|
|
|
2000-09-17 15:17:13 -04:00
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
2000-09-26 17:59:37 -04:00
|
|
|
#include <wx/wxprec.h>
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// for all others, include the necessary headers (this file is usually all you
|
|
|
|
// need because it includes almost all "standard" wxWindows headers
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include <wx/wx.h>
|
|
|
|
#endif
|
|
|
|
|
2000-09-17 15:17:13 -04:00
|
|
|
|
|
|
|
#include "rc2wxr.h"
|
|
|
|
#include "wx/image.h"
|
|
|
|
#include "wx/resource.h"
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Construction/Destruction
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
rc2wxr::rc2wxr()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
m_done=FALSE;
|
|
|
|
m_controlid=6000;
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
rc2wxr::~rc2wxr()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::Convert(wxString wxrfile, wxString rcfile)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
m_rc.Open(rcfile);
|
|
|
|
m_filesize=m_rc.Length();
|
2000-09-17 15:17:13 -04:00
|
|
|
if( (m_wxr = fopen( wxrfile, "wt" )) == NULL )
|
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
return;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString tok,prevtok;
|
|
|
|
|
|
|
|
|
|
|
|
while (!m_done)
|
|
|
|
{
|
|
|
|
|
|
|
|
tok=GetToken();
|
|
|
|
|
|
|
|
if (tok=="DIALOG")
|
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseDialog(prevtok);
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (tok=="MENU")
|
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseMenu(prevtok);
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
prevtok=tok;
|
|
|
|
}
|
2000-09-26 17:59:37 -04:00
|
|
|
|
2000-09-17 15:17:13 -04:00
|
|
|
fclose(m_wxr);
|
|
|
|
//fclose(m_rc);
|
|
|
|
m_rc.Close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Example .rc
|
|
|
|
Microsoft style as of v5.0
|
|
|
|
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55
|
|
|
|
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
|
|
|
CAPTION "About Funimator"
|
|
|
|
FONT 8, "MS Sans Serif"
|
|
|
|
|
|
|
|
Borland 4.5 style rc
|
|
|
|
IDD_DIBATTR DIALOG 7, 16, 172, 119
|
|
|
|
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
|
|
|
CAPTION "DIB Attributes"
|
|
|
|
FONT 8, "MS Sans Serif"
|
|
|
|
{
|
|
|
|
DEFPUSHBUTTON "Ok", IDOK, 114, 8, 50, 14
|
|
|
|
PUSHBUTTON "Cancel", IDCANCEL, 114, 28, 50, 14
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseDialog(wxString dlgname)
|
|
|
|
{
|
|
|
|
wxString tok;
|
|
|
|
static int dlgid=999;
|
|
|
|
dlgid++;
|
|
|
|
/* Make sure that this really is a dialog
|
|
|
|
microsoft reuses the keyword DIALOG for other things
|
|
|
|
*/
|
|
|
|
tok=PeekToken();
|
|
|
|
//Microsoft notation?
|
|
|
|
if (tok=="DISCARDABLE")
|
|
|
|
{
|
|
|
|
tok=GetToken();
|
|
|
|
tok=PeekToken();
|
|
|
|
}
|
|
|
|
//This isn't a Dialog resource eject eject
|
|
|
|
if (!tok.IsNumber())
|
|
|
|
return;
|
2000-09-17 15:17:13 -04:00
|
|
|
//Generate Dialog text
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr,"static char *dialog%i = \"dialog(name = '%s',\\\n",dlgid,dlgname);
|
2000-09-17 15:17:13 -04:00
|
|
|
//be lazy about style for now. add it later
|
|
|
|
fprintf(m_wxr,"style = 'wxRAISED_BORDER | wxCAPTION | wxTHICK_FRAME | wxSYSTEM_MENU',\\\n");
|
|
|
|
|
|
|
|
fprintf(m_wxr,"id = %i,\\\n",dlgid);
|
|
|
|
|
|
|
|
//Record x,y,width,height
|
|
|
|
int x,y,width,height;
|
|
|
|
ReadRect(x,y,width,height);
|
|
|
|
fprintf(m_wxr,"x = %i, y = %i, width = %i, height = %i,\\\n",x,y,width,height);
|
|
|
|
|
|
|
|
|
|
|
|
//CAPTION "About Funimator"
|
|
|
|
//Get Title
|
|
|
|
tok=GetToken();
|
|
|
|
wxString title;
|
|
|
|
|
|
|
|
while ((tok!="BEGIN")&(tok!="{"))
|
|
|
|
{
|
|
|
|
if (tok=="CAPTION")
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
title=GetQuoteField();
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr,"title = '%s',\\\n",title);
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
tok=GetToken();
|
|
|
|
}
|
|
|
|
fprintf(m_wxr,"use_dialog_units = 1,\\\n");
|
|
|
|
fprintf(m_wxr,"use_system_defaults = 0,\\\n");
|
|
|
|
|
|
|
|
fprintf(m_wxr,"font = [8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif'],\\\n");
|
|
|
|
ParseControls();
|
|
|
|
fprintf(m_wxr,").\";\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EDITTEXT IDC_BANDS,36,83,22,14,ES_AUTOHSCROLL | ES_NUMBER | NOT
|
|
|
|
WS_TABSTOP
|
|
|
|
LTEXT "Bands",IDC_STATIC,11,86,21,8
|
|
|
|
EDITTEXT IDC_NAME,10,3,75,14,ES_AUTOHSCROLL
|
|
|
|
END
|
|
|
|
*/
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseControls()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok;
|
|
|
|
|
|
|
|
tok=GetToken();
|
|
|
|
while ((tok!="END")&(tok!="}"))
|
|
|
|
{
|
|
|
|
if (tok=="LTEXT")
|
|
|
|
ParseStaticText();
|
|
|
|
if (tok=="EDITTEXT")
|
|
|
|
ParseTextCtrl();
|
|
|
|
if (tok=="PUSHBUTTON")
|
|
|
|
ParsePushButton();
|
|
|
|
if (tok=="DEFPUSHBUTTON")
|
|
|
|
ParsePushButton();
|
|
|
|
if (tok=="GROUPBOX")
|
|
|
|
ParseGroupBox();
|
|
|
|
if (tok=="COMBOBOX")
|
|
|
|
ParseComboBox();
|
|
|
|
if (tok=="CONTROL")
|
|
|
|
ParseControlMS();
|
|
|
|
|
|
|
|
tok=GetToken();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//LTEXT "Radius",IDC_STATIC,9,67,23,8
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseStaticText()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok;
|
|
|
|
wxString phrase,varname;
|
|
|
|
phrase=GetQuoteField();
|
|
|
|
varname=GetToken();
|
|
|
|
m_controlid++;
|
|
|
|
int x,y,width,height;
|
|
|
|
ReadRect(x,y,width,height);
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," control = [%i,wxStaticText,'%s','0','%s',",m_controlid,phrase,varname);
|
2000-09-17 15:17:13 -04:00
|
|
|
fprintf(m_wxr,"%i,%i,%i,%i,'',\\\n",x,y,width,height);
|
|
|
|
fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n");
|
|
|
|
}
|
|
|
|
//EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseTextCtrl()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok;
|
|
|
|
wxString varname;
|
|
|
|
varname=GetToken();
|
|
|
|
m_controlid++;
|
|
|
|
int x,y,width,height;
|
|
|
|
ReadRect(x,y,width,height);
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," control = [%i,wxTextCtrl,'','0','%s',",m_controlid,varname);
|
2000-09-17 15:17:13 -04:00
|
|
|
fprintf(m_wxr,"%i,%i,%i,%i,'',\\\n",x,y,width,height);
|
|
|
|
fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
//PUSHBUTTON "Create/Update",IDC_CREATE,15,25,53,13,NOT WS_TABSTOP
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParsePushButton()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok;
|
|
|
|
wxString phrase,varname;
|
|
|
|
phrase=GetQuoteField();
|
|
|
|
varname=GetToken();
|
|
|
|
int c;
|
|
|
|
m_controlid++;
|
|
|
|
c=m_controlid;
|
|
|
|
if (varname=="IDOK")
|
|
|
|
c=wxID_OK;
|
|
|
|
|
|
|
|
if (varname=="IDCANCEL")
|
|
|
|
c=wxID_CANCEL;
|
|
|
|
|
|
|
|
if (varname=="IDAPPLY")
|
|
|
|
c=wxID_APPLY;
|
|
|
|
|
|
|
|
int x,y,width,height;
|
|
|
|
ReadRect(x,y,width,height);
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," control = [%i,wxButton,'%s','0','%s',",c,phrase,varname);
|
2000-09-17 15:17:13 -04:00
|
|
|
fprintf(m_wxr,"%i,%i,%i,%i,'',\\\n",x,y,width,height);
|
|
|
|
fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
bool rc2wxr::Seperator(int ch)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|'))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (ch==EOF)
|
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
m_done=TRUE;
|
|
|
|
return TRUE;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseGroupBox()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
// GROUPBOX "Rotate",IDC_STATIC,1,1,71,79
|
|
|
|
wxString tok;
|
|
|
|
wxString phrase,varname;
|
|
|
|
phrase=GetQuoteField();
|
|
|
|
varname=GetToken();
|
|
|
|
m_controlid++;
|
|
|
|
int x,y,width,height;
|
|
|
|
ReadRect(x,y,width,height);
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," control = [%i,wxStaticBox,'%s','0','%s',",m_controlid,phrase,varname);
|
2000-09-17 15:17:13 -04:00
|
|
|
fprintf(m_wxr,"%i,%i,%i,%i,'',\\\n",x,y,width,height);
|
|
|
|
fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ReadRect(int & x, int & y, int & width, int & height)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
x=atoi(GetToken());
|
|
|
|
y=atoi(GetToken());
|
|
|
|
width=atoi(GetToken());
|
|
|
|
height=atoi(GetToken());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString rc2wxr::GetToken()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok="";
|
|
|
|
|
|
|
|
if (m_rc.Eof())
|
|
|
|
{
|
|
|
|
m_done=TRUE;
|
|
|
|
return tok;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ch=0;
|
|
|
|
ReadChar(ch);
|
|
|
|
if (ch==EOF)
|
|
|
|
{
|
|
|
|
m_done=TRUE;
|
|
|
|
return tok;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (Seperator(ch))
|
|
|
|
{
|
|
|
|
ReadChar(ch);
|
|
|
|
if (m_done)
|
2000-09-26 17:59:37 -04:00
|
|
|
return tok;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ch==EOF)
|
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
m_done=TRUE;
|
2000-09-17 15:17:13 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while (!Seperator(ch))
|
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
tok+=(char)ch;
|
|
|
|
ReadChar(ch);
|
2000-09-17 15:17:13 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch==EOF)
|
|
|
|
m_done=TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
return tok;
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString rc2wxr::GetQuoteField()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString phrase;
|
|
|
|
//ASCII code 34 "
|
|
|
|
int ch=0;
|
|
|
|
ReadChar(ch);
|
|
|
|
|
|
|
|
while (ch!=34)
|
|
|
|
ReadChar(ch);
|
|
|
|
|
|
|
|
ReadChar(ch);
|
|
|
|
|
|
|
|
while (ch!=34)
|
|
|
|
{
|
|
|
|
phrase+=(char)ch;
|
|
|
|
ReadChar(ch);
|
|
|
|
}
|
|
|
|
return phrase;
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ReadChar(int &ch)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
result=m_rc.Tell();
|
|
|
|
|
|
|
|
if((result>=m_filesize))
|
|
|
|
m_done=TRUE;
|
|
|
|
|
|
|
|
result=m_rc.Read(&ch,1);
|
|
|
|
|
|
|
|
if((result==-1))
|
|
|
|
m_done=TRUE;
|
|
|
|
|
|
|
|
if(ch==EOF)
|
|
|
|
m_done=TRUE;
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseComboBox()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
/* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT |
|
|
|
|
WS_VSCROLL | WS_TABSTOP */
|
|
|
|
wxString tok;
|
|
|
|
wxString varname;
|
|
|
|
varname=GetToken();
|
|
|
|
m_controlid++;
|
|
|
|
int x,y,width,height;
|
|
|
|
ReadRect(x,y,width,height);
|
|
|
|
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," control = [%i,wxChoice,'','0','%s',",m_controlid,varname);
|
2000-09-17 15:17:13 -04:00
|
|
|
fprintf(m_wxr,"%i,%i,%i,%i,[],\\\n",x,y,width,height);
|
|
|
|
fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseMenu(wxString name)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok="";
|
|
|
|
static int menuid=0;
|
|
|
|
menuid++;
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr,"static char *MenuBar%i = \"menu(name = '%s',\\\n",menuid,name);
|
2000-09-17 15:17:13 -04:00
|
|
|
fprintf(m_wxr,"menu = \\\n");
|
|
|
|
fprintf(m_wxr,"[\\\n");
|
|
|
|
|
|
|
|
while ((tok!="BEGIN")&(tok!="{"))
|
|
|
|
tok=GetToken();
|
|
|
|
|
|
|
|
while ((tok!="END")&(tok!="}"))
|
|
|
|
{
|
|
|
|
tok=GetToken();
|
|
|
|
if (tok=="POPUP")
|
|
|
|
{
|
|
|
|
ParsePopupMenu();
|
|
|
|
fprintf(m_wxr," ],\\\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(m_wxr,"]).\";\n\n");
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParsePopupMenu()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
static int menuitem=99;
|
|
|
|
menuitem++;
|
|
|
|
|
|
|
|
wxString tok;
|
|
|
|
tok=GetQuoteField();
|
|
|
|
int spot;
|
|
|
|
//Remove /t because it causes problems
|
|
|
|
spot=tok.First("\\t");
|
|
|
|
tok=tok.Left(spot);
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," ['%s',%i,'',\\\n",tok,menuitem);
|
2000-09-17 15:17:13 -04:00
|
|
|
while ((tok!="BEGIN")&(tok!="{"))
|
|
|
|
tok=GetToken();
|
|
|
|
|
|
|
|
while ((tok!="END")&(tok!="}"))
|
|
|
|
{
|
|
|
|
tok=GetToken();
|
|
|
|
if (tok=="MENUITEM")
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (PeekToken()=="SEPARATOR")
|
|
|
|
fprintf(m_wxr," [],\\\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tok=GetQuoteField();
|
|
|
|
//Remove /t because it causes problems
|
|
|
|
spot=tok.First("\\t");
|
|
|
|
tok=tok.Left(spot);
|
|
|
|
menuitem++;
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," ['%s',%i,''],\\\n",tok,menuitem);
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString rc2wxr::PeekToken()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok;
|
|
|
|
int p;
|
|
|
|
p=m_rc.Tell();
|
|
|
|
tok=GetToken();
|
|
|
|
|
|
|
|
m_rc.Seek(p);
|
|
|
|
return tok;
|
|
|
|
}
|
|
|
|
//Windows pain in the butt CONTROL
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseControlMS()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString label,varname,kindctrl,tok;
|
|
|
|
label=GetQuoteField();
|
|
|
|
varname=GetToken();
|
|
|
|
kindctrl=GetQuoteField();
|
|
|
|
kindctrl.MakeUpper();
|
|
|
|
|
|
|
|
|
|
|
|
if (kindctrl=="MSCTLS_TRACKBAR32")
|
|
|
|
ParseSlider(label,varname);
|
|
|
|
if (kindctrl=="MSCTLS_PROGRESS32")
|
|
|
|
ParseProgressBar(label,varname);
|
|
|
|
if (kindctrl=="BUTTON")
|
|
|
|
ParseCtrlButton(label,varname);
|
|
|
|
}
|
|
|
|
/* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH |
|
|
|
|
TBS_NOTICKS | WS_TABSTOP,52,73,100,15
|
|
|
|
*/
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseSlider(wxString label, wxString varname)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString tok;
|
|
|
|
while (ReadOrs(tok));
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," control = [%i,wxSlider,'','wxSL_HORIZONTAL','%s',",m_controlid,varname);
|
2000-09-17 15:17:13 -04:00
|
|
|
int x,y,width,height;
|
|
|
|
ReadRect(x,y,width,height);
|
|
|
|
fprintf(m_wxr,"%i,%i,%i,%i,",x,y,width,height);
|
|
|
|
fprintf(m_wxr," 1, 1, 10,\\\n");
|
|
|
|
fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n");
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
CONTROL "Progress1",CG_IDC_PROGDLG_PROGRESS,"msctls_progress32",
|
|
|
|
WS_BORDER,15,52,154,13
|
|
|
|
*/
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseProgressBar(wxString label, wxString varname)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok;
|
|
|
|
while (ReadOrs(tok));
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," control = [%i,wxGauge,'','wxGA_HORIZONTAL','%s',",m_controlid,varname);
|
2000-09-17 15:17:13 -04:00
|
|
|
int x,y,width,height;
|
|
|
|
ReadRect(x,y,width,height);
|
|
|
|
fprintf(m_wxr,"%i,%i,%i,%i,",x,y,width,height);
|
|
|
|
fprintf(m_wxr," 0, 10,\\\n");
|
|
|
|
fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n");
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
bool rc2wxr::ReadOrs(wxString & w)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok;
|
|
|
|
tok=PeekToken();
|
|
|
|
if (tok.IsNumber())
|
|
|
|
return false;
|
|
|
|
w=GetToken();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Is it a check button or a radio button
|
2000-09-26 17:59:37 -04:00
|
|
|
void rc2wxr::ParseCtrlButton(wxString label, wxString varname)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
wxString tok;
|
2000-09-26 17:59:37 -04:00
|
|
|
tok=GetToken();
|
2000-09-17 15:17:13 -04:00
|
|
|
|
|
|
|
m_controlid++;
|
2000-09-26 17:59:37 -04:00
|
|
|
int x,y,width,height;
|
2000-09-17 15:17:13 -04:00
|
|
|
|
|
|
|
if (tok=="BS_AUTOCHECKBOX")
|
|
|
|
{
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," control = [%i,wxCheckBox,'%s','0','%s',",m_controlid,label,varname);
|
2000-09-17 15:17:13 -04:00
|
|
|
while (ReadOrs(tok));
|
2000-09-26 17:59:37 -04:00
|
|
|
ReadRect(x,y,width,height);
|
2000-09-17 15:17:13 -04:00
|
|
|
fprintf(m_wxr,"%i,%i,%i,%i,0,\\\n",x,y,width,height);
|
|
|
|
fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tok=="BS_AUTORADIOBUTTON")
|
|
|
|
{
|
2000-10-18 17:51:04 -04:00
|
|
|
fprintf(m_wxr," control = [%i,wxRadioButton,'%s','0','%s',",m_controlid,label,varname);
|
2000-09-17 15:17:13 -04:00
|
|
|
while(ReadOrs(tok));
|
2000-09-26 17:59:37 -04:00
|
|
|
ReadRect(x,y,width,height);
|
2000-09-17 15:17:13 -04:00
|
|
|
fprintf(m_wxr,"%i,%i,%i,%i,0,\\\n",x,y,width,height);
|
|
|
|
fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|