Applied patch #845402 ("RichEdit sample fixing and cleaning"); In addition made compilation with MSVC (nearly) warning free+some more cleaning up.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24613 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -136,7 +136,7 @@ public:
|
||||
deleted by list. See the constructor for more details.
|
||||
@param ownsflag if true, list will own entries
|
||||
*/
|
||||
void ownsObjects(bool ownsflag = true)
|
||||
void ownsObjects(bool ownsflag)
|
||||
{ ownsEntries = ownsflag; }
|
||||
|
||||
/** Query whether list owns entries.
|
||||
@@ -236,7 +236,10 @@ protected:
|
||||
param iterator i
|
||||
*/
|
||||
inline void deleteContent(iterator i)
|
||||
{ if(ownsEntries) delete *i; }
|
||||
{
|
||||
iterator *i_ptr = &i;
|
||||
if(ownsEntries) delete i_ptr;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
@@ -17,8 +17,8 @@
|
||||
#endif
|
||||
|
||||
#include "wxLayout.h"
|
||||
#include <wx/textfile.h>
|
||||
#include <wx/image.h>
|
||||
#include "wx/textfile.h"
|
||||
#include "wx/image.h"
|
||||
|
||||
#if wxUSE_IOSTREAMH
|
||||
#include <iostream.h>
|
||||
@@ -26,6 +26,9 @@
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#include "wx/wfstream.h"
|
||||
#include "wx/txtstrm.h"
|
||||
|
||||
#include "Micon.xpm"
|
||||
|
||||
|
||||
@@ -69,9 +72,9 @@ BEGIN_EVENT_TABLE(MyFrame,wxFrame)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
MyFrame::MyFrame(void) :
|
||||
wxFrame( (wxFrame *) NULL, -1, _T("wxLayout"),
|
||||
wxPoint(880,100), wxSize(256,256) )
|
||||
MyFrame::MyFrame() :
|
||||
wxFrame( (wxFrame *) NULL, wxID_ANY, _T("wxLayout"),
|
||||
wxDefaultPosition, wxDefaultSize )
|
||||
{
|
||||
CreateStatusBar( 2 );
|
||||
|
||||
@@ -119,7 +122,7 @@ MyFrame::MyFrame(void) :
|
||||
menu_bar->Append(edit_menu, _T("&Edit") );
|
||||
|
||||
#ifndef __WXMSW__
|
||||
menu_bar->Show( TRUE );
|
||||
menu_bar->Show(true);
|
||||
#endif // MSW
|
||||
|
||||
SetMenuBar( menu_bar );
|
||||
@@ -157,12 +160,13 @@ MyFrame::MyFrame(void) :
|
||||
#endif // 0
|
||||
};
|
||||
|
||||
void
|
||||
MyFrame::AddSampleText(wxLayoutList *llist)
|
||||
void MyFrame::AddSampleText(wxLayoutList *llist)
|
||||
{
|
||||
llist->Clear(wxSWISS,16,wxNORMAL,wxNORMAL, false);
|
||||
llist->SetFont(-1,-1,-1,-1,-1,_T("blue"));
|
||||
llist->Insert(_T("blue"));
|
||||
llist->LineBreak();
|
||||
|
||||
llist->SetFont(-1,-1,-1,-1,-1,_T("black"));
|
||||
llist->Insert(_T("The quick brown fox jumps over the lazy dog."));
|
||||
llist->LineBreak();
|
||||
@@ -174,35 +178,46 @@ MyFrame::AddSampleText(wxLayoutList *llist)
|
||||
llist->SetFont(wxROMAN);
|
||||
llist->Insert(_T("The quick brown fox jumps over the lazy dog."));
|
||||
llist->LineBreak();
|
||||
|
||||
llist->Insert(_T("Hello "));
|
||||
wxBitmap *icon =
|
||||
#if wxICON_IS_BITMAP
|
||||
llist->Insert(new wxLayoutObjectIcon(new wxICON(Micon)));
|
||||
new wxIcon(Micon_xpm)
|
||||
#else
|
||||
llist->Insert(new wxLayoutObjectIcon(new wxBitmap (wxICON(Micon))));
|
||||
new wxBitmap (wxIcon(Micon_xpm))
|
||||
#endif
|
||||
|
||||
;
|
||||
|
||||
llist->Insert(new wxLayoutObjectIcon(icon));
|
||||
llist->SetFontWeight(wxBOLD);
|
||||
llist->Insert(_T("World! "));
|
||||
llist->SetFontWeight(wxNORMAL);
|
||||
llist->Insert(_T("The quick brown fox jumps..."));
|
||||
llist->LineBreak();
|
||||
|
||||
llist->Insert(_T("over the lazy dog."));
|
||||
llist->SetFont(-1,-1,-1,-1,true);
|
||||
llist->Insert(_T("underlined"));
|
||||
llist->SetFont(-1,-1,-1,-1,false);
|
||||
llist->SetFont(wxROMAN);
|
||||
llist->Insert(_T("This is "));
|
||||
llist->SetFont(-1,-1,-1,wxBOLD); llist->Insert(_T("BOLD ")); llist->SetFont(-1,-1,-1,wxNORMAL);
|
||||
llist->SetFont(-1,-1,-1,wxBOLD);
|
||||
llist->Insert(_T("BOLD "));
|
||||
llist->SetFont(-1,-1,-1,wxNORMAL);
|
||||
llist->Insert(_T("and "));
|
||||
llist->SetFont(-1,-1,wxITALIC);
|
||||
llist->Insert(_T("italics "));
|
||||
llist->SetFont(-1,-1,wxNORMAL);
|
||||
llist->LineBreak();
|
||||
|
||||
llist->Insert(_T("and "));
|
||||
llist->SetFont(-1,-1,wxSLANT);
|
||||
llist->Insert(_T("slanted"));
|
||||
llist->SetFont(-1,-1,wxNORMAL);
|
||||
llist->Insert(_T(" text."));
|
||||
llist->LineBreak();
|
||||
|
||||
llist->Insert(_T("and "));
|
||||
llist->SetFont(-1,-1,-1,-1,-1,_T("blue"));
|
||||
llist->Insert(_T("blue"));
|
||||
@@ -227,23 +242,20 @@ MyFrame::AddSampleText(wxLayoutList *llist)
|
||||
// add some more text for testing:
|
||||
llist->Insert(_T("And here the source for the test program:"));
|
||||
llist->LineBreak();
|
||||
|
||||
llist->SetFont(wxTELETYPE,16);
|
||||
llist->Insert(_T("And here the source for the test program:"));
|
||||
llist->LineBreak();
|
||||
llist->Insert(_T("And here the source for the test program:"));
|
||||
llist->LineBreak();
|
||||
llist->Insert(_T("And here the source for the test program:"));
|
||||
|
||||
wxFile file( _T("wxLayout.cpp") );
|
||||
if ( file.IsOpened() )
|
||||
wxTextFile file(_T("wxLayout.cpp"));
|
||||
if ( file.Open() )
|
||||
{
|
||||
off_t len = file.Length();
|
||||
wxChar *data = (wxChar *)malloc(2*len);
|
||||
if ( file.Read(data, len) == len )
|
||||
for ( wxString s = file.GetFirstLine(); !file.Eof(); s = file.GetNextLine() )
|
||||
{
|
||||
wxLayoutImportText(llist, data);
|
||||
wxString line;
|
||||
llist->Insert(line.Format(_T("%6u: %s"),file.GetCurrentLine()+1,s.c_str()));
|
||||
llist->LineBreak();
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
|
||||
llist->MoveCursorTo(wxPoint(0,0));
|
||||
@@ -251,8 +263,7 @@ MyFrame::AddSampleText(wxLayoutList *llist)
|
||||
m_lwin->Refresh();
|
||||
}
|
||||
|
||||
void
|
||||
MyFrame::Clear(void)
|
||||
void MyFrame::Clear()
|
||||
{
|
||||
wxColour colBg(0, 0, 0);
|
||||
|
||||
@@ -265,13 +276,13 @@ void MyFrame::OnCommand( wxCommandEvent &event )
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_QUIT:
|
||||
Close( TRUE );
|
||||
Close(true);
|
||||
break;
|
||||
case ID_PRINT:
|
||||
{
|
||||
wxPrinter printer;
|
||||
wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout"));
|
||||
if (! printer.Print(this, &printout, TRUE))
|
||||
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
|
||||
@@ -297,76 +308,100 @@ void MyFrame::OnCommand( wxCommandEvent &event )
|
||||
Clear();
|
||||
break;
|
||||
case ID_CLICK:
|
||||
cerr << "Received click event." << endl;
|
||||
wxLogError( _T("Received click event.") );
|
||||
break;
|
||||
case ID_PASTE:
|
||||
m_lwin->Paste(TRUE);
|
||||
m_lwin->Refresh(FALSE);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
m_lwin->Copy(true, true, false);
|
||||
m_lwin->Refresh(false);
|
||||
break;
|
||||
case ID_CUT:
|
||||
m_lwin->Cut();
|
||||
m_lwin->Refresh(FALSE);
|
||||
m_lwin->Refresh(false);
|
||||
break;
|
||||
#ifdef M_BASEDIR
|
||||
case ID_FIND:
|
||||
m_lwin->Find("void");
|
||||
m_lwin->Refresh(FALSE);
|
||||
m_lwin->Refresh(false);
|
||||
break;
|
||||
#endif
|
||||
case ID_HTML:
|
||||
{
|
||||
wxLayoutExportObject *export0;
|
||||
wxLayoutExportStatus status(m_lwin->GetLayoutList());
|
||||
wxFileDialog
|
||||
HTML_dialog( this,
|
||||
_T("Save As HTML..."),
|
||||
wxEmptyString,
|
||||
wxEmptyString,
|
||||
_T("HTML file (*.html)|*.html|Text file (*.txt)|*.txt|Any file (*)|*"),
|
||||
wxSAVE|wxOVERWRITE_PROMPT
|
||||
);
|
||||
if (HTML_dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
wxFFileOutputStream output( HTML_dialog.GetPath() );
|
||||
wxTextOutputStream textout( output );
|
||||
|
||||
cout << "<HTML>" << endl;
|
||||
while((export0 = wxLayoutExport( &status,
|
||||
WXLO_EXPORT_AS_HTML)) != NULL)
|
||||
wxLayoutExportObject *export0;
|
||||
wxString object;
|
||||
wxLayoutExportStatus status(m_lwin->GetLayoutList());
|
||||
while((export0 = wxLayoutExport( &status, WXLO_EXPORT_AS_HTML)) != NULL)
|
||||
{
|
||||
if(export0->type == WXLO_EXPORT_HTML)
|
||||
cout << *(export0->content.text);
|
||||
object = *(export0->content.text);
|
||||
else
|
||||
; // ignore itcout << "<!--UNKNOWN OBJECT>";
|
||||
|
||||
; // ignore "<!--UNKNOWN OBJECT>";
|
||||
delete export0;
|
||||
textout << object;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_TEXT:
|
||||
{
|
||||
wxLayoutExportObject *export0;
|
||||
wxLayoutExportStatus status(m_lwin->GetLayoutList());
|
||||
wxFileDialog
|
||||
TEXT_dialog( this,
|
||||
_T("Save As TXT..."),
|
||||
wxEmptyString,
|
||||
wxEmptyString,
|
||||
_T("Text file (*.txt)|*.txt|Any file (*)|*"),
|
||||
wxSAVE|wxOVERWRITE_PROMPT
|
||||
);
|
||||
if (TEXT_dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
wxFFileOutputStream output( TEXT_dialog.GetPath() );
|
||||
wxTextOutputStream textout( output );
|
||||
|
||||
wxLayoutExportObject *export0;
|
||||
wxString object;
|
||||
wxLayoutExportStatus status(m_lwin->GetLayoutList());
|
||||
while((export0 = wxLayoutExport( &status, WXLO_EXPORT_AS_TEXT)) != NULL)
|
||||
{
|
||||
if(export0->type == WXLO_EXPORT_TEXT)
|
||||
cout << *(export0->content.text);
|
||||
object = *(export0->content.text);
|
||||
else
|
||||
cout << "<!--UNKNOWN OBJECT>";
|
||||
|
||||
object = _T("<!--UNKNOWN OBJECT>");
|
||||
delete export0;
|
||||
textout << object;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case ID_LONG_TEST:
|
||||
{
|
||||
wxString line;
|
||||
@@ -400,6 +435,7 @@ void MyFrame::OnCommand( wxCommandEvent &event )
|
||||
// wxLayoutWindow should have a flag m_highlightUrls and do it itself
|
||||
// (instead of doing it manually like M does now)
|
||||
m_lwin->GetLayoutList()->Insert(_T("http://www.wxwindows.org/"));
|
||||
m_lwin->Refresh();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -412,7 +448,7 @@ void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
|
||||
#endif
|
||||
wxPrinter printer;
|
||||
wxLayoutPrintout printout( m_lwin->GetLayoutList(), _T("Printout from wxLayout"));
|
||||
if (! printer.Print(this, &printout, TRUE))
|
||||
if (! printer.Print(this, &printout, true))
|
||||
wxMessageBox(
|
||||
_T("There was a problem printing.\nPerhaps your current printer is not set correctly?"),
|
||||
_T("Printing"), wxOK);
|
||||
@@ -425,7 +461,7 @@ void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
|
||||
#ifdef OS_UNIX
|
||||
wxPostScriptPrinter printer;
|
||||
wxLayoutPrintout printout( m_lwin->GetLayoutList(),"My printout");
|
||||
printer.Print(this, &printout, TRUE);
|
||||
printer.Print(this, &printout, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -452,7 +488,7 @@ void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
|
||||
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
|
||||
frame->Centre(wxBOTH);
|
||||
frame->Initialize();
|
||||
frame->Show(TRUE);
|
||||
frame->Show(true);
|
||||
}
|
||||
|
||||
void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -466,7 +502,7 @@ void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
|
||||
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
|
||||
frame->Centre(wxBOTH);
|
||||
frame->Initialize();
|
||||
frame->Show(TRUE);
|
||||
frame->Show(true);
|
||||
}
|
||||
|
||||
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -531,18 +567,18 @@ void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
|
||||
// MyApp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
MyApp::MyApp(void) :
|
||||
MyApp::MyApp() :
|
||||
wxApp( )
|
||||
{
|
||||
};
|
||||
|
||||
bool MyApp::OnInit(void)
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
wxFrame *frame = new MyFrame();
|
||||
wxInitAllImageHandlers();
|
||||
frame->Show( TRUE );
|
||||
frame->Show( true );
|
||||
// wxSetAFMPath("/usr/local/src/wxWindows/misc/afm/");
|
||||
return TRUE;
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include "wx/wx.h"
|
||||
|
||||
#include "wxllist.h"
|
||||
#include "wxlwindow.h"
|
||||
@@ -26,13 +26,12 @@ class MyApp;
|
||||
|
||||
class MyFrame: public wxFrame
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(MyFrame)
|
||||
|
||||
public:
|
||||
|
||||
MyFrame(void);
|
||||
MyFrame();
|
||||
void AddSampleText(wxLayoutList *llist);
|
||||
void Clear(void);
|
||||
void Clear();
|
||||
void OnCommand( wxCommandEvent &event );
|
||||
|
||||
void OnPrint(wxCommandEvent& event);
|
||||
@@ -44,11 +43,14 @@ class MyFrame: public wxFrame
|
||||
void OnPrintSetupPS(wxCommandEvent& event);
|
||||
void OnPageSetupPS(wxCommandEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
private:
|
||||
wxLayoutWindow *m_lwin;
|
||||
wxPrintData m_PrintData;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(MyFrame)
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -59,8 +61,11 @@ class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
|
||||
MyApp(void);
|
||||
virtual bool OnInit(void);
|
||||
MyApp();
|
||||
|
||||
virtual bool OnInit();
|
||||
|
||||
};
|
||||
|
||||
#endif // __WXCONVERTH__
|
||||
|
||||
|
@@ -51,15 +51,15 @@
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
# include <wx/dc.h>
|
||||
# include <wx/dcps.h>
|
||||
# include <wx/print.h>
|
||||
# include <wx/log.h>
|
||||
# include <wx/filefn.h>
|
||||
# include "wx/dc.h"
|
||||
# include "wx/dcps.h"
|
||||
# include "wx/print.h"
|
||||
# include "wx/log.h"
|
||||
# include "wx/filefn.h"
|
||||
#endif
|
||||
|
||||
#ifdef WXLAYOUT_USE_CARET
|
||||
# include <wx/caret.h>
|
||||
# include "wx/caret.h"
|
||||
#endif // WXLAYOUT_USE_CARET
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -78,7 +78,7 @@
|
||||
_T("invalid"), _T("text"), _T("cmd"), _T("icon")
|
||||
};
|
||||
wxString
|
||||
wxLayoutObject::DebugDump(void) const
|
||||
wxLayoutObject::DebugDump() const
|
||||
{
|
||||
wxString str;
|
||||
str.Printf(wxT("%s"), g_aTypeStrings[GetType()]);
|
||||
@@ -213,9 +213,9 @@ wxLayoutObject::Read(wxString &istr)
|
||||
return wxLayoutObjectCmd::Read(istr);
|
||||
case WXLO_TYPE_ICON:
|
||||
return wxLayoutObjectIcon::Read(istr);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
@@ -234,7 +234,7 @@ wxLayoutObjectText::wxLayoutObjectText(const wxString &txt)
|
||||
}
|
||||
|
||||
wxLayoutObject *
|
||||
wxLayoutObjectText::Copy(void)
|
||||
wxLayoutObjectText::Copy()
|
||||
{
|
||||
wxLayoutObjectText *obj = new wxLayoutObjectText(m_Text);
|
||||
obj->m_Width = m_Width;
|
||||
@@ -386,7 +386,7 @@ wxLayoutObjectText::Layout(wxDC &dc, class wxLayoutList *WXUNUSED(llist))
|
||||
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
wxString
|
||||
wxLayoutObjectText::DebugDump(void) const
|
||||
wxLayoutObjectText::DebugDump() const
|
||||
{
|
||||
wxString str;
|
||||
str = wxLayoutObject::DebugDump();
|
||||
@@ -450,12 +450,12 @@ wxLayoutObjectIcon::Read(wxString &istr)
|
||||
delete obj;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
wxLayoutObject *
|
||||
wxLayoutObjectIcon::Copy(void)
|
||||
wxLayoutObjectIcon::Copy()
|
||||
{
|
||||
wxLayoutObjectIcon *obj = new wxLayoutObjectIcon(new
|
||||
wxBitmap(*m_Icon));
|
||||
@@ -476,7 +476,7 @@ wxLayoutObjectIcon::Draw(wxDC &dc, wxPoint const &coords,
|
||||
CoordType WXUNUSED(begin), CoordType WXUNUSED(len) )
|
||||
{
|
||||
dc.DrawBitmap(*m_Icon, coords.x, coords.y-m_Icon->GetHeight(),
|
||||
(m_Icon->GetMask() == NULL) ? FALSE : TRUE);
|
||||
(m_Icon->GetMask() == NULL) ? false : true);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -552,7 +552,7 @@ wxLayoutObjectCmd::wxLayoutObjectCmd(const wxLayoutStyleInfo &si)
|
||||
}
|
||||
|
||||
wxLayoutObject *
|
||||
wxLayoutObjectCmd::Copy(void)
|
||||
wxLayoutObjectCmd::Copy()
|
||||
{
|
||||
wxLayoutObjectCmd *obj = new wxLayoutObjectCmd(
|
||||
m_StyleInfo->family,
|
||||
@@ -675,7 +675,7 @@ wxLayoutObjectCmd::~wxLayoutObjectCmd()
|
||||
}
|
||||
|
||||
wxLayoutStyleInfo *
|
||||
wxLayoutObjectCmd::GetStyle(void) const
|
||||
wxLayoutObjectCmd::GetStyle() const
|
||||
{
|
||||
return m_StyleInfo;
|
||||
}
|
||||
@@ -851,9 +851,7 @@ wxLayoutLine::FindObjectScreen(wxDC &dc, wxLayoutList *llist,
|
||||
CoordType
|
||||
wxLayoutLine::FindText(const wxString &needle, CoordType xpos) const
|
||||
{
|
||||
int
|
||||
cpos = 0,
|
||||
relpos = -1;
|
||||
int cpos = 0;
|
||||
wxString const *text;
|
||||
|
||||
for(wxLOiterator i = m_ObjectList.begin(); i != m_ObjectList.end(); i++)
|
||||
@@ -863,7 +861,7 @@ wxLayoutLine::FindText(const wxString &needle, CoordType xpos) const
|
||||
if((**i).GetType() == WXLO_TYPE_TEXT)
|
||||
{
|
||||
text = & ((wxLayoutObjectText*)(*i))->GetText();
|
||||
relpos = text->Find(needle);
|
||||
int relpos = text->Find(needle);
|
||||
if(relpos >= cpos-xpos) // -1 if not found
|
||||
{
|
||||
return cpos+relpos;
|
||||
@@ -1118,7 +1116,9 @@ wxLayoutLine::Draw(wxDC &dc,
|
||||
if(highlight == -1) // partially highlight line
|
||||
{
|
||||
// parts of the line need highlighting
|
||||
xpos+(**i).GetLength();
|
||||
|
||||
// Next line commented, code has no effect
|
||||
// xpos+(**i).GetLength();
|
||||
(**i).Draw(dc, pos, llist, from-xpos, to-xpos);
|
||||
}
|
||||
else
|
||||
@@ -1357,12 +1357,12 @@ bool
|
||||
wxLayoutLine::Wrap(CoordType wrapmargin, wxLayoutList *llist)
|
||||
{
|
||||
if(GetLength() < wrapmargin)
|
||||
return FALSE; // nothing to do
|
||||
return false; // nothing to do
|
||||
|
||||
// find the object which covers the wrapmargin:
|
||||
CoordType offset;
|
||||
wxLOiterator i = FindObject(wrapmargin, &offset);
|
||||
wxCHECK_MSG( i != NULLIT, FALSE,
|
||||
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
|
||||
@@ -1387,7 +1387,7 @@ wxLayoutLine::Wrap(CoordType wrapmargin, wxLayoutList *llist)
|
||||
}
|
||||
else
|
||||
{
|
||||
bool foundSpace = FALSE;
|
||||
bool foundSpace = false;
|
||||
do
|
||||
{
|
||||
// while(i != NULLIT && (**i).GetType() != WXLO_TYPE_TEXT)
|
||||
@@ -1413,7 +1413,7 @@ wxLayoutLine::Wrap(CoordType wrapmargin, wxLayoutList *llist)
|
||||
if(! foundSpace) // breakpos == 0!
|
||||
{
|
||||
if(i == m_ObjectList.begin())
|
||||
return FALSE; // could not break line
|
||||
return false; // could not break line
|
||||
else
|
||||
{
|
||||
i--;
|
||||
@@ -1478,11 +1478,11 @@ wxLayoutLine::Wrap(CoordType wrapmargin, wxLayoutList *llist)
|
||||
#endif
|
||||
llist->MoveCursorTo( wxPoint( xpos, m_Next->GetLineNumber()) );
|
||||
}
|
||||
return TRUE; // we wrapped the line
|
||||
return true; // we wrapped the line
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutLine::ReNumber(void)
|
||||
wxLayoutLine::ReNumber()
|
||||
{
|
||||
CoordType lineNo = m_Previous ? m_Previous->m_LineNumber+1 : 0;
|
||||
m_LineNumber = lineNo++;
|
||||
@@ -1611,7 +1611,7 @@ wxLayoutLine::GetWrapPosition(CoordType column)
|
||||
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
void
|
||||
wxLayoutLine::Debug(void) const
|
||||
wxLayoutLine::Debug() const
|
||||
{
|
||||
wxPoint pos = GetPosition();
|
||||
WXLO_DEBUG((wxT("Line %ld, Pos (%ld,%ld), Height %ld, BL %ld, Font: %d"),
|
||||
@@ -1707,15 +1707,15 @@ wxLayoutList::wxLayoutList()
|
||||
|
||||
m_numLines = 0;
|
||||
m_FirstLine = NULL;
|
||||
SetAutoFormatting(TRUE);
|
||||
ForceTotalLayout(TRUE); // for the first time, do all
|
||||
SetAutoFormatting(true);
|
||||
ForceTotalLayout(true); // for the first time, do all
|
||||
InvalidateUpdateRect();
|
||||
Clear();
|
||||
}
|
||||
|
||||
wxLayoutList::~wxLayoutList()
|
||||
{
|
||||
SetAutoFormatting(FALSE);
|
||||
SetAutoFormatting(false);
|
||||
InternalClear();
|
||||
Empty();
|
||||
m_FirstLine->DeleteLine(false, this);
|
||||
@@ -1724,7 +1724,7 @@ wxLayoutList::~wxLayoutList()
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutList::Empty(void)
|
||||
wxLayoutList::Empty()
|
||||
{
|
||||
while(m_FirstLine)
|
||||
m_FirstLine = m_FirstLine->DeleteLine(false, this);
|
||||
@@ -1740,7 +1740,7 @@ wxLayoutList::Empty(void)
|
||||
|
||||
|
||||
void
|
||||
wxLayoutList::InternalClear(void)
|
||||
wxLayoutList::InternalClear()
|
||||
{
|
||||
m_Selection.m_selecting = false;
|
||||
m_Selection.m_valid = false;
|
||||
@@ -1750,9 +1750,9 @@ wxLayoutList::InternalClear(void)
|
||||
m_DefaultStyleInfo.style = wxNORMAL;
|
||||
m_DefaultStyleInfo.weight = wxNORMAL;
|
||||
m_DefaultStyleInfo.underline = 0;
|
||||
m_DefaultStyleInfo.m_fg_valid = TRUE;
|
||||
m_DefaultStyleInfo.m_fg_valid = true;
|
||||
m_DefaultStyleInfo.m_fg = *wxBLACK;
|
||||
m_DefaultStyleInfo.m_bg_valid = TRUE;
|
||||
m_DefaultStyleInfo.m_bg_valid = true;
|
||||
m_DefaultStyleInfo.m_bg = *wxWHITE;
|
||||
|
||||
m_CurrentStyleInfo = m_DefaultStyleInfo;
|
||||
@@ -2216,7 +2216,7 @@ bool
|
||||
wxLayoutList::Insert(wxLayoutList *llist)
|
||||
{
|
||||
wxASSERT(llist);
|
||||
bool rc = TRUE;
|
||||
bool rc = true;
|
||||
|
||||
for(wxLayoutLine *line = llist->GetFirstLine();
|
||||
line;
|
||||
@@ -2233,7 +2233,7 @@ wxLayoutList::Insert(wxLayoutList *llist)
|
||||
}
|
||||
|
||||
bool
|
||||
wxLayoutList::LineBreak(void)
|
||||
wxLayoutList::LineBreak()
|
||||
{
|
||||
wxASSERT(m_CursorLine);
|
||||
|
||||
@@ -2280,8 +2280,8 @@ wxLayoutList::WrapAll(CoordType column)
|
||||
{
|
||||
wxLayoutLine *line = m_FirstLine;
|
||||
if(! line)
|
||||
return FALSE;
|
||||
bool rc = TRUE;
|
||||
return false;
|
||||
bool rc = true;
|
||||
while(line && rc)
|
||||
{
|
||||
rc &= line->Wrap(column, this);
|
||||
@@ -2422,7 +2422,7 @@ wxLayoutList::Recalculate(wxDC &dc, CoordType bottom)
|
||||
}
|
||||
|
||||
wxPoint
|
||||
wxLayoutList::GetCursorScreenPos(void) const
|
||||
wxLayoutList::GetCursorScreenPos() const
|
||||
{
|
||||
return m_CursorScreenPos;
|
||||
}
|
||||
@@ -2442,10 +2442,11 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
|
||||
|
||||
if(m_ReLayoutAll)
|
||||
{
|
||||
forceAll = TRUE;
|
||||
forceAll = true;
|
||||
bottom = -1;
|
||||
}
|
||||
ForceTotalLayout(FALSE);
|
||||
|
||||
ForceTotalLayout(false);
|
||||
|
||||
|
||||
// If one line was dirty, we need to re-calculate all
|
||||
@@ -2496,7 +2497,8 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
|
||||
if ( csize )
|
||||
*csize = m_CursorSize;
|
||||
}
|
||||
cursorReached = TRUE;
|
||||
|
||||
cursorReached = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2505,12 +2507,13 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
|
||||
line->Layout(dc, this,
|
||||
cpos,
|
||||
csize, NULL, cpos->x);
|
||||
cursorReached = TRUE;
|
||||
cursorReached = true;
|
||||
}
|
||||
else
|
||||
line->Layout(dc, this);
|
||||
}
|
||||
}
|
||||
|
||||
line = line->GetNextLine();
|
||||
}
|
||||
|
||||
@@ -2520,6 +2523,7 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
|
||||
m_CursorLine->GetNextLine() == NULL &&
|
||||
m_CursorLine == m_FirstLine));
|
||||
#endif // WXLAYOUT_USE_CARET
|
||||
|
||||
AddCursorPosToUpdateRect();
|
||||
}
|
||||
|
||||
@@ -2579,13 +2583,16 @@ wxLayoutList::Draw(wxDC &dc,
|
||||
&& line->GetPosition().y
|
||||
+(clipStrictly ? line->GetHeight() : 0) >= bottom)
|
||||
break;
|
||||
|
||||
line->Draw(dc, this, offset);
|
||||
}
|
||||
|
||||
line = line->GetNextLine();
|
||||
}
|
||||
|
||||
InvalidateUpdateRect();
|
||||
|
||||
WXLO_DEBUG((wxT("Selection is %s : %ld,%ld/%ld,%ld"),
|
||||
WXLO_DEBUG((wxT("Selection is %s : %d,%d/%d,%d"),
|
||||
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));
|
||||
@@ -2593,8 +2600,7 @@ wxLayoutList::Draw(wxDC &dc,
|
||||
|
||||
wxLayoutObject *
|
||||
wxLayoutList::FindObjectScreen(wxDC &dc, wxPoint const pos,
|
||||
wxPoint *cursorPos,
|
||||
bool *found)
|
||||
wxPoint *cursorPos, bool *found)
|
||||
{
|
||||
// First, find the right line:
|
||||
wxLayoutLine
|
||||
@@ -2642,6 +2648,7 @@ wxLayoutList::FindObjectScreen(wxDC &dc, wxPoint const pos,
|
||||
pos.x,
|
||||
NULL,
|
||||
&foundinline);
|
||||
|
||||
if ( found )
|
||||
*found = didFind && foundinline;
|
||||
|
||||
@@ -2650,7 +2657,7 @@ wxLayoutList::FindObjectScreen(wxDC &dc, wxPoint const pos,
|
||||
}
|
||||
|
||||
wxPoint
|
||||
wxLayoutList::GetSize(void) const
|
||||
wxLayoutList::GetSize() const
|
||||
{
|
||||
wxLayoutLine
|
||||
*line = m_FirstLine,
|
||||
@@ -2745,6 +2752,7 @@ wxLayoutList::DrawCursor(wxDC &
|
||||
SetUpdateRect(coords.x, coords.y+m_CursorSize.y-1);
|
||||
SetUpdateRect(coords.x, coords.y);
|
||||
}
|
||||
|
||||
dc.SetLogicalFunction(wxCOPY);
|
||||
//dc.SetBrush(wxNullBrush);
|
||||
#endif // WXLAYOUT_USE_CARET/!WXLAYOUT_USE_CARET
|
||||
@@ -2754,7 +2762,9 @@ void
|
||||
wxLayoutList::SetUpdateRect(CoordType x, CoordType y)
|
||||
{
|
||||
if(m_UpdateRectValid)
|
||||
{
|
||||
GrowRect(m_UpdateRect, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_UpdateRect.x = x;
|
||||
@@ -2771,7 +2781,9 @@ wxLayoutList::StartSelection(const wxPoint& cposOrig, const wxPoint& spos)
|
||||
wxPoint cpos(cposOrig);
|
||||
if ( cpos.x == -1 )
|
||||
cpos = m_CursorPos;
|
||||
WXLO_DEBUG((wxT("Starting selection at %ld/%ld"), cpos.x, cpos.y));
|
||||
|
||||
WXLO_DEBUG((wxT("Starting selection at %d/%d"), cpos.x, cpos.y));
|
||||
|
||||
m_Selection.m_CursorA = cpos;
|
||||
m_Selection.m_CursorB = cpos;
|
||||
m_Selection.m_ScreenA = spos;
|
||||
@@ -2789,7 +2801,7 @@ wxLayoutList::ContinueSelection(const wxPoint& cposOrig, const wxPoint& spos)
|
||||
|
||||
wxASSERT(m_Selection.m_selecting == true);
|
||||
wxASSERT(m_Selection.m_valid == false);
|
||||
WXLO_DEBUG((wxT("Continuing selection at %ld/%ld"), cpos.x, cpos.y));
|
||||
WXLO_DEBUG((wxT("Continuing selection at %d/%d"), cpos.x, cpos.y));
|
||||
|
||||
m_Selection.m_ScreenB = spos;
|
||||
m_Selection.m_CursorB = cpos;
|
||||
@@ -2799,9 +2811,13 @@ void
|
||||
wxLayoutList::EndSelection(const wxPoint& cposOrig, const wxPoint& spos)
|
||||
{
|
||||
wxPoint cpos(cposOrig);
|
||||
|
||||
if(cpos.x == -1) cpos = m_CursorPos;
|
||||
|
||||
ContinueSelection(cpos, spos);
|
||||
WXLO_DEBUG((wxT("Ending selection at %ld/%ld"), cpos.x, cpos.y));
|
||||
|
||||
WXLO_DEBUG((wxT("Ending selection at %d/%d"), cpos.x, cpos.y));
|
||||
|
||||
// we always want m_CursorA <= m_CursorB!
|
||||
if( m_Selection.m_CursorA > m_Selection.m_CursorB )
|
||||
{
|
||||
@@ -2814,13 +2830,16 @@ wxLayoutList::EndSelection(const wxPoint& cposOrig, const wxPoint& spos)
|
||||
m_Selection.m_ScreenB = m_Selection.m_ScreenA;
|
||||
m_Selection.m_ScreenA = help;
|
||||
}
|
||||
|
||||
m_Selection.m_selecting = false;
|
||||
m_Selection.m_valid = true;
|
||||
/// In case we just clicked somewhere, the selection will have zero
|
||||
/// size, so we discard it immediately.
|
||||
if(m_Selection.m_CursorA == m_Selection.m_CursorB)
|
||||
{
|
||||
DiscardSelection();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutList::DiscardSelection()
|
||||
@@ -2834,7 +2853,7 @@ wxLayoutList::DiscardSelection()
|
||||
}
|
||||
|
||||
bool
|
||||
wxLayoutList::IsSelecting(void) const
|
||||
wxLayoutList::IsSelecting() const
|
||||
{
|
||||
return m_Selection.m_selecting;
|
||||
}
|
||||
@@ -2870,16 +2889,18 @@ wxLayoutList::IsSelected(const wxLayoutLine *line, CoordType *from,
|
||||
return 0;
|
||||
|
||||
CoordType y = line->GetLineNumber();
|
||||
if(
|
||||
(m_Selection.m_CursorA.y < y && m_Selection.m_CursorB.y > y)
|
||||
|| (m_Selection.m_CursorB.y < y && m_Selection.m_CursorA.y > y)
|
||||
)
|
||||
if ( (m_Selection.m_CursorA.y < y && m_Selection.m_CursorB.y > y)
|
||||
|| (m_Selection.m_CursorB.y < y && m_Selection.m_CursorA.y > y) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (m_Selection.m_CursorA.y == y)
|
||||
{
|
||||
*from = m_Selection.m_CursorA.x;
|
||||
if(m_Selection.m_CursorB.y == y)
|
||||
{
|
||||
*to = m_Selection.m_CursorB.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_Selection.m_CursorB > m_Selection.m_CursorA)
|
||||
@@ -2887,19 +2908,23 @@ wxLayoutList::IsSelected(const wxLayoutLine *line, CoordType *from,
|
||||
else
|
||||
*to = 0;
|
||||
}
|
||||
|
||||
if(*to < *from)
|
||||
{
|
||||
CoordType help = *to;
|
||||
*to = *from;
|
||||
*from = help;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
else if (m_Selection.m_CursorB.y == y)
|
||||
{
|
||||
*to = m_Selection.m_CursorB.x;
|
||||
if (m_Selection.m_CursorA.y == y)
|
||||
{
|
||||
*from = m_Selection.m_CursorA.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_Selection.m_CursorB > m_Selection.m_CursorA)
|
||||
@@ -2907,6 +2932,7 @@ wxLayoutList::IsSelected(const wxLayoutLine *line, CoordType *from,
|
||||
else
|
||||
*from = line->GetLength();
|
||||
}
|
||||
|
||||
if(*to < *from)
|
||||
{
|
||||
CoordType help = *to;
|
||||
@@ -2916,11 +2942,13 @@ wxLayoutList::IsSelected(const wxLayoutLine *line, CoordType *from,
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutList::DeleteSelection(void)
|
||||
wxLayoutList::DeleteSelection()
|
||||
{
|
||||
if (! m_Selection.m_valid)
|
||||
return;
|
||||
@@ -2940,6 +2968,7 @@ wxLayoutList::DeleteSelection(void)
|
||||
wxLayoutLine
|
||||
* firstLine = GetLine(m_Selection.m_CursorA.y),
|
||||
* lastLine = GetLine(m_Selection.m_CursorB.y);
|
||||
|
||||
// be a bit paranoid:
|
||||
if(! firstLine || ! lastLine)
|
||||
return;
|
||||
@@ -2950,8 +2979,11 @@ wxLayoutList::DeleteSelection(void)
|
||||
|
||||
wxLayoutLine *prevLine = firstLine->GetPreviousLine(),
|
||||
*nextLine = firstLine->GetNextLine();
|
||||
|
||||
while(nextLine && nextLine != lastLine)
|
||||
{
|
||||
nextLine = nextLine->DeleteLine(false, this);
|
||||
}
|
||||
|
||||
// Now nextLine = lastLine;
|
||||
Delete(1); // This joins firstLine and nextLine
|
||||
@@ -2998,8 +3030,7 @@ wxLayoutList::GetLine(CoordType index) const
|
||||
CoordType lineNo = 0;
|
||||
#endif
|
||||
|
||||
for ( line = m_FirstLine; line && n-- > 0; line =
|
||||
line->GetNextLine() )
|
||||
for ( line = m_FirstLine; line && n-- > 0; line = line->GetNextLine() )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
wxASSERT(line->GetLineNumber() == lineNo );
|
||||
@@ -3022,13 +3053,14 @@ wxLayoutList::Copy(const wxPoint &from,
|
||||
const wxPoint &to)
|
||||
{
|
||||
wxLayoutLine
|
||||
* firstLine = NULL,
|
||||
* lastLine = NULL;
|
||||
* firstLine,
|
||||
* lastLine;
|
||||
|
||||
for(firstLine = m_FirstLine;
|
||||
firstLine && firstLine->GetLineNumber() < from.y;
|
||||
firstLine=firstLine->GetNextLine())
|
||||
;
|
||||
|
||||
if(!firstLine || firstLine->GetLineNumber() != from.y)
|
||||
return NULL;
|
||||
|
||||
@@ -3036,6 +3068,7 @@ wxLayoutList::Copy(const wxPoint &from,
|
||||
lastLine && lastLine->GetLineNumber() < to.y;
|
||||
lastLine=lastLine->GetNextLine())
|
||||
;
|
||||
|
||||
if(!lastLine || lastLine->GetLineNumber() != to.y)
|
||||
return NULL;
|
||||
|
||||
@@ -3065,9 +3098,11 @@ wxLayoutList::Copy(const wxPoint &from,
|
||||
line->Copy(llist);
|
||||
llist->LineBreak();
|
||||
}
|
||||
|
||||
// Extract objects from last line
|
||||
lastLine->Copy(llist, 0, to.x);
|
||||
}
|
||||
|
||||
return llist;
|
||||
}
|
||||
|
||||
@@ -3101,19 +3136,21 @@ wxLayoutList::GetSelection(wxLayoutDataObject *wxlo, bool invalidate)
|
||||
exp->content.object->Write(string);
|
||||
delete exp;
|
||||
}
|
||||
|
||||
wxlo->SetLayoutData(string);
|
||||
}
|
||||
|
||||
return llist;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define COPY_SI(what) if(si.what != -1) { m_CurrentStyleInfo.what = si.what; fontChanged = TRUE; }
|
||||
#define COPY_SI(what) if(si.what != -1) { m_CurrentStyleInfo.what = si.what; fontChanged = true; }
|
||||
|
||||
void
|
||||
wxLayoutList::ApplyStyle(wxLayoutStyleInfo const &si, wxDC &dc)
|
||||
{
|
||||
bool fontChanged = FALSE;
|
||||
bool fontChanged = false;
|
||||
COPY_SI(family);
|
||||
COPY_SI(size);
|
||||
COPY_SI(style);
|
||||
@@ -3128,6 +3165,7 @@ wxLayoutList::ApplyStyle(wxLayoutStyleInfo const &si, wxDC &dc)
|
||||
m_CurrentStyleInfo.m_fg_valid = true;
|
||||
dc.SetTextForeground(m_CurrentStyleInfo.m_fg);
|
||||
}
|
||||
|
||||
if(si.m_bg_valid)
|
||||
{
|
||||
m_CurrentStyleInfo.m_bg = si.m_bg;
|
||||
@@ -3140,10 +3178,10 @@ wxLayoutList::ApplyStyle(wxLayoutStyleInfo const &si, wxDC &dc)
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
|
||||
void
|
||||
wxLayoutList::Debug(void)
|
||||
wxLayoutList::Debug()
|
||||
{
|
||||
WXLO_DEBUG((wxT("Cursor is in line %d, screen pos = (%d, %d)"),
|
||||
m_CursorLine->GetLineNumber(),
|
||||
(int)m_CursorLine->GetLineNumber(),
|
||||
m_CursorScreenPos.x, m_CursorScreenPos.y));
|
||||
|
||||
wxLayoutLine *line;
|
||||
@@ -3190,6 +3228,7 @@ wxLayoutPrintout::ScaleDC(wxDC *dc)
|
||||
* the screen text size. This page also draws lines of actual length 5cm
|
||||
* on the page.
|
||||
*/
|
||||
|
||||
// Get the logical pixels per inch of screen and printer
|
||||
int ppiScreenX, ppiScreenY;
|
||||
GetPPIScreen(&ppiScreenX, &ppiScreenY);
|
||||
@@ -3201,11 +3240,14 @@ wxLayoutPrintout::ScaleDC(wxDC *dc)
|
||||
ppiScreenX = 100;
|
||||
ppiScreenY = 100;
|
||||
}
|
||||
wxUnusedVar(ppiScreenY);
|
||||
|
||||
if(ppiPrinterX == 0) // not yet set, need to guess
|
||||
{
|
||||
ppiPrinterX = 72;
|
||||
ppiPrinterY = 72;
|
||||
}
|
||||
wxUnusedVar(ppiPrinterY);
|
||||
|
||||
// This scales the DC so that the printout roughly represents the
|
||||
// the screen scaling. The text point size _should_ be the right size
|
||||
@@ -3220,12 +3262,14 @@ wxLayoutPrintout::ScaleDC(wxDC *dc)
|
||||
int w, h;
|
||||
dc->GetSize(&w, &h);
|
||||
GetPageSizePixels(&pageWidth, &pageHeight);
|
||||
wxUnusedVar(pageHeight);
|
||||
if(pageWidth != 0) // doesn't work always
|
||||
{
|
||||
// If printer pageWidth == current DC width, then this doesn't
|
||||
// change. But w might be the preview bitmap width, so scale down.
|
||||
scale = scale * (float)(w/(float)pageWidth);
|
||||
}
|
||||
|
||||
dc->SetUserScale(scale, scale);
|
||||
return scale;
|
||||
}
|
||||
@@ -3244,16 +3288,18 @@ bool wxLayoutPrintout::OnPrintPage(int page)
|
||||
|
||||
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.
|
||||
wxPoint translate(m_Offset.x,m_Offset.y-top);
|
||||
m_llist->Draw(*dc, translate, top, bottom, TRUE /* clip strictly
|
||||
*/);
|
||||
m_llist->Draw(*dc, translate, top, bottom, true /* clip strictly */);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void wxLayoutPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
|
||||
{
|
||||
|
@@ -16,12 +16,12 @@
|
||||
|
||||
#include "kbList.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/print.h>
|
||||
#include <wx/printdlg.h>
|
||||
#include <wx/generic/printps.h>
|
||||
#include <wx/generic/prntdlgg.h>
|
||||
#include <wx/dataobj.h>
|
||||
#include "wx/wx.h"
|
||||
#include "wx/print.h"
|
||||
#include "wx/printdlg.h"
|
||||
#include "wx/generic/printps.h"
|
||||
#include "wx/generic/prntdlgg.h"
|
||||
#include "wx/dataobj.h"
|
||||
|
||||
// skip the following defines if embedded in M application
|
||||
#ifndef M_BASEDIR
|
||||
@@ -87,12 +87,16 @@ enum wxLayoutObjectType
|
||||
{
|
||||
/// illegal object type, should never appear
|
||||
WXLO_TYPE_INVALID = 0,
|
||||
|
||||
/// text object, containing normal text
|
||||
WXLO_TYPE_TEXT,
|
||||
|
||||
/// command object, containing font or colour changes
|
||||
WXLO_TYPE_CMD,
|
||||
|
||||
/// icon object, any kind of image
|
||||
WXLO_TYPE_ICON,
|
||||
|
||||
/// a linebreak, does not exist as an object
|
||||
WXLO_TYPE_LINEBREAK
|
||||
};
|
||||
@@ -134,10 +138,10 @@ public:
|
||||
struct UserData
|
||||
{
|
||||
UserData() { m_refcount = 1; }
|
||||
inline void IncRef(void) { m_refcount++; }
|
||||
inline void DecRef(void) { m_refcount--; if(m_refcount == 0) delete this;}
|
||||
inline void IncRef() { m_refcount++; }
|
||||
inline void DecRef() { m_refcount--; if(m_refcount == 0) delete this;}
|
||||
inline void SetLabel(const wxString &l) { m_label = l; }
|
||||
inline const wxString & GetLabel(void) const { return m_label; }
|
||||
inline const wxString & GetLabel() const { return m_label; }
|
||||
private:
|
||||
int m_refcount;
|
||||
wxString m_label;
|
||||
@@ -148,7 +152,7 @@ public:
|
||||
};
|
||||
|
||||
/// return the type of this object
|
||||
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_INVALID; }
|
||||
virtual wxLayoutObjectType GetType() const { return WXLO_TYPE_INVALID; }
|
||||
/** Calculates the size of an object.
|
||||
@param dc the wxDC to draw on
|
||||
@param llist the wxLayoutList
|
||||
@@ -164,9 +168,9 @@ public:
|
||||
*/
|
||||
virtual void Draw(wxDC & /* dc */,
|
||||
wxPoint const & /* coords */,
|
||||
wxLayoutList *wxllist,
|
||||
CoordType begin = -1,
|
||||
CoordType end = -1) { }
|
||||
wxLayoutList *WXUNUSED(wxllist),
|
||||
CoordType WXUNUSED(begin) = -1,
|
||||
CoordType WXUNUSED(end) = -1) { }
|
||||
|
||||
/** Calculates and returns the size of the object.
|
||||
@param top where to store height above baseline
|
||||
@@ -177,24 +181,31 @@ public:
|
||||
{ *top = 0; *bottom = 0; return wxPoint(0,0); }
|
||||
|
||||
/// Return just the width of the object on the screen.
|
||||
virtual CoordType GetWidth(void) const { return 0; }
|
||||
virtual CoordType GetWidth() const { return 0; }
|
||||
|
||||
/// returns the number of cursor positions occupied by this object
|
||||
virtual CoordType GetLength(void) const { return 1; }
|
||||
virtual CoordType GetLength() const { return 1; }
|
||||
|
||||
/** Returns the cursor offset relating to the screen x position
|
||||
relative to begin of object.
|
||||
@param dc the wxDC to use for calculations
|
||||
@param xpos relative x position from head of object
|
||||
@return cursor coordinate offset
|
||||
*/
|
||||
virtual CoordType GetOffsetScreen(wxDC &dc, CoordType xpos) const { return 0; }
|
||||
virtual CoordType GetOffsetScreen( wxDC & WXUNUSED(dc),
|
||||
CoordType WXUNUSED(xpos) ) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// constructor
|
||||
wxLayoutObject() { m_UserData = NULL; }
|
||||
|
||||
/// delete the user data
|
||||
virtual ~wxLayoutObject() { if(m_UserData) m_UserData->DecRef(); }
|
||||
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
virtual wxString DebugDump(void) const;
|
||||
virtual wxString DebugDump() const;
|
||||
#endif
|
||||
|
||||
/** Tells the object about some user data. This data is associated
|
||||
@@ -205,7 +216,9 @@ public:
|
||||
{
|
||||
if(m_UserData)
|
||||
m_UserData->DecRef();
|
||||
|
||||
m_UserData = data;
|
||||
|
||||
if(m_UserData)
|
||||
m_UserData->IncRef();
|
||||
}
|
||||
@@ -214,17 +227,18 @@ public:
|
||||
Increments the object's reference count. When no longer needed,
|
||||
caller must call DecRef() on the pointer returned.
|
||||
*/
|
||||
UserData * GetUserData(void) const { if(m_UserData) m_UserData->IncRef(); return m_UserData; }
|
||||
UserData * GetUserData() const { if(m_UserData) m_UserData->IncRef(); return m_UserData; }
|
||||
|
||||
/** Makes a copy of this object.
|
||||
*/
|
||||
virtual wxLayoutObject *Copy(void) = 0;
|
||||
virtual wxLayoutObject *Copy() = 0;
|
||||
|
||||
/** Clipboard support function. Read and write objects to
|
||||
strings. */
|
||||
//@{
|
||||
/// Writes the object to the string.
|
||||
virtual void Write(wxString &ostr) = 0;
|
||||
|
||||
/** Reads an object.
|
||||
@param str stream to read from, will bee changed
|
||||
@return true on success
|
||||
@@ -232,7 +246,7 @@ public:
|
||||
static wxLayoutObject *Read(wxString &istr);
|
||||
//@}
|
||||
|
||||
/// returns TRUE if the object is shown on the screen (i.e. not cmd object)
|
||||
/// returns true if the object is shown on the screen (i.e. not cmd object)
|
||||
bool IsVisibleObject() const { return GetType() != WXLO_TYPE_CMD; }
|
||||
|
||||
protected:
|
||||
@@ -248,6 +262,7 @@ KBLIST_DEFINE(wxLayoutObjectList, wxLayoutObject);
|
||||
|
||||
/// An illegal iterator to save typing.
|
||||
#define NULLIT (wxLayoutObjectList::iterator(NULL))
|
||||
|
||||
/// The iterator type.
|
||||
typedef wxLayoutObjectList::iterator wxLOiterator;
|
||||
|
||||
@@ -263,20 +278,23 @@ class wxLayoutObjectText : public wxLayoutObject
|
||||
public:
|
||||
wxLayoutObjectText(const wxString &txt = wxEmptyString);
|
||||
|
||||
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_TEXT; }
|
||||
virtual wxLayoutObjectType GetType() const { return WXLO_TYPE_TEXT; }
|
||||
virtual void Layout(wxDC &dc, wxLayoutList *llist);
|
||||
virtual void Draw(wxDC &dc, wxPoint const &coords,
|
||||
wxLayoutList *wxllist,
|
||||
CoordType begin = -1,
|
||||
CoordType end = -1);
|
||||
|
||||
/** Calculates and returns the size of the object.
|
||||
@param top where to store height above baseline
|
||||
@param bottom where to store height below baseline
|
||||
@return the size of the object's box in pixels
|
||||
*/
|
||||
virtual wxPoint GetSize(CoordType * top, CoordType *bottom) const;
|
||||
|
||||
/// Return just the width of the object on the screen.
|
||||
virtual CoordType GetWidth(void) const { return m_Width; }
|
||||
virtual CoordType GetWidth() const { return m_Width; }
|
||||
|
||||
/** Returns the cursor offset relating to the screen x position
|
||||
relative to begin of object.
|
||||
@param dc the wxDC to use for calculations
|
||||
@@ -289,23 +307,28 @@ public:
|
||||
static wxLayoutObjectText *Read(wxString &istr);
|
||||
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
virtual wxString DebugDump(void) const;
|
||||
virtual wxString DebugDump() const;
|
||||
#endif
|
||||
|
||||
virtual CoordType GetLength(void) const { return wxStrlen(m_Text.c_str()); }
|
||||
virtual CoordType GetLength() const { return wxStrlen(m_Text.c_str()); }
|
||||
|
||||
// for editing:
|
||||
wxString & GetText(void) { return m_Text; }
|
||||
wxString & GetText() { return m_Text; }
|
||||
|
||||
void SetText(wxString const &text) { m_Text = text; }
|
||||
/** Makes a copy of this object.
|
||||
*/
|
||||
virtual wxLayoutObject *Copy(void);
|
||||
virtual wxLayoutObject *Copy();
|
||||
|
||||
private:
|
||||
wxString m_Text;
|
||||
|
||||
/// size of the box containing text
|
||||
long m_Width, m_Height;
|
||||
|
||||
/// Height above baseline.
|
||||
long m_Top;
|
||||
|
||||
/// Height below baseline.
|
||||
long m_Bottom;
|
||||
};
|
||||
@@ -325,7 +348,7 @@ public:
|
||||
|
||||
~wxLayoutObjectIcon() { if(m_Icon) delete m_Icon; }
|
||||
|
||||
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_ICON; }
|
||||
virtual wxLayoutObjectType GetType() const { return WXLO_TYPE_ICON; }
|
||||
virtual void Layout(wxDC &dc, wxLayoutList *llist);
|
||||
virtual void Draw(wxDC &dc, wxPoint const &coords,
|
||||
wxLayoutList *wxllist,
|
||||
@@ -338,15 +361,19 @@ public:
|
||||
@return the size of the object's box in pixels
|
||||
*/
|
||||
virtual wxPoint GetSize(CoordType * top, CoordType *bottom) const;
|
||||
|
||||
/// Return just the width of the object on the screen.
|
||||
virtual CoordType GetWidth(void) const { return m_Icon->GetWidth(); }
|
||||
virtual CoordType GetWidth() const { return m_Icon->GetWidth(); }
|
||||
|
||||
// return a pointer to the icon
|
||||
wxBitmap *GetIcon(void) const { return m_Icon; }
|
||||
wxBitmap *GetIcon() const { return m_Icon; }
|
||||
|
||||
/** Makes a copy of this object.
|
||||
*/
|
||||
virtual wxLayoutObject *Copy(void);
|
||||
virtual wxLayoutObject *Copy();
|
||||
virtual void Write(wxString &ostr);
|
||||
static wxLayoutObjectIcon *Read(wxString &istr);
|
||||
|
||||
private:
|
||||
wxBitmap *m_Icon;
|
||||
};
|
||||
@@ -362,12 +389,14 @@ struct wxLayoutStyleInfo
|
||||
int iul = -1,
|
||||
wxColour *fg = NULL,
|
||||
wxColour *bg = NULL);
|
||||
|
||||
wxLayoutStyleInfo & operator=(const wxLayoutStyleInfo &right);
|
||||
|
||||
wxColour & GetBGColour() { return m_bg; }
|
||||
|
||||
/// Font change parameters.
|
||||
int size, family, style, weight, underline;
|
||||
|
||||
/// Colours
|
||||
wxColour m_bg, m_fg;
|
||||
int m_fg_valid, m_bg_valid; // bool, but must be int!
|
||||
@@ -385,6 +414,7 @@ public:
|
||||
m_Font = new wxFont(m_Size, m_Family,
|
||||
m_Style, m_Weight, m_Underline);
|
||||
}
|
||||
|
||||
bool Matches(int family, int size, int style, int weight,
|
||||
bool underline) const
|
||||
{
|
||||
@@ -392,11 +422,13 @@ public:
|
||||
&& style == m_Style && weight == m_Weight
|
||||
&& underline == m_Underline;
|
||||
}
|
||||
wxFont & GetFont(void) { return *m_Font; }
|
||||
|
||||
wxFont & GetFont() { return *m_Font; }
|
||||
~wxFontCacheEntry()
|
||||
{
|
||||
delete m_Font;
|
||||
}
|
||||
|
||||
private:
|
||||
wxFont *m_Font;
|
||||
|
||||
@@ -412,11 +444,13 @@ class wxFontCache
|
||||
public:
|
||||
wxFont & GetFont(int family, int size, int style, int weight,
|
||||
bool underline);
|
||||
|
||||
wxFont & GetFont(wxLayoutStyleInfo const &si)
|
||||
{
|
||||
return GetFont(si.family, si.size, si.style, si.weight,
|
||||
si.underline != 0);
|
||||
}
|
||||
|
||||
private:
|
||||
wxFCEList m_FontList;
|
||||
};
|
||||
@@ -431,12 +465,13 @@ private:
|
||||
class wxLayoutObjectCmd : public wxLayoutObject
|
||||
{
|
||||
public:
|
||||
virtual wxLayoutObjectType GetType(void) const { return WXLO_TYPE_CMD; }
|
||||
virtual wxLayoutObjectType GetType() const { return WXLO_TYPE_CMD; }
|
||||
virtual void Layout(wxDC &dc, wxLayoutList *llist);
|
||||
virtual void Draw(wxDC &dc, wxPoint const &coords,
|
||||
wxLayoutList *wxllist,
|
||||
CoordType begin = -1,
|
||||
CoordType end = -1);
|
||||
|
||||
wxLayoutObjectCmd(int family = -1,
|
||||
int size = -1,
|
||||
int style = -1,
|
||||
@@ -444,15 +479,17 @@ public:
|
||||
int underline = -1,
|
||||
wxColour *fg = NULL,
|
||||
wxColour *bg = NULL);
|
||||
|
||||
wxLayoutObjectCmd(const wxLayoutStyleInfo &si);
|
||||
~wxLayoutObjectCmd();
|
||||
/** Stores the current style in the styleinfo structure */
|
||||
wxLayoutStyleInfo * GetStyle(void) const;
|
||||
wxLayoutStyleInfo * GetStyle() const;
|
||||
/** Makes a copy of this object.
|
||||
*/
|
||||
virtual wxLayoutObject *Copy(void);
|
||||
virtual wxLayoutObject *Copy();
|
||||
virtual void Write(wxString &ostr);
|
||||
static wxLayoutObjectCmd *Read(wxString &istr);
|
||||
|
||||
private:
|
||||
wxLayoutStyleInfo *m_StyleInfo;
|
||||
};
|
||||
@@ -531,7 +568,7 @@ public:
|
||||
/** This function wraps the line: breaks it at a suitable point
|
||||
and merges it with the next.
|
||||
@param wrapmargin
|
||||
@return TRUE if broken
|
||||
@return true if broken
|
||||
*/
|
||||
bool Wrap(CoordType wrapmargin, wxLayoutList *llist);
|
||||
|
||||
@@ -589,14 +626,13 @@ public:
|
||||
functions to export the list.
|
||||
@return iterator to the first object
|
||||
*/
|
||||
wxLayoutObjectList::iterator GetFirstObject(void) const
|
||||
wxLayoutObjectList::iterator GetFirstObject() const
|
||||
{
|
||||
return m_ObjectList.begin();
|
||||
}
|
||||
|
||||
/** Get the last object in the list.
|
||||
*/
|
||||
wxLayoutObjectList::iterator GetLastObject(void) const
|
||||
/// Get the last object in the list.
|
||||
wxLayoutObjectList::iterator GetLastObject() const
|
||||
{
|
||||
return m_ObjectList.tail();
|
||||
}
|
||||
@@ -611,11 +647,12 @@ public:
|
||||
/** Return the line number of this line.
|
||||
@return the line number
|
||||
*/
|
||||
inline CoordType GetLineNumber(void) const { return m_LineNumber; }
|
||||
inline CoordType GetLineNumber() const { return m_LineNumber; }
|
||||
|
||||
/** Return the length of the line.
|
||||
@return line lenght in cursor positions
|
||||
*/
|
||||
inline CoordType GetLength(void) const { return m_Length; }
|
||||
inline CoordType GetLength() const { return m_Length; }
|
||||
//@}
|
||||
|
||||
/**@name Drawing and Layout */
|
||||
@@ -645,7 +682,8 @@ public:
|
||||
wxPoint *cursorSize = NULL,
|
||||
wxLayoutStyleInfo *cursorStyle = NULL,
|
||||
int cx = 0,
|
||||
bool suppressStyleUpdate = FALSE);
|
||||
bool suppressStyleUpdate = false);
|
||||
|
||||
/** This function finds an object belonging to a given cursor
|
||||
position. It assumes that Layout() has been called before.
|
||||
@param dc the wxDC to use for calculations
|
||||
@@ -658,6 +696,7 @@ public:
|
||||
wxLayoutObject * FindObjectScreen(wxDC &dc,
|
||||
CoordType xpos,
|
||||
bool *found = NULL);
|
||||
|
||||
/** This sets the style info for the beginning of this line.
|
||||
@param si styleinfo structure
|
||||
*/
|
||||
@@ -669,23 +708,29 @@ public:
|
||||
/**@name List traversal */
|
||||
//@{
|
||||
/// Returns pointer to next line.
|
||||
wxLayoutLine *GetNextLine(void) const { return m_Next; }
|
||||
wxLayoutLine *GetNextLine() const { return m_Next; }
|
||||
|
||||
/// Returns pointer to previous line.
|
||||
wxLayoutLine *GetPreviousLine(void) const { return m_Previous; }
|
||||
wxLayoutLine *GetPreviousLine() const { return m_Previous; }
|
||||
|
||||
/// Sets the link to the next line.
|
||||
void SetNext(wxLayoutLine *next)
|
||||
{ m_Next = next; if(next) next->m_Previous = this; }
|
||||
|
||||
/// Sets the link to the previous line.
|
||||
void SetPrevious(wxLayoutLine *previous)
|
||||
{ m_Previous = previous; if(previous) previous->m_Next = this; }
|
||||
//@}
|
||||
|
||||
/// Returns the position of this line on the canvas.
|
||||
wxPoint GetPosition(void) const { return m_Position; }
|
||||
wxPoint GetPosition() const { return m_Position; }
|
||||
|
||||
/// Returns the height of this line.
|
||||
CoordType GetHeight(void) const { return m_Height; }
|
||||
CoordType GetHeight() const { return m_Height; }
|
||||
|
||||
/// Returns the width of this line.
|
||||
CoordType GetWidth(void) const { return m_Width; }
|
||||
CoordType GetWidth() const { return m_Width; }
|
||||
|
||||
/// Recalculates the position of this line on the canvas.
|
||||
wxPoint RecalculatePosition(wxLayoutList *llist);
|
||||
|
||||
@@ -699,12 +744,13 @@ public:
|
||||
CoordType to = -1);
|
||||
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
void Debug(void) const;
|
||||
void Debug() const;
|
||||
#endif
|
||||
wxLayoutStyleInfo const & GetStyleInfo() const { return m_StyleInfo; }
|
||||
|
||||
/// Returns dirty state
|
||||
bool IsDirty(void) const { return m_Dirty; }
|
||||
bool IsDirty() const { return m_Dirty; }
|
||||
|
||||
/** Marks this line as diry.
|
||||
@param left xpos from where it is dirty or -1 for all
|
||||
*/
|
||||
@@ -719,6 +765,7 @@ public:
|
||||
m_Dirty = true;
|
||||
if(m_Next) m_Next->MarkDirty();
|
||||
}
|
||||
|
||||
/// Reset the dirty flag
|
||||
void MarkClean() { m_Dirty = false; m_updateLeft = -1; }
|
||||
|
||||
@@ -732,39 +779,55 @@ private:
|
||||
dirty.
|
||||
@param height new height
|
||||
*/
|
||||
void SetHeight(CoordType height, wxLayoutList *llist)
|
||||
{ m_Height = height; MarkDirty(); }
|
||||
void SetHeight( CoordType height, wxLayoutList * WXUNUSED(llist) )
|
||||
{
|
||||
m_Height = height; MarkDirty();
|
||||
}
|
||||
|
||||
/** Updates the line numbers. */
|
||||
void ReNumber(void);
|
||||
void ReNumber();
|
||||
//@}
|
||||
|
||||
private:
|
||||
/// The line number.
|
||||
CoordType m_LineNumber;
|
||||
|
||||
/// The line length in cursor positions.
|
||||
CoordType m_Length;
|
||||
|
||||
/// The total height of the line.
|
||||
CoordType m_Height;
|
||||
|
||||
/// The total width of the line on screen.
|
||||
CoordType m_Width;
|
||||
|
||||
/// The baseline for drawing objects
|
||||
CoordType m_BaseLine;
|
||||
|
||||
/// The position on the canvas.
|
||||
wxPoint m_Position;
|
||||
|
||||
/// The list of objects
|
||||
wxLayoutObjectList m_ObjectList;
|
||||
|
||||
/// Have we been changed since the last layout?
|
||||
bool m_Dirty;
|
||||
|
||||
/// The coordinate of the left boundary of the update rectangle (if m_Dirty)
|
||||
CoordType m_updateLeft;
|
||||
|
||||
/// Pointer to previous line if it exists.
|
||||
wxLayoutLine *m_Previous;
|
||||
|
||||
/// Pointer to next line if it exists.
|
||||
wxLayoutLine *m_Next;
|
||||
|
||||
/// A StyleInfo structure, holding the current settings.
|
||||
wxLayoutStyleInfo m_StyleInfo;
|
||||
|
||||
/// Just to suppress gcc compiler warnings.
|
||||
friend class dummy;
|
||||
|
||||
private:
|
||||
wxLayoutLine(const wxLayoutLine &);
|
||||
};
|
||||
@@ -784,6 +847,7 @@ class wxLayoutList
|
||||
public:
|
||||
/// Constructor.
|
||||
wxLayoutList();
|
||||
|
||||
/// Destructor.
|
||||
~wxLayoutList();
|
||||
|
||||
@@ -800,17 +864,20 @@ public:
|
||||
int underline=0,
|
||||
wxColour *fg=NULL,
|
||||
wxColour *bg=NULL);
|
||||
|
||||
/// Empty: clear the list but leave font settings.
|
||||
void Empty(void);
|
||||
void Empty();
|
||||
|
||||
/** Enable or disable auto-formatting. Normally, while editing this
|
||||
should be enabled which is the default. While
|
||||
inserting/deleting lots of text, it makes sense to temporarily
|
||||
disable this.
|
||||
@param enable TRUE to enable, FALSE to disable
|
||||
@param enable true to enable, false to disable
|
||||
*/
|
||||
void SetAutoFormatting(bool enable = TRUE)
|
||||
|
||||
void SetAutoFormatting(bool enable = true)
|
||||
{ m_AutoFormat = enable; }
|
||||
|
||||
/**@name Cursor Management */
|
||||
//@{
|
||||
/** Set new cursor position.
|
||||
@@ -818,16 +885,19 @@ public:
|
||||
@return bool if it could be set
|
||||
*/
|
||||
bool MoveCursorTo(wxPoint const &p);
|
||||
|
||||
/** Move cursor up or down.
|
||||
@param n
|
||||
@return bool if it could be moved
|
||||
*/
|
||||
bool MoveCursorVertically(int n);
|
||||
|
||||
/** Move cursor left or right.
|
||||
@param n = number of positions to move
|
||||
@return bool if it could be moved
|
||||
*/
|
||||
bool MoveCursorHorizontally(int n);
|
||||
|
||||
/** Move cursor to the left or right counting in words
|
||||
@param n = number of positions in words
|
||||
@param untilNext: puts the cursor at the start of the next word if true,
|
||||
@@ -837,26 +907,27 @@ public:
|
||||
bool MoveCursorWord(int n, bool untilNext = true);
|
||||
|
||||
/// Move cursor to end of line.
|
||||
void MoveCursorToEndOfLine(void)
|
||||
void MoveCursorToEndOfLine()
|
||||
{
|
||||
wxASSERT(m_CursorLine);
|
||||
MoveCursorHorizontally(m_CursorLine->GetLength()-m_CursorPos.x);
|
||||
}
|
||||
|
||||
/// Move cursor to the start of line.
|
||||
void MoveCursorToBeginOfLine(void)
|
||||
void MoveCursorToBeginOfLine()
|
||||
{ MoveCursorHorizontally(-m_CursorPos.x); }
|
||||
|
||||
/// get the number of lines in the list
|
||||
size_t GetNumLines() const { return m_numLines; }
|
||||
|
||||
/// Returns current cursor position.
|
||||
const wxPoint &GetCursorPos(wxDC &dc) const { return m_CursorPos; }
|
||||
const wxPoint &GetCursorPos(wxDC & WXUNUSED(dc) ) const
|
||||
{ return m_CursorPos; }
|
||||
const wxPoint &GetCursorPos() const { return m_CursorPos; }
|
||||
wxLayoutLine * GetCursorLine(void) { return m_CursorLine; }
|
||||
wxLayoutLine * GetCursorLine() { return m_CursorLine; }
|
||||
|
||||
/// move cursor to the end of text
|
||||
void MoveCursorToEnd(void)
|
||||
void MoveCursorToEnd()
|
||||
{
|
||||
MoveCursorTo(wxPoint(0, GetNumLines() - 1));
|
||||
MoveCursorToEndOfLine();
|
||||
@@ -870,13 +941,15 @@ public:
|
||||
//@{
|
||||
/// Insert text at current cursor position.
|
||||
bool Insert(wxString const &text);
|
||||
|
||||
/// Insert some other object at current cursor position.
|
||||
bool Insert(wxLayoutObject *obj);
|
||||
|
||||
/// Inserts objects at current cursor positions
|
||||
bool Insert(wxLayoutList *llist);
|
||||
|
||||
/// Inserts a linebreak at current cursor position.
|
||||
bool LineBreak(void);
|
||||
bool LineBreak();
|
||||
/** Wraps the current line. Searches to the left of the cursor to
|
||||
break the line. Does nothing if the cursor position is before
|
||||
the break position parameter.
|
||||
@@ -903,13 +976,14 @@ public:
|
||||
int DeleteLines(int n);
|
||||
|
||||
/// Delete to end of line.
|
||||
void DeleteToEndOfLine(void)
|
||||
void DeleteToEndOfLine()
|
||||
{
|
||||
wxASSERT(m_CursorLine);
|
||||
Delete(m_CursorLine->GetLength()-m_CursorPos.x);
|
||||
}
|
||||
|
||||
/// Delete to begin of line.
|
||||
void DeleteToBeginOfLine(void)
|
||||
void DeleteToBeginOfLine()
|
||||
{
|
||||
wxASSERT(m_CursorLine);
|
||||
CoordType n = m_CursorPos.x;
|
||||
@@ -923,7 +997,7 @@ public:
|
||||
|
||||
/** Delete the next word.
|
||||
*/
|
||||
void DeleteWord(void)
|
||||
void DeleteWord()
|
||||
{
|
||||
wxASSERT(m_CursorLine);
|
||||
m_CursorLine->DeleteWord(m_CursorPos.x);
|
||||
@@ -945,31 +1019,40 @@ public:
|
||||
int weight, int underline,
|
||||
wxColour *fg,
|
||||
wxColour *bg);
|
||||
|
||||
/// sets font parameters, colours by name
|
||||
void SetFont(int family=-1, int size = -1, int style=-1,
|
||||
int weight=-1, int underline = -1,
|
||||
wxChar const *fg = NULL,
|
||||
wxChar const *bg = NULL);
|
||||
|
||||
/// changes to the next larger font size
|
||||
inline void SetFontLarger(void)
|
||||
inline void SetFontLarger()
|
||||
{ SetFont(-1,(12*m_CurrentStyleInfo.size)/10); }
|
||||
|
||||
/// changes to the next smaller font size
|
||||
inline void SetFontSmaller(void)
|
||||
inline void SetFontSmaller()
|
||||
{ SetFont(-1,(10*m_CurrentStyleInfo.size)/12); }
|
||||
|
||||
/// set font family
|
||||
inline void SetFontFamily(int family) { SetFont(family); }
|
||||
|
||||
/// set font size
|
||||
inline void SetFontSize(int size) { SetFont(-1,size); }
|
||||
|
||||
/// set font style
|
||||
inline void SetFontStyle(int style) { SetFont(-1,-1,style); }
|
||||
|
||||
/// set font weight
|
||||
inline void SetFontWeight(int weight) { SetFont(-1,-1,-1,weight); }
|
||||
|
||||
/// toggle underline flag
|
||||
inline void SetFontUnderline(bool ul) { SetFont(-1,-1,-1,-1,(int)ul); }
|
||||
|
||||
/// set font colours by name
|
||||
inline void SetFontColour(wxChar const *fg, wxChar const *bg = NULL)
|
||||
{ SetFont(-1,-1,-1,-1,-1,fg,bg); }
|
||||
|
||||
/// set font colours by colour
|
||||
inline void SetFontColour(wxColour *fg, wxColour *bg = NULL)
|
||||
{ SetFont(-1,-1,-1,-1,-1,fg,bg); }
|
||||
@@ -980,15 +1063,17 @@ public:
|
||||
anywhere.
|
||||
@return the default settings of the list
|
||||
*/
|
||||
wxLayoutStyleInfo &GetDefaultStyleInfo(void) { return m_DefaultStyleInfo ; }
|
||||
wxLayoutStyleInfo &GetStyleInfo(void) { return m_CurrentStyleInfo ; }
|
||||
const wxLayoutStyleInfo &GetStyleInfo(void) const { return m_CurrentStyleInfo ; }
|
||||
const wxLayoutStyleInfo &GetCursorStyleInfo(void) const { return m_CursorStyleInfo ; }
|
||||
wxLayoutStyleInfo &GetDefaultStyleInfo() { return m_DefaultStyleInfo ; }
|
||||
wxLayoutStyleInfo &GetStyleInfo() { return m_CurrentStyleInfo ; }
|
||||
const wxLayoutStyleInfo &GetStyleInfo() const { return m_CurrentStyleInfo ; }
|
||||
const wxLayoutStyleInfo &GetCursorStyleInfo() const { return m_CursorStyleInfo ; }
|
||||
|
||||
/// is the current font underlined?
|
||||
bool IsFontUnderlined() const { return GetCursorStyleInfo().underline != 0; }
|
||||
|
||||
/// is the current font bold?
|
||||
bool IsFontBold() const { return GetCursorStyleInfo().weight == wxBOLD; }
|
||||
|
||||
/// is the current font italic?
|
||||
bool IsFontItalic() const { return GetCursorStyleInfo().style == wxITALIC; }
|
||||
|
||||
@@ -1036,9 +1121,9 @@ public:
|
||||
|
||||
/** Ensure that the whole list will be recalculate on the next call
|
||||
to Layout() or Draw().
|
||||
@param redrawAll TRUE or FALSE to reset it
|
||||
@param redrawAll true or false to reset it
|
||||
*/
|
||||
void ForceTotalLayout(bool redrawAll = TRUE)
|
||||
void ForceTotalLayout(bool redrawAll = true)
|
||||
{ m_ReLayoutAll = redrawAll; }
|
||||
|
||||
/** Returns the screen coordinates relating to a given cursor
|
||||
@@ -1063,11 +1148,11 @@ public:
|
||||
@return a wxPoint holding the maximal x/y coordinates used for
|
||||
drawing
|
||||
*/
|
||||
wxPoint GetSize(void) const;
|
||||
wxPoint GetSize() const;
|
||||
|
||||
/** Returns the cursor position on the screen.
|
||||
*/
|
||||
wxPoint GetCursorScreenPos(void) const;
|
||||
wxPoint GetCursorScreenPos() const;
|
||||
|
||||
/** Draws the cursor.
|
||||
@param active If true, draw a bold cursor to mark window as
|
||||
@@ -1096,11 +1181,13 @@ public:
|
||||
@param y vertical coordinate to include in rectangle
|
||||
*/
|
||||
void SetUpdateRect(CoordType x, CoordType y);
|
||||
|
||||
/** Called by the objects to update the update rectangle.
|
||||
@param p a point to include in it
|
||||
*/
|
||||
void SetUpdateRect(const wxPoint &p)
|
||||
{ SetUpdateRect(p.x,p.y); }
|
||||
|
||||
/// adds the cursor position to the update rectangle
|
||||
void AddCursorPosToUpdateRect()
|
||||
{
|
||||
@@ -1110,10 +1197,12 @@ public:
|
||||
//#else - the caret will take care of refreshing itself
|
||||
#endif // !WXLAYOUT_USE_CARET
|
||||
}
|
||||
|
||||
/// Invalidates the update rectangle.
|
||||
void InvalidateUpdateRect(void) { m_UpdateRectValid = false; }
|
||||
void InvalidateUpdateRect() { m_UpdateRectValid = false; }
|
||||
|
||||
/// Returns the update rectangle.
|
||||
const wxRect *GetUpdateRect(void) const { return &m_UpdateRect; }
|
||||
const wxRect *GetUpdateRect() const { return &m_UpdateRect; }
|
||||
//@}
|
||||
|
||||
/// get the current cursor size
|
||||
@@ -1122,7 +1211,7 @@ public:
|
||||
/**@name For exporting one object after another. */
|
||||
//@{
|
||||
/** Returns a pointer to the first line in the list. */
|
||||
wxLayoutLine *GetFirstLine(void)
|
||||
wxLayoutLine *GetFirstLine()
|
||||
{
|
||||
wxASSERT(m_FirstLine);
|
||||
return m_FirstLine;
|
||||
@@ -1132,18 +1221,24 @@ public:
|
||||
/// Begin selecting text
|
||||
void StartSelection(const wxPoint& cpos = wxPoint(-1,-1),
|
||||
const wxPoint& spos = wxPoint(-1,-1));
|
||||
|
||||
// Continue selecting text
|
||||
void ContinueSelection(const wxPoint& cpos = wxPoint(-1,-1),
|
||||
const wxPoint& spos = wxPoint(-1,-1));
|
||||
|
||||
/// End selecting text.
|
||||
void EndSelection(const wxPoint& cpos = wxPoint(-1,-1),
|
||||
const wxPoint& spos = wxPoint(-1,-1));
|
||||
|
||||
/// Discard the current selection
|
||||
void DiscardSelection();
|
||||
|
||||
/// Are we still selecting text?
|
||||
bool IsSelecting(void) const;
|
||||
bool IsSelecting() const;
|
||||
|
||||
/// Is the given point (text coords) selected?
|
||||
bool IsSelected(const wxPoint &cursor) const;
|
||||
|
||||
/// Do we have a non null selection?
|
||||
bool HasSelection() const
|
||||
{ return m_Selection.m_valid || m_Selection.m_selecting; }
|
||||
@@ -1152,15 +1247,17 @@ public:
|
||||
@param invalidate if true, the selection will be invalidated after this and can no longer be used.
|
||||
@return Another layout list object holding the selection, must be freed by caller
|
||||
*/
|
||||
wxLayoutList *GetSelection(class wxLayoutDataObject *wxldo = NULL, bool invalidate = TRUE);
|
||||
wxLayoutList *GetSelection(class wxLayoutDataObject *wxldo = NULL, bool invalidate = true);
|
||||
|
||||
/// Delete selected bit
|
||||
void DeleteSelection(void);
|
||||
void DeleteSelection();
|
||||
|
||||
wxLayoutList *Copy(const wxPoint &from = wxPoint(0,0),
|
||||
const wxPoint &to = wxPoint(-1,-1));
|
||||
|
||||
/// starts highlighting of text for selections
|
||||
void StartHighlighting(wxDC &dc);
|
||||
|
||||
/// ends highlighting of text for selections
|
||||
void EndHighlighting(wxDC &dc);
|
||||
|
||||
@@ -1171,13 +1268,12 @@ public:
|
||||
@param to set to last cursorpos to be highlighted (for returncode == -1)
|
||||
@return 0 = not selected, 1 = fully selected, -1 = partially
|
||||
selected
|
||||
|
||||
*/
|
||||
int IsSelected(const wxLayoutLine *line, CoordType *from, CoordType *to);
|
||||
|
||||
void ApplyStyle(wxLayoutStyleInfo const &si, wxDC &dc);
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
void Debug(void);
|
||||
void Debug();
|
||||
#endif
|
||||
|
||||
// for wxLayoutLine usage only
|
||||
@@ -1195,34 +1291,43 @@ public:
|
||||
|
||||
private:
|
||||
/// Clear the list.
|
||||
void InternalClear(void);
|
||||
void InternalClear();
|
||||
|
||||
/// The list of lines.
|
||||
wxLayoutLine *m_FirstLine;
|
||||
|
||||
/// The number of lines in the list (store instead recalculating for speed)
|
||||
size_t m_numLines;
|
||||
|
||||
/// The update rectangle which needs to be refreshed:
|
||||
wxRect m_UpdateRect;
|
||||
|
||||
/// Is the update rectangle valid?
|
||||
bool m_UpdateRectValid;
|
||||
|
||||
/// Shall we auto-format?
|
||||
bool m_AutoFormat;
|
||||
|
||||
/// Shall we re-layout everything?
|
||||
bool m_ReLayoutAll;
|
||||
|
||||
/**@name Cursor Management */
|
||||
//@{
|
||||
/// Where the text cursor (column,line) is.
|
||||
wxPoint m_CursorPos;
|
||||
|
||||
/// Where the cursor should be drawn.
|
||||
wxPoint m_CursorScreenPos;
|
||||
|
||||
/// The line where the cursor is.
|
||||
wxLayoutLine *m_CursorLine;
|
||||
|
||||
/// The size of the cursor.
|
||||
wxPoint m_CursorSize;
|
||||
|
||||
/// Has the cursor moved (is m_CursorScreenPos up to date)?
|
||||
bool m_movedCursor;
|
||||
|
||||
#ifdef WXLAYOUT_USE_CARET
|
||||
/// the caret
|
||||
wxCaret *m_caret;
|
||||
@@ -1236,7 +1341,7 @@ private:
|
||||
|
||||
bool m_valid;
|
||||
bool m_selecting;
|
||||
bool m_discarded; // may be TRUE only until the next redraw
|
||||
bool m_discarded; // may be true only until the next redraw
|
||||
|
||||
// returns true if we already have the screen coordinates of the
|
||||
// selection start and end
|
||||
@@ -1253,10 +1358,13 @@ private:
|
||||
//@{
|
||||
/// this object manages the fonts for us
|
||||
wxFontCache m_FontCache;
|
||||
|
||||
/// the default setting:
|
||||
wxLayoutStyleInfo m_DefaultStyleInfo;
|
||||
|
||||
/// the current setting:
|
||||
wxLayoutStyleInfo m_CurrentStyleInfo;
|
||||
|
||||
/// the current setting:
|
||||
wxLayoutStyleInfo m_CursorStyleInfo;
|
||||
//@}
|
||||
@@ -1279,6 +1387,7 @@ public:
|
||||
// type safe wrappers
|
||||
void SetLayoutData(const wxString& text)
|
||||
{ SetData(text.length() + 1, text.c_str()); }
|
||||
|
||||
const wxChar *GetLayoutData() const { return (const wxChar *)GetData(); }
|
||||
};
|
||||
|
||||
@@ -1301,6 +1410,7 @@ public:
|
||||
wxLayoutPrintout(wxLayoutList *llist,
|
||||
wxString const & title =
|
||||
_T("wxLayout Printout"));
|
||||
|
||||
/// Destructor.
|
||||
~wxLayoutPrintout();
|
||||
|
||||
@@ -1335,17 +1445,23 @@ protected:
|
||||
/* no longer used
|
||||
virtual void DrawHeader(wxDC &dc, wxPoint topleft, wxPoint bottomright, int pageno);
|
||||
*/
|
||||
|
||||
private:
|
||||
/// The list to print.
|
||||
wxLayoutList *m_llist;
|
||||
|
||||
/// Title for PS file or window.
|
||||
wxString m_title;
|
||||
|
||||
/// The real paper size.
|
||||
int m_PageHeight, m_PageWidth;
|
||||
|
||||
/// How much we actually print per page.
|
||||
int m_PrintoutHeight;
|
||||
|
||||
/// How many pages we need to print.
|
||||
int m_NumOfPages;
|
||||
|
||||
/// Top left corner where we start printing.
|
||||
wxPoint m_Offset;
|
||||
};
|
||||
|
@@ -45,6 +45,7 @@ void wxLayoutImportText(wxLayoutList *list, wxString const &str)
|
||||
// VZ: I still don't like it... the string data may be shared...
|
||||
wxChar * cptr = (wxChar *)str.c_str(); // const_cast
|
||||
const wxChar * begin = cptr;
|
||||
wxUnusedVar(begin);
|
||||
wxChar backup;
|
||||
|
||||
for(;;)
|
||||
@@ -165,7 +166,7 @@ wxLayoutExportStatus::wxLayoutExportStatus(wxLayoutList *list)
|
||||
m_si = list->GetDefaultStyleInfo();
|
||||
m_line = list->GetFirstLine();
|
||||
m_iterator = m_line->GetFirstObject();
|
||||
m_FirstTime = TRUE;
|
||||
m_FirstTime = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,6 +216,7 @@ wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
|
||||
else
|
||||
type = WXLO_TYPE_TEXT;
|
||||
}
|
||||
wxUnusedVar(type);
|
||||
|
||||
wxString *str = new wxString();
|
||||
// text must be concatenated
|
||||
@@ -250,7 +252,7 @@ wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
|
||||
*str += wxLayoutExportCmdAsHTML(
|
||||
*(wxLayoutObjectCmd const *)*status->m_iterator,
|
||||
& status->m_si, status->m_FirstTime);
|
||||
status->m_FirstTime = FALSE;
|
||||
status->m_FirstTime = false;
|
||||
break;
|
||||
default: // ignore icons
|
||||
;
|
||||
|
@@ -39,19 +39,19 @@
|
||||
# include "strutil.h"
|
||||
#else
|
||||
# ifdef __WXMSW__
|
||||
# include <wx/msw/private.h>
|
||||
# include "wx/msw/private.h"
|
||||
# endif
|
||||
|
||||
# include "wxlwindow.h"
|
||||
# include "wxlparser.h"
|
||||
#endif
|
||||
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/dataobj.h>
|
||||
#include "wx/clipbrd.h"
|
||||
#include "wx/textctrl.h"
|
||||
#include "wx/dataobj.h"
|
||||
|
||||
#ifdef WXLAYOUT_USE_CARET
|
||||
# include <wx/caret.h>
|
||||
# include "wx/caret.h"
|
||||
#endif // WXLAYOUT_USE_CARET
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -130,7 +130,7 @@ END_EVENT_TABLE()
|
||||
// function prototypes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// returns TRUE if keyCode is one of arrows/home/end/page{up|down} keys
|
||||
/// returns true if keyCode is one of arrows/home/end/page{up|down} keys
|
||||
static bool IsDirectionKey(long keyCode);
|
||||
|
||||
// ============================================================================
|
||||
@@ -184,14 +184,14 @@ wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
|
||||
m_llist->SetCaret(caret);
|
||||
#endif // WXLAYOUT_USE_CARET
|
||||
|
||||
m_HaveFocus = FALSE;
|
||||
m_HandCursor = FALSE;
|
||||
m_HaveFocus = false;
|
||||
m_HandCursor = false;
|
||||
m_CursorVisibility = -1;
|
||||
SetCursor(wxCURSOR_IBEAM);
|
||||
SetDirty();
|
||||
|
||||
// at least under Windows, this should be the default behaviour
|
||||
m_AutoDeleteSelection = TRUE;
|
||||
m_AutoDeleteSelection = true;
|
||||
}
|
||||
|
||||
wxLayoutWindow::~wxLayoutWindow()
|
||||
@@ -217,7 +217,7 @@ wxLayoutWindow::Clear(int family,
|
||||
//wxScrolledWindow::Clear();
|
||||
ResizeScrollbars(true);
|
||||
SetDirty();
|
||||
SetModified(FALSE);
|
||||
SetModified(false);
|
||||
if ( m_Editable )
|
||||
m_CursorVisibility = 1;
|
||||
|
||||
@@ -243,9 +243,11 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
||||
#ifndef __WXMSW__
|
||||
|| m_FocusFollowMode
|
||||
#endif
|
||||
) && (wxWindow::FindFocus() != this)
|
||||
)
|
||||
&& (wxWindow::FindFocus() != this) )
|
||||
{
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
wxPoint findPos;
|
||||
findPos.x = dc.DeviceToLogicalX(event.GetX());
|
||||
@@ -256,6 +258,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
||||
|
||||
if(findPos.x < 0)
|
||||
findPos.x = 0;
|
||||
|
||||
if(findPos.y < 0)
|
||||
findPos.y = 0;
|
||||
|
||||
@@ -276,6 +279,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
||||
xdelta = event.GetX()-size.x+WXLO_SCROLLMARGIN_X;
|
||||
else
|
||||
xdelta = 0;
|
||||
|
||||
if(event.GetY() < WXLO_SCROLLMARGIN_Y)
|
||||
ydelta = -(WXLO_SCROLLMARGIN_Y-event.GetY());
|
||||
else if(event.GetY() > size.y-WXLO_SCROLLMARGIN_Y)
|
||||
@@ -314,7 +318,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
||||
{
|
||||
if(!m_HandCursor)
|
||||
SetCursor(wxCURSOR_HAND);
|
||||
m_HandCursor = TRUE;
|
||||
m_HandCursor = true;
|
||||
if(m_StatusBar && m_StatusFieldLabel != -1)
|
||||
{
|
||||
const wxString &label = u->GetLabel();
|
||||
@@ -330,7 +334,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
||||
{
|
||||
if(m_HandCursor)
|
||||
SetCursor(wxCURSOR_IBEAM);
|
||||
m_HandCursor = FALSE;
|
||||
m_HandCursor = false;
|
||||
if( m_StatusBar && m_StatusFieldLabel != -1 &&
|
||||
s_hasPutMessageInStatusBar )
|
||||
{
|
||||
@@ -382,6 +386,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
||||
|
||||
if(m_CursorVisibility == -1)
|
||||
m_CursorVisibility = 1;
|
||||
|
||||
#ifdef WXLAYOUT_USE_CARET
|
||||
if ( m_CursorVisibility == 1 )
|
||||
GetCaret()->Show();
|
||||
@@ -416,7 +421,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
||||
break;
|
||||
|
||||
case WXLOWIN_MENU_MDOWN:
|
||||
Paste(TRUE);
|
||||
Paste(true);
|
||||
break;
|
||||
|
||||
case WXLOWIN_MENU_DBLCLICK:
|
||||
@@ -464,7 +469,7 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
||||
void
|
||||
wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
int keyCode = event.KeyCode();
|
||||
int keyCode = event.GetKeyCode();
|
||||
bool ctrlDown = event.ControlDown();
|
||||
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
@@ -493,8 +498,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
&& !m_Selecting
|
||||
&& m_llist->HasSelection()
|
||||
&& ! IsDirectionKey(keyCode)
|
||||
&& ! (event.AltDown() || ctrlDown)
|
||||
)
|
||||
&& ! (event.AltDown() || ctrlDown) )
|
||||
{
|
||||
m_llist->DeleteSelection();
|
||||
deletedSelection = true;
|
||||
@@ -506,7 +510,9 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
// just continue the old selection
|
||||
if ( m_Selecting && event.ShiftDown() )
|
||||
{
|
||||
m_llist->ContinueSelection();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_llist->DiscardSelection();
|
||||
@@ -530,62 +536,78 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
*/
|
||||
switch(keyCode)
|
||||
{
|
||||
|
||||
case WXK_RIGHT:
|
||||
if ( ctrlDown )
|
||||
m_llist->MoveCursorWord(1);
|
||||
else
|
||||
m_llist->MoveCursorHorizontally(1);
|
||||
break;
|
||||
|
||||
case WXK_LEFT:
|
||||
if ( ctrlDown )
|
||||
m_llist->MoveCursorWord(-1);
|
||||
else
|
||||
m_llist->MoveCursorHorizontally(-1);
|
||||
|
||||
break;
|
||||
|
||||
case WXK_UP:
|
||||
m_llist->MoveCursorVertically(-1);
|
||||
break;
|
||||
|
||||
case WXK_DOWN:
|
||||
m_llist->MoveCursorVertically(1);
|
||||
break;
|
||||
|
||||
case WXK_PRIOR:
|
||||
m_llist->MoveCursorVertically(-Y_SCROLL_PAGE);
|
||||
break;
|
||||
|
||||
case WXK_NEXT:
|
||||
m_llist->MoveCursorVertically(Y_SCROLL_PAGE);
|
||||
break;
|
||||
|
||||
case WXK_HOME:
|
||||
if ( ctrlDown )
|
||||
m_llist->MoveCursorTo(wxPoint(0, 0));
|
||||
else
|
||||
m_llist->MoveCursorToBeginOfLine();
|
||||
break;
|
||||
|
||||
case WXK_END:
|
||||
if ( ctrlDown )
|
||||
m_llist->MoveCursorToEnd();
|
||||
else
|
||||
m_llist->MoveCursorToEndOfLine();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if(ctrlDown && ! IsEditable())
|
||||
{
|
||||
switch(keyCode)
|
||||
{
|
||||
|
||||
case 'c':
|
||||
// this should work even in read-only mode
|
||||
Copy(TRUE, TRUE);
|
||||
Copy(true, true);
|
||||
break;
|
||||
|
||||
case 's': // search
|
||||
Find(wxEmptyString);
|
||||
break;
|
||||
|
||||
case 't': // search again
|
||||
FindAgain();
|
||||
break;
|
||||
|
||||
default:
|
||||
// we don't handle it, maybe an accelerator?
|
||||
event.Skip();
|
||||
;
|
||||
}
|
||||
}
|
||||
else if( IsEditable() )
|
||||
{
|
||||
/* First, handle control keys */
|
||||
@@ -593,11 +615,14 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
if(keyCode >= 'A' && keyCode <= 'Z')
|
||||
keyCode = tolower(keyCode);
|
||||
|
||||
switch(keyCode)
|
||||
{
|
||||
|
||||
case WXK_INSERT:
|
||||
Copy();
|
||||
break;
|
||||
|
||||
case WXK_DELETE :
|
||||
if(! deletedSelection)
|
||||
{
|
||||
@@ -605,6 +630,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
SetDirty();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if(! deletedSelection) // already done
|
||||
{
|
||||
@@ -612,10 +638,12 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
SetDirty();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
m_llist->DeleteLines(1);
|
||||
SetDirty();
|
||||
break;
|
||||
|
||||
case 'h': // like backspace
|
||||
if(m_llist->MoveCursorHorizontally(-1))
|
||||
{
|
||||
@@ -623,45 +651,57 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
SetDirty();
|
||||
}
|
||||
break;
|
||||
|
||||
case 's': // search
|
||||
Find(wxEmptyString);
|
||||
break;
|
||||
|
||||
case 't': // search again
|
||||
FindAgain();
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
m_llist->DeleteToBeginOfLine();
|
||||
SetDirty();
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
m_llist->DeleteToEndOfLine();
|
||||
SetDirty();
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
Copy(TRUE, TRUE);
|
||||
Copy(true, true);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
Paste( TRUE );
|
||||
Paste(true);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
Cut();
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
if(m_WrapMargin > 0)
|
||||
m_llist->WrapLine(m_WrapMargin);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
if(m_WrapMargin > 0)
|
||||
m_llist->WrapAll(m_WrapMargin);
|
||||
break;
|
||||
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
case WXK_F1:
|
||||
m_llist->SetFont(-1,-1,-1,-1,true); // underlined
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
Refresh(TRUE);
|
||||
Refresh(true);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
// we don't handle it, maybe an accelerator?
|
||||
event.Skip();
|
||||
@@ -677,6 +717,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
m_llist->DeleteWord();
|
||||
SetDirty();
|
||||
break;
|
||||
|
||||
default:
|
||||
// we don't handle it, maybe an accelerator?
|
||||
event.Skip();
|
||||
@@ -691,29 +732,38 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
if(event.ShiftDown())
|
||||
Paste();
|
||||
break;
|
||||
|
||||
case WXK_DELETE :
|
||||
if(event.ShiftDown())
|
||||
{
|
||||
Cut();
|
||||
else
|
||||
if(! deletedSelection)
|
||||
}
|
||||
else if(! deletedSelection)
|
||||
{
|
||||
m_llist->Delete(1);
|
||||
SetDirty();
|
||||
}
|
||||
break;
|
||||
|
||||
case WXK_BACK: // backspace
|
||||
if(! deletedSelection)
|
||||
{
|
||||
if(m_llist->MoveCursorHorizontally(-1))
|
||||
{
|
||||
m_llist->Delete(1);
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WXK_RETURN:
|
||||
if (m_DoWordWrap &&
|
||||
m_WrapMargin > 0
|
||||
&& m_llist->GetCursorPos().x > m_WrapMargin )
|
||||
{
|
||||
m_llist->WrapLine(m_WrapMargin);
|
||||
}
|
||||
|
||||
m_llist->LineBreak();
|
||||
SetDirty();
|
||||
break;
|
||||
@@ -732,10 +782,8 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
break;
|
||||
|
||||
default:
|
||||
if((!(event.ControlDown() || event.AltDown()
|
||||
))
|
||||
&& (keyCode < 256 && keyCode >= 32)
|
||||
)
|
||||
if ( ( !(event.ControlDown() || event.AltDown()) )
|
||||
&& (keyCode < 256 && keyCode >= 32) )
|
||||
{
|
||||
if ( m_DoWordWrap
|
||||
&& m_WrapMargin > 0
|
||||
@@ -749,15 +797,20 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
SetDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
// we don't handle it, maybe an accelerator?
|
||||
event.Skip();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}// if(IsEditable())
|
||||
else
|
||||
{
|
||||
// we don't handle it, maybe an accelerator?
|
||||
event.Skip();
|
||||
}
|
||||
}// first switch()
|
||||
|
||||
if ( m_Selecting )
|
||||
@@ -765,6 +818,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
// continue selection to the current (new) cursor position
|
||||
m_llist->ContinueSelection();
|
||||
}
|
||||
|
||||
ScrollToCursor();
|
||||
// refresh the screen
|
||||
RequestUpdate(m_llist->GetUpdateRect());
|
||||
@@ -773,7 +827,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
void
|
||||
wxLayoutWindow::OnKeyUp(wxKeyEvent& event)
|
||||
{
|
||||
if ( event.KeyCode() == WXK_SHIFT && m_Selecting )
|
||||
if ( event.GetKeyCode() == WXK_SHIFT && m_Selecting )
|
||||
{
|
||||
m_llist->EndSelection();
|
||||
m_Selecting = false;
|
||||
@@ -784,7 +838,7 @@ wxLayoutWindow::OnKeyUp(wxKeyEvent& event)
|
||||
|
||||
|
||||
void
|
||||
wxLayoutWindow::ScrollToCursor(void)
|
||||
wxLayoutWindow::ScrollToCursor()
|
||||
{
|
||||
//is always needed to make sure we know where the cursor is
|
||||
//if(IsDirty())
|
||||
@@ -814,6 +868,7 @@ wxLayoutWindow::ScrollToCursor(void)
|
||||
wxPoint cs(m_llist->GetCursorSize());
|
||||
int nx = -1,
|
||||
ny = -1;
|
||||
|
||||
if ( cc.x < x0 || cc.x >= x0 + x1 - cs.x )
|
||||
{
|
||||
nx = cc.x - x1/2;
|
||||
@@ -861,7 +916,7 @@ wxLayoutWindow::RequestUpdate(const wxRect *
|
||||
// shouldn't specify the update rectangle if it doesn't include all the
|
||||
// changed locations - otherwise, they won't be repainted at all because
|
||||
// the system clips the display to the update rect
|
||||
Refresh(FALSE); //, updateRect);
|
||||
Refresh(false); //, updateRect);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -930,8 +985,13 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
|
||||
w = m_BGbitmap->GetWidth(),
|
||||
h = m_BGbitmap->GetHeight();
|
||||
for(y = 0; y < y1; y+=h)
|
||||
{
|
||||
for(x = 0; x < x1; x+=w)
|
||||
{
|
||||
m_memDC->DrawBitmap(*m_BGbitmap, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
m_memDC->SetBackgroundMode(wxTRANSPARENT);
|
||||
}
|
||||
|
||||
@@ -975,8 +1035,9 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
|
||||
{
|
||||
WXLO_DEBUG(("UpdateRegion: %ld,%ld, %ld,%ld",
|
||||
ri.GetX(),ri.GetY(),ri.GetW(),ri.GetH()));
|
||||
|
||||
dc.Blit(x0+ri.GetX(),y0+ri.GetY(),ri.GetW(),ri.GetH(),
|
||||
m_memDC,ri.GetX(),ri.GetY(),wxCOPY,FALSE);
|
||||
m_memDC,ri.GetX(),ri.GetY(),wxCOPY,false);
|
||||
ri++;
|
||||
}
|
||||
else
|
||||
@@ -988,8 +1049,9 @@ wxLayoutWindow::InternalPaint(const wxRect *updateRect)
|
||||
// if(updateRect->height < y1)
|
||||
// y1 = updateRect->height;
|
||||
// y1 += WXLO_YOFFSET; //FIXME might not be needed
|
||||
dc.Blit(x0,y0,x1,y1,m_memDC,0,0,wxCOPY,FALSE);
|
||||
dc.Blit(x0,y0,x1,y1,m_memDC,0,0,wxCOPY,false);
|
||||
}
|
||||
|
||||
WXLO_TIMER_STOP(BlitTimer);
|
||||
|
||||
|
||||
@@ -1051,6 +1113,7 @@ wxLayoutWindow::ResizeScrollbars(bool exact)
|
||||
m_llist->Layout(dc, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
WXLO_TIMER_START(LayoutTimer);
|
||||
m_llist->Layout(dc, -1);
|
||||
WXLO_TIMER_STOP(LayoutTimer);
|
||||
@@ -1065,6 +1128,7 @@ wxLayoutWindow::ResizeScrollbars(bool exact)
|
||||
// in the absence of scrollbars we should compare with the client size
|
||||
if ( !m_hasHScrollbar )
|
||||
m_maxx = size.x;// - WXLO_ROFFSET;
|
||||
|
||||
if ( !m_hasVScrollbar )
|
||||
m_maxy = size.y;// - WXLO_BOFFSET;
|
||||
|
||||
@@ -1084,25 +1148,28 @@ wxLayoutWindow::ResizeScrollbars(bool exact)
|
||||
max.y += WXLO_BOFFSET;
|
||||
}
|
||||
|
||||
bool done = FALSE;
|
||||
bool done = false;
|
||||
|
||||
if(max.x < X_SCROLL_PAGE && m_hasHScrollbar)
|
||||
{
|
||||
SetScrollbars(0,-1,0,-1,0,-1,true);
|
||||
m_hasHScrollbar = FALSE;
|
||||
done = TRUE;
|
||||
m_hasHScrollbar = false;
|
||||
done = true;
|
||||
}
|
||||
|
||||
if(max.y < Y_SCROLL_PAGE && m_hasVScrollbar)
|
||||
{
|
||||
SetScrollbars(-1,0,-1,0,-1,0,true);
|
||||
m_hasVScrollbar = FALSE;
|
||||
done = TRUE;
|
||||
m_hasVScrollbar = false;
|
||||
done = true;
|
||||
}
|
||||
|
||||
if (! done &&
|
||||
// (max.x > X_SCROLL_PAGE || max.y > Y_SCROLL_PAGE)
|
||||
(max.x > size.x - X_SCROLL_PAGE|| max.y > size.y - Y_SCROLL_PAGE)
|
||||
)
|
||||
(max.x > size.x - X_SCROLL_PAGE|| max.y > size.y - Y_SCROLL_PAGE) )
|
||||
{
|
||||
GetViewStart(&m_ViewStartX, &m_ViewStartY);
|
||||
|
||||
SetScrollbars(X_SCROLL_PAGE,
|
||||
Y_SCROLL_PAGE,
|
||||
max.x / X_SCROLL_PAGE + 2,
|
||||
@@ -1110,6 +1177,7 @@ wxLayoutWindow::ResizeScrollbars(bool exact)
|
||||
m_ViewStartX,
|
||||
m_ViewStartY,
|
||||
true);
|
||||
|
||||
m_hasHScrollbar =
|
||||
m_hasVScrollbar = true;
|
||||
// ScrollToCursor();
|
||||
@@ -1150,6 +1218,7 @@ wxLayoutWindow::Paste(bool usePrivate, bool primary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxTextDataObject data;
|
||||
if (wxTheClipboard->IsSupported( data.GetFormat() )
|
||||
&& wxTheClipboard->GetData(data) )
|
||||
@@ -1197,7 +1266,7 @@ wxLayoutWindow::Copy(bool invalidate, bool privateFormat, bool primary)
|
||||
wxLayoutDataObject *wldo = new wxLayoutDataObject;
|
||||
wxLayoutList *llist = m_llist->GetSelection(wldo, invalidate);
|
||||
if(! llist)
|
||||
return FALSE;
|
||||
return false;
|
||||
// Export selection as text:
|
||||
wxString text;
|
||||
wxLayoutExportObject *exp;
|
||||
@@ -1206,8 +1275,10 @@ wxLayoutWindow::Copy(bool invalidate, bool privateFormat, bool primary)
|
||||
{
|
||||
if(exp->type == WXLO_EXPORT_TEXT)
|
||||
text << *(exp->content.text);
|
||||
|
||||
delete exp;
|
||||
}
|
||||
|
||||
delete llist;
|
||||
|
||||
// The exporter always appends a newline, so we chop it off if it
|
||||
@@ -1237,18 +1308,20 @@ if(! primary) // always copy as text-only to primary selection
|
||||
if (wxTheClipboard->Open())
|
||||
{
|
||||
wxTextDataObject *data = new wxTextDataObject( text );
|
||||
bool rc;
|
||||
bool rc = wxTheClipboard->SetData( data );
|
||||
|
||||
rc = wxTheClipboard->SetData( data );
|
||||
if(privateFormat)
|
||||
rc |= wxTheClipboard->SetData( wldo );
|
||||
|
||||
wxTheClipboard->Close();
|
||||
return rc;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete wldo;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1258,10 +1331,12 @@ wxLayoutWindow::Cut(bool privateFormat, bool usePrimary)
|
||||
{
|
||||
m_llist->DeleteSelection();
|
||||
SetDirty();
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -1269,25 +1344,15 @@ wxLayoutWindow::Cut(bool privateFormat, bool usePrimary)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool
|
||||
wxLayoutWindow::Find(const wxString &
|
||||
wxLayoutWindow::Find(
|
||||
#ifdef M_BASEDIR
|
||||
needle
|
||||
const wxString &needle,
|
||||
wxPoint * fromWhere,
|
||||
const wxString &configPath
|
||||
#else
|
||||
WXUNUSED(needle)
|
||||
#endif
|
||||
,
|
||||
wxPoint *
|
||||
#ifdef M_BASEDIR
|
||||
fromWhere
|
||||
#else
|
||||
WXUNUSED(fromWhere)
|
||||
#endif
|
||||
,
|
||||
const wxString &
|
||||
#ifdef M_BASEDIR
|
||||
configPath
|
||||
#else
|
||||
WXUNUSED(configPath)
|
||||
const wxString & WXUNUSED(needle),
|
||||
wxPoint * WXUNUSED(fromWhere),
|
||||
const wxString & WXUNUSED(configPath)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -1302,15 +1367,20 @@ wxLayoutWindow::Find(const wxString &
|
||||
this,
|
||||
configPath, "")
|
||||
|| strutil_isempty(m_FindString))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FindString = needle;
|
||||
}
|
||||
|
||||
if(fromWhere == NULL)
|
||||
found = m_llist->FindText(m_FindString, m_llist->GetCursorPos());
|
||||
else
|
||||
found = m_llist->FindText(m_FindString, *fromWhere);
|
||||
|
||||
if(found.x != -1)
|
||||
{
|
||||
if(fromWhere)
|
||||
@@ -1318,18 +1388,21 @@ wxLayoutWindow::Find(const wxString &
|
||||
*fromWhere = found;
|
||||
fromWhere->x ++;
|
||||
}
|
||||
|
||||
m_llist->MoveCursorTo(found);
|
||||
ScrollToCursor();
|
||||
RequestUpdate();
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
wxLayoutWindow::FindAgain(void)
|
||||
wxLayoutWindow::FindAgain()
|
||||
{
|
||||
bool rc = Find(m_FindString);
|
||||
return rc;
|
||||
@@ -1344,16 +1417,16 @@ wxLayoutWindow::MakeFormatMenu()
|
||||
{
|
||||
wxMenu *m = new wxMenu(_("Layout Menu"));
|
||||
|
||||
m->Append(WXLOWIN_MENU_LARGER ,_("&Larger"),_("Switch to larger font."), false);
|
||||
m->Append(WXLOWIN_MENU_SMALLER ,_("&Smaller"),_("Switch to smaller font."), false);
|
||||
m->Append(WXLOWIN_MENU_LARGER ,_("&Larger"),_("Switch to larger font."));
|
||||
m->Append(WXLOWIN_MENU_SMALLER ,_("&Smaller"),_("Switch to smaller font."));
|
||||
m->AppendSeparator();
|
||||
m->Append(WXLOWIN_MENU_UNDERLINE, _("&Underline"),_("Underline mode."), true);
|
||||
m->Append(WXLOWIN_MENU_BOLD, _("&Bold"),_("Bold mode."), true);
|
||||
m->Append(WXLOWIN_MENU_ITALICS, _("&Italics"),_("Italics mode."), true);
|
||||
m->Append(WXLOWIN_MENU_UNDERLINE, _("&Underline"),_("Underline mode."), wxITEM_CHECK);
|
||||
m->Append(WXLOWIN_MENU_BOLD, _("&Bold"),_("Bold mode."), wxITEM_CHECK);
|
||||
m->Append(WXLOWIN_MENU_ITALICS, _("&Italics"),_("Italics mode."), wxITEM_CHECK);
|
||||
m->AppendSeparator();
|
||||
m->Append(WXLOWIN_MENU_ROMAN ,_("&Roman"),_("Switch to roman font."), false);
|
||||
m->Append(WXLOWIN_MENU_TYPEWRITER,_("&Typewriter"),_("Switch to typewriter font."), false);
|
||||
m->Append(WXLOWIN_MENU_SANSSERIF ,_("&Sans Serif"),_("Switch to sans serif font."), false);
|
||||
m->Append(WXLOWIN_MENU_ROMAN ,_("&Roman"),_("Switch to roman font."));
|
||||
m->Append(WXLOWIN_MENU_TYPEWRITER,_("&Typewriter"),_("Switch to typewriter font."));
|
||||
m->Append(WXLOWIN_MENU_SANSSERIF ,_("&Sans Serif"),_("Switch to sans serif font."));
|
||||
|
||||
return m;
|
||||
}
|
||||
@@ -1379,18 +1452,25 @@ void wxLayoutWindow::OnMenu(wxCommandEvent& event)
|
||||
{
|
||||
case WXLOWIN_MENU_LARGER:
|
||||
m_llist->SetFontLarger(); RequestUpdate(); break;
|
||||
|
||||
case WXLOWIN_MENU_SMALLER:
|
||||
m_llist->SetFontSmaller(); RequestUpdate(); break;
|
||||
|
||||
case WXLOWIN_MENU_UNDERLINE:
|
||||
m_llist->ToggleFontUnderline(); RequestUpdate(); break;
|
||||
|
||||
case WXLOWIN_MENU_BOLD:
|
||||
m_llist->ToggleFontWeight(); RequestUpdate(); break;
|
||||
|
||||
case WXLOWIN_MENU_ITALICS:
|
||||
m_llist->ToggleFontItalics(); RequestUpdate(); break;
|
||||
|
||||
case WXLOWIN_MENU_ROMAN:
|
||||
m_llist->SetFontFamily(wxROMAN); RequestUpdate(); break;
|
||||
|
||||
case WXLOWIN_MENU_TYPEWRITER:
|
||||
m_llist->SetFontFamily(wxFIXED); RequestUpdate(); break;
|
||||
|
||||
case WXLOWIN_MENU_SANSSERIF:
|
||||
m_llist->SetFontFamily(wxSWISS); RequestUpdate(); break;
|
||||
}
|
||||
@@ -1438,3 +1518,4 @@ static bool IsDirectionKey(long keyCode)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef USE_PCH
|
||||
# include <wx/wx.h>
|
||||
# include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "wxllist.h"
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
wxColour *bg = NULL);
|
||||
|
||||
/// override base class virtual to also refresh the scrollbar position
|
||||
virtual void Refresh(bool eraseBackground = TRUE,
|
||||
virtual void Refresh(bool eraseBackground = true,
|
||||
const wxRect *rect = (const wxRect *)NULL);
|
||||
|
||||
/** Sets a background image, only used on screen, not on printouts.
|
||||
@@ -80,36 +80,47 @@ public:
|
||||
if(m_BGbitmap) delete m_BGbitmap;
|
||||
m_BGbitmap = bitmap;
|
||||
}
|
||||
|
||||
/// Enable or disable editing, i.e. processing of keystrokes.
|
||||
void SetEditable(bool toggle)
|
||||
{ m_Editable = toggle; SetCursorVisibility(toggle); }
|
||||
{
|
||||
m_Editable = toggle;
|
||||
SetCursorVisibility(toggle);
|
||||
}
|
||||
|
||||
/// Query whether list can be edited by user.
|
||||
bool IsEditable(void) const { return m_Editable; }
|
||||
bool IsEditable() const { return m_Editable; }
|
||||
|
||||
/** Sets cursor visibility, visible=1, invisible=0,
|
||||
visible-on-demand=-1, to hide it until moved.
|
||||
@param visibility -1,0 or 1
|
||||
@return the old visibility
|
||||
*/
|
||||
inline int SetCursorVisibility(int visibility = -1)
|
||||
{ int v =m_CursorVisibility;
|
||||
m_CursorVisibility = visibility; return v;}
|
||||
{
|
||||
int v =m_CursorVisibility;
|
||||
m_CursorVisibility = visibility; return v;
|
||||
}
|
||||
|
||||
/// Pastes text from clipboard.
|
||||
void Paste(bool privateFormat = FALSE, bool usePrimarySelection = FALSE);
|
||||
void Paste(bool privateFormat = false, bool usePrimarySelection = false);
|
||||
|
||||
/** Copies selection to clipboard.
|
||||
@param invalidate used internally, see wxllist.h for details
|
||||
*/
|
||||
bool Copy(bool invalidate = true, bool privateFormat = FALSE, bool primary = FALSE);
|
||||
bool Copy(bool invalidate = true, bool privateFormat = false, bool primary = false);
|
||||
|
||||
/// Copies selection to clipboard and deletes it.
|
||||
bool Cut(bool privateFormat = FALSE, bool usePrimary = FALSE);
|
||||
bool Cut(bool privateFormat = false, bool usePrimary = false);
|
||||
//@}
|
||||
|
||||
/// find string in buffer
|
||||
bool Find(const wxString &needle,
|
||||
wxPoint * fromWhere = NULL,
|
||||
const wxString &configPath = _T("MsgViewFindString"));
|
||||
|
||||
/// find the same string again
|
||||
bool FindAgain(void);
|
||||
bool FindAgain();
|
||||
|
||||
void EnablePopup(bool enable = true) { m_DoPopupMenu = enable; }
|
||||
|
||||
@@ -135,10 +146,10 @@ public:
|
||||
/// if the flag is true, we send events when user clicks on embedded objects
|
||||
inline void SetMouseTracking(bool doIt = true) { m_doSendEvents = doIt; }
|
||||
|
||||
/* Returns a pointer to the wxLayoutList object.
|
||||
/** Returns a pointer to the wxLayoutList object.
|
||||
@return the list
|
||||
*/
|
||||
wxLayoutList * GetLayoutList(void) { return m_llist; }
|
||||
wxLayoutList * GetLayoutList() { return m_llist; }
|
||||
|
||||
/**@name Callbacks */
|
||||
//@{
|
||||
@@ -161,7 +172,8 @@ public:
|
||||
//@}
|
||||
|
||||
/// Creates a wxMenu for use as a format popup.
|
||||
static wxMenu * MakeFormatMenu(void);
|
||||
static wxMenu * MakeFormatMenu();
|
||||
|
||||
/// Redraws the window, used by RequestUpdate() or OnPaint().
|
||||
void InternalPaint(const wxRect *updateRect);
|
||||
|
||||
@@ -178,65 +190,85 @@ public:
|
||||
m_StatusBar = bar; m_StatusFieldLabel = labelfield;
|
||||
m_StatusFieldCursor = cursorfield;
|
||||
}
|
||||
|
||||
#ifndef __WXMSW__
|
||||
/// Enable or disable focus follow mode under non-MSW
|
||||
void SetFocusFollowMode(bool enable = TRUE)
|
||||
{ m_FocusFollowMode = enable; }
|
||||
void SetFocusFollowMode(bool enable = true)
|
||||
{
|
||||
m_FocusFollowMode = enable;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @name Modified flag handling, will not get reset by list unless
|
||||
in Clear() */
|
||||
//@{
|
||||
/// Set dirty flag.
|
||||
void SetModified(bool modified = TRUE) { m_Modified = modified; }
|
||||
void SetModified(bool modified = true) { m_Modified = modified; }
|
||||
|
||||
/// Query whether window needs redrawing.
|
||||
bool IsModified(void) const { return m_Modified; }
|
||||
bool IsModified() const { return m_Modified; }
|
||||
//@}
|
||||
|
||||
/**@name Dirty flag handling for optimisations.
|
||||
/**
|
||||
@name Dirty flag handling for optimisations.
|
||||
Normally one should only need to call SetDirty(), e.g. when
|
||||
manipulating the wxLayoutList directly, so the window will update
|
||||
itself. ResetDirty() and IsDirty() should only be used
|
||||
internally. */
|
||||
//@{
|
||||
/// Set dirty flag.
|
||||
void SetDirty(void) { m_Dirty = true; m_Modified = true; }
|
||||
void SetDirty() { m_Dirty = true; m_Modified = true; }
|
||||
|
||||
/// Query whether window needs redrawing.
|
||||
bool IsDirty(void) const { return m_Dirty; }
|
||||
bool IsDirty() const { return m_Dirty; }
|
||||
|
||||
/// Reset dirty flag.
|
||||
void ResetDirty(void) { m_Dirty = false; }
|
||||
void ResetDirty() { m_Dirty = false; }
|
||||
//@}
|
||||
|
||||
|
||||
protected:
|
||||
/// generic function for mouse events processing
|
||||
void OnMouse(int eventId, wxMouseEvent& event);
|
||||
|
||||
/// as the name says
|
||||
void ScrollToCursor(void);
|
||||
void ScrollToCursor();
|
||||
|
||||
/// for sending events
|
||||
wxWindow *m_Parent;
|
||||
|
||||
/// Shall we send events?
|
||||
bool m_doSendEvents;
|
||||
|
||||
/// Where does the current view start?
|
||||
int m_ViewStartX; int m_ViewStartY;
|
||||
|
||||
/// Do we currently have the focus?
|
||||
bool m_HaveFocus;
|
||||
|
||||
/// do we handle clicks of the right mouse button?
|
||||
bool m_DoPopupMenu;
|
||||
|
||||
/// Should InternalPaint() scroll to cursor (VZ: seems unused any more)
|
||||
bool m_ScrollToCursor;
|
||||
|
||||
/// Do we currently have a non-standard cursor?
|
||||
bool m_HandCursor;
|
||||
|
||||
/// the menu
|
||||
wxMenu * m_PopupMenu;
|
||||
|
||||
/// for derived classes, set when mouse is clicked
|
||||
wxPoint m_ClickPosition;
|
||||
|
||||
/// for scrollbar calculations:
|
||||
int m_maxx;
|
||||
int m_maxy;
|
||||
int m_lineHeight;
|
||||
|
||||
/// do we want automatic word wrap?
|
||||
bool m_DoWordWrap;
|
||||
|
||||
/// wrap margin
|
||||
CoordType m_WrapMargin;
|
||||
|
||||
@@ -249,7 +281,7 @@ protected:
|
||||
*/
|
||||
int m_CursorVisibility;
|
||||
|
||||
bool SetAutoDeleteSelection(bool enable = TRUE)
|
||||
bool SetAutoDeleteSelection(bool enable = true)
|
||||
{
|
||||
bool old = m_AutoDeleteSelection;
|
||||
m_AutoDeleteSelection = enable;
|
||||
@@ -258,29 +290,40 @@ protected:
|
||||
private:
|
||||
/// The layout list to be displayed.
|
||||
wxLayoutList *m_llist;
|
||||
|
||||
/// Can user edit the window?
|
||||
bool m_Editable;
|
||||
|
||||
/// Are we currently building a selection with the keyboard?
|
||||
bool m_Selecting;
|
||||
|
||||
/// Has list changed since last redraw, e.g. in size?
|
||||
bool m_Dirty;
|
||||
|
||||
/// Has the list ever been modified?
|
||||
bool m_Modified;
|
||||
|
||||
wxMemoryDC *m_memDC;
|
||||
wxBitmap *m_bitmap;
|
||||
wxPoint m_bitmapSize;
|
||||
|
||||
/// A frame's statusbar to update
|
||||
class wxStatusBar *m_StatusBar;
|
||||
|
||||
/// statusbar field for labels
|
||||
int m_StatusFieldLabel;
|
||||
|
||||
/// statusbar field for cursor positions
|
||||
int m_StatusFieldCursor;
|
||||
|
||||
/// a pointer to a bitmap for the background
|
||||
wxBitmap *m_BGbitmap;
|
||||
|
||||
/**@name Some configuration options */
|
||||
//@{
|
||||
/// Do we want to auto-replace the selection with new text?
|
||||
bool m_AutoDeleteSelection;
|
||||
|
||||
#ifndef __WXMSW__
|
||||
/// Do we want the focus to follow the mouse?
|
||||
bool m_FocusFollowMode;
|
||||
@@ -288,6 +331,7 @@ private:
|
||||
/// For finding text and finding it again:
|
||||
wxString m_FindString;
|
||||
//@}
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user