1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "popupwin.h"
18 #include "wx/popupwin.h"
21 #include "wx/x11/private.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 BEGIN_EVENT_TABLE(wxPopupWindow
,wxPopupWindowBase
)
30 IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow
, wxWindow
)
32 bool wxPopupWindow
::Create( wxWindow
*parent
, int style
)
34 if (!CreateBase( parent
, -1, wxDefaultPosition
, wxDefaultSize
, style
, wxDefaultValidator
, "popup" ))
36 wxFAIL_MSG( wxT("wxPopupWindow creation failed") );
40 // All dialogs should really have this style
41 m_windowStyle
= style
;
42 m_windowStyle
|= wxTAB_TRAVERSAL
;
45 if (m_parent
) m_parent
->AddChild( this );
47 wxTopLevelWindows
.Append(this);
49 Display
*xdisplay
= wxGlobalDisplay();
50 int xscreen
= DefaultScreen( xdisplay
);
51 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
52 Window xparent
= RootWindow( xdisplay
, xscreen
);
54 XSetWindowAttributes xattributes
;
55 XSizeHints size_hints
;
58 long xattributes_mask
=
60 CWBorderPixel
| CWBackPixel
;
61 xattributes
.background_pixel
= BlackPixel( xdisplay
, xscreen
);
62 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
63 xattributes
.override_redirect
= False
;
65 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
66 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
68 XSelectInput( xdisplay
, xwindow
,
69 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
70 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
71 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
74 m_mainWindow
= (WXWindow
) xwindow
;
75 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
77 XSetTransientForHint( xdisplay
, xwindow
, xparent
);
79 size_hints
.flags
= PSize
;
80 size_hints
.width
= size
.x
;
81 size_hints
.height
= size
.y
;
82 XSetWMNormalHints( xdisplay
, xwindow
, &size_hints
);
84 wm_hints
.flags
= InputHint
| StateHint
/* | WindowGroupHint */;
85 wm_hints
.input
= True
;
86 wm_hints
.initial_state
= NormalState
;
87 XSetWMHints( xdisplay
, xwindow
, &wm_hints
);
89 Atom wm_delete_window
= XInternAtom( xdisplay
, "WM_DELETE_WINDOW", False
);
90 XSetWMProtocols( xdisplay
, xwindow
, &wm_delete_window
, 1);
92 wxSetWMDecorations((Window
) GetMainWindow(), style
);
97 void wxPopupWindow
::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
99 wxFAIL_MSG( wxT("DoMoveWindow called for wxPopupWindow") );
102 void wxPopupWindow
::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
104 wxWindowX11
::DoSetSize(x
, y
, width
, height
, sizeFlags
);
107 bool wxPopupWindow
::Show( bool show
)
109 return wxWindow11
::Show( show
);
112 #endif // wxUSE_POPUPWIN