void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxString msg;
- msg.Printf(_T("This is the network functions test sample.\n"
- "© 1999 Vadim Zeitlin"));
+ msg.Printf( wxT("This is the network functions test sample.\n")
+ wxT("© 1999 Vadim Zeitlin") );
- wxMessageBox(msg, _T("About NetTest"), wxOK | wxICON_INFORMATION, this);
+ wxMessageBox(msg, wxT("About NetTest"), wxOK | wxICON_INFORMATION, this);
}
void MyFrame::OnHangUp(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
- wxMessageBox(_T("Event sample shows different ways of using events\n"
- "© 2001 Vadim Zeitlin"),
- _T("About Event Sample"), wxOK | wxICON_INFORMATION, this);
+ wxMessageBox( wxT("Event sample shows different ways of using events\n")
+ wxT("© 2001 Vadim Zeitlin"),
+ wxT("About Event Sample"), wxOK | wxICON_INFORMATION, this );
}
// ----------------------------------------------------------------------------
void MyFrame::OnDynamic(wxCommandEvent& WXUNUSED(event))
{
- wxMessageBox(_T("This is a dynamic event handler which can be connected "
- "and disconnected during run-time."),
- _T("Dynamic Event Handler"), wxOK | wxICON_INFORMATION, this);
+ wxMessageBox
+ (
+ wxT("This is a dynamic event handler which can be connected ")
+ wxT("and disconnected at run-time."),
+ wxT("Dynamic Event Handler"), wxOK | wxICON_INFORMATION, this
+ );
}
void MyFrame::OnConnect(wxCommandEvent& event)
#include "wx/wx.h"
#endif
+#if wxUSE_UNICODE
+ #error "This sample can't be compiled in Unicode mode."
+#endif // wxUSE_UNICODE
+
#include "wx/resource.h"
#include <ctype.h>
// Under Windows, some compilers can't include
// a whole .wxr file. So we use a .rc user-defined resource
// instead. dialog1 will point to the whole .wxr 'file'.
-static char *dialog1 = NULL;
-static char *menu1 = NULL;
+static wxChar *dialog1 = NULL;
+static wxChar *menu1 = NULL;
#else
// Other platforms should have sensible compilers that
// cope with long strings.
bool MyApp::OnInit(void)
{
#if defined(__WXMSW__)
- // Load the .wxr 'file' from a .rc resource, under Windows.
- dialog1 = wxLoadUserResource("dialog1", "WXRDATA");
- menu1 = wxLoadUserResource("menu1", "WXRDATA");
- // All resources in the file (only one in this case) get parsed
- // by this call.
- wxResourceParseString(dialog1);
- wxResourceParseString(menu1);
+ // Load the .wxr 'file' from a .rc resource, under Windows.
+ dialog1 = wxLoadUserResource(wxT("dialog1"), wxT("WXRDATA"));
+ menu1 = wxLoadUserResource(wxT("menu1"), wxT("WXRDATA"));
+ // All resources in the file (only one in this case) get parsed
+ // by this call.
+ wxResourceParseString(dialog1);
+ wxResourceParseString(menu1);
#else
- // Simply parse the data pointed to by the variable dialog1.
- // If there were several resources, there would be several
- // variables, and this would need to be called several times.
- wxResourceParseData(dialog1);
- wxResourceParseData(menu1);
+ // Simply parse the data pointed to by the variable dialog1.
+ // If there were several resources, there would be several
+ // variables, and this would need to be called several times.
+ wxResourceParseData(dialog1);
+ wxResourceParseData(menu1);
#endif
- // Create the main frame window
- frame = new MyFrame((wxFrame *) NULL, -1, (char *) "wxWindows Resource Sample", wxPoint(-1, -1), wxSize(300, 250));
+ // Create the main frame window
+ frame = new MyFrame( (wxFrame *) NULL, -1,
+ (char *) "wxWindows Resource Sample",
+ wxPoint(-1, -1), wxSize(300, 250) );
+
+ // Give it a status line
+ frame->CreateStatusBar(2);
- // Give it a status line
- frame->CreateStatusBar(2);
+ wxMenuBar *menu_bar = wxResourceCreateMenuBar("menu1");
- wxMenuBar *menu_bar = wxResourceCreateMenuBar("menu1");
-
- // Associate the menu bar with the frame
- frame->SetMenuBar(menu_bar);
+ // Associate the menu bar with the frame
+ frame->SetMenuBar(menu_bar);
- // Make a panel
- frame->panel = new MyPanel(frame, -1, wxPoint(0, 0), wxSize(400, 400), 0, "MyMainFrame");
- frame->Show(TRUE);
+ // Make a panel
+ frame->panel = new MyPanel( frame, -1, wxPoint(0, 0), wxSize(400, 400),
+ 0, "MyMainFrame" );
+ frame->Show(TRUE);
- SetTopWindow(frame);
+ SetTopWindow(frame);
- return TRUE;
+ return TRUE;
}
MyApp::~MyApp()
EVT_LEFT_DOWN( MyPanel::OnClick)
END_EVENT_TABLE()
-MyPanel::MyPanel( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
- int style, const wxString &name ) :
- wxPanel( parent, id, pos, size, style, name )
+MyPanel::MyPanel
+(
+ wxWindow *parent, wxWindowID id, const wxPoint& pos,
+ const wxSize& size,
+ int style, const wxString &name
+) : wxPanel( parent, id, pos, size, style, name )
{
}
void MyPanel::OnClick( wxMouseEvent &WXUNUSED(event2) )
{
- MyFrame *frame = (MyFrame*)(wxTheApp->GetTopWindow());
- wxCommandEvent event;
- frame->OnTestDialog( event );
+ MyFrame *frame = (MyFrame*)(wxTheApp->GetTopWindow());
+ wxCommandEvent event;
+ frame->OnTestDialog( event );
}
END_EVENT_TABLE()
// Define my frame constructor
-MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
- wxFrame(parent, id, title, pos, size)
+MyFrame::MyFrame
+(
+ wxWindow *parent, const wxWindowID id,
+ const wxString& title, const wxPoint& pos, const wxSize& size
+) : wxFrame(parent, id, title, pos, size)
{
- panel = (wxWindow *) NULL;
+ panel = (wxWindow *) NULL;
}
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event) )
{
- MyDialog *dialog = new MyDialog;
- if (dialog->LoadFromResource(this, "dialog1"))
- {
+ MyDialog *dialog = new MyDialog;
+
+ if (dialog->LoadFromResource(this, "dialog1"))
+ {
wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName("multitext3", dialog);
if (text)
- text->SetValue("wxWindows resource demo");
+ {
+ text->SetValue("wxWindows resource demo");
+ }
+
dialog->ShowModal();
- }
- dialog->Close(TRUE);
+ }
+
+ dialog->Close(TRUE);
}
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event) )
{
- // EndModal(RESOURCE_OK);
+ // EndModal(RESOURCE_OK);
}
void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event) )
{
- EndModal(ID_BUTTON109);
+ EndModal(ID_BUTTON109);
}
void MyFrame::OnCommand( wxCommandEvent &event )
{
- switch (event.GetId())
- {
- case ID_QUIT:
- Close( TRUE );
- break;
- case ID_PRINT:
- {
- wxPrinter printer;
- wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout"));
- if (! printer.Print(this, &printout, TRUE))
- wxMessageBox(
- _("There was a problem with printing the message:\n"
- "perhaps your current printer is not set up correctly?"),
- _("Printing"), wxOK);
- }
- break;
- case ID_NOWRAP:
- case ID_WRAP:
- m_lwin->SetWrapMargin(event.GetId() == ID_NOWRAP ? 0 : 40);
- break;
- case ID_ADD_SAMPLE:
- AddSampleText(m_lwin->GetLayoutList());
- break;
- case ID_CLEAR:
- Clear();
- break;
+ switch (event.GetId())
+ {
+ case ID_QUIT:
+ Close( TRUE );
+ break;
+ case ID_PRINT:
+ {
+ wxPrinter printer;
+ wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout"));
+ if (! printer.Print(this, &printout, TRUE))
+ {
+ // Had to remove the split up strings that used to be below, and
+ // put them into one long strong. Otherwise MSVC would give an
+ // error "C2308: concatenating mismatched wide strings" when
+ // building a Unicode version.
+ wxMessageBox
+ (
+ _("There was a problem with printing the message:\nperhaps your current printer is not set up correctly?"),
+ _("Printing"), wxOK
+ );
+ }
+ break;
+ }
+
+ case ID_NOWRAP:
+ case ID_WRAP:
+ m_lwin->SetWrapMargin(event.GetId() == ID_NOWRAP ? 0 : 40);
+ break;
+ case ID_ADD_SAMPLE:
+ AddSampleText(m_lwin->GetLayoutList());
+ break;
+ case ID_CLEAR:
+ Clear();
+ break;
case ID_CLICK:
- cerr << "Received click event." << endl;
- break;
+ cerr << "Received click event." << endl;
+ break;
case ID_PASTE:
- m_lwin->Paste(TRUE);
- m_lwin->Refresh(FALSE);
- break;
+ m_lwin->Paste(TRUE);
+ m_lwin->Refresh(FALSE);
+ break;
#ifdef __WXGTK__
- case ID_PASTE_PRIMARY:
- // text only from primary:
- m_lwin->Paste(FALSE, TRUE);
- m_lwin->Refresh(FALSE);
- break;
- case ID_COPY_PRIMARY:
- // copy text-only to primary selection:
- m_lwin->Copy(FALSE,FALSE,TRUE);
- m_lwin->Refresh(FALSE);
- break;
+ case ID_PASTE_PRIMARY:
+ // text only from primary:
+ m_lwin->Paste(FALSE, TRUE);
+ m_lwin->Refresh(FALSE);
+ break;
+ case ID_COPY_PRIMARY:
+ // copy text-only to primary selection:
+ m_lwin->Copy(FALSE,FALSE,TRUE);
+ m_lwin->Refresh(FALSE);
+ break;
#endif
- case ID_COPY:
- m_lwin->Copy(TRUE,TRUE,FALSE);
- m_lwin->Refresh(FALSE);
- break;
- case ID_CUT:
- m_lwin->Cut();
- m_lwin->Refresh(FALSE);
- break;
+ case ID_COPY:
+ m_lwin->Copy(TRUE,TRUE,FALSE);
+ m_lwin->Refresh(FALSE);
+ break;
+ case ID_CUT:
+ m_lwin->Cut();
+ m_lwin->Refresh(FALSE);
+ break;
#ifdef M_BASEDIR
- case ID_FIND:
- m_lwin->Find("void");
- m_lwin->Refresh(FALSE);
- break;
+ case ID_FIND:
+ m_lwin->Find("void");
+ m_lwin->Refresh(FALSE);
+ break;
#endif
- case ID_HTML:
- {
- wxLayoutExportObject *export0;
- wxLayoutExportStatus status(m_lwin->GetLayoutList());
-
- cout << "<HTML>" << endl;
- while((export0 = wxLayoutExport( &status,
- WXLO_EXPORT_AS_HTML)) != NULL)
- {
- if(export0->type == WXLO_EXPORT_HTML)
- cout << *(export0->content.text);
- else
- ; // ignore itcout << "<!--UNKNOWN OBJECT>";
- delete export0;
- }
- }
- break;
- case ID_TEXT:
- {
- wxLayoutExportObject *export0;
- wxLayoutExportStatus status(m_lwin->GetLayoutList());
-
- while((export0 = wxLayoutExport( &status, WXLO_EXPORT_AS_TEXT)) != NULL)
- {
- if(export0->type == WXLO_EXPORT_TEXT)
- cout << *(export0->content.text);
- else
- cout << "<!--UNKNOWN OBJECT>";
- delete export0;
- }
- }
- break;
- case ID_LONG_TEST:
- {
- wxString line;
- wxLayoutList *llist = m_lwin->GetLayoutList();
- for(int i = 1; i < 300; i++)
- {
- line.Printf("This is line number %d.", i);
- llist->Insert(line);
- llist->LineBreak();
- }
- llist->MoveCursorTo(wxPoint(0,0));
- m_lwin->SetDirty();
- m_lwin->Refresh();
- break;
- }
-
- case ID_LINEBREAKS_TEST:
- wxLayoutImportText(m_lwin->GetLayoutList(),
- "This is a text\n"
- "with embedded line\n"
- "breaks.\n");
- m_lwin->SetDirty();
- m_lwin->Refresh();
- break;
-
- case ID_URL_TEST:
- // VZ: this doesn't work, of course, but I think it should -
- // wxLayoutWindow should have a flag m_highlightUrls and do it itself
- // (instead of doing it manually like M does now)
- m_lwin->GetLayoutList()->Insert("http://www.wxwindows.org/");
- }
+ case ID_HTML:
+ {
+ wxLayoutExportObject *export0;
+ wxLayoutExportStatus status(m_lwin->GetLayoutList());
+
+ cout << "<HTML>" << endl;
+ while((export0 = wxLayoutExport( &status,
+ WXLO_EXPORT_AS_HTML)) != NULL)
+ {
+ if(export0->type == WXLO_EXPORT_HTML)
+ cout << *(export0->content.text);
+ else
+ ; // ignore itcout << "<!--UNKNOWN OBJECT>";
+
+ delete export0;
+ }
+ break;
+ }
+
+ case ID_TEXT:
+ {
+ wxLayoutExportObject *export0;
+ wxLayoutExportStatus status(m_lwin->GetLayoutList());
+
+ while((export0 = wxLayoutExport( &status, WXLO_EXPORT_AS_TEXT)) != NULL)
+ {
+ if(export0->type == WXLO_EXPORT_TEXT)
+ cout << *(export0->content.text);
+ else
+ cout << "<!--UNKNOWN OBJECT>";
+
+ delete export0;
+ }
+
+ break;
+ }
+
+
+ case ID_LONG_TEST:
+ {
+ wxString line;
+ wxLayoutList *llist = m_lwin->GetLayoutList();
+ for(int i = 1; i < 300; i++)
+ {
+ line.Printf(wxT("This is line number %d."), i);
+ llist->Insert(line);
+ llist->LineBreak();
+ }
+
+ llist->MoveCursorTo(wxPoint(0,0));
+ m_lwin->SetDirty();
+ m_lwin->Refresh();
+ break;
+ }
+
+ case ID_LINEBREAKS_TEST:
+ wxLayoutImportText
+ (
+ m_lwin->GetLayoutList(),
+ wxT("This is a text\nwith embedded line\nbreaks.\n")
+ );
+
+ m_lwin->SetDirty();
+ m_lwin->Refresh();
+ break;
+
+ case ID_URL_TEST:
+ // VZ: this doesn't work, of course, but I think it should -
+ // wxLayoutWindow should have a flag m_highlightUrls and do it itself
+ // (instead of doing it manually like M does now)
+ m_lwin->GetLayoutList()->Insert("http://www.wxwindows.org/");
+ }
};
void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
wxLayoutObject::DebugDump(void) const
{
wxString str;
- str.Printf("%s",g_aTypeStrings[GetType()]);
+ str.Printf(wxT("%s"), g_aTypeStrings[GetType()]);
return str;
}
#else
static
void ReadString(wxString &to, wxString &from)
{
- to = "";
- const char *cptr = from.c_str();
- while(*cptr && *cptr != '\n')
- to += *cptr++;
- if(*cptr) cptr++;
- from = cptr;
+ to = wxT("");
+ const wxChar *cptr = from.c_str();
+ while(*cptr && *cptr != wxT('\n'))
+ {
+ to += cptr;
+ cptr++;
+ }
+
+ if(*cptr) cptr++;
+
+ from = cptr;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
wxLayoutObject *
wxLayoutObject::Read(wxString &istr)
{
- wxString tmp;
- ReadString(tmp, istr);
- int type = WXLO_TYPE_INVALID;
- sscanf(tmp.c_str(),"%d", &type);
-
- switch(type)
- {
- case WXLO_TYPE_TEXT:
- return wxLayoutObjectText::Read(istr);
- case WXLO_TYPE_CMD:
- return wxLayoutObjectCmd::Read(istr);
- case WXLO_TYPE_ICON:
- return wxLayoutObjectIcon::Read(istr);
- default:
- return NULL;
- }
+ wxString tmp;
+ ReadString(tmp, istr);
+ long l = WXLO_TYPE_INVALID;
+ tmp.ToLong(&l);
+ int type = (int) l;
+
+ switch(type)
+ {
+ case WXLO_TYPE_TEXT:
+ return wxLayoutObjectText::Read(istr);
+ case WXLO_TYPE_CMD:
+ return wxLayoutObjectCmd::Read(istr);
+ case WXLO_TYPE_ICON:
+ return wxLayoutObjectIcon::Read(istr);
+ default:
+ return NULL;
+ }
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
wxString str;
str = wxLayoutObject::DebugDump();
wxString str2;
- str2.Printf(" `%s`", m_Text.c_str());
+ str2.Printf(wxT(" `%s`"), m_Text.c_str());
return str+str2;
}
#endif
{
if ( !icon.Ok() )
{
- wxFAIL_MSG("invalid icon");
+ wxFAIL_MSG(wxT("invalid icon"));
m_Icon = NULL;
wxLayoutObjectCmd *
wxLayoutObjectCmd::Read(wxString &istr)
{
- wxLayoutObjectCmd *obj = new wxLayoutObjectCmd;
-
- wxString tmp;
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->family);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->size);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->style);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->weight);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->underline);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->m_fg_valid);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->m_bg_valid);
- if(obj->m_StyleInfo->m_fg_valid)
- {
- int red, green, blue;
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &red);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &green);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &blue);
- obj->m_StyleInfo->m_fg = wxColour(red, green, blue);
- }
- if(obj->m_StyleInfo->m_bg_valid)
- {
- int red, green, blue;
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &red);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &green);
- ReadString(tmp, istr);
- sscanf(tmp.c_str(),"%d", &blue);
- obj->m_StyleInfo->m_bg = wxColour(red, green, blue);
- }
- return obj;
+ wxLayoutObjectCmd *obj = new wxLayoutObjectCmd;
+
+ long l = 0;
+ wxString tmp;
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ obj->m_StyleInfo->family = (int) l;
+
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ obj->m_StyleInfo->size = (int) l;
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ obj->m_StyleInfo->style = (int) l;
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ obj->m_StyleInfo->weight = (int) l;
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ obj->m_StyleInfo->underline = (int) l;
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ obj->m_StyleInfo->m_fg_valid = (int) l;
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ obj->m_StyleInfo->m_bg_valid = (int) l;
+
+ if(obj->m_StyleInfo->m_fg_valid)
+ {
+ int red, green, blue;
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ red = (int) l;
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ green = (int) l;
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ blue = (int) l;
+
+ obj->m_StyleInfo->m_fg = wxColour(red, green, blue);
+ }
+
+ if(obj->m_StyleInfo->m_bg_valid)
+ {
+ int red, green, blue;
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ red = (int) l;
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ green = (int) l;
+
+ ReadString(tmp, istr);
+ tmp.ToLong(&l);
+ blue = (int) l;
+
+ obj->m_StyleInfo->m_bg = wxColour(red, green, blue);
+ }
+
+ return obj;
}
bool
wxLayoutLine::DeleteWord(CoordType xpos)
{
- wxASSERT(xpos >= 0);
- CoordType offset;
- MarkDirty(xpos);
+ wxASSERT(xpos >= 0);
+ CoordType offset;
+ MarkDirty(xpos);
+
+ wxLOiterator i = FindObject(xpos, &offset);
+
+ for(;;)
+ {
+ if(i == NULLIT) return false;
+ if((**i).GetType() != WXLO_TYPE_TEXT)
+ {
+ // This should only happen when at end of line, behind a non-text
+ // object:
+ if(offset == (**i).GetLength()) return false;
+ m_Length -= (**i).GetLength(); // -1
+ m_ObjectList.erase(i);
+ return true; // we are done
+ }
+ else
+ { // text object:
+ if(offset == (**i).GetLength()) // at end of object
+ {
+ i++; offset = 0;
+ continue;
+ }
- wxLOiterator i = FindObject(xpos, &offset);
+ wxLayoutObjectText *tobj = (wxLayoutObjectText *)*i;
+ size_t count = 0;
+ wxString str = tobj->GetText();
+ str = str.substr(offset,str.Length()-offset);
+ // Find out how many positions we need to delete:
+ // 1. eat leading space
+ while(isspace(str.c_str()[count])) count++;
+ // 2. eat the word itself:
+ while(isalnum(str.c_str()[count])) count++;
+ // now delete it:
+ wxASSERT(count+offset <= (size_t) (**i).GetLength());
+ ((wxLayoutObjectText *)*i)->GetText().erase(offset,count);
+ m_Length -= count;
- for(;;)
- {
- if(i == NULLIT) return false;
- if((**i).GetType() != WXLO_TYPE_TEXT)
- {
- // This should only happen when at end of line, behind a non-text
- // object:
- if(offset == (**i).GetLength()) return false;
- m_Length -= (**i).GetLength(); // -1
- m_ObjectList.erase(i);
- return true; // we are done
- }
- else
- { // text object:
- if(offset == (**i).GetLength()) // at end of object
- {
- i++; offset = 0;
- continue;
- }
- wxLayoutObjectText *tobj = (wxLayoutObjectText *)*i;
- size_t count = 0;
- wxString str = tobj->GetText();
- str = str.substr(offset,str.Length()-offset);
- // Find out how many positions we need to delete:
- // 1. eat leading space
- while(isspace(str.c_str()[count])) count++;
- // 2. eat the word itself:
- while(isalnum(str.c_str()[count])) count++;
- // now delete it:
- wxASSERT(count+offset <= (size_t) (**i).GetLength());
- ((wxLayoutObjectText *)*i)->GetText().erase(offset,count);
- m_Length -= count;
- return true;
- }
- }
+ return true;
+ }
+ }
- wxFAIL_MSG("unreachable");
+ wxFAIL_MSG(wxT("unreachable"));
}
wxLayoutLine *
// find the object which covers the wrapmargin:
CoordType offset;
wxLOiterator i = FindObject(wrapmargin, &offset);
- wxCHECK_MSG( i != NULLIT, FALSE, "Cannot find object covering wrapmargin.");
+ wxCHECK_MSG( i != NULLIT, FALSE,
+ wxT("Cannot find object covering wrapmargin."));
// from this object on, the rest of the line must be copied to the
// next one:
void
wxLayoutLine::MergeNextLine(wxLayoutList *llist)
{
- wxCHECK_RET(GetNextLine(),"wxLayout internal error: no next line to merge");
+ wxCHECK_RET( GetNextLine(),
+ wxT("wxLayout internal error: no next line to merge"));
wxLayoutObjectList &list = GetNextLine()->m_ObjectList;
wxLOiterator i;
wxLayoutLine::Debug(void) const
{
wxPoint pos = GetPosition();
- WXLO_DEBUG(("Line %ld, Pos (%ld,%ld), Height %ld, BL %ld, Font: %d",
+ WXLO_DEBUG((wxT("Line %ld, Pos (%ld,%ld), Height %ld, BL %ld, Font: %d"),
(long int) GetLineNumber(),
(long int) pos.x, (long int) pos.y,
(long int) GetHeight(),
Empty();
m_FirstLine->DeleteLine(false, this);
- wxASSERT_MSG( m_numLines == 0, "line count calculation broken" );
+ wxASSERT_MSG( m_numLines == 0, wxT("line count calculation broken"));
}
void
// check for a linebreak:
wxString tmp;
tmp = istr.BeforeFirst('\n');
- int type = WXLO_TYPE_INVALID;
- sscanf(tmp.c_str(),"%d", &type);
+ long l = WXLO_TYPE_INVALID;
+ tmp.ToLong(&l);
+ int type = (int) l;
+
if(type == WXLO_TYPE_LINEBREAK)
{
LineBreak();
bool
wxLayoutList::MoveCursorWord(int n, bool untilNext)
{
- wxCHECK_MSG( m_CursorLine, false, "no current line" );
- wxCHECK_MSG( n == -1 || n == +1, false, "not implemented yet" );
+ wxCHECK_MSG( m_CursorLine, false, wxT("no current line") );
+ wxCHECK_MSG( n == -1 || n == +1, false, wxT("not implemented yet") );
CoordType moveDistance = 0;
CoordType offset;
if ( canAdvance )
{
const wxString& text = tobj->GetText();
- const char *start = text.c_str();
- const char *end = start + text.length();
- const char *p = start + offset;
+ const wxChar *start = text.c_str();
+ const wxChar *end = start + text.length();
+ const wxChar *p = start + offset;
if ( n < 0 )
{
wxLayoutList::Insert(wxString const &text)
{
wxASSERT(m_CursorLine);
- wxASSERT_MSG( text.Find('\n') == wxNOT_FOUND, "use wxLayoutImportText!" );
+ wxASSERT_MSG( text.Find(wxT('\n')) == wxNOT_FOUND,
+ wxT("use wxLayoutImportText!") );
if ( !text )
return true;
bool
wxLayoutList::Delete(CoordType npos)
{
- wxCHECK_MSG(m_CursorLine, false, "can't delete in non existing line");
+ wxCHECK_MSG(m_CursorLine, false, wxT("can't delete in non existing line"));
if ( npos == 0 )
return true;
}
else
{
- wxFAIL_MSG("can't delete all this");
+ wxFAIL_MSG(wxT("can't delete all this"));
return false;
}
}
InvalidateUpdateRect();
- WXLO_DEBUG(("Selection is %s : %ld,%ld/%ld,%ld",
- m_Selection.m_valid ? "valid" : "invalid",
+ WXLO_DEBUG((wxT("Selection is %s : %ld,%ld/%ld,%ld"),
+ m_Selection.m_valid ? wxT("valid") : wxT("invalid"),
m_Selection.m_CursorA.x, m_Selection.m_CursorA.y,
m_Selection.m_CursorB.x, m_Selection.m_CursorB.y));
}
coords += translate;
#ifdef WXLAYOUT_DEBUG
- WXLO_DEBUG(("Drawing cursor (%ld,%ld) at %ld,%ld, size %ld,%ld, line: %ld, len %ld",
+ WXLO_DEBUG((wxT("Drawing cursor (%ld,%ld) at %ld,%ld, size %ld,%ld, line: %ld, len %ld"),
(long)m_CursorPos.x, (long)m_CursorPos.y,
(long)coords.x, (long)coords.y,
(long)m_CursorSize.x, (long)m_CursorSize.y,
(long)m_CursorLine->GetLineNumber(),
(long)m_CursorLine->GetLength()));
- wxLogStatus("Cursor is at (%d, %d)", m_CursorPos.x, m_CursorPos.y);
+ wxLogStatus(wxT("Cursor is at (%d, %d)"), m_CursorPos.x, m_CursorPos.y);
#endif
#ifdef WXLAYOUT_USE_CARET
wxPoint cpos(cposOrig);
if ( cpos.x == -1 )
cpos = m_CursorPos;
- WXLO_DEBUG(("Starting selection at %ld/%ld", cpos.x, cpos.y));
+ WXLO_DEBUG((wxT("Starting selection at %ld/%ld"), cpos.x, cpos.y));
m_Selection.m_CursorA = cpos;
m_Selection.m_CursorB = cpos;
m_Selection.m_ScreenA = spos;
wxASSERT(m_Selection.m_selecting == true);
wxASSERT(m_Selection.m_valid == false);
- WXLO_DEBUG(("Continuing selection at %ld/%ld", cpos.x, cpos.y));
+ WXLO_DEBUG((wxT("Continuing selection at %ld/%ld"), cpos.x, cpos.y));
m_Selection.m_ScreenB = spos;
m_Selection.m_CursorB = cpos;
wxPoint cpos(cposOrig);
if(cpos.x == -1) cpos = m_CursorPos;
ContinueSelection(cpos, spos);
- WXLO_DEBUG(("Ending selection at %ld/%ld", cpos.x, cpos.y));
+ WXLO_DEBUG((wxT("Ending selection at %ld/%ld"), cpos.x, cpos.y));
// we always want m_CursorA <= m_CursorB!
if( m_Selection.m_CursorA > m_Selection.m_CursorB )
{
wxLayoutList::GetLine(CoordType index) const
{
wxASSERT_MSG( (0 <= index) && (index < (CoordType)m_numLines),
- "invalid index" );
+ wxT("invalid index") );
wxLayoutLine *line;
CoordType n = index;
void
wxLayoutList::Debug(void)
{
- WXLO_DEBUG(("Cursor is in line %d, screen pos = (%d, %d)",
+ WXLO_DEBUG((wxT("Cursor is in line %d, screen pos = (%d, %d)"),
m_CursorLine->GetLineNumber(),
m_CursorScreenPos.x, m_CursorScreenPos.y));
top = (page - 1)*m_PrintoutHeight;
bottom = top + m_PrintoutHeight;
- WXLO_DEBUG(("OnPrintPage(%d) printing from %d to %d", page, top,
+ WXLO_DEBUG((wxT("OnPrintPage(%d) printing from %d to %d"), page, top,
bottom));
// SetDeviceOrigin() doesn't work here, so we need to manually
// translate all coordinates.
virtual wxString DebugDump(void) const;
#endif
- virtual CoordType GetLength(void) const { return strlen(m_Text.c_str()); }
+ virtual CoordType GetLength(void) const { return wxStrlen(m_Text.c_str()); }
// for editing:
wxString & GetText(void) { return m_Text; }
public:
wxLayoutDataObject()
{
- SetFormat("application/wxlayoutlist");
+ SetFormat(wxT("application/wxlayoutlist"));
}
// type safe wrappers
&& m_WrapMargin > 0
&& m_llist->GetCursorPos().x > m_WrapMargin
&& isspace(keyCode))
+ {
m_llist->WrapLine(m_WrapMargin);
- m_llist->Insert((char)keyCode);
+ }
+
+ m_llist->Insert((wxChar)keyCode);
SetDirty();
}
else
void MyFrame::SetMinSize(wxCommandEvent& WXUNUSED(event) )
{
wxString str;
- str.Printf( _T(_T("%d")), m_splitter->GetMinimumPaneSize());
+ str.Printf( wxT("%d"), m_splitter->GetMinimumPaneSize());
str = wxGetTextFromUser(_T("Enter minimal size for panes:"), _T(""), str, this);
if ( str.IsEmpty() )
return;
int minsize = wxStrtol( str, (wxChar**)NULL, 10 );
m_splitter->SetMinimumPaneSize(minsize);
- str.Printf( _T(_T("Min pane size = %d")), minsize);
+ str.Printf( wxT("Min pane size = %d"), minsize);
SetStatusText(str, 1);
}
data = new char[size];
sockstrm->Read(data, size);
- connection->OnExecute (topic_name, data, size, format);
+ connection->OnExecute (topic_name, (wxChar *) data, size, format);
delete [] data;
break;
data = new char[size];
sockstrm->Read(data, size);
- connection->OnAdvise (topic_name, item, data, size, format);
+ connection->OnAdvise (topic_name, item, (wxChar *) data, size, format);
delete [] data;
break;
0);
DdeFreeDataHandle(hData);
if ( connection->OnExecute(connection->m_topicName,
- connection->m_bufPtr,
+ (wxChar *) connection->m_bufPtr,
(int)len,
(wxIPCFormat) wFmt) )
{
DdeFreeDataHandle(hData);
if ( connection->OnAdvise(connection->m_topicName,
item_name,
- connection->m_bufPtr,
+ (wxChar *) connection->m_bufPtr,
(int)len,
(wxIPCFormat) wFmt) )
{