]>
Commit | Line | Data |
---|---|---|
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 | ||
29 | BEGIN_EVENT_TABLE(wxPopupWindow,wxPopupWindowBase) | |
30 | END_EVENT_TABLE() | |
31 | ||
32 | IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow) | |
33 | ||
34 | bool 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 | Display *xdisplay = wxGlobalDisplay(); |
53 | int xscreen = DefaultScreen( xdisplay ); | |
54 | Visual *xvisual = DefaultVisual( xdisplay, xscreen ); | |
55 | Window xparent = RootWindow( xdisplay, xscreen ); | |
56 | ||
788519c6 JS |
57 | #if wxUSE_NANOX |
58 | long xattributes_mask = 0; | |
59 | #else | |
b28d3abf | 60 | XSetWindowAttributes xattributes; |
b28d3abf JS |
61 | |
62 | long xattributes_mask = | |
ea596687 | 63 | CWOverrideRedirect | |
0d1dff01 | 64 | CWSaveUnder | |
b28d3abf JS |
65 | CWBorderPixel | CWBackPixel; |
66 | xattributes.background_pixel = BlackPixel( xdisplay, xscreen ); | |
67 | xattributes.border_pixel = BlackPixel( xdisplay, xscreen ); | |
0d1dff01 RR |
68 | xattributes.override_redirect = True; |
69 | xattributes.save_under = True; | |
788519c6 JS |
70 | #endif |
71 | ||
68dc6d2a | 72 | Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y, |
b28d3abf JS |
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 | ||
6a44bffd | 81 | m_mainWidget = (WXWindow) xwindow; |
b28d3abf | 82 | wxAddWindowToTable( xwindow, (wxWindow*) this ); |
5e29f97a | 83 | |
ba696cfa RR |
84 | // Set background to None which will prevent X11 from clearing the |
85 | // background comletely. | |
86 | XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); | |
87 | ||
86fd8bda | 88 | XSetTransientForHint( xdisplay, xwindow, xparent ); |
5e29f97a | 89 | |
70b8ab77 JS |
90 | #if wxUSE_NANOX |
91 | // Switch off WM | |
92 | wxSetWMDecorations(xwindow, 0); | |
93 | #else | |
86fd8bda | 94 | XWMHints wm_hints; |
b28d3abf JS |
95 | wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */; |
96 | wm_hints.input = True; | |
97 | wm_hints.initial_state = NormalState; | |
98 | XSetWMHints( xdisplay, xwindow, &wm_hints); | |
788519c6 JS |
99 | #endif |
100 | ||
1246e28f JS |
101 | return TRUE; |
102 | } | |
103 | ||
27398643 | 104 | void wxPopupWindow::DoMoveWindow(int x, int y, int width, int height ) |
1246e28f | 105 | { |
27398643 | 106 | wxWindowX11::DoMoveWindow( x, y, width, height ); |
1246e28f JS |
107 | } |
108 | ||
109 | void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) | |
110 | { | |
b28d3abf | 111 | wxWindowX11::DoSetSize(x, y, width, height, sizeFlags); |
1246e28f | 112 | } |
b28d3abf | 113 | |
1246e28f JS |
114 | bool wxPopupWindow::Show( bool show ) |
115 | { | |
86fd8bda RR |
116 | bool ret = wxWindowX11::Show( show ); |
117 | ||
90f501b1 | 118 | Raise(); |
86fd8bda RR |
119 | |
120 | return ret; | |
1246e28f JS |
121 | } |
122 | ||
123 | #endif // wxUSE_POPUPWIN |