]> git.saurik.com Git - wxWidgets.git/commitdiff
wxMotif: wxWindow/Client/PaintDC starting to work.
authorJulian Smart <julian@anthemion.co.uk>
Wed, 23 Sep 1998 13:56:00 +0000 (13:56 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 23 Sep 1998 13:56:00 +0000 (13:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@769 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/motif/todo.txt
include/wx/defs.h
include/wx/motif/dcclient.h
src/generic/statusbr.cpp
src/motif/colour.cpp
src/motif/dcclient.cpp
src/motif/font.cpp
src/motif/settings.cpp
src/motif/window.cpp

index 52f9d8e0f93fcbe2c381258f5b0ca7a66b259f56..8d6a1775aac8f7cf3780a76c82578a9d72df75ff 100644 (file)
@@ -11,6 +11,9 @@ Updated: 21/9/98
   libxpm exists and use that? What about PNGs? Can we use gdk
   as per wxGTK? Probably not.
 
   libxpm exists and use that? What about PNGs? Can we use gdk
   as per wxGTK? Probably not.
 
+- Work out why XFreeFont in font.cpp produces a segv. This is
+  currently commented out, which presumably causes a memory leak.
+
 - wxRegion
 
 - Bitmap versions of widgets (wxBitmapButton etc.)
 - wxRegion
 
 - Bitmap versions of widgets (wxBitmapButton etc.)
index 0082470ae12dee632f30825ef8c9a06349420d06..13c94ff050bac1bbd81270eda7796336e73be513 100644 (file)
@@ -901,6 +901,7 @@ typedef void*           WXPixmap;
 typedef void*           WXFontStructPtr;
 typedef void*           WXGC;
 typedef void*           WXRegion;
 typedef void*           WXFontStructPtr;
 typedef void*           WXGC;
 typedef void*           WXRegion;
+typedef void*           WXFont;
 #endif
 
 #endif
 #endif
 
 #endif
index a4d303e885c35fca215c504c840f7881d204fb9d..10bae9365f4a61b6675465ab72d9fee03386533b 100644 (file)
@@ -118,6 +118,7 @@ protected:
     int          m_currentStyle ;
     int          m_currentFill ;
     int          m_autoSetting ; // See comment in dcclient.cpp
     int          m_currentStyle ;
     int          m_currentFill ;
     int          m_autoSetting ; // See comment in dcclient.cpp
+    WXFont       m_oldFont;
 };
 
 class WXDLLEXPORT wxPaintDC: public wxWindowDC
 };
 
 class WXDLLEXPORT wxPaintDC: public wxWindowDC
index 58a104aa7e0efd74b0d9e37d87af5a2a5b49b77d..da95f833d9f3469845b92229cdf03b5082f55ec4 100644 (file)
@@ -62,9 +62,9 @@ wxStatusBar::wxStatusBar(void)
 
 wxStatusBar::~wxStatusBar(void)
 {
 
 wxStatusBar::~wxStatusBar(void)
 {
-#ifdef __WXMSW__
+  // #ifdef __WXMSW__
     SetFont(wxNullFont);
     SetFont(wxNullFont);
-#endif
+    // #endif
 
        if ( m_statusWidths )
                delete[] m_statusWidths;
 
        if ( m_statusWidths )
                delete[] m_statusWidths;
@@ -178,6 +178,8 @@ void wxStatusBar::OnPaint(wxPaintEvent& WXUNUSED(event) )
 
   for ( i = 0; i < m_nFields; i ++ )
        DrawField(dc, i);
 
   for ( i = 0; i < m_nFields; i ++ )
        DrawField(dc, i);
+
+  dc.SetFont(wxNullFont);
 }
 
 void wxStatusBar::DrawFieldText(wxDC& dc, int i)
 }
 
 void wxStatusBar::DrawFieldText(wxDC& dc, int i)
