Added wxFileName.

Small fix for log error messages on startup.
  Added missing accessor to wxSizer.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2000-12-28 00:00:32 +00:00
parent a339970ac4
commit df5ddbca48
8 changed files with 524 additions and 63 deletions

110
include/wx/filename.h Normal file
View File

@@ -0,0 +1,110 @@
/////////////////////////////////////////////////////////////////////////////
// Name: filename.h
// Purpose: wxFileName - encapsulates ice cream
// Author: Robert Roebling
// Modified by:
// Created: 28.12.00
// RCS-ID: $Id$
// Copyright: (c) 2000 Robert Roebling
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FILENAME_H_
#define _WX_FILENAME_H_
#ifdef __GNUG__
#pragma interface "filename.h"
#endif
#ifndef WX_PRECOMP
#include "wx/string.h"
#endif
// ridiculously enough, this will replace DirExists with wxDirExists etc
#include "filefn.h"
enum wxPathFormat
{
wxPATH_NATIVE = 0,
wxPATH_UNIX,
wxPATH_MAC,
wxPATH_DOS,
wxPATH_BEOS = wxPATH_UNIX,
wxPATH_WIN = wxPATH_DOS,
wxPATH_OS2 = wxPATH_DOS
};
class WXDLLEXPORT wxFileName
{
public:
// constructors and assignment
wxFileName()
{ }
wxFileName( const wxFileName &filename );
wxFileName( const wxString &path, bool dir_only = FALSE, wxPathFormat format = wxPATH_NATIVE )
{ Assign( path, dir_only, format ); }
void Assign( const wxString &path, bool dir_only = FALSE, wxPathFormat format = wxPATH_NATIVE );
// Only native form
bool FileExists();
bool DirExists();
void AssignCwd();
void SetCwd();
void AssignTempFileName( const wxString &prefix );
void Mkdir( int perm = 0777 );
void Rmdir();
// Remove . and .. (under Unix ~ as well)
void MakeAbsolute();
// Comparison
bool SameAs( const wxFileName &filename, bool upper_on_dos = TRUE );
// Tests
bool IsCaseSensitive( wxPathFormat format = wxPATH_NATIVE );
bool IsRelative( wxPathFormat format = wxPATH_NATIVE );
bool IsAbsolute( wxPathFormat format = wxPATH_NATIVE );
bool IsWild( wxPathFormat format = wxPATH_NATIVE );
// Dir accessors
void AppendDir( const wxString &dir );
void PrependDir( const wxString &dir );
void InsertDir( int before, const wxString &dir );
void RemoveDir( int pos );
size_t GetDirCount() { return m_dirs.GetCount(); }
// Other accessors
void SetExt( const wxString &ext ) { m_ext = ext; }
wxString GetExt() const { return m_ext; }
bool HasExt() const { return !m_ext.IsEmpty(); }
void SetName( const wxString &name ) { m_name = name; }
wxString GetName() const { return m_name; }
bool HasName() const { return !m_name.IsEmpty(); }
const wxArrayString &GetDirs() const { return m_dirs; }
// Construct path only
wxString GetPath( wxPathFormat format = wxPATH_NATIVE ) const;
// Construct full path with name and ext
wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const;
static wxPathFormat GetFormat( wxPathFormat format = wxPATH_NATIVE );
private:
wxArrayString m_dirs;
wxString m_name;
wxString m_ext;
};
#endif // _WX_FFILENAME_H_

View File

@@ -40,78 +40,85 @@ class wxStaticBoxSizer;
class WXDLLEXPORT wxSizerItem: public wxObject
{
DECLARE_CLASS(wxSizerItem);
public:
// spacer
wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData);
// spacer
wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData);
// window
wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData );
// window
wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData );
// subsizer
wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData );
// subsizer
wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData );
~wxSizerItem();
~wxSizerItem();
virtual wxSize GetSize();
virtual wxSize CalcMin();
virtual void SetDimension( wxPoint pos, wxSize size );
virtual wxSize GetSize();
virtual wxSize CalcMin();
virtual void SetDimension( wxPoint pos, wxSize size );
void SetRatio( int width, int height )
// if either of dimensions is zero, ratio is assumed to be 1
// to avoid "divide by zero" errors
{ m_ratio = (width && height) ? ((float) width / (float) height) : 1; }
void SetRatio( wxSize size )
{ m_ratio = (size.x && size.y) ? ((float) size.x / (float) size.y) : 1; }
void SetRatio( float ratio ) { m_ratio = ratio; }
float GetRatio() const { return m_ratio; }
wxSize GetMinSize()
{ return m_minSize; }
bool IsWindow();
bool IsSizer();
bool IsSpacer();
void SetRatio( int width, int height )
// if either of dimensions is zero, ratio is assumed to be 1
// to avoid "divide by zero" errors
{ m_ratio = (width && height) ? ((float) width / (float) height) : 1; }
void SetRatio( wxSize size )
{ m_ratio = (size.x && size.y) ? ((float) size.x / (float) size.y) : 1; }
void SetRatio( float ratio )
{ m_ratio = ratio; }
float GetRatio() const
{ return m_ratio; }
bool IsWindow();
bool IsSizer();
bool IsSpacer();
void SetInitSize( int x, int y )
{ m_minSize.x = x; m_minSize.y = y; }
void SetOption( int option )
{ m_option = option; }
void SetFlag( int flag )
{ m_flag = flag; }
void SetBorder( int border )
{ m_border = border; }
void SetInitSize( int x, int y )
{ m_minSize.x = x; m_minSize.y = y; }
void SetOption( int option )
{ m_option = option; }
void SetFlag( int flag )
{ m_flag = flag; }
void SetBorder( int border )
{ m_border = border; }
wxWindow *GetWindow() const
{ return m_window; }
void SetWindow( wxWindow *window )
{ m_window = window; }
wxSizer *GetSizer() const
{ return m_sizer; }
void SetSizer( wxSizer *sizer )
{ m_sizer = sizer; }
int GetOption() const
{ return m_option; }
int GetFlag() const
{ return m_flag; }
int GetBorder() const
{ return m_border; }
wxObject* GetUserData()
{ return m_userData; }
wxPoint GetPosition()
{ return m_pos; }
wxWindow *GetWindow() const
{ return m_window; }
void SetWindow( wxWindow *window )
{ m_window = window; }
wxSizer *GetSizer() const
{ return m_sizer; }
void SetSizer( wxSizer *sizer )
{ m_sizer = sizer; }
int GetOption() const
{ return m_option; }
int GetFlag() const
{ return m_flag; }
int GetBorder() const
{ return m_border; }
wxObject* GetUserData()
{ return m_userData; }
wxPoint GetPosition()
{ return m_pos; }
protected:
wxWindow *m_window;
wxSizer *m_sizer;
wxSize m_size;
wxPoint m_pos;
wxSize m_minSize;
int m_option;
int m_border;
int m_flag;
// als: aspect ratio can always be calculated from m_size,
// but this would cause precision loss when the window
// is shrinked. it is safer to preserve initial value.
float m_ratio;
wxObject *m_userData;
wxWindow *m_window;
wxSizer *m_sizer;
wxSize m_size;
wxPoint m_pos;
wxSize m_minSize;
int m_option;
int m_border;
int m_flag;
// als: aspect ratio can always be calculated from m_size,
// but this would cause precision loss when the window
// is shrinked. it is safer to preserve initial value.
float m_ratio;
wxObject *m_userData;
private:
DECLARE_CLASS(wxSizerItem);
};
//---------------------------------------------------------------------------