Minor Motif changes, made scrollsub sample work somehow.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-10-27 19:01:58 +00:00
parent bd8ed12c5a
commit 76db86e7e1
8 changed files with 138 additions and 166 deletions

View File

@@ -1,5 +1,5 @@
# #
# This file was automatically generated by tmake at 20:51, 1999/10/26 # This file was automatically generated by tmake at 18:44, 1999/10/27
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
# #
@@ -1128,7 +1128,6 @@ MOTIF_COMMONOBJS = \
mstream.o \ mstream.o \
object.o \ object.o \
objstrm.o \ objstrm.o \
odbc.o \
paper.o \ paper.o \
prntbase.o \ prntbase.o \
process.o \ process.o \
@@ -1224,7 +1223,6 @@ MOTIF_COMMONDEPS = \
mstream.d \ mstream.d \
object.d \ object.d \
objstrm.d \ objstrm.d \
odbc.d \
paper.d \ paper.d \
prntbase.d \ prntbase.d \
process.d \ process.d \

View File

@@ -149,7 +149,7 @@ module.cpp C B
mstream.cpp C mstream.cpp C
object.cpp C B object.cpp C B
objstrm.cpp C objstrm.cpp C
odbc.cpp C R odbc.cpp C R,X
paper.cpp C paper.cpp C
prntbase.cpp C prntbase.cpp C
process.cpp C 32,B process.cpp C 32,B

View File

@@ -1,11 +1,11 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: motif/dataform.h // Name: motif/dataform.h
// Purpose: declaration of the wxDataFormat class // Purpose: declaration of the wxDataFormat class
// Author: Vadim Zeitlin // Author: Robert Roebling
// Modified by: // Modified by:
// Created: 19.10.99 (extracted from motif/dataobj.h) // Created: 19.10.99 (extracted from motif/dataobj.h)
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1999 Robert Roebling
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@@ -15,42 +15,52 @@
class wxDataFormat class wxDataFormat
{ {
public: public:
typedef unsigned long /* Atom */ NativeFormat; // the clipboard formats under Xt are Atoms
typedef Atom NativeFormat;
wxDataFormat(); wxDataFormat();
wxDataFormat( wxDataFormatId type ); wxDataFormat( wxDataFormatId type );
wxDataFormat( const wxString &id ); wxDataFormat( const wxString &id );
wxDataFormat( const wxChar *id ); wxDataFormat( const wxChar *id );
wxDataFormat( const wxDataFormat &format ); wxDataFormat( NativeFormat format );
wxDataFormat( const Atom atom );
void SetType( wxDataFormatId type ); wxDataFormat& operator=(NativeFormat format)
NativeFormat GetType() const { return m_type; } { SetId(format); return *this; }
/* the string Id identifies the format of clipboard or DnD data. a word // comparison (must have both versions)
* processor would e.g. add a wxTextDataObject and a wxPrivateDataObject bool operator==(NativeFormat format) const
* to the clipboard - the latter with the Id "application/wxword", an { return m_format == (NativeFormat)format; }
* image manipulation program would put a wxBitmapDataObject and a bool operator!=(NativeFormat format) const
* wxPrivateDataObject to the clipboard - the latter with "image/png". */ { return m_format != (NativeFormat)format; }
bool operator==(wxDataFormatId format) const
{ return m_type == (wxDataFormatId)format; }
bool operator!=(wxDataFormatId format) const
{ return m_type != (wxDataFormatId)format; }
wxString GetId() const { return m_id; } // explicit and implicit conversions to NativeFormat which is one of
// standard data types (implicit conversion is useful for preserving the
// compatibility with old code)
NativeFormat GetFormatId() const { return m_format; }
operator NativeFormat() const { return m_format; }
void SetId( NativeFormat format );
// string ids are used for custom types - this SetId() must be used for
// application-specific formats
wxString GetId() const;
void SetId( const wxChar *id ); void SetId( const wxChar *id );
Atom GetAtom(); // implementation
void SetAtom(Atom atom) { m_hasAtom = TRUE; m_atom = atom; } wxDataFormatId GetType() const;
// implicit conversion to wxDataFormatId
operator NativeFormat() const { return m_type; }
bool operator==(NativeFormat type) const { return m_type == type; }
bool operator!=(NativeFormat type) const { return m_type != type; }
private: private:
NativeFormat m_type; wxDataFormatId m_type;
wxString m_id; NativeFormat m_format;
bool m_hasAtom;
Atom m_atom; void PrepareFormats();
void SetType( wxDataFormatId type );
}; };
#endif // _WX_MOTIF_DATAFORM_H #endif // _WX_MOTIF_DATAFORM_H

