1 /* AbiSource Application Framework
2 * Copyright (C) 1998-2000 AbiSource, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #include "xap_Frame.h"
21 #include "ut_debugmsg.h"
22 #include "xap_UnixFontPreview.h"
23 #include "gr_UnixCairoGraphics.h"
24 #include "xap_UnixDialogHelper.h"
25
XAP_UnixFontPreview(XAP_Frame * pFrame,UT_sint32 left,UT_uint32 top)26 XAP_UnixFontPreview::XAP_UnixFontPreview(XAP_Frame * pFrame, UT_sint32 left, UT_uint32 top)
27 : XAP_FontPreview()
28 {
29 m_pFrame = static_cast<XAP_Frame *>(pFrame);
30 m_left = left;
31 m_top = top;
32
33 m_pPreviewWindow = gtk_window_new(GTK_WINDOW_POPUP);
34 gtk_widget_set_size_request(m_pPreviewWindow, m_width, m_height);
35
36 m_pDrawingArea = createDrawingArea ();
37 gtk_container_add(GTK_CONTAINER(m_pPreviewWindow), m_pDrawingArea);
38 #if GTK_CHECK_VERSION(3,0,0)
39 g_object_set(G_OBJECT(m_pDrawingArea), "expand", TRUE, NULL);
40 #endif
41
42 gtk_widget_show_all(m_pPreviewWindow);
43 gtk_window_move(GTK_WINDOW(m_pPreviewWindow), m_left, m_top);
44 UT_DEBUGMSG(("gtk_window_move left %d top %d \n",m_left,m_top));
45
46 XAP_App *pApp = XAP_App::getApp();
47 GR_UnixCairoAllocInfo ai(GTK_WIDGET(m_pDrawingArea));
48 m_gc = (GR_CairoGraphics*) pApp->newGraphics(ai);
49
50 _createFontPreviewFromGC(m_gc, m_width, m_height);
51 }
52
~XAP_UnixFontPreview(void)53 XAP_UnixFontPreview::~XAP_UnixFontPreview(void)
54 {
55 DELETEP(m_gc);
56 gtk_widget_destroy(m_pDrawingArea);
57 gtk_widget_destroy(m_pPreviewWindow);
58 }
59