Miscellaneous, mostly cosmetic changes. wxPen/wxFont/wxBrush altered so Set...

functions don't change shared objects.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@489 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 1998-08-09 16:46:37 +00:00
parent 5e25ba908f
commit b823f5a145
17 changed files with 205 additions and 187 deletions

View File

@ -27,6 +27,7 @@ class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
friend class WXDLLEXPORT wxBrush;
public:
wxBrushRefData(void);
wxBrushRefData(const wxBrushRefData& data);
~wxBrushRefData(void);
protected:
@ -49,7 +50,7 @@ public:
wxBrush(const wxString& col, int style);
wxBrush(const wxBitmap& stipple);
inline wxBrush(const wxBrush& brush) { Ref(brush); }
inline wxBrush(const wxBrush* brush) { /* UnRef(); */ if (brush) Ref(*brush); }
inline wxBrush(const wxBrush* brush) { if (brush) Ref(*brush); }
~wxBrush(void);
virtual void SetColour(const wxColour& col) ;
@ -72,12 +73,8 @@ public:
bool RealizeResource(void);
WXHANDLE GetResourceHandle(void) ;
bool FreeResource(bool force = FALSE);
/*
bool UseResource(void);
bool ReleaseResource(void);
*/
bool IsFree(void);
void Unshare();
};
#endif

View File

@ -104,7 +104,7 @@ class WXDLLEXPORT wxClipboard : public wxObject
void WXDLLEXPORT wxInitClipboard(void);
/* The clipboard */
extern wxClipboard* WXDLLEXPORT wxTheClipboard;
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
#endif // USE_CLIPBOARD
#endif

View File

@ -52,7 +52,7 @@ public:
}
virtual void CrossHair(long x, long y) ;
virtual void CrossHair(const wxPoint& pt)
inline void CrossHair(const wxPoint& pt)
{
CrossHair(pt.x, pt.y);
}

View File

@ -25,6 +25,7 @@ class WXDLLEXPORT wxFontRefData: public wxGDIRefData
friend class WXDLLEXPORT wxFont;
public:
wxFontRefData(void);
wxFontRefData(const wxFontRefData& data);
~wxFontRefData(void);
protected:
bool m_temporary; // If TRUE, the pointer to the actual font
@ -53,7 +54,7 @@ public:
wxFont(void);
wxFont(int PointSize, int Family, int Style, int Weight, bool underlined = FALSE, const wxString& Face = wxEmptyString);
inline wxFont(const wxFont& font) { Ref(font); }
inline wxFont(const wxFont* font) { /* UnRef(); */ if (font) Ref(*font); }
inline wxFont(const wxFont* font) { if (font) Ref(*font); }
~wxFont(void);
@ -92,6 +93,9 @@ public:
inline wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; }
inline bool operator == (const wxFont& font) { return m_refData == font.m_refData; }
inline bool operator != (const wxFont& font) { return m_refData != font.m_refData; }
protected:
void Unshare();
};
#endif

View File

@ -27,6 +27,7 @@ class WXDLLEXPORT wxPenRefData: public wxGDIRefData
friend class WXDLLEXPORT wxPen;
public:
wxPenRefData(void);
wxPenRefData(const wxPenRefData& data);
~wxPenRefData(void);
protected:
@ -53,7 +54,7 @@ public:
wxPen(const wxString& col, int width, int style);
wxPen(const wxBitmap& stipple, int width);
inline wxPen(const wxPen& pen) { Ref(pen); }
inline wxPen(const wxPen* pen) { /* UnRef(); */ if (pen) Ref(*pen); }
inline wxPen(const wxPen* pen) { if (pen) Ref(*pen); }
~wxPen(void);
inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
@ -90,6 +91,7 @@ public:
bool FreeResource(bool force = FALSE);
WXHANDLE GetResourceHandle(void) ;
bool IsFree(void);
void Unshare();
};
int wx2msPenStyle(int wx_style);

View File

@ -147,7 +147,7 @@ public:
protected:
bool m_isRich; // Are we using rich text edit to implement this?
wxString fileName;
wxString m_fileName;
DECLARE_EVENT_TABLE()
};

View File

@ -67,7 +67,7 @@ class WXDLLEXPORT wxDC;
class WXDLLEXPORT wxValidator;
#if USE_DRAG_AND_DROP
class wxDropTarget;
class WXDLLEXPORT wxDropTarget;
#endif
#if USE_WX_RESOURCES

View File

@ -14,7 +14,7 @@
#elif defined(__WXGTK__)
# include "wx/gtk/tbargtk.h"
#elif defined(__WXQT__)
# include "wx/qt/tbargtk.h"
# include "wx/qt/tbarqt.h"
#endif
#endif