index c3dca7072c0a83f3eaf509d9a488985d9365c5b9..a6a1287ff6471440fc67cef6b940dee1bec34cd9 100644 (file)
@@ -73,6 +73,7 @@ wxColour::wxColour (const wxString& col)
         m_red = the_colour->Red ();
         m_green = the_colour->Green ();
         m_blue = the_colour->Blue ();
         m_red = the_colour->Red ();
         m_green = the_colour->Green ();
         m_blue = the_colour->Blue ();
+        m_pixel = the_colour->m_pixel;
         m_isInit = TRUE;
     }
     else
         m_isInit = TRUE;
     }
     else
@@ -82,9 +83,6 @@ wxColour::wxColour (const wxString& col)
         m_blue = 0;
         m_isInit = FALSE;
     }
         m_blue = 0;
         m_isInit = FALSE;
     }
-/* TODO
-    m_pixel = PALETTERGB (m_red, m_green, m_blue);
-*/
 }
 
 wxColour::~wxColour ()
 }
 
 wxColour::~wxColour ()
@@ -99,6 +97,7 @@ wxColour& wxColour::operator = (const wxString& col)
         m_red = the_colour->Red ();
         m_green = the_colour->Green ();
         m_blue = the_colour->Blue ();
         m_red = the_colour->Red ();
         m_green = the_colour->Green ();
         m_blue = the_colour->Blue ();
+        m_pixel = the_colour->m_pixel;
         m_isInit = TRUE;
     }
     else
         m_isInit = TRUE;
     }
     else
@@ -108,9 +107,7 @@ wxColour& wxColour::operator = (const wxString& col)
         m_blue = 0;
         m_isInit = FALSE;
     }
         m_blue = 0;
         m_isInit = FALSE;
     }
-/* TODO
-    m_pixel = PALETTERGB (m_red, m_green, m_blue);
-*/
+
     return (*this);
 }
 
     return (*this);
 }
 
@@ -120,9 +117,7 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
     m_green = g;
     m_blue = b;
     m_isInit = TRUE;
     m_green = g;
     m_blue = b;
     m_isInit = TRUE;
-/* TODO
-    m_pixel = PALETTERGB (m_red, m_green, m_blue);
-*/
+    m_pixel = -1;
 }
 
 // Allocate a colour, or nearest colour, using the given display.
 }
 
 // Allocate a colour, or nearest colour, using the given display.
index 7ef4bf61efe252cb5ab883e87ce4c459da0894cb..9f994b2747c0852f259e8c410617b53ebd9c0466 100644 (file)
@@ -89,6 +89,7 @@ wxWindowDC::wxWindowDC(void)
     m_userRegion = (WXRegion) 0;
     m_pixmap = (WXPixmap) 0;
     m_autoSetting = 0;
     m_userRegion = (WXRegion) 0;
     m_pixmap = (WXPixmap) 0;
     m_autoSetting = 0;
+    m_oldFont = (WXFont) 0;
 };
 
 wxWindowDC::wxWindowDC( wxWindow *window )
 };
 
 wxWindowDC::wxWindowDC( wxWindow *window )
@@ -136,10 +137,23 @@ wxWindowDC::wxWindowDC( wxWindow *window )
     }
 
     m_backgroundPixel = (int) gcvalues.background;
     }
 
     m_backgroundPixel = (int) gcvalues.background;
+
+    // Get the current Font so we can set it back later
+    XGCValues valReturn;
+    XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
+    m_oldFont = (WXFont) valReturn.font;
 };
 
 wxWindowDC::~wxWindowDC(void)
 {
 };
 
 wxWindowDC::~wxWindowDC(void)
 {
+    if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1))
+    {
+      XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
+
+      if (m_window && m_window->GetBackingPixmap())
+          XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
+    }
+
     if (m_gc)
         XFreeGC ((Display*) m_display, (GC) m_gc);
     m_gc = (WXGC) 0;
     if (m_gc)
         XFreeGC ((Display*) m_display, (GC) m_gc);
     m_gc = (WXGC) 0;
@@ -1323,7 +1337,16 @@ void wxWindowDC::SetFont( const wxFont &font )
   m_font = font;
 
   if (!m_font.Ok())
   m_font = font;
 
   if (!m_font.Ok())
