From 8480b297e70a29b785421ded6db22ae024e35038 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 31 Jan 2000 17:37:37 +0000 Subject: [PATCH] Using the best visual is now an option. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5760 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/app.tex | 30 +++++++++++++++++++++++++++++- include/wx/app.h | 8 ++++++++ src/gtk/app.cpp | 5 ++++- src/gtk/minifram.cpp | 8 ++++---- src/gtk1/app.cpp | 5 ++++- src/gtk1/minifram.cpp | 8 ++++---- 6 files changed, 53 insertions(+), 11 deletions(-) diff --git a/docs/latex/wx/app.tex b/docs/latex/wx/app.tex index af67ba0e18..54648146b3 100644 --- a/docs/latex/wx/app.tex +++ b/docs/latex/wx/app.tex @@ -144,7 +144,18 @@ function will find the first top-level window (frame or dialog) and return that. \wxheading{See also} -\helpref{wxApp::SetTopWindow}{wxappsettopwindow} +\helpref{SetTopWindow}{wxappsettopwindow} + +\membersection{wxApp::GetUseBestVisual}\label{wxappgetusebestvisual} + +\constfunc{bool}{GetUseBestVisual}{\void} + +Returns TRUE if the application will use the best visual on system that support +different visuals, FALSE otherwise. + +\wxheading{See also} + +\helpref{SetUseBestVisual}{wxappsetusebestvisual} \membersection{wxApp::ExitMainLoop}\label{wxappexitmainloop} @@ -448,3 +459,20 @@ can be overridden by the user to change the default icons. \docparam{which}{One of the wxICON\_XXX defines and chooses which icon to return.} +\membersection{wxApp::SetUseBestVisual}\label{wxappsetusebestvisual} + +\func{void}{SetUseBestVisual}{\param{bool}{ flag}} + +Allows the programmer to specify whether the application will use the best visual +on system that support several visual on the same display. This is typically the +case under Solaris and IRIX, where the default visual is only 8-bit but some apps +are supposed to run in TrueColour mode. + +Note that this function has to be called in the constructor of the {\tt wxApp} +instance and won't have any effect when called later on. + +This function currently only has effect under GTK. + +\wxheading{Parameters} + +\docparam{flag}{If TRUE, the app will use the best visual.} diff --git a/include/wx/app.h b/include/wx/app.h index 7d408278bb..79d794857b 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -215,6 +215,10 @@ public: void SetWantDebugOutput( bool flag ) { m_wantDebugOutput = flag; } bool GetWantDebugOutput() const { return m_wantDebugOutput; } + // set use of best visual flag (see below) + void SetUseBestVisual( bool flag ) { m_useBestVisual = flag; } + bool GetUseBestVisual() const { return m_useBestVisual; } + // set/get printing mode: see wxPRINT_XXX constants. // // default behaviour is the normal one for Unix: always use PostScript @@ -254,6 +258,10 @@ protected: // TRUE if the application wants to get debug output bool m_wantDebugOutput; + + // TRUE if the apps whats to use the best visual on systems where + // more than one are available (Sun, SGI, XFree86 4.0 ?) + bool m_useBestVisual; #if wxUSE_GUI // the main top level window - may be NULL diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 98327a2aee..9b13515ed4 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -250,6 +250,8 @@ wxApp::wxApp() #endif m_colorCube = (unsigned char*) NULL; + + m_useBestVisual = FALSE; } wxApp::~wxApp() @@ -271,7 +273,8 @@ bool wxApp::OnInitGui() we make sure we get the best. this can sometimes be wasteful, of course, but what do these guys pay $30.000 for? */ - if (gdk_visual_get_best() != gdk_visual_get_system()) + if ((gdk_visual_get_best() != gdk_visual_get_system()) && + (m_useBestVisual)) { GdkVisual* vis = gdk_visual_get_best(); gtk_widget_set_default_visual( vis ); diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp index bdcc5ef8a9..fb7412dba9 100644 --- a/src/gtk/minifram.cpp +++ b/src/gtk/minifram.cpp @@ -35,8 +35,9 @@ extern bool g_isIdle; // data //----------------------------------------------------------------------------- -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; +extern bool g_blockEventsOnDrag; +extern bool g_blockEventsOnScroll; +extern GtkWidget *wxRootWindow; //----------------------------------------------------------------------------- // local functions @@ -321,8 +322,7 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) { GdkBitmap *mask = (GdkBitmap*) NULL; - GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, cross_xpm ); + GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( wxRootWindow->window, &mask, NULL, cross_xpm ); GtkWidget *pw = gtk_pixmap_new( pixmap, mask ); gdk_bitmap_unref( mask ); diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 98327a2aee..9b13515ed4 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -250,6 +250,8 @@ wxApp::wxApp() #endif m_colorCube = (unsigned char*) NULL; + + m_useBestVisual = FALSE; } wxApp::~wxApp() @@ -271,7 +273,8 @@ bool wxApp::OnInitGui() we make sure we get the best. this can sometimes be wasteful, of course, but what do these guys pay $30.000 for? */ - if (gdk_visual_get_best() != gdk_visual_get_system()) + if ((gdk_visual_get_best() != gdk_visual_get_system()) && + (m_useBestVisual)) { GdkVisual* vis = gdk_visual_get_best(); gtk_widget_set_default_visual( vis ); diff --git a/src/gtk1/minifram.cpp b/src/gtk1/minifram.cpp index bdcc5ef8a9..fb7412dba9 100644 --- a/src/gtk1/minifram.cpp +++ b/src/gtk1/minifram.cpp @@ -35,8 +35,9 @@ extern bool g_isIdle; // data //----------------------------------------------------------------------------- -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; +extern bool g_blockEventsOnDrag; +extern bool g_blockEventsOnScroll; +extern GtkWidget *wxRootWindow; //----------------------------------------------------------------------------- // local functions @@ -321,8 +322,7 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) { GdkBitmap *mask = (GdkBitmap*) NULL; - GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, cross_xpm ); + GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( wxRootWindow->window, &mask, NULL, cross_xpm ); GtkWidget *pw = gtk_pixmap_new( pixmap, mask ); gdk_bitmap_unref( mask );