View File

@ -40,7 +40,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
wxBrushRefData::wxBrushRefData(void)
{
m_style = wxSOLID;
// m_stipple = NULL ;
m_hBrush = 0;
}
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
{
m_style = data.m_style;
m_stipple = data.m_stipple;
m_colour = data.m_colour;
m_hBrush = 0;
}
@ -186,77 +193,69 @@ bool wxBrush::FreeResource(bool force)
else return FALSE;
}
/*
bool wxBrush::UseResource(void)
{
IncrementResourceUsage();
return TRUE;
}
bool wxBrush::ReleaseResource(void)
{
DecrementResourceUsage();
return TRUE;
}
*/
bool wxBrush::IsFree(void)
{
return (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0));
}
void wxBrush::Unshare()
{
// Don't change shared data
if (!m_refData)
{
m_refData = new wxBrushRefData();
}
else
{
wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
UnRef();
m_refData = ref;
}
}
void wxBrush::SetColour(const wxColour& col)
{
if ( !M_BRUSHDATA )
m_refData = new wxBrushRefData;
Unshare();
M_BRUSHDATA->m_colour = col;
if (FreeResource())
RealizeResource();
}
void wxBrush::SetColour(const wxString& col)
{
if ( !M_BRUSHDATA )
m_refData = new wxBrushRefData;
Unshare();
M_BRUSHDATA->m_colour = col;
if (FreeResource())
RealizeResource();
}
void wxBrush::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
{
if ( !M_BRUSHDATA )
m_refData = new wxBrushRefData;
Unshare();
M_BRUSHDATA->m_colour.Set(r, g, b);
if (FreeResource())
RealizeResource();
}
void wxBrush::SetStyle(int Style)
{
if ( !M_BRUSHDATA )
m_refData = new wxBrushRefData;
Unshare();
M_BRUSHDATA->m_style = Style;
if (FreeResource())
RealizeResource();
}
void wxBrush::SetStipple(const wxBitmap& Stipple)
{
if ( !M_BRUSHDATA )
m_refData = new wxBrushRefData;
Unshare();
M_BRUSHDATA->m_stipple = Stipple;
if (FreeResource())
RealizeResource();
}

View File