+  {
+    if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1))
+    {
+      XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
+
+      if (m_window && m_window->GetBackingPixmap())
+          XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
+    }
     return;
     return;
+  }
 
   WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY);
 
 
   WXFontStructPtr pFontStruct = m_font.FindOrCreateFontStruct(m_userScaleY*m_logicalScaleY);
 
@@ -1339,7 +1362,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
   if (!Ok()) return;
 
   m_pen = pen;
   if (!Ok()) return;
 
   m_pen = pen;
-  if (m_pen.Ok())
+  if (!m_pen.Ok())
     return;
 
   wxBitmap oldStipple = m_currentStipple;
     return;
 
   wxBitmap oldStipple = m_currentStipple;
index feeb310e0bacf7a884d9eedd459050fa63642d76..ae4ccd07ffe8c6beae3fe89eb18bfd3e09d75260 100644 (file)
@@ -56,7 +56,10 @@ wxFontRefData::~wxFontRefData()
     while (node)
     {
         XFontStruct* fontStruct = (XFontStruct*) node->Data();
     while (node)
     {
         XFontStruct* fontStruct = (XFontStruct*) node->Data();
-        XFreeFont((Display*) wxGetDisplay, fontStruct);
+       // TODO: why does freeing the font produce a segv???
+       // Commenting it out will result in memory leaks, and
+       // maybe X resource problems, who knows...
+       //        XFreeFont((Display*) wxGetDisplay, fontStruct);
         node = node->Next();
     }
     m_fontsByScale.Clear();
         node = node->Next();
     }
     m_fontsByScale.Clear();
@@ -290,6 +293,7 @@ WXFontStructPtr wxFont::FindOrCreateFontStruct(double scale)
        if (!font)
            font = LoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
                                    M_FONTDATA->m_underlined);
        if (!font)
            font = LoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
                                    M_FONTDATA->m_underlined);
