2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nscore.h" // needed for 'nsnull'
|
|
|
|
#include "nsGTKToolkit.h"
|
|
|
|
|
2011-10-25 08:05:32 -07:00
|
|
|
nsGTKToolkit* nsGTKToolkit::gToolkit = nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// constructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsGTKToolkit::nsGTKToolkit()
|
2011-10-25 08:05:32 -07:00
|
|
|
: mSharedGC(nsnull), mFocusTimestamp(0)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-25 08:05:32 -07:00
|
|
|
CreateSharedGC();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// destructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsGTKToolkit::~nsGTKToolkit()
|
|
|
|
{
|
|
|
|
if (mSharedGC) {
|
2009-02-02 09:49:58 -08:00
|
|
|
g_object_unref(mSharedGC);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsGTKToolkit::CreateSharedGC(void)
|
|
|
|
{
|
|
|
|
GdkPixmap *pixmap;
|
|
|
|
|
|
|
|
if (mSharedGC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pixmap = gdk_pixmap_new(NULL, 1, 1, gdk_rgb_get_visual()->depth);
|
|
|
|
mSharedGC = gdk_gc_new(pixmap);
|
2009-02-02 09:49:58 -08:00
|
|
|
g_object_unref(pixmap);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
GdkGC *nsGTKToolkit::GetSharedGC(void)
|
|
|
|
{
|
2009-02-02 09:49:58 -08:00
|
|
|
return (GdkGC *)g_object_ref(mSharedGC);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-10-25 08:05:32 -07:00
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
// Return the toolkit. If a toolkit does not yet exist, then one will be created.
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
// static
|
|
|
|
nsGTKToolkit* nsGTKToolkit::GetToolkit()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-25 08:05:32 -07:00
|
|
|
if (!gToolkit) {
|
|
|
|
gToolkit = new nsGTKToolkit();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-10-25 08:05:32 -07:00
|
|
|
|
|
|
|
return gToolkit;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|