Typos and other fixes
[wxWidgets.git] / src / x11 / popupwin.cpp
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
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 {
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 m_parent = parent;
47 if (m_parent) m_parent->AddChild( this );
48
49 wxTopLevelWindows.Append(this);
50
51 Display *xdisplay = wxGlobalDisplay();
52 int xscreen = DefaultScreen( xdisplay );
53 Visual *xvisual = DefaultVisual( xdisplay, xscreen );
54 Window xparent = RootWindow( xdisplay, xscreen );
55
56 XSetWindowAttributes xattributes;
57 XSizeHints size_hints;
58 XWMHints wm_hints;
59
60 long xattributes_mask =
61 CWEventMask |
62 CWBorderPixel | CWBackPixel;
63 xattributes.background_pixel = BlackPixel( xdisplay, xscreen );
64 xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
65 xattributes.override_redirect = False;
66
67 wxSize size(2, 2);
68
69 Window xwindow = XCreateWindow( xdisplay, xparent, 0, 0, size.x, size.y,
70 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
71
72 XSelectInput( xdisplay, xwindow,
73 ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
74 ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
75 KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
76 PropertyChangeMask );
77
78 m_mainWidget = (WXWindow) xwindow;
79 wxAddWindowToTable( xwindow, (wxWindow*) this );
80
81 XSetTransientForHint( xdisplay, xwindow, xparent );
82
83 size_hints.flags = PSize;
84 size_hints.width = size.x;
85 size_hints.height = size.y;
86 XSetWMNormalHints( xdisplay, xwindow, &size_hints);
87
88 wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */;
89 wm_hints.input = True;
90 wm_hints.initial_state = NormalState;
91 XSetWMHints( xdisplay, xwindow, &wm_hints);
92
93 Atom wm_delete_window = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False);
94 XSetWMProtocols( xdisplay, xwindow, &wm_delete_window, 1);
95
96 wxSetWMDecorations((Window) GetMainWindow(), style);
97
98 return TRUE;
99 }
100
101 void wxPopupWindow::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
102 {
103 wxFAIL_MSG( wxT("DoMoveWindow called for wxPopupWindow") );
104 }
105
106 void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
107 {
108 wxWindowX11::DoSetSize(x, y, width, height, sizeFlags);
109 }
110
111 bool wxPopupWindow::Show( bool show )
112 {
113 return wxWindowX11::Show( show );
114 }
115
116 #endif // wxUSE_POPUPWIN