View File

@@ -155,21 +155,10 @@ public:
return (wxCoord)((double)(y) * m_scaleY - 0.5); return (wxCoord)((double)(y) * m_scaleY - 0.5);
} }
void SetInternalDeviceOrigin( wxCoord x, wxCoord y );
void GetInternalDeviceOrigin( wxCoord *x, wxCoord *y );
public: public:
// not sure what for, but what is a mm on a screen you don't know the size of? // not sure what for, but what is a mm on a screen you don't know the size of?
double m_mm_to_pix_x,m_mm_to_pix_y; double m_mm_to_pix_x,m_mm_to_pix_y;
// If un-scrolled is non-zero or d.o. changes with scrolling. Set using
// SetInternalDeviceOrigin().
wxCoord m_internalDeviceOriginX,m_internalDeviceOriginY;
// To be set by external classes such as wxScrolledWindow using
// SetDeviceOrigin()
wxCoord m_externalDeviceOriginX,m_externalDeviceOriginY;
// recompute scale? // recompute scale?
bool m_needComputeScaleX, m_needComputeScaleY; bool m_needComputeScaleX, m_needComputeScaleY;

View File

@@ -171,6 +171,8 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
wxPaintDC dc( this ); wxPaintDC dc( this );
m_owner->PrepareDC( dc ); m_owner->PrepareDC( dc );
dc.SetPen( *wxBLACK_PEN );
dc.DrawText( "Some text", 140, 140 ); dc.DrawText( "Some text", 140, 140 );
dc.DrawRectangle( 100, 160, 200, 200 ); dc.DrawRectangle( 100, 160, 200, 200 );

View File

