From 69c4481222795d89f470020b63ec788bb717c0b3 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Thu, 20 Feb 2003 18:20:47 +0000 Subject: [PATCH] Use some wxX11 files (currently pen.cpp and brush.cpp) in wxMotif. Add src/x11 to VPATH in configure, and add a new flag to filelist.txt indicating a file used in wxMotif but not in wxMotif directory. Modifed VMS makefiles, too (should be checked by someone with VMS, though). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19265 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure | 2 +- configure.in | 2 +- descrip.mms | 2 + distrib/msw/tmake/filelist.t | 24 ++++ distrib/msw/tmake/filelist.txt | 19 ++- distrib/msw/tmake/lib/wxFileInfo.pm | 90 ++++++++++++++ distrib/msw/tmake/lib/wxFileList.pm | 148 ++++++++++++++++++++++ distrib/msw/tmake/motif.t | 85 +++++-------- include/wx/brush.h | 2 +- include/wx/motif/brush.h | 80 ------------ include/wx/motif/dcclient.h | 2 +- include/wx/motif/pen.h | 102 ---------------- include/wx/pen.h | 2 +- include/wx/x11/brush.h | 4 +- include/wx/x11/pen.h | 10 +- src/motif/brush.cpp | 123 ------------------- src/motif/dcclient.cpp | 22 ++-- src/motif/descrip.mms | 6 - src/motif/files.lst | 16 +-- src/motif/pen.cpp | 182 ---------------------------- src/x11/brush.cpp | 1 + src/x11/descrip.mms | 41 +++++++ src/x11/pen.cpp | 18 +++ 23 files changed, 399 insertions(+), 584 deletions(-) create mode 100644 distrib/msw/tmake/lib/wxFileInfo.pm create mode 100644 distrib/msw/tmake/lib/wxFileList.pm delete mode 100644 include/wx/motif/brush.h delete mode 100644 include/wx/motif/pen.h delete mode 100644 src/motif/brush.cpp delete mode 100644 src/motif/pen.cpp create mode 100644 src/x11/descrip.mms diff --git a/configure b/configure index 48586c3a89..7bc346c7a9 100755 --- a/configure +++ b/configure @@ -15615,7 +15615,7 @@ rm -f conftest* fi GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXm$xpm_link${libp_link} -lXmu -lXext -lXt${libsm_ice_link} -lX11" - TOOLKIT_VPATH="\${top_srcdir}/src/motif${PATH_IFS}\${top_srcdir}/src/motif/xmcombo" + TOOLKIT_VPATH="\${top_srcdir}/src/motif${PATH_IFS}\${top_srcdir}/src/motif/xmcombo${PATH_IFS}\${top_srcdir}/src/x11" TOOLKIT=MOTIF GUIDIST=MOTIF_DIST fi diff --git a/configure.in b/configure.in index a67a7fa24d..c94f9ad4e1 100644 --- a/configure.in +++ b/configure.in @@ -2541,7 +2541,7 @@ equivalent variable and GTK+ is version 1.2.3 or above. fi GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXm$xpm_link${libp_link} -lXmu -lXext -lXt${libsm_ice_link} -lX11" - TOOLKIT_VPATH="\${top_srcdir}/src/motif${PATH_IFS}\${top_srcdir}/src/motif/xmcombo" + TOOLKIT_VPATH="\${top_srcdir}/src/motif${PATH_IFS}\${top_srcdir}/src/motif/xmcombo${PATH_IFS}\${top_srcdir}/src/x11" TOOLKIT=MOTIF GUIDIST=MOTIF_DIST fi diff --git a/descrip.mms b/descrip.mms index a8c05ba901..fb6d12e1c3 100644 --- a/descrip.mms +++ b/descrip.mms @@ -141,6 +141,8 @@ motif : [.include.wx]setup.h $(MMS)$(MMSQUALIFIERS)/macro=(__WXMOTIF__=1) set default [-.motif] $(MMS)$(MMSQUALIFIERS)/macro=(__WXMOTIF__=1) + set default [-.x11] + $(MMS)$(MMSQUALIFIERS)/macro=(__WXMOTIF__=1) set default [--.demos.bombs] $(MMS)$(MMSQUALIFIERS)/macro=(__WXMOTIF__=1) set default [--.samples.calendar] diff --git a/distrib/msw/tmake/filelist.t b/distrib/msw/tmake/filelist.t index 22f5f60a9d..b8897313fe 100644 --- a/distrib/msw/tmake/filelist.t +++ b/distrib/msw/tmake/filelist.t @@ -7,8 +7,28 @@ #! Version: $Id$ #!############################################################################# #${ + use lib './lib'; + use wxFileInfo; + open(FILELIST, "filelist.txt") or die "Can't open filelist file: $!\n"; + #! maps file types to array names, for example an entry of the form + #! FooH => 'wxXYZ' means that all files with type "FooH" will be + #! added to an array named @wxXYZ + my %type_2_array = ( + Common => "wxCommon", + Generic => "wxGeneric", + GenericH => "wxGenericInclude", + HTML => "wxHtml", + HtmlH => "wxHtmlInclude", + Motif => "wxMotif", + MotifH => "wxMotifInclude", + ProtoH => "wxProtocolInclude", + Unix => "wxUnix", + UnixH => "wxUnixInclude", + WXH => "wxWxInclude", + ); + line: while ( defined($_ = ) ) { chomp; @@ -36,6 +56,10 @@ print STDERR "File $filename: type '$filetype', flags '$fileflags'\n"; } + #! save all information in @wxALL + my $fileinfo = new wxFileInfo( $filename, $filetype, $fileflags ); + push @wxALL, $fileinfo; + #! this is a bit stupid but all templates are written using the old #! single letter flags which became so unreadable that I decided to #! replace them with more readable strings, but it was easier to do diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index 947fb505ae..b93102be53 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -64,6 +64,7 @@ # NotUniv Not required for the wxUniversal # LowLevel Low level GUI toolkit file, used by wxUniversal as well # Theme implements a wxUniv theme +# Motif used by Motif, even if in another port's directory ############################################################################### # File name Type Flags @@ -235,7 +236,6 @@ textbuf.cpp Common Base textcmn.cpp Common textfile.cpp Common Base timercmn.cpp Common Base -toplvcmn.cpp Common tokenzr.cpp Common Base treebase.cpp Common txtstrm.cpp Common Base @@ -567,7 +567,7 @@ accel.cpp Motif app.cpp Motif bitmap.cpp Motif bmpbuttn.cpp Motif -brush.cpp Motif +# brush.cpp Motif button.cpp Motif checkbox.cpp Motif checklst.cpp Motif @@ -602,7 +602,7 @@ menuitem.cpp Motif minifram.cpp Motif msgdlg.cpp Motif palette.cpp Motif -pen.cpp Motif +# pen.cpp Motif radiobox.cpp Motif radiobut.cpp Motif region.cpp Motif @@ -624,7 +624,7 @@ gsockx11.c X11 Socket nanox.c X11 app.cpp X11 bitmap.cpp X11 -brush.cpp X11 +brush.cpp X11 Motif clipbrd.cpp X11 colour.cpp X11 cursor.cpp X11 @@ -644,7 +644,7 @@ joystick.cpp X11 main.cpp X11 minifram.cpp X11 palette.cpp X11 -pen.cpp X11 +pen.cpp X11 Motif popupwin.cpp X11 region.cpp X11 reparent.cpp X11 @@ -861,7 +861,6 @@ iconbndl.h WXH image.h WXH imaggif.h WXH imagiff.h WXH -imagxpm.h WXH imagbmp.h WXH imagpng.h WXH imagpcx.h WXH @@ -1148,7 +1147,7 @@ accel.h MotifH app.h MotifH bitmap.h MotifH bmpbuttn.h MotifH -brush.h MotifH +# brush.h MotifH button.h MotifH checkbox.h MotifH checklst.h MotifH @@ -1185,7 +1184,7 @@ metafile.h MotifH minifram.h MotifH msgdlg.h MotifH palette.h MotifH -pen.h MotifH +# pen.h MotifH print.h MotifH printdlg.h MotifH private.h MotifH @@ -1208,7 +1207,7 @@ window.h MotifH app.h X11H bitmap.h X11H -brush.h X11H +brush.h X11H Motif clipbrd.h X11H colour.h X11H cursor.h X11H @@ -1228,7 +1227,7 @@ icon.h X11H joystick.h X11H minifram.h X11H palette.h X11H -pen.h X11H +pen.h X11H Motif print.h X11H private.h X11H region.h X11H diff --git a/distrib/msw/tmake/lib/wxFileInfo.pm b/distrib/msw/tmake/lib/wxFileInfo.pm new file mode 100644 index 0000000000..4bcf88ae14 --- /dev/null +++ b/distrib/msw/tmake/lib/wxFileInfo.pm @@ -0,0 +1,90 @@ +package wxFileInfo; + +=head1 NAME + +wxFileInfo + +=head1 SYNOPSIS + + use wxFileInfo; + + my $info = new wxFileInfo( $filename, $filetype, $fileflags ); + my $info2 = new wxFileInfo( 'mdig.cpp', 'Generic', + 'NotWin32,NotGTK,NotMac' ); + + $f = $info->filename; + $t = $info->filetype; + $flags = $info->fileflags; + $bool = $info->is_header; + $bool = $info->is_source; + $file = $info->object_file; + $file = $info->source_file; + $bool = $info->has_flag( 'NotX' ); + +=cut + +use strict; + +sub new { + my $ref = shift; + my $class = ref( $ref ) || $ref; + my $self = bless {}, $class; + + my( $filename, $filetype, $fileflags ) = @_; + $fileflags =~ tr/ \t//d; + + @{$self}{'filename', 'filetype'} = ( $filename, $filetype ); + $self->{fileflags} = [ split /,/, $fileflags ]; + + return $self; +} + +sub filename { $_[0]->{filename} } +sub filetype { $_[0]->{filetype} } +sub fileflags { $_[0]->{fileflags} } +sub is_header { scalar( $_[0]->{filename} =~ m/\.h$/i ) } +sub is_source { !scalar( $_[0]->{filename} =~ m/\.h$/i ) } + +sub object_file { + my $self = shift; + my $obj = $self->{filename}; + + $obj =~ s/cp?p?$/o/i; # PORTABILITY + + return $obj; +} + +my %src_prefix = ( Common => 'common/', + Generic => 'generic/', + MSW => 'msw/', + Mac => 'mac/', + Motif => 'motif/', + GTK => 'gtk/', + Univ => 'univ/', + X11 => 'x11/', + HTML => 'html/', + Unix => 'unix/', + WXH => '', + ProtoH => 'protocol/', + HtmlH => 'html/', + MotifH => 'motif/', + X11H => 'x11/', + GenericH => 'generic/', + UnixH => 'unix/', + ); + +sub source_file { + my $self = shift; + my $type = $self->filetype; + + die "Unknown file type '$type'" unless exists $src_prefix{$type}; + return $src_prefix{$type} . $self->filename; # PORTABILITY +} + +sub has_flag { + my( $self, $flag ) = @_; + $flag = lc( $flag ); + return grep { lc( $_ ) eq $flag } @{$self->{fileflags}}; +} + +1; diff --git a/distrib/msw/tmake/lib/wxFileList.pm b/distrib/msw/tmake/lib/wxFileList.pm new file mode 100644 index 0000000000..94fb7cc74d --- /dev/null +++ b/distrib/msw/tmake/lib/wxFileList.pm @@ -0,0 +1,148 @@ +package wxFileList; + +=head1 NAME + +wxFileList + +=head1 SYNOPSIS + + use wxFileList qw(grep_filetype grep_fileflag grep_not_fileflag + grep_source grep_header sort_files make_arrays); + + # shorthand for + # @wxGeneric = sort_files grep_filetype 'Generic', @wxALL; + # @wxGenericInclude = sort_files grep_filetype 'GenericH', @wxALL; + make_arrays( 'wxGeneric', 'wxGenericInclude' ); + +=head1 METHODS + +=cut + +use strict; + +# alias wxALL from main +use vars qw(@wxALL); +*wxALL = \@main::wxALL; + +use base 'Exporter'; +use vars qw(@EXPORT_OK %EXPORT_TAGS); + +@EXPORT_OK = qw(grep_filetype grep_fileflag grep_not_fileflag + grep_source grep_header sort_files make_arrays); + +%EXPORT_TAGS = ( 'default' => [ qw(grep_filetype grep_fileflag grep_source + grep_not_fileflag grep_header + sort_files) ], + ); + +my %type_2_array = ( + Common => "wxCommon", + Generic => "wxGeneric", + GenericH => "wxGenericInclude", + HTML => "wxHtml", + HtmlH => "wxHtmlInclude", + Motif => "wxMotif", + MotifH => "wxMotifInclude", + ProtoH => "wxProtocolInclude", + Unix => "wxUnix", + UnixH => "wxUnixInclude", + WXH => "wxWxInclude", + ); +# inverse mapping +my %array_2_type = map { ( $type_2_array{$_}, $_ ) } keys %type_2_array; + +sub _sort { + sort { $a->filename cmp $b->filename } @_; +} + +=head2 grep_filetype + + my @files = grep_filetype 'Type', @all_files; + +Returns files in C<@all_files> whose file type matches C<'Type'>. + +=cut + +sub grep_filetype { + my $filetype = lc( shift ); + + return _sort grep { $filetype eq lc( $_->filetype ) } @_; +} + +=head2 grep_fileflag + +=head2 grep_not_fileflag + + my @files = grep_fileflag 'NotX', @all_files; + my @files2 = grep_not_fileflag 'NotX', @all_files; + +Return files in C<@all_files> [not] having the given file flag. + +=cut + +sub grep_fileflag { + my $fileflag = shift; + + return _sort grep { $_->has_flag( $fileflag ) } @_; +} + +sub grep_not_fileflag { + my $fileflag = shift; + + return _sort grep { !( $_->has_flag( $fileflag ) ) } @_; +} + +=head2 grep_header + +=head2 grep_source + + my @headers = grep_header @all_files; + my @sources = grep_source @all_files; + +Return header/source files contained in C<@all_files>. + +=cut + +sub grep_header { + return _sort grep { $_->is_header } @_; +} + +sub grep_source { + return _sort grep { $_->is_source } @_; +} + +=head2 sort_files + + my @sorted_files = sort_files @files; + +Sorts files by file name. + +=cut + +sub sort_files { + return sort { $a->{filename} cmp $b->{filename} } @_; +} + +=head2 make_arrays + +See SYNOPSIS. + +=cut + +sub make_arrays { + my( $package ) = caller; + + foreach my $array ( @_ ) { + my $type = $array_2_type{$array}; + + unless( $type ) { + require Carp; + croak( "Invalid array name '$array'" ); + } + + no strict 'refs'; + @{"${package}::${array}"} = sort_files grep_filetype $type, @wxALL; + } +} + +1; diff --git a/distrib/msw/tmake/motif.t b/distrib/msw/tmake/motif.t index 9cc31f2883..33924f081b 100644 --- a/distrib/msw/tmake/motif.t +++ b/distrib/msw/tmake/motif.t @@ -1,83 +1,64 @@ -#!################################################################################ +#!############################################################################# #! File: motif.t #! Purpose: tmake template file from which src/motif/files.lst containing the #! list of files for wxMotif library is generated by tmake #! Author: Vadim Zeitlin #! Created: 28.01.00 #! Version: $Id$ -#!################################################################################ +#!############################################################################# #${ + use lib './lib'; + use wxFileList qw(:default make_arrays); + #! include the code which parses filelist.txt file and initializes #! %wxCommon, %wxGeneric, %wxHtml, %wxUNIX, %wxMOTIF, %wxMOTIF and #! %wxOS2PM hashes. IncludeTemplate("filelist.t"); + make_arrays( 'wxGeneric', 'wxCommon', 'wxMotif', + 'wxUnix', 'wxHtml', + 'wxWxInclude', 'wxMotifInclude', 'wxGenericInclude', + 'wxUnixInclude', 'wxHtmlInclude', 'wxProtocolInclude' ); + #! find all our sources $project{"GUIOBJS"} .= "xmcombo.o "; - foreach $file (sort keys %wxGeneric) { - next if $wxGeneric{$file} =~ /\bNotX\b/; - - ($fileobj = $file) =~ s/cp?p?$/\o/; - - $project{"MOTIF_SOURCES"} .= "generic/" . $file . " "; - $project{"GENERICOBJS"} .= $fileobj . " "; - } - - foreach $file (sort keys %wxCommon) { - next if $wxCommon{$file} =~ /\bNotX\b/; - - ($fileobj = $file) =~ s/cp?p?$/\o/; - - $project{"MOTIF_SOURCES"} .= "common/" . $file . " "; - $project{"COMMONOBJS"} .= $fileobj . " "; - } - - foreach $file (sort keys %wxMOTIF) { - ($fileobj = $file) =~ s/cp?p?$/\o/; + my @generic = grep_not_fileflag 'NotX', @wxGeneric; + my @common = grep_not_fileflag 'NotX', @wxCommon; + my @motif = ( @wxMotif, + grep_source( grep_fileflag 'Motif', @wxALL ) ); - $project{"MOTIF_SOURCES"} .= "motif/" . $file . " "; - $project{"GUIOBJS"} .= $fileobj . " "; + foreach my $file ( @generic ) { + $project{"GENERICOBJS"} .= $file->object_file . " "; } - foreach $file (sort keys %wxUNIX) { - ($fileobj = $file) =~ s/cp?p?$/\o/; - - $project{"MOTIF_SOURCES"} .= "unix/" . $file . " "; - $project{"UNIXOBJS"} .= $fileobj . " "; + foreach my $file ( @common ) { + $project{"COMMONOBJS"} .= $file->object_file . " "; } - foreach $file (sort keys %wxHTML) { - ($fileobj = $file) =~ s/cp?p?$/\o/; - - $project{"MOTIF_SOURCES"} .= "html/" . $file . " "; - $project{"HTMLOBJS"} .= $fileobj . " "; + foreach my $file ( @motif ) { + $project{"GUIOBJS"} .= $file->object_file . " "; } - #! find all our headers - foreach $file (sort keys %wxWXINCLUDE) { - next if $wxWXINCLUDE{$file} =~ /\bNotX\b/; - $project{"MOTIF_HEADERS"} .= $file . " " + foreach my $file ( @wxUnix ) { + $project{"UNIXOBJS"} .= $file->object_file . " "; } - foreach $file (sort keys %wxMOTIFINCLUDE) { - $project{"MOTIF_HEADERS"} .= "motif/" . $file . " " + foreach my $file ( @wxHtml ) { + $project{"HTMLOBJS"} .= $file->object_file . " "; } - foreach $file (sort keys %wxGENERICINCLUDE) { - $project{"MOTIF_HEADERS"} .= "generic/" . $file . " " + foreach my $file ( @generic, @common, @motif, + @wxUnix, @wxHtml ) { + $project{"MOTIF_SOURCES"} .= $file->source_file . " "; } - foreach $file (sort keys %wxUNIXINCLUDE) { - $project{"MOTIF_HEADERS"} .= "unix/" . $file . " " - } - - foreach $file (sort keys %wxHTMLINCLUDE) { - $project{"MOTIF_HEADERS"} .= "html/" . $file . " " - } - - foreach $file (sort keys %wxPROTOCOLINCLUDE) { - $project{"MOTIF_HEADERS"} .= "protocol/" . $file . " " + #! find all our headers + foreach my $file ( grep_not_fileflag( 'NotX', @wxWxInclude ), + @wxMotifInclude, @wxGenericInclude, @wxUnixInclude, + @wxHtmlInclude, @wxProtocolInclude, + grep_header( grep_fileflag( 'Motif', @wxALL ) ) ) { + $project{MOTIF_HEADERS} .= $file->source_file . " "; } #$} # This file was automatically generated by tmake diff --git a/include/wx/brush.h b/include/wx/brush.h index d31fb46627..1d34cf702e 100644 --- a/include/wx/brush.h +++ b/include/wx/brush.h @@ -4,7 +4,7 @@ #if defined(__WXMSW__) #include "wx/msw/brush.h" #elif defined(__WXMOTIF__) -#include "wx/motif/brush.h" +#include "wx/x11/brush.h" #elif defined(__WXGTK__) #include "wx/gtk/brush.h" #elif defined(__WXX11__) diff --git a/include/wx/motif/brush.h b/include/wx/motif/brush.h deleted file mode 100644 index a0a5e51b7c..0000000000 --- a/include/wx/motif/brush.h +++ /dev/null @@ -1,80 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: brush.h -// Purpose: wxBrush class -// Author: Julian Smart -// Modified by: -// Created: 17/09/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_BRUSH_H_ -#define _WX_BRUSH_H_ - -#ifdef __GNUG__ -#pragma interface "brush.h" -#endif - -#include "wx/gdicmn.h" -#include "wx/gdiobj.h" -#include "wx/bitmap.h" -#include "wx/colour.h" - -class WXDLLEXPORT wxBrush; - -class WXDLLEXPORT wxBrushRefData: public wxGDIRefData -{ - friend class WXDLLEXPORT wxBrush; -public: - wxBrushRefData(); - wxBrushRefData(const wxBrushRefData& data); - ~wxBrushRefData(); - -protected: - int m_style; - wxBitmap m_stipple ; - wxColour m_colour; -}; - -#define M_BRUSHDATA ((wxBrushRefData *)m_refData) - -// Brush -class WXDLLEXPORT wxBrush: public wxGDIObject -{ - DECLARE_DYNAMIC_CLASS(wxBrush) - -public: - wxBrush(); - wxBrush(const wxColour& col, int style); - wxBrush(const wxBitmap& stipple); - inline wxBrush(const wxBrush& brush) { Ref(brush); } - ~wxBrush(); - - virtual void SetColour(const wxColour& col) ; - virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ; - virtual void SetStyle(int style) ; - virtual void SetStipple(const wxBitmap& stipple) ; - - inline wxBrush& operator = (const wxBrush& brush) { if (*this == brush) return (*this); Ref(brush); return *this; } - inline bool operator == (const wxBrush& brush) const { return m_refData == brush.m_refData; } - inline bool operator != (const wxBrush& brush) const { return m_refData != brush.m_refData; } - - inline wxColour& GetColour() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); }; - inline int GetStyle() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); }; - inline wxBitmap *GetStipple() const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); }; - - virtual bool Ok() const { return (m_refData != NULL) ; } - - // Implementation - - // Useful helper: create the brush resource - bool RealizeResource(); - - // When setting properties, we must make sure we're not changing - // another object - void Unshare(); -}; - -#endif -// _WX_BRUSH_H_ diff --git a/include/wx/motif/dcclient.h b/include/wx/motif/dcclient.h index b1db3e481f..a92cc083cb 100644 --- a/include/wx/motif/dcclient.h +++ b/include/wx/motif/dcclient.h @@ -157,7 +157,7 @@ protected: int m_currentPenJoin ; int m_currentPenCap ; int m_currentPenDashCount ; - wxMOTIFDash* m_currentPenDash ; + wxX11Dash* m_currentPenDash ; wxBitmap m_currentStipple ; int m_currentStyle ; int m_currentFill ; diff --git a/include/wx/motif/pen.h b/include/wx/motif/pen.h deleted file mode 100644 index 35247eb99c..0000000000 --- a/include/wx/motif/pen.h +++ /dev/null @@ -1,102 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pen.h -// Purpose: wxPen class -// Author: Julian Smart -// Modified by: -// Created: 17/09/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_PEN_H_ -#define _WX_PEN_H_ - -#ifdef __GNUG__ -#pragma interface "pen.h" -#endif - -#include "wx/gdiobj.h" -#include "wx/colour.h" -#include "wx/bitmap.h" - -typedef char wxMOTIFDash; - -class WXDLLEXPORT wxPen; - -class WXDLLEXPORT wxPenRefData: public wxGDIRefData -{ - friend class WXDLLEXPORT wxPen; -public: - wxPenRefData(); - wxPenRefData(const wxPenRefData& data); - ~wxPenRefData(); - -protected: - int m_width; - int m_style; - int m_join ; - int m_cap ; - wxBitmap m_stipple ; - int m_nbDash ; - wxMOTIFDash *m_dash ; - wxColour m_colour; -}; - -#define M_PENDATA ((wxPenRefData *)m_refData) - -// Pen -class WXDLLEXPORT wxPen: public wxGDIObject -{ - DECLARE_DYNAMIC_CLASS(wxPen) -public: - wxPen(); - wxPen(const wxColour& col, int width, int style); - wxPen(const wxBitmap& stipple, int width); - inline wxPen(const wxPen& pen) { Ref(pen); } - ~wxPen(); - - inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; } - inline bool operator == (const wxPen& pen) const { return m_refData == pen.m_refData; } - inline bool operator != (const wxPen& pen) const { return m_refData != pen.m_refData; } - - virtual bool Ok() const { return (m_refData != NULL) ; } - - // Override in order to recreate the pen - void SetColour(const wxColour& col) ; - void SetColour(unsigned char r, unsigned char g, unsigned char b) ; - - void SetWidth(int width) ; - void SetStyle(int style) ; - void SetStipple(const wxBitmap& stipple) ; - void SetDashes(int nb_dashes, const wxDash *dash) ; - void SetJoin(int join) ; - void SetCap(int cap) ; - - inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; - inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; - inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; - inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; - inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; - inline int GetDashes(wxDash **ptr) const - { - *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); - return (M_PENDATA ? M_PENDATA->m_nbDash : 0); - } - inline int GetDashCount() const { return (M_PENDATA->m_nbDash); } - inline wxDash* GetDash() const { return (wxDash*)M_PENDATA->m_dash; } - - inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); }; - - // Implementation - - // Useful helper: create the brush resource - bool RealizeResource(); - - // When setting properties, we must make sure we're not changing - // another object - void Unshare(); -}; - -#endif -// _WX_PEN_H_ diff --git a/include/wx/pen.h b/include/wx/pen.h index 4b0b27d357..d4603f714d 100644 --- a/include/wx/pen.h +++ b/include/wx/pen.h @@ -4,7 +4,7 @@ #if defined(__WXMSW__) #include "wx/msw/pen.h" #elif defined(__WXMOTIF__) -#include "wx/motif/pen.h" +#include "wx/x11/pen.h" #elif defined(__WXGTK__) #include "wx/gtk/pen.h" #elif defined(__WXX11__) diff --git a/include/wx/x11/brush.h b/include/wx/x11/brush.h index 25f2efd422..7544f90877 100644 --- a/include/wx/x11/brush.h +++ b/include/wx/x11/brush.h @@ -16,15 +16,15 @@ #pragma interface "brush.h" #endif -#include "wx/gdicmn.h" #include "wx/gdiobj.h" -#include "wx/bitmap.h" //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- class wxBrush; +class wxColour; +class wxBitmap; //----------------------------------------------------------------------------- // wxBrush diff --git a/include/wx/x11/pen.h b/include/wx/x11/pen.h index 46d954158f..3f83b5ab43 100644 --- a/include/wx/x11/pen.h +++ b/include/wx/x11/pen.h @@ -16,15 +16,16 @@ #pragma interface "pen.h" #endif +#include "wx/gdicmn.h" #include "wx/gdiobj.h" -#include "wx/colour.h" -#include "wx/bitmap.h" //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- class wxPen; +class wxColour; +class wxBitmap; typedef char wxX11Dash; @@ -38,6 +39,7 @@ public: wxPen() { } wxPen( const wxColour &colour, int width, int style ); + wxPen( const wxBitmap &stipple, int width ); ~wxPen(); wxPen( const wxPen& pen ) { Ref(pen); } @@ -55,7 +57,8 @@ public: void SetStyle( int style ); void SetWidth( int width ); void SetDashes( int number_of_dashes, const wxDash *dash ); - + void SetStipple( wxBitmap *stipple ); + wxColour &GetColour() const; int GetCap() const; int GetJoin() const; @@ -64,6 +67,7 @@ public: int GetDashes(wxDash **ptr) const; int GetDashCount() const; wxDash* GetDash() const; + wxBitmap* GetStipple() const; private: // ref counting code diff --git a/src/motif/brush.cpp b/src/motif/brush.cpp deleted file mode 100644 index 685b376427..0000000000 --- a/src/motif/brush.cpp +++ /dev/null @@ -1,123 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/motif/brush.cpp -// Purpose: wxBrush -// Author: Julian Smart -// Modified by: -// Created: 17/09/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "brush.h" -#endif - -#include "wx/setup.h" -#include "wx/utils.h" -#include "wx/brush.h" - -IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) - -wxBrushRefData::wxBrushRefData() -{ - m_style = wxSOLID; -} - -wxBrushRefData::wxBrushRefData(const wxBrushRefData& data) -{ - m_style = data.m_style; - m_stipple = data.m_stipple; - m_colour = data.m_colour; -} - -wxBrushRefData::~wxBrushRefData() -{ -} - -// Brushes -wxBrush::wxBrush() -{ -} - -wxBrush::~wxBrush() -{ -} - -wxBrush::wxBrush(const wxColour& col, int Style) -{ - m_refData = new wxBrushRefData; - - M_BRUSHDATA->m_colour = col; - M_BRUSHDATA->m_style = Style; - - RealizeResource(); -} - -wxBrush::wxBrush(const wxBitmap& stipple) -{ - m_refData = new wxBrushRefData; - - M_BRUSHDATA->m_style = wxSTIPPLE; - M_BRUSHDATA->m_stipple = stipple; - - RealizeResource(); -} - -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) -{ - Unshare(); - - M_BRUSHDATA->m_colour = col; - - RealizeResource(); -} - -void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b) -{ - Unshare(); - - M_BRUSHDATA->m_colour.Set(r, g, b); - - RealizeResource(); -} - -void wxBrush::SetStyle(int Style) -{ - Unshare(); - - M_BRUSHDATA->m_style = Style; - - RealizeResource(); -} - -void wxBrush::SetStipple(const wxBitmap& Stipple) -{ - Unshare(); - - M_BRUSHDATA->m_stipple = Stipple; - - RealizeResource(); -} - -bool wxBrush::RealizeResource() -{ - // Nothing more to do - return TRUE; -} - diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index 9c18f84d94..e4f7c3282a 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -135,7 +135,7 @@ wxWindowDC::wxWindowDC() m_currentPenWidth = 1; m_currentPenJoin = -1; m_currentPenDashCount = -1; - m_currentPenDash = (wxMOTIFDash*) NULL; + m_currentPenDash = (wxX11Dash*) NULL; m_currentStyle = -1; m_currentFill = -1; // m_currentBkMode = wxTRANSPARENT; @@ -160,7 +160,7 @@ wxWindowDC::wxWindowDC( wxWindow *window ) m_currentPenWidth = 1; m_currentPenJoin = -1; m_currentPenDashCount = -1; - m_currentPenDash = (wxMOTIFDash*) NULL; + m_currentPenDash = (wxX11Dash*) NULL; m_currentStyle = -1; m_currentFill = -1; // m_currentBkMode = wxTRANSPARENT; @@ -1636,7 +1636,7 @@ void wxWindowDC::SetPen( const wxPen &pen ) int old_pen_join = m_currentPenJoin; int old_pen_cap = m_currentPenCap; int old_pen_nb_dash = m_currentPenDashCount; - wxMOTIFDash *old_pen_dash = m_currentPenDash; + wxX11Dash *old_pen_dash = m_currentPenDash; wxColour oldPenColour = m_currentColour; m_currentColour = m_pen.GetColour (); @@ -1646,7 +1646,7 @@ void wxWindowDC::SetPen( const wxPen &pen ) m_currentPenJoin = m_pen.GetJoin (); m_currentPenCap = m_pen.GetCap (); m_currentPenDashCount = m_pen.GetDashCount(); - m_currentPenDash = (wxMOTIFDash*)m_pen.GetDash(); + m_currentPenDash = (wxX11Dash*)m_pen.GetDash(); if (m_currentStyle == wxSTIPPLE) m_currentStipple = * m_pen.GetStipple (); @@ -1674,15 +1674,15 @@ void wxWindowDC::SetPen( const wxPen &pen ) int style; int join; int cap; - static const wxMOTIFDash dotted[] = {2, 5}; - static const wxMOTIFDash short_dashed[] = {4, 4}; - static const wxMOTIFDash long_dashed[] = {4, 8}; - static const wxMOTIFDash dotted_dashed[] = {6, 6, 2, 6}; + static const wxX11Dash dotted[] = {2, 5}; + static const wxX11Dash short_dashed[] = {4, 4}; + static const wxX11Dash long_dashed[] = {4, 8}; + static const wxX11Dash dotted_dashed[] = {6, 6, 2, 6}; // We express dash pattern in pen width unit, so we are // independent of zoom factor and so on... int req_nb_dash; - const wxMOTIFDash *req_dash; + const wxX11Dash *req_dash; switch (m_pen.GetStyle ()) { @@ -1716,13 +1716,13 @@ void wxWindowDC::SetPen( const wxPen &pen ) case wxTRANSPARENT: default: style = LineSolid; - req_dash = (wxMOTIFDash*)NULL; + req_dash = (wxX11Dash*)NULL; req_nb_dash = 0; } if (req_dash && req_nb_dash) { - wxMOTIFDash *real_req_dash = new wxMOTIFDash[req_nb_dash]; + wxX11Dash *real_req_dash = new wxX11Dash[req_nb_dash]; if (real_req_dash) { int factor = scaled_width == 0 ? 1 : scaled_width; diff --git a/src/motif/descrip.mms b/src/motif/descrip.mms index 4b29eaee5c..000269f7c7 100644 --- a/src/motif/descrip.mms +++ b/src/motif/descrip.mms @@ -29,7 +29,6 @@ OBJECTS = \ app.obj,\ bitmap.obj,\ bmpbuttn.obj,\ - brush.obj,\ button.obj,\ checkbox.obj,\ checklst.obj,\ @@ -63,7 +62,6 @@ OBJECTS = \ minifram.obj,\ msgdlg.obj,\ palette.obj,\ - pen.obj,\ radiobox.obj,\ radiobut.obj,\ region.obj,\ @@ -86,7 +84,6 @@ SOURCES = \ app.cpp,\ bitmap.cpp,\ bmpbuttn.cpp,\ - brush.cpp,\ button.cpp,\ checkbox.cpp,\ checklst.cpp,\ @@ -120,7 +117,6 @@ SOURCES = \ minifram.cpp,\ msgdlg.cpp,\ palette.cpp,\ - pen.cpp,\ radiobox.cpp,\ radiobut.cpp,\ region.cpp,\ @@ -152,7 +148,6 @@ accel.obj : accel.cpp app.obj : app.cpp bitmap.obj : bitmap.cpp bmpbuttn.obj : bmpbuttn.cpp -brush.obj : brush.cpp button.obj : button.cpp checkbox.obj : checkbox.cpp checklst.obj : checklst.cpp @@ -186,7 +181,6 @@ menuitem.obj : menuitem.cpp minifram.obj : minifram.cpp msgdlg.obj : msgdlg.cpp palette.obj : palette.cpp -pen.obj : pen.cpp radiobox.obj : radiobox.cpp radiobut.obj : radiobut.cpp region.obj : region.cpp diff --git a/src/motif/files.lst b/src/motif/files.lst index 756e55871e..7a4fcad484 100644 --- a/src/motif/files.lst +++ b/src/motif/files.lst @@ -182,7 +182,6 @@ ALL_SOURCES = \ motif/app.cpp \ motif/bitmap.cpp \ motif/bmpbuttn.cpp \ - motif/brush.cpp \ motif/button.cpp \ motif/checkbox.cpp \ motif/checklst.cpp \ @@ -218,7 +217,6 @@ ALL_SOURCES = \ motif/minifram.cpp \ motif/msgdlg.cpp \ motif/palette.cpp \ - motif/pen.cpp \ motif/radiobox.cpp \ motif/radiobut.cpp \ motif/region.cpp \ @@ -235,6 +233,8 @@ ALL_SOURCES = \ motif/toplevel.cpp \ motif/utils.cpp \ motif/window.cpp \ + x11/brush.cpp \ + x11/pen.cpp \ unix/dialup.cpp \ unix/dir.cpp \ unix/fontenum.cpp \ @@ -513,7 +513,6 @@ ALL_HEADERS = \ motif/app.h \ motif/bitmap.h \ motif/bmpbuttn.h \ - motif/brush.h \ motif/button.h \ motif/checkbox.h \ motif/checklst.h \ @@ -550,7 +549,6 @@ ALL_HEADERS = \ motif/minifram.h \ motif/msgdlg.h \ motif/palette.h \ - motif/pen.h \ motif/print.h \ motif/printdlg.h \ motif/private.h \ @@ -631,7 +629,9 @@ ALL_HEADERS = \ protocol/file.h \ protocol/ftp.h \ protocol/http.h \ - protocol/protocol.h + protocol/protocol.h \ + x11/brush.h \ + x11/pen.h COMMONOBJS = \ appcmn.o \ @@ -820,7 +820,6 @@ GUIOBJS = \ app.o \ bitmap.o \ bmpbuttn.o \ - brush.o \ button.o \ checkbox.o \ checklst.o \ @@ -856,7 +855,6 @@ GUIOBJS = \ minifram.o \ msgdlg.o \ palette.o \ - pen.o \ radiobox.o \ radiobut.o \ region.o \ @@ -872,7 +870,9 @@ GUIOBJS = \ toolbar.o \ toplevel.o \ utils.o \ - window.o + window.o \ + brush.o \ + pen.o UNIXOBJS = \ dialup.o \ diff --git a/src/motif/pen.cpp b/src/motif/pen.cpp deleted file mode 100644 index 4bc2b0bd89..0000000000 --- a/src/motif/pen.cpp +++ /dev/null @@ -1,182 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/motif/pen.cpp -// Purpose: wxPen -// Author: Julian Smart -// Modified by: -// Created: 17/09/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "pen.h" -#endif - -#include "wx/setup.h" -#include "wx/utils.h" -#include "wx/pen.h" - -IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject) - -wxPenRefData::wxPenRefData() -{ - m_style = wxSOLID; - m_width = 1; - m_join = wxJOIN_ROUND ; - m_cap = wxCAP_ROUND ; - m_nbDash = 0 ; - m_dash = (wxMOTIFDash*)NULL; -} - -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; -} - -wxPenRefData::~wxPenRefData() -{ -} - -// Pens - -wxPen::wxPen() -{ -} - -wxPen::~wxPen() -{ -} - -// Should implement Create -wxPen::wxPen(const wxColour& col, int Width, int Style) -{ - m_refData = new wxPenRefData; - - M_PENDATA->m_colour = col; - M_PENDATA->m_width = Width; - M_PENDATA->m_style = Style; - M_PENDATA->m_join = wxJOIN_ROUND ; - M_PENDATA->m_cap = wxCAP_ROUND ; - M_PENDATA->m_nbDash = 0 ; - M_PENDATA->m_dash = (wxMOTIFDash*)NULL; - - RealizeResource(); -} - -wxPen::wxPen(const wxBitmap& stipple, int Width) -{ - m_refData = new wxPenRefData; - - M_PENDATA->m_stipple = stipple; - M_PENDATA->m_width = Width; - M_PENDATA->m_style = wxSTIPPLE; - M_PENDATA->m_join = wxJOIN_ROUND ; - M_PENDATA->m_cap = wxCAP_ROUND ; - M_PENDATA->m_nbDash = 0 ; - M_PENDATA->m_dash = (wxMOTIFDash*)NULL; - - RealizeResource(); -} - -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) -{ - Unshare(); - - M_PENDATA->m_colour = col; - - RealizeResource(); -} - -void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) -{ - Unshare(); - - M_PENDATA->m_colour.Set(r, g, b); - - RealizeResource(); -} - -void wxPen::SetWidth(int Width) -{ - Unshare(); - - M_PENDATA->m_width = Width; - - RealizeResource(); -} - -void wxPen::SetStyle(int Style) -{ - Unshare(); - - M_PENDATA->m_style = Style; - - RealizeResource(); -} - -void wxPen::SetStipple(const wxBitmap& Stipple) -{ - Unshare(); - - M_PENDATA->m_stipple = Stipple; - M_PENDATA->m_style = wxSTIPPLE; - - RealizeResource(); -} - -void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) -{ - Unshare(); - - M_PENDATA->m_nbDash = nb_dashes; - M_PENDATA->m_dash = (wxMOTIFDash *)Dash; - - RealizeResource(); -} - -void wxPen::SetJoin(int Join) -{ - Unshare(); - - M_PENDATA->m_join = Join; - - RealizeResource(); -} - -void wxPen::SetCap(int Cap) -{ - Unshare(); - - M_PENDATA->m_cap = Cap; - - RealizeResource(); -} - -bool wxPen::RealizeResource() -{ - // Nothing more to do - return TRUE; -} - diff --git a/src/x11/brush.cpp b/src/x11/brush.cpp index 85614366cb..5fa6c149e8 100644 --- a/src/x11/brush.cpp +++ b/src/x11/brush.cpp @@ -16,6 +16,7 @@ #include "wx/setup.h" #include "wx/utils.h" #include "wx/brush.h" +#include "wx/bitmap.h" #include "wx/colour.h" //----------------------------------------------------------------------------- diff --git a/src/x11/descrip.mms b/src/x11/descrip.mms new file mode 100644 index 0000000000..f2744fa84b --- /dev/null +++ b/src/x11/descrip.mms @@ -0,0 +1,41 @@ +#***************************************************************************** +# * +# Make file for VMS * +# Author : J.Jansen (joukj@hrem.stm.tudelft.nl) * +# Date : 10 November 1999 * +# * +#***************************************************************************** +.first + define wx [--.include.wx] + +.ifdef __WXMOTIF__ +CXX_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short)\ + /assume=(nostdnew,noglobal_array_new) +CC_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short) +.else +CXX_DEFINE = +.endif + +.suffixes : .cpp + +.cpp.obj : + cxx $(CXXFLAGS)$(CXX_DEFINE) $(MMS$TARGET_NAME).cpp +.c.obj : + cc $(CFLAGS)$(CC_DEFINE) $(MMS$TARGET_NAME).c + +OBJECTS = \ + brush.obj,\ + pen.obj + +SOURCES = \ + brush.cpp,\ + pen.cpp + +all : $(SOURCES) + $(MMS)$(MMSQUALIFIERS) $(OBJECTS) +.ifdef __WXMOTIF__ + library [--.lib]libwx_motif.olb $(OBJECTS) +.endif + +brush.obj : brush.cpp +pen.obj : pen.cpp diff --git a/src/x11/pen.cpp b/src/x11/pen.cpp index 339ef203f5..80a64d6edb 100644 --- a/src/x11/pen.cpp +++ b/src/x11/pen.cpp @@ -16,6 +16,8 @@ #include "wx/setup.h" #include "wx/utils.h" #include "wx/pen.h" +#include "wx/colour.h" +#include "wx/bitmap.h" //----------------------------------------------------------------------------- // wxPen @@ -47,6 +49,7 @@ public: m_dash = new */ m_dash = data.m_dash; + m_stipple = data.m_stipple; } bool operator == (const wxPenRefData& data) const @@ -64,6 +67,7 @@ public: int m_capStyle; wxColour m_colour; int m_countDashes; + wxBitmap m_stipple; wxX11Dash *m_dash; }; @@ -141,6 +145,13 @@ void wxPen::SetJoin( int joinStyle ) M_PENDATA->m_joinStyle = joinStyle; } +void wxPen::SetStipple( wxBitmap *stipple ) +{ + AllocExclusive(); + + M_PENDATA->m_stipple = *stipple;; +} + void wxPen::SetStyle( int style ) { AllocExclusive(); @@ -205,3 +216,10 @@ wxColour &wxPen::GetColour() const return M_PENDATA->m_colour; } + +wxBitmap *wxPen::GetStipple() const +{ + wxCHECK_MSG( Ok(), &wxNullBitmap, wxT("invalid pen") ); + + return &M_PENDATA->m_stipple; +} -- 2.45.2