Made tex2rtf compile again,

Added wxSizer::SetMinSize() (documented)
  Added wxSizer::SetItemMinSize()


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7172 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2000-04-15 09:20:56 +00:00
parent 1d0430ce13
commit dc4ab3c264
4 changed files with 160 additions and 10 deletions

View File

@@ -128,13 +128,25 @@ the layout "on screen" after removing a child fom the sizer.
Returns TRUE if the child item was found and removed, FALSE otherwise.
\membersection{wxSizer::SetMinSize}\label{wxsizersetminsize}
\func{void}{SetMinSize}{\param{int }{width}, \param{int }{height}}
\func{void}{SetMinSize}{\param{wxSize }{size}}
Call this to give the sizer a minimal size. Normally, the sizer will calculate its
minimal size based purely on how much space its children need. After calling this
method \helpref{GetMinSize}{wxsizergetminsize} will return either the minimal size
as requested by its children or the minimal size set here, depending on what is
bigger.
\membersection{wxSizer::SetDimension}\label{wxsizersetdimension}
\func{void}{SetDimension}{\param{int }{x}, \param{int }{y}, \param{int }{width}, \param{int }{height}}
Call this to force the sizer to take the given dimension and thus force the items owned
by the sizer to resize themselves according to the rules defined by the paramater in the
\helpref{wxSizer::Add}{wxsizeradd} and \helpref{wxSizer::Prepend}{wxsizerprepend} methods.
\helpref{Add}{wxsizeradd} and \helpref{Prepend}{wxsizerprepend} methods.
\membersection{wxSizer::GetSize}\label{wxsizergetsize}
@@ -152,7 +164,9 @@ Returns the current position of the sizer.
\func{wxSize}{GetMinSize}{\void}
Returns the minimal size of the sizer.
Returns the minimal size of the sizer. This is either the combined minimal
size of all the children and their borders or the minimal size set by
\helpref{SetMinSize}{wxsizersetminsize}, depending on what is bigger.
\membersection{wxSizer::RecalcSizes}\label{wxsizerrecalcsizes}

View File

@@ -138,14 +138,35 @@ public:
virtual bool Remove( wxSizer *sizer );
virtual bool Remove( int pos );
void SetDimension( int x, int y, int width, int height );
void SetMinSize( int width, int height )
{ DoSetMinSize( width, height ); }
void SetMinSize( wxSize size )
{ DoSetMinSize( size.x, size.y ); }
/* Searches recursively */
bool SetItemMinSize( wxWindow *window, int width, int height )
{ return DoSetItemMinSize( window, width, height ); }
bool SetItemMinSize( wxWindow *window, wxSize size )
{ return DoSetItemMinSize( window, size.x, size.y ); }
/* Searches recursively */
bool SetItemMinSize( wxSizer *sizer, int width, int height )
{ return DoSetItemMinSize( sizer, width, height ); }
bool SetItemMinSize( wxSizer *sizer, wxSize size )
{ return DoSetItemMinSize( sizer, size.x, size.y ); }
bool SetItemMinSize( int pos, int width, int height )
{ return DoSetItemMinSize( pos, width, height ); }
bool SetItemMinSize( int pos, wxSize size )
{ return DoSetItemMinSize( pos, size.x, size.y ); }
wxSize GetSize()
{ return m_size; }
wxPoint GetPosition()
{ return m_position; }
wxSize GetMinSize()
{ return CalcMin(); }
/* Calculate the minimal size or return m_minSize if bigger. */
wxSize GetMinSize();
virtual void RecalcSizes() = 0;
virtual wxSize CalcMin() = 0;
@@ -158,13 +179,21 @@ public:
wxList& GetChildren()
{ return m_children; }
void SetDimension( int x, int y, int width, int height );
protected:
wxSize m_size;
wxSize m_minSize;
wxPoint m_position;
wxList m_children;
wxSize GetMinWindowSize( wxWindow *window );
virtual void DoSetMinSize( int width, int height );
virtual bool DoSetItemMinSize( wxWindow *window, int width, int height );
virtual bool DoSetItemMinSize( wxSizer *sizer, int width, int height );
virtual bool DoSetItemMinSize( int pos, int width, int height );
private:
DECLARE_CLASS(wxSizer);
};

