]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/x11/popupwin.cpp
more fixes to radio menu items: fixed Check() for them; allow separators inside the...
[wxWidgets.git] / src / x11 / popupwin.cpp
... / ...
CommitLineData
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"
19#include "wx/app.h"
20
21#include "wx/x11/private.h"
22#include "X11/Xatom.h"
23#include "X11/Xutil.h"
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{
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
43 m_windowStyle = style;
44 m_windowStyle |= wxTAB_TRAVERSAL;
45
46 wxPoint pos( 20,20 );
47 wxSize size( 20,20 );
48
49 m_parent = parent;
50 if (m_parent) m_parent->AddChild( this );
51
52 Display *xdisplay = wxGlobalDisplay();
53 int xscreen = DefaultScreen( xdisplay );
54 Visual *xvisual = DefaultVisual( xdisplay, xscreen );
55 Window xparent = RootWindow( xdisplay, xscreen );
56
57#if wxUSE_NANOX
58 long xattributes_mask = 0;
59#else
60 XSetWindowAttributes xattributes;
61
62 long xattributes_mask =
63 CWOverrideRedirect |
64 CWSaveUnder |
65 CWBorderPixel | CWBackPixel;
66 xattributes.background_pixel = BlackPixel( xdisplay, xscreen );
67 xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
68 xattributes.override_redirect = True;
69 xattributes.save_under = True;
70#endif
71
72 Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y,
73 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
74
75 XSelectInput( xdisplay, xwindow,
76 ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
77 ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
78 KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
79 PropertyChangeMask );
80
81 m_mainWindow = (WXWindow) xwindow;
82 m_clientWindow = (WXWindow) xwindow;
83 wxAddWindowToTable( xwindow, (wxWindow*) this );
84
85 // Set background to None which will prevent X11 from clearing the
86 // background comletely.
87 XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
88
89 XSetTransientForHint( xdisplay, xwindow, xparent );
90
91#if wxUSE_NANOX
92 // Switch off WM
93 wxSetWMDecorations(xwindow, 0);
94#else
95 XWMHints wm_hints;
96 wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */;
97 wm_hints.input = True;
98 wm_hints.initial_state = NormalState;
99 XSetWMHints( xdisplay, xwindow, &wm_hints);
100#endif
101
102 return TRUE;
103}
104
105void wxPopupWindow::DoMoveWindow(int x, int y, int width, int height )
106{
107 wxWindowX11::DoMoveWindow( x, y, width, height );
108}
109
110void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
111{
112 wxWindowX11::DoSetSize(x, y, width, height, sizeFlags);
113}
114
115bool wxPopupWindow::Show( bool show )
116{
117 bool ret = wxWindowX11::Show( show );
118
119 Raise();
120
121 return ret;
122}
123
124#endif // wxUSE_POPUPWIN