@ -55,6 +55,20 @@ wxFontRefData::wxFontRefData(void)
m_hFont = 0;
}
wxFontRefData::wxFontRefData(const wxFontRefData& data)
{
m_style = data.m_style;
m_temporary = FALSE;
m_pointSize = data.m_pointSize;
m_family = data.m_family;
m_fontId = data.m_fontId;
m_style = data.m_style;
m_weight = data.m_weight;
m_underlined = data.m_underlined;
m_faceName = data.m_faceName;
m_hFont = 0;
}
wxFontRefData::~wxFontRefData(void)
{
if ( m_hFont )
@ -70,27 +84,25 @@ wxFont::wxFont(void)
/* Constructor for a font. Note that the real construction is done
* in wxDC::SetFont, when information is available about scaling etc.
*/
wxFont::wxFont(int PointSize, int Family, int Style, int Weight, bool Underlined, const wxString& Face)
wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
{
Create(PointSize, Family, Style, Weight, Underlined, Face);
Create(pointSize, family, style, weight, underlined, faceName);
if ( wxTheFontList )
wxTheFontList->Append(this);
}
bool wxFont::Create(int PointSize, int Family, int Style, int Weight, bool Underlined, const wxString& Face)
bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
{
UnRef();
m_refData = new wxFontRefData;
M_FONTDATA->m_family = Family;
M_FONTDATA->m_style = Style;
M_FONTDATA->m_weight = Weight;
M_FONTDATA->m_pointSize = PointSize;
M_FONTDATA->m_underlined = Underlined;
M_FONTDATA->m_faceName = Face;
M_FONTDATA->m_temporary = FALSE;
M_FONTDATA->m_hFont = 0;
M_FONTDATA->m_family = family;
M_FONTDATA->m_style = style;
M_FONTDATA->m_weight = weight;
M_FONTDATA->m_pointSize = pointSize;
M_FONTDATA->m_underlined = underlined;
M_FONTDATA->m_faceName = faceName;
RealizeResource();
@ -216,21 +228,7 @@ bool wxFont::FreeResource(bool force)
return FALSE;
}
/*
bool wxFont::UseResource(void)
{
IncrementResourceUsage();
return TRUE;
}
bool wxFont::ReleaseResource(void)
{
DecrementResourceUsage();
return TRUE;
}
*/
WXHANDLE wxFont::GetResourceHandle(void)
WXHANDLE wxFont::GetResourceHandle()
{
if ( !M_FONTDATA )
return 0;
@ -238,51 +236,78 @@ WXHANDLE wxFont::GetResourceHandle(void)
return (WXHANDLE)M_FONTDATA->m_hFont ;
}
bool wxFont::IsFree(void)
bool wxFont::IsFree()
{
return (M_FONTDATA && (M_FONTDATA->m_hFont == 0));
}
void wxFont::Unshare()
{
// Don't change shared data
if (!m_refData)
{
m_refData = new wxFontRefData();
}
else
{
wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
UnRef();
m_refData = ref;
}
}
void wxFont::SetPointSize(int pointSize)
{
if ( !m_refData )
m_refData = new wxFontRefData;
Unshare();
M_FONTDATA->m_pointSize = pointSize;
RealizeResource();
}
void wxFont::SetFamily(int family)
{
if ( !m_refData )
m_refData = new wxFontRefData;
Unshare();
M_FONTDATA->m_family = family;
RealizeResource();
}
void wxFont::SetStyle(int style)
{
if ( !m_refData )
m_refData = new wxFontRefData;
Unshare();
M_FONTDATA->m_style = style;
RealizeResource();
}
void wxFont::SetWeight(int weight)
{
if ( !m_refData )
m_refData = new wxFontRefData;
Unshare();
M_FONTDATA->m_weight = weight;
RealizeResource();
}
void wxFont::SetFaceName(const wxString& faceName)
{
if ( !m_refData )
m_refData = new wxFontRefData;
Unshare();
M_FONTDATA->m_faceName = faceName;
RealizeResource();
}
void wxFont::SetUnderlined(bool underlined)
{
if ( !m_refData )
m_refData = new wxFontRefData;
Unshare();
M_FONTDATA->m_underlined = underlined;
RealizeResource();
}
wxString wxFont::GetFamilyString(void) const
@ -315,7 +340,6 @@ wxString wxFont::GetFamilyString(void) const
return fam;
}
/* New font system */
wxString wxFont::GetFaceName(void) const
{
wxString str("");

View File

@ -49,8 +49,8 @@
#include <string.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxWindow)
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxWindow)
IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
#endif
// ============================================================================

View File

@ -38,7 +38,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
wxPenRefData::wxPenRefData(void)
{
// m_stipple = NULL ;
m_style = wxSOLID;
m_width = 1;
m_join = wxJOIN_ROUND ;
@ -48,6 +47,18 @@ wxPenRefData::wxPenRefData(void)
m_hPen = 0;
}
wxPenRefData::wxPenRefData(const wxPenRefData& data)
{
m_style = data.m_style;
m_width = data.m_width;
m_join = data.m_join;
m_cap = data.m_cap;
m_nbDash = data.m_nbDash;
m_dash = data.m_dash;
m_colour = data.m_colour;
m_hPen = 0;
}
wxPenRefData::~wxPenRefData(void)
{
if ( m_hPen )
@ -288,123 +299,106 @@ bool wxPen::FreeResource(bool force)
else return FALSE;
}
/*
bool wxPen::UseResource(void)
{
IncrementResourceUsage();
return TRUE;
}
bool wxPen::ReleaseResource(void)
{
DecrementResourceUsage();
return TRUE;
}
*/
bool wxPen::IsFree(void)
{
return (M_PENDATA && M_PENDATA->m_hPen == 0);
}
void wxPen::Unshare()
{
// Don't change shared data
if (!m_refData)
{
m_refData = new wxPenRefData();
}
else
{
wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
UnRef();
m_refData = ref;
}
}
void wxPen::SetColour(const wxColour& col)
{
if ( !M_PENDATA )
m_refData = new wxPenRefData;
Unshare();
M_PENDATA->m_colour = col;
if (FreeResource())
RealizeResource();
}
void wxPen::SetColour(const wxString& col)
{
if ( !M_PENDATA )
m_refData = new wxPenRefData;
Unshare();
M_PENDATA->m_colour = col;
if (FreeResource())
RealizeResource();
}
void wxPen::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
{
if ( !M_PENDATA )
m_refData = new wxPenRefData;
Unshare();
M_PENDATA->m_colour.Set(r, g, b);
if (FreeResource())
RealizeResource();
}
void wxPen::SetWidth(int Width)
{
if ( !M_PENDATA )
m_refData = new wxPenRefData;
Unshare();
M_PENDATA->m_width = Width;
if (FreeResource())
RealizeResource();
}
void wxPen::SetStyle(int Style)
{
if ( !M_PENDATA )
m_refData = new wxPenRefData;
Unshare();
M_PENDATA->m_style = Style;
if (FreeResource())
RealizeResource();
}
void wxPen::SetStipple(const wxBitmap& Stipple)
{
if ( !M_PENDATA )
m_refData = new wxPenRefData;
Unshare();
M_PENDATA->m_stipple = Stipple;
M_PENDATA->m_style = wxSTIPPLE;
if (FreeResource())
RealizeResource();
}
void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
{
if ( !M_PENDATA )
m_refData = new wxPenRefData;
Unshare();
M_PENDATA->m_nbDash = nb_dashes;
M_PENDATA->m_dash = (wxDash *)Dash;
if (FreeResource())
RealizeResource();
}
void wxPen::SetJoin(int Join)
{
if ( !M_PENDATA )
m_refData = new wxPenRefData;
Unshare();
M_PENDATA->m_join = Join;
if (FreeResource())
RealizeResource();
}
void wxPen::SetCap(int Cap)
{
if ( !M_PENDATA )
m_refData = new wxPenRefData;
Unshare();
M_PENDATA->m_cap = Cap;
if (FreeResource())
RealizeResource();
}