View File

@@ -235,6 +235,8 @@ bool wxSizerItem::IsSpacer()
wxSizer::wxSizer()
{
m_children.DeleteContents( TRUE );
m_minSize.x = 0;
m_minSize.y = 0;
}
wxSizer::~wxSizer()
@@ -297,7 +299,7 @@ bool wxSizer::Remove( wxWindow *window )
if (item->GetWindow() == window)
{
m_children.DeleteNode( node );
return TRUE;
return TRUE;
}
node = node->Next();
}
@@ -370,6 +372,111 @@ void wxSizer::SetDimension( int x, int y, int width, int height )
RecalcSizes();
}
wxSize wxSizer::GetMinSize()
{
wxSize ret( CalcMin() );
if (ret.x < m_minSize.x) ret.x = m_minSize.x;
if (ret.y < m_minSize.y) ret.y = m_minSize.y;
return ret;
}
void wxSizer::DoSetMinSize( int width, int height )
{
m_minSize.x = width;
m_minSize.y = height;
}
bool wxSizer::DoSetItemMinSize( wxWindow *window, int width, int height )
{
wxASSERT( window );
wxNode *node = m_children.First();
while (node)
{
wxSizerItem *item = (wxSizerItem*)node->Data();
if (item->GetWindow() == window)
{
item->SetInitSize( width, height );
return TRUE;
}
node = node->Next();
}
node = m_children.First();
while (node)
{
wxSizerItem *item = (wxSizerItem*)node->Data();
if (item->GetSizer())
{
/* It's a sizer, so lets search recursively. */
if (item->GetSizer()->DoSetItemMinSize( window, width, height ))
{
/* A child sizer found the requested windw, exit. */
return TRUE;
}
}
node = node->Next();
}
return FALSE;
}
bool wxSizer::DoSetItemMinSize( wxSizer *sizer, int width, int height )
{
wxASSERT( sizer );
wxNode *node = m_children.First();
while (node)
{
wxSizerItem *item = (wxSizerItem*)node->Data();
if (item->GetSizer() == sizer)
{
item->GetSizer()->DoSetMinSize( width, height );
return TRUE;
}
node = node->Next();
}
node = m_children.First();
while (node)
{
wxSizerItem *item = (wxSizerItem*)node->Data();
if (item->GetSizer())
{
/* It's a sizer, so lets search recursively. */
if (item->GetSizer()->DoSetItemMinSize( sizer, width, height ))
{
/* A child sizer found the requested windw, exit. */
return TRUE;
}
}
node = node->Next();
}
return FALSE;
}
bool wxSizer::DoSetItemMinSize( int pos, int width, int height )
{
wxNode *node = m_children.Nth( pos );
if (!node) return FALSE;
wxSizerItem *item = (wxSizerItem*) node->Data();
if (item->GetSizer())
{
/* Sizers contains the minimal size in them, if not calculated ... */
item->GetSizer()->DoSetMinSize( width, height );
}
else
{
/* ... whereas the minimal size of spacers and windows in stored
in the item */
item->SetInitSize( width, height );
}
return TRUE;
}
//---------------------------------------------------------------------------
// wxGridSizer
//---------------------------------------------------------------------------

View File

@@ -363,9 +363,9 @@ bool FindEndEnvironment(char *buffer, int *pos, char *env)
bool readingVerbatim = FALSE;
bool readInVerbatim = FALSE; // Within a verbatim, but not nec. verbatiminput
unsigned long leftCurly = 0;
unsigned long rightCurly = 0;
wxString currentFile = "";
unsigned long leftCurly = 0;
unsigned long rightCurly = 0;
static wxString currentFileName = "";
bool read_a_line(char *buf)
{