Applied patch #15286: documentation and col/rowspan demo by dghart
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74304 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -5373,7 +5373,14 @@ protected:
|
|||||||
/**
|
/**
|
||||||
@class wxRichTextCell
|
@class wxRichTextCell
|
||||||
|
|
||||||
wxRichTextCell is the cell in a table.
|
wxRichTextCell is the cell in a table, in which the user can type. As well as
|
||||||
|
text, it can also contain objects e.g. an image, or even another wxRichTextTable.
|
||||||
|
|
||||||
|
A cell's appearance can be changed via its associated wxRichTextAttr; for example
|
||||||
|
its size altered or its background colour set. It also has the properties of
|
||||||
|
column- and row-span. By default these are 1, meaning that the cell only spans
|
||||||
|
itself, but can be increased using the SetColspan() and SetRowspan() methods.
|
||||||
|
Attempts to set too large a span are silently truncated to the table edge.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class wxRichTextCell: public wxRichTextBox
|
class wxRichTextCell: public wxRichTextBox
|
||||||
@@ -5407,6 +5414,52 @@ public:
|
|||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the number of columns spanned by the cell.
|
||||||
|
|
||||||
|
By default a cell doesn't span extra columns, so this function returns 1.
|
||||||
|
|
||||||
|
@since 2.9.5
|
||||||
|
|
||||||
|
@see SetColspan(), GetRowspan()
|
||||||
|
*/
|
||||||
|
int GetColspan() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the number of columns spanned by the cell.
|
||||||
|
|
||||||
|
By default colspan is 1 i.e. a cell doesn't span extra columns. Pass a value >1
|
||||||
|
to change this. Attempting to set a colspan <1 will assert and be ignored.
|
||||||
|
|
||||||
|
@since 2.9.5
|
||||||
|
|
||||||
|
@see GetColspan(), SetRowspan()
|
||||||
|
*/
|
||||||
|
void SetColspan(long span);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the number of rows spanned by the cell.
|
||||||
|
|
||||||
|
By default a cell doesn't span extra rows, so this function returns 1.
|
||||||
|
|
||||||
|
@since 2.9.5
|
||||||
|
|
||||||
|
@see SetRowspan(), GetColspan()
|
||||||
|
*/
|
||||||
|
int GetRowspan() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the number of rows spanned by the cell.
|
||||||
|
|
||||||
|
By default colspan is 1 i.e. a cell doesn't span extra rows. Pass a value >1
|
||||||
|
to change this. Attempting to set a rowspan <1 will assert and be ignored.
|
||||||
|
|
||||||
|
@since 2.9.5
|
||||||
|
|
||||||
|
@see GetRowspan(), SetColspan()
|
||||||
|
*/
|
||||||
|
void SetRowspan(long span);
|
||||||
|
|
||||||
// Operations
|
// Operations
|
||||||
|
|
||||||
virtual wxRichTextObject* Clone() const { return new wxRichTextCell(*this); }
|
virtual wxRichTextObject* Clone() const { return new wxRichTextCell(*this); }
|
||||||
|
@@ -538,7 +538,9 @@ bool MyApp::OnInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// create the main application window
|
// create the main application window
|
||||||
MyFrame *frame = new MyFrame(wxT("wxRichTextCtrl Sample"), wxID_ANY, wxDefaultPosition, wxSize(700, 600));
|
wxSize size = wxGetDisplaySize();
|
||||||
|
size.Scale(0.75, 0.75);
|
||||||
|
MyFrame *frame = new MyFrame(wxT("wxRichTextCtrl Sample"), wxID_ANY, wxDefaultPosition, size);
|
||||||
|
|
||||||
m_printing->SetParentWindow(frame);
|
m_printing->SetParentWindow(frame);
|
||||||
|
|
||||||
@@ -875,14 +877,14 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos,
|
|||||||
|
|
||||||
toolBar->Realize();
|
toolBar->Realize();
|
||||||
|
|
||||||
wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxSize(100,100), wxSP_LIVE_UPDATE);
|
wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);
|
||||||
sizer->Add(splitter, 1, wxEXPAND);
|
sizer->Add(splitter, 1, wxEXPAND);
|
||||||
|
|
||||||
wxFont textFont = wxFont(12, wxROMAN, wxNORMAL, wxNORMAL);
|
wxFont textFont = wxFont(12, wxROMAN, wxNORMAL, wxNORMAL);
|
||||||
wxFont boldFont = wxFont(12, wxROMAN, wxNORMAL, wxBOLD);
|
wxFont boldFont = wxFont(12, wxROMAN, wxNORMAL, wxBOLD);
|
||||||
wxFont italicFont = wxFont(12, wxROMAN, wxITALIC, wxNORMAL);
|
wxFont italicFont = wxFont(12, wxROMAN, wxITALIC, wxNORMAL);
|
||||||
|
|
||||||
m_richTextCtrl = new MyRichTextCtrl(splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxWANTS_CHARS);
|
m_richTextCtrl = new MyRichTextCtrl(splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxVSCROLL|wxHSCROLL|wxWANTS_CHARS);
|
||||||
wxASSERT(!m_richTextCtrl->GetBuffer().GetAttributes().HasFontPixelSize());
|
wxASSERT(!m_richTextCtrl->GetBuffer().GetAttributes().HasFontPixelSize());
|
||||||
|
|
||||||
wxFont font(12, wxROMAN, wxNORMAL, wxNORMAL);
|
wxFont font(12, wxROMAN, wxNORMAL, wxNORMAL);
|
||||||
@@ -908,7 +910,9 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
splitter->SplitVertically(m_richTextCtrl, styleListCtrl, 500);
|
int width = GetClientSize().GetWidth() * 0.8;
|
||||||
|
splitter->SplitVertically(m_richTextCtrl, styleListCtrl, width);
|
||||||
|
splitter->SetSashGravity(0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
@@ -1181,8 +1185,8 @@ void MyFrame::WriteInitialText()
|
|||||||
cellAttr.GetTextBoxAttr().GetWidth().SetValue(200, wxTEXT_ATTR_UNITS_PIXELS);
|
cellAttr.GetTextBoxAttr().GetWidth().SetValue(200, wxTEXT_ATTR_UNITS_PIXELS);
|
||||||
cellAttr.GetTextBoxAttr().GetHeight().SetValue(150, wxTEXT_ATTR_UNITS_PIXELS);
|
cellAttr.GetTextBoxAttr().GetHeight().SetValue(150, wxTEXT_ATTR_UNITS_PIXELS);
|
||||||
|
|
||||||
//wxRichTextTable* table = r.WriteTable(3, 2, attr, cellAttr);
|
wxRichTextTable* table = r.WriteTable(6, 4, attr, cellAttr);
|
||||||
wxRichTextTable* table = r.WriteTable(24, 2, attr, cellAttr);
|
|
||||||
int i, j;
|
int i, j;
|
||||||
for (j = 0; j < table->GetRowCount(); j++)
|
for (j = 0; j < table->GetRowCount(); j++)
|
||||||
{
|
{
|
||||||
@@ -1193,12 +1197,33 @@ void MyFrame::WriteInitialText()
|
|||||||
r.WriteText(msg);
|
r.WriteText(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Demonstrate colspan and rowspan
|
||||||
|
wxRichTextCell* cell = table->GetCell(1, 0);
|
||||||
|
cell->SetColspan(2);
|
||||||
|
r.SetFocusObject(cell);
|
||||||
|
cell->Clear();
|
||||||
|
r.WriteText("This cell spans 2 columns");
|
||||||
|
|
||||||
|
cell = table->GetCell(1, 3);
|
||||||
|
cell->SetRowspan(2);
|
||||||
|
r.SetFocusObject(cell);
|
||||||
|
cell->Clear();
|
||||||
|
r.WriteText("This cell spans 2 rows");
|
||||||
|
|
||||||
|
cell = table->GetCell(2, 1);
|
||||||
|
cell->SetColspan(2);
|
||||||
|
cell->SetRowspan(3);
|
||||||
|
r.SetFocusObject(cell);
|
||||||
|
cell->Clear();
|
||||||
|
r.WriteText("This cell spans 2 columns and 3 rows");
|
||||||
|
|
||||||
r.SetFocusObject(NULL); // Set the focus back to the main buffer
|
r.SetFocusObject(NULL); // Set the focus back to the main buffer
|
||||||
r.SetInsertionPointEnd();
|
r.SetInsertionPointEnd();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
r.Newline();
|
r.Newline(); r.Newline();
|
||||||
|
|
||||||
wxRichTextProperties properties;
|
wxRichTextProperties properties;
|
||||||
r.WriteText(wxT("This is a rectangle field: "));
|
r.WriteText(wxT("This is a rectangle field: "));
|
||||||
|
Reference in New Issue
Block a user