+        wxASSERT_MSG( (font != (XFontStruct*) NULL), "Could not allocate even a default font -- something is wrong." );
   }
   if (font)
   {
   }
   if (font)
   {
index 357fe42c8fba3c6554997d120359a5a5e7aae829..9bfe3411ca7646c8e03645f49d4098792f3a54c4 100644 (file)
 #endif
 
 #include "wx/settings.h"
 #endif
 
 #include "wx/settings.h"
+#include "wx/gdicmn.h"
 
 wxColour wxSystemSettings::GetSystemColour(int index)
 {
 
 wxColour wxSystemSettings::GetSystemColour(int index)
 {
-    // TODO
-    return wxColour();
+  switch (index)
+  {
+    case wxSYS_COLOUR_SCROLLBAR:
+      //    case wxSYS_COLOUR_DESKTOP:          // Same as wxSYS_COLOUR_BACKGROUND
+    case wxSYS_COLOUR_BACKGROUND:
+    case wxSYS_COLOUR_ACTIVECAPTION:
+    case wxSYS_COLOUR_INACTIVECAPTION:
+    case wxSYS_COLOUR_MENU:
+    case wxSYS_COLOUR_WINDOW:
+    case wxSYS_COLOUR_WINDOWFRAME:
+    case wxSYS_COLOUR_ACTIVEBORDER:
+    case wxSYS_COLOUR_INACTIVEBORDER:
+    case wxSYS_COLOUR_BTNFACE:
+      //    case wxSYS_COLOUR_3DFACE:           // Same as wxSYS_COLOUR_BTNFACE
+    case wxSYS_COLOUR_GRAYTEXT:
+    {
+        return wxColour("LIGHT GREY");
+    }
+    case wxSYS_COLOUR_BTNSHADOW:
+      //    case wxSYS_COLOUR_3DSHADOW:         // Same as wxSYS_COLOUR_BTNSHADOW
+    {
+        return wxColour("GREY");
+    }
+    case wxSYS_COLOUR_3DDKSHADOW:
+    {
+        return *wxBLACK;
+    }
+    case wxSYS_COLOUR_HIGHLIGHT:
+    case wxSYS_COLOUR_BTNHIGHLIGHT:
+      //    case wxSYS_COLOUR_3DHIGHLIGHT:      // Same as wxSYS_COLOUR_BTNHIGHLIGHT
+    {
+        return *wxWHITE;
+    }
+    case wxSYS_COLOUR_3DLIGHT:
+    {
+        return wxColour("LIGHT GREY");
+    }
+    case wxSYS_COLOUR_MENUTEXT:
+    case wxSYS_COLOUR_WINDOWTEXT:
+    case wxSYS_COLOUR_CAPTIONTEXT:
+    case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
+    case wxSYS_COLOUR_INFOTEXT:
+    {
+      return *wxBLACK;
+    }
+    case wxSYS_COLOUR_HIGHLIGHTTEXT:
+    {
+      return *wxWHITE;
+    }
+    case wxSYS_COLOUR_INFOBK:
+    case wxSYS_COLOUR_APPWORKSPACE:
+    {
+      return *wxWHITE;
+    }
+  }
+  return *wxWHITE;
 }
 
 wxFont wxSystemSettings::GetSystemFont(int index)
 {
 }
 
 wxFont wxSystemSettings::GetSystemFont(int index)
 {
-    // TODO
     switch (index)
     {
     switch (index)
     {
-        case wxSYS_DEVICE_DEFAULT_FONT:
-        {
-            break;
-        }
-        case wxSYS_DEFAULT_PALETTE:
-        {
-            break;
-        }
         case wxSYS_SYSTEM_FIXED_FONT:
         {
         case wxSYS_SYSTEM_FIXED_FONT:
         {
+            return wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, FALSE);
             break;
         }
             break;
         }
+        case wxSYS_DEVICE_DEFAULT_FONT:
         case wxSYS_SYSTEM_FONT:
         case wxSYS_SYSTEM_FONT:
-        {
-            break;
-        }
-        default:
         case wxSYS_DEFAULT_GUI_FONT:
         case wxSYS_DEFAULT_GUI_FONT:
+        default:
         {
         {
+            return wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE);
             break;
         }
     }
             break;
         }
     }
index dffcfcc268fef8df60a791430ef77d271e18e380..bdf67fa1f314135e8172ad9044c38448fe6244b2 100644 (file)
@@ -419,7 +419,9 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
   XtAddEventHandler ((Widget) m_drawingArea, PointerMotionHintMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask,
     False, (XtEventHandler) wxCanvasEnterLeave, (XtPointer) this);
 
   XtAddEventHandler ((Widget) m_drawingArea, PointerMotionHintMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask,
     False, (XtEventHandler) wxCanvasEnterLeave, (XtPointer) this);
 
-    return TRUE;
+  SetSize(pos.x, pos.y, size.x, size.y);
+
+  return TRUE;
 }
 
 void wxWindow::SetFocus()
 }
 
 void wxWindow::SetFocus()
@@ -759,6 +761,8 @@ void wxWindow::Refresh(bool eraseBack, const wxRectangle *rect)
     if (eraseBack)
     {
         wxClientDC dc(this);
     if (eraseBack)
     {
         wxClientDC dc(this);
+        wxBrush backgroundBrush(GetBackgroundColour(), wxSOLID);
+        dc.SetBackground(backgroundBrush);
         dc.Clear();
     }
 
         dc.Clear();
     }
 
@@ -1553,7 +1557,7 @@ void wxWindow::OnDefaultAction(wxControl *initiatingItem)
 
 void wxWindow::Clear()
 {
 
 void wxWindow::Clear()
 {
-       wxClientDC dc(this);
+    wxClientDC dc(this);
     wxBrush brush(GetBackgroundColour(), wxSOLID);
     dc.SetBackground(brush);
     dc.Clear();
     wxBrush brush(GetBackgroundColour(), wxSOLID);
     dc.SetBackground(brush);
     dc.Clear();