]> git.saurik.com Git - wxWidgets.git/blame - src/x11/popupwin.cpp
Correction for 'protected' compiler error
[wxWidgets.git] / src / x11 / popupwin.cpp
CommitLineData
1246e28f
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: popupwin.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "popupwin.h"
12#endif
13
14#include "wx/defs.h"
15
16#if wxUSE_POPUPWIN
17
18#include "wx/popupwin.h"
1246e28f 19#include "wx/app.h"
1246e28f
JS
20
21#include "wx/x11/private.h"
6a44bffd
JS
22#include "X11/Xatom.h"
23#include "X11/Xutil.h"
1246e28f
JS
24
25//-----------------------------------------------------------------------------
26// wxPopupWindow
27//-----------------------------------------------------------------------------
28
29BEGIN_EVENT_TABLE(wxPopupWindow,wxPopupWindowBase)
30END_EVENT_TABLE()
31
32IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow)
33
34bool wxPopupWindow::Create( wxWindow *parent, int style )
35{
1246e28f
JS
36 if (!CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, "popup" ))
37 {
38 wxFAIL_MSG( wxT("wxPopupWindow creation failed") );
39 return FALSE;
40 }
41
42 // All dialogs should really have this style
b28d3abf 43 m_windowStyle = style;
1246e28f 44 m_windowStyle |= wxTAB_TRAVERSAL;
1b0b798d
RR
45
46 wxPoint pos( 20,20 );
47 wxSize size( 20,20 );
1246e28f 48
b28d3abf 49 m_parent = parent;
1246e28f
JS
50 if (m_parent) m_parent->AddChild( this );
51
b28d3abf
JS
52 wxTopLevelWindows.Append(this);
53
54 Display *xdisplay = wxGlobalDisplay();
55 int xscreen = DefaultScreen( xdisplay );
56 Visual *xvisual = DefaultVisual( xdisplay, xscreen );
57 Window xparent = RootWindow( xdisplay, xscreen );
58
59 XSetWindowAttributes xattributes;
60 XSizeHints size_hints;
61 XWMHints wm_hints;
62
63 long xattributes_mask =
ea596687 64 CWOverrideRedirect |
b28d3abf
JS
65 CWBorderPixel | CWBackPixel;
66 xattributes.background_pixel = BlackPixel( xdisplay, xscreen );
67 xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
68 xattributes.override_redirect = False;
6a44bffd 69
68dc6d2a 70 Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y,
b28d3abf
JS
71 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
72
73 XSelectInput( xdisplay, xwindow,
74 ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
75 ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
76 KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
77 PropertyChangeMask );
78
6a44bffd 79 m_mainWidget = (WXWindow) xwindow;
b28d3abf
JS
80 wxAddWindowToTable( xwindow, (wxWindow*) this );
81
82 XSetTransientForHint( xdisplay, xwindow, xparent );
83
84 size_hints.flags = PSize;
85 size_hints.width = size.x;
86 size_hints.height = size.y;
87 XSetWMNormalHints( xdisplay, xwindow, &size_hints);
88
89 wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */;
90 wm_hints.input = True;
91 wm_hints.initial_state = NormalState;
92 XSetWMHints( xdisplay, xwindow, &wm_hints);
93
94 Atom wm_delete_window = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False);
95 XSetWMProtocols( xdisplay, xwindow, &wm_delete_window, 1);
96
97 wxSetWMDecorations((Window) GetMainWindow(), style);
1246e28f
JS
98
99 return TRUE;
100}
101
102void wxPopupWindow::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
103{
104 wxFAIL_MSG( wxT("DoMoveWindow called for wxPopupWindow") );
105}
106
107void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
108{
b28d3abf 109 wxWindowX11::DoSetSize(x, y, width, height, sizeFlags);
1246e28f 110}
b28d3abf 111
1246e28f
JS
112bool wxPopupWindow::Show( bool show )
113{
6a44bffd 114 return wxWindowX11::Show( show );
1246e28f
JS
115}
116
117#endif // wxUSE_POPUPWIN