View File

@ -36,6 +36,7 @@ class WXDLLEXPORT wxRegionRefData : public wxGDIRefData {
public:
wxRegionRefData(void)
{
m_region = 0;
}
wxRegionRefData(const wxRegionRefData& data)

View File

@ -72,7 +72,7 @@ wxTextCtrl::wxTextCtrl(void)
:streambuf()
#endif
{
fileName = "";
m_fileName = "";
m_isRich = FALSE;
}
@ -83,7 +83,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
fileName = "";
m_fileName = "";
SetName(name);
SetValidator(validator);
if (parent) parent->AddChild(this);
@ -504,7 +504,7 @@ bool wxTextCtrl::LoadFile(const wxString& file)
if (!FileExists(WXSTRINGCAST file))
return FALSE;
fileName = file;
m_fileName = file;
Clear();
@ -553,14 +553,14 @@ bool wxTextCtrl::LoadFile(const wxString& file)
// Returns TRUE if succeeds.
bool wxTextCtrl::SaveFile(const wxString& file)
{
wxString theFile;
if (file == "")
theFile = fileName;
if (file == "")
wxString theFile(file);
if (theFile == "")
theFile = m_fileName;
if (theFile == "")
return FALSE;
fileName = theFile;
m_fileName = theFile;
ofstream output(WXSTRINGCAST file);
ofstream output((char*) (const char*) theFile);
if (output.bad())
return FALSE;
@ -848,33 +848,33 @@ wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
wxTextCtrl& wxTextCtrl::operator<<(float f)
{
static char buf[100];
sprintf(buf, "%.2f", f);
WriteText(buf);
wxString str;
str.Printf("%.2f", f);
WriteText(str);
return *this;
}
wxTextCtrl& wxTextCtrl::operator<<(double d)
{
static char buf[100];
sprintf(buf, "%.2f", d);
WriteText(buf);
wxString str;
str.Printf("%.2f", d);
WriteText(str);
return *this;
}
wxTextCtrl& wxTextCtrl::operator<<(int i)
{
static char buf[100];
sprintf(buf, "%i", i);
WriteText(buf);
wxString str;
str.Printf("%d", i);
WriteText(str);
return *this;
}
wxTextCtrl& wxTextCtrl::operator<<(long i)
{
static char buf[100];
sprintf(buf, "%ld", i);
WriteText(buf);
wxString str;
str.Printf("%ld", i);
WriteText(str);
return *this;
}
@ -888,7 +888,6 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
return *this;
}
WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{

View File

@ -1,13 +1,13 @@
/*
* File: TreeCtrl.cpp
* Purpose: Tree control
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright:
*/
/* static const char sccsid[] = "%W% %G%"; */
/////////////////////////////////////////////////////////////////////////////
// Name: treectrl.cpp
// Purpose: wxTreeCtrl
// Author: Julian Smart
// Modified by:
// Created: 1997
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "treectrl.h"

View File

@ -4362,7 +4362,6 @@ void wxWindow::SetupColours(void)
void wxWindow::OnIdle(wxIdleEvent& event)
{
#if 0
// Check if we need to send a LEAVE event
if (m_mouseInWindow)
{
@ -4376,7 +4375,6 @@ void wxWindow::OnIdle(wxIdleEvent& event)
}
}
UpdateWindowUI();
#endif
}
// Raise the window to the top of the Z order