@@ -26,6 +26,8 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
Atom g_textAtom = 0; Atom g_textAtom = 0;
Atom g_pngAtom = 0;
Atom g_fileAtom = 0;
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// wxDataFormat // wxDataFormat
@@ -33,134 +35,108 @@ Atom g_textAtom = 0;
wxDataFormat::wxDataFormat() wxDataFormat::wxDataFormat()
{ {
// do *not* call PrepareFormats() from here for 2 reasons:
//
// 1. we will have time to do it later because some other Set function
// must be called before we really need them
//
// 2. doing so prevents us from declaring global wxDataFormats because
// calling PrepareFormats (and thus gdk_atom_intern) before GDK is
// initialised will result in a crash
m_type = wxDF_INVALID; m_type = wxDF_INVALID;
m_hasAtom = FALSE; m_format = (Atom) 0;
m_atom = (Atom) 0;
} }
wxDataFormat::wxDataFormat( wxDataFormatId type ) wxDataFormat::wxDataFormat( wxDataFormatId type )
{ {
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE ); PrepareFormats();
SetType( type ); SetType( type );
} }
wxDataFormat::wxDataFormat( const wxChar *id ) wxDataFormat::wxDataFormat( const wxChar *id )
{ {
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE ); PrepareFormats();
SetId( id ); SetId( id );
} }
wxDataFormat::wxDataFormat( const wxString &id ) wxDataFormat::wxDataFormat( const wxString &id )
{ {
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE ); PrepareFormats();
SetId( id ); SetId( id );
} }
wxDataFormat::wxDataFormat( const wxDataFormat &format ) wxDataFormat::wxDataFormat( NativeFormat format )
{ {
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE ); PrepareFormats();
m_type = format.GetType(); SetId( format );
m_id = format.GetId();
m_hasAtom = TRUE;
m_atom = ((wxDataFormat &)format).GetAtom(); // const_cast
}
wxDataFormat::wxDataFormat( const Atom atom )
{
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
m_hasAtom = TRUE;
m_atom = atom;
if (m_atom == g_textAtom)
{
m_type = wxDF_TEXT;
} else
/*
if (m_atom == GDK_TARGET_BITMAP)
{
m_type = wxDF_BITMAP;
} else
*/
{
m_type = wxDF_PRIVATE;
m_id = XGetAtomName( (Display*) wxGetDisplay(), m_atom );
if (m_id == wxT("file:ALL"))
{
m_type = wxDF_FILENAME;
}
}
} }
void wxDataFormat::SetType( wxDataFormatId type ) void wxDataFormat::SetType( wxDataFormatId type )
{ {
PrepareFormats();
m_type = type; m_type = type;
if (m_type == wxDF_TEXT) if (m_type == wxDF_TEXT)
{ m_format = g_textAtom;
m_id = wxT("STRING");
}
else else
if (m_type == wxDF_BITMAP) if (m_type == wxDF_BITMAP)
{ m_format = g_pngAtom;
m_id = wxT("BITMAP");
}
else else
if (m_type == wxDF_FILENAME) if (m_type == wxDF_FILENAME)
{ m_format = g_fileAtom;
m_id = wxT("file:ALL");
}
else else
{ {
wxFAIL_MSG( wxT("invalid dataformat") ); wxFAIL_MSG( wxT("invalid dataformat") );
} }
}
m_hasAtom = FALSE; wxDataFormatId wxDataFormat::GetType() const
{
return m_type;
}
wxString wxDataFormat::GetId() const
{
char *t = XGetAtomName ((Display*) wxGetDisplay(), m_format);
wxString ret( t ); // this will convert from ascii to Unicode
if (t)
XFree( t );
return ret;
}
void wxDataFormat::SetId( NativeFormat format )
{
PrepareFormats();
m_format = format;
if (m_format == g_textAtom)
m_type = wxDF_TEXT;
else
if (m_format == g_pngAtom)
m_type = wxDF_BITMAP;
else
if (m_format == g_fileAtom)
m_type = wxDF_FILENAME;
else
m_type = wxDF_PRIVATE;
} }
void wxDataFormat::SetId( const wxChar *id ) void wxDataFormat::SetId( const wxChar *id )
{ {
PrepareFormats();
m_type = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
m_id = id; wxString tmp( id );
m_hasAtom = FALSE; m_format = XInternAtom( (Display*) wxGetDisplay(), wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
} }
Atom wxDataFormat::GetAtom() void wxDataFormat::PrepareFormats()
{ {
if (!m_hasAtom) if (!g_textAtom)
{ g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
m_hasAtom = TRUE; if (!g_pngAtom)
g_pngAtom = XInternAtom( (Display*) wxGetDisplay(), "image/png", FALSE );
if (m_type == wxDF_TEXT) if (!g_fileAtom)
{ g_fileAtom = XInternAtom( (Display*) wxGetDisplay(), "file:ALL", FALSE );
m_atom = g_textAtom;
}
else
/*
if (m_type == wxDF_BITMAP)
{
m_atom = GDK_TARGET_BITMAP;
}
else
*/
if (m_type == wxDF_PRIVATE)
{
m_atom = XInternAtom( (Display*) wxGetDisplay(), wxMBSTRINGCAST m_id.mbc_str(), FALSE );
}
else
if (m_type == wxDF_FILENAME)
{
m_atom = XInternAtom( (Display*) wxGetDisplay(), "file:ALL", FALSE );
}
else
{
m_hasAtom = FALSE;
m_atom = (Atom) 0;
}
}
return m_atom;
} }
#if 0 #if 0

View File

@@ -46,11 +46,6 @@ wxDC::wxDC()
m_backgroundMode = wxTRANSPARENT; m_backgroundMode = wxTRANSPARENT;
m_isInteractive = FALSE; m_isInteractive = FALSE;
m_internalDeviceOriginX = 0;
m_internalDeviceOriginY = 0;
m_externalDeviceOriginX = 0;
m_externalDeviceOriginY = 0;
} }
void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y)
@@ -178,24 +173,12 @@ void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
{ {
m_externalDeviceOriginX = x; // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
m_externalDeviceOriginY = y; m_deviceOriginX = x;
m_deviceOriginY = y;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
} }
void wxDC::SetInternalDeviceOrigin( wxCoord x, wxCoord y )
{
m_internalDeviceOriginX = x;
m_internalDeviceOriginY = y;
ComputeScaleAndOrigin();
}
void wxDC::GetInternalDeviceOrigin( wxCoord *x, wxCoord *y )
{
if (x) *x = m_internalDeviceOriginX;
if (y) *y = m_internalDeviceOriginY;
}
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{ {
m_signX = xLeftRight ? 1 : -1; m_signX = xLeftRight ? 1 : -1;
@@ -245,25 +228,7 @@ wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
void wxDC::ComputeScaleAndOrigin() void wxDC::ComputeScaleAndOrigin()
{ {
// CMB: copy scale to see if it changes
double origScaleX = m_scaleX;
double origScaleY = m_scaleY;
m_scaleX = m_logicalScaleX * m_userScaleX; m_scaleX = m_logicalScaleX * m_userScaleX;
m_scaleY = m_logicalScaleY * m_userScaleY; m_scaleY = m_logicalScaleY * m_userScaleY;
m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
// CMB: if scale has changed call SetPen to recalulate the line width
if (m_scaleX != origScaleX || m_scaleY != origScaleY)
{
// this is a bit artificial, but we need to force wxDC to think
// the pen has changed
wxPen* pen = & GetPen();
wxPen tempPen;
m_pen = tempPen;
SetPen(* pen);
}
} }

View File

@@ -245,13 +245,33 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
XtAppAddActions ((XtAppContext) wxTheApp->GetAppContext(), actions, 1); XtAppAddActions ((XtAppContext) wxTheApp->GetAppContext(), actions, 1);
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
if (style & wxBORDER)
if (style & wxSIMPLE_BORDER)
{ {
m_borderWidget = (WXWidget)XtVaCreateManagedWidget m_borderWidget = (WXWidget)XtVaCreateManagedWidget
( (
"canvasBorder", "canvasBorder",
xmFrameWidgetClass, parentWidget, xmFrameWidgetClass, parentWidget,
XmNshadowType, XmSHADOW_IN, XmNshadowType, XmSHADOW_IN,
XmNshadowThickness, 1,
NULL
);
} else if (style & wxSUNKEN_BORDER)
{
m_borderWidget = (WXWidget)XtVaCreateManagedWidget
(
"canvasBorder",
xmFrameWidgetClass, parentWidget,
XmNshadowType, XmSHADOW_IN,
NULL
);
} else if (style & wxRAISED_BORDER)
{
m_borderWidget = (WXWidget)XtVaCreateManagedWidget
(
"canvasBorder",
xmFrameWidgetClass, parentWidget,
XmNshadowType, XmSHADOW_OUT,
NULL NULL
); );
} }
@@ -880,6 +900,18 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
GetClientSize(& w, & h); GetClientSize(& w, & h);
} }
wxNode *cnode = m_children.First();
while (cnode)
{
wxWindow *child = (wxWindow*) cnode->Data();
int sx = 0;
int sy = 0;
child->GetSize( &sx, &sy );
wxPoint pos( child->GetPosition() );
child->SetSize( pos.x + dx, pos.y + dy, sx, sy, wxSIZE_ALLOW_MINUS_ONE );
cnode = cnode->Next();
}
int x1 = (dx >= 0) ? x : x - dx; int x1 = (dx >= 0) ? x : x - dx;
int y1 = (dy >= 0) ? y : y - dy; int y1 = (dy >= 0) ? y : y - dy;
int w1 = w - abs(dx); int w1 = w - abs(dx);