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"
22 #include "X11/Xatom.h"
23 #include "X11/Xutil.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 BEGIN_EVENT_TABLE(wxPopupWindow
,wxPopupWindowBase
)
32 IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow
, wxWindow
)
34 bool wxPopupWindow::Create( wxWindow
*parent
, int style
)
36 if (!CreateBase( parent
, -1, wxDefaultPosition
, wxDefaultSize
, style
, wxDefaultValidator
, "popup" ))
38 wxFAIL_MSG( wxT("wxPopupWindow creation failed") );
42 // All dialogs should really have this style
43 m_windowStyle
= style
;
44 m_windowStyle
|= wxTAB_TRAVERSAL
;
52 if (m_parent
) m_parent
->AddChild( this );
54 Display
*xdisplay
= wxGlobalDisplay();
55 int xscreen
= DefaultScreen( xdisplay
);
56 Visual
*xvisual
= DefaultVisual( xdisplay
, xscreen
);
57 Window xparent
= RootWindow( xdisplay
, xscreen
);
62 bool need_two_windows
=
63 ((( wxSUNKEN_BORDER
| wxRAISED_BORDER
| wxSIMPLE_BORDER
| wxHSCROLL
| wxVSCROLL
) & m_windowStyle
) != 0);
65 bool need_two_windows
= FALSE
;
68 XSetWindowAttributes xattributes
;
69 long xattributes_mask
= 0;
71 xattributes_mask
|= CWBackPixel
;
72 xattributes
.background_pixel
= m_backgroundColour
.GetPixel();
74 xattributes_mask
|= CWBorderPixel
;
75 xattributes
.border_pixel
= BlackPixel( xdisplay
, xscreen
);
77 xattributes_mask
|= CWOverrideRedirect
| CWSaveUnder
;
78 xattributes
.override_redirect
= True
;
79 xattributes
.save_under
= True
;
81 xattributes_mask
|= CWEventMask
;
85 xattributes
.event_mask
=
86 ExposureMask
| StructureNotifyMask
| ColormapChangeMask
;
88 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
89 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
91 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
93 m_mainWindow
= (WXWindow
) xwindow
;
94 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
96 XMapWindow( xdisplay
, xwindow
);
98 xattributes
.event_mask
=
99 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
100 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
101 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
102 PropertyChangeMask
| VisibilityChangeMask
;
104 if (HasFlag( wxSUNKEN_BORDER
) || HasFlag( wxRAISED_BORDER
))
111 if (HasFlag( wxSIMPLE_BORDER
))
123 xwindow
= XCreateWindow( xdisplay
, xwindow
, pos2
.x
, pos2
.y
, size2
.x
, size2
.y
,
124 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
126 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
128 m_clientWindow
= (WXWindow
) xwindow
;
129 wxAddClientWindowToTable( xwindow
, (wxWindow
*) this );
131 XMapWindow( xdisplay
, xwindow
);
135 xattributes
.event_mask
=
136 ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
|
137 ButtonMotionMask
| EnterWindowMask
| LeaveWindowMask
| PointerMotionMask
|
138 KeymapStateMask
| FocusChangeMask
| ColormapChangeMask
| StructureNotifyMask
|
139 PropertyChangeMask
| VisibilityChangeMask
;
141 Window xwindow
= XCreateWindow( xdisplay
, xparent
, pos
.x
, pos
.y
, size
.x
, size
.y
,
142 0, DefaultDepth(xdisplay
,xscreen
), InputOutput
, xvisual
, xattributes_mask
, &xattributes
);
144 XSetWindowBackgroundPixmap( xdisplay
, xwindow
, None
);
146 m_mainWindow
= (WXWindow
) xwindow
;
147 m_clientWindow
= (WXWindow
) xwindow
;
148 wxAddWindowToTable( xwindow
, (wxWindow
*) this );
150 XMapWindow( xdisplay
, xwindow
);
156 XSetTransientForHint( xdisplay
, (Window
) m_mainWindow
, xparent
);
160 wxSetWMDecorations( (Window
) m_mainWindow
, 0 );
163 wm_hints
.flags
= InputHint
| StateHint
/* | WindowGroupHint */;
164 wm_hints
.input
= True
;
165 wm_hints
.initial_state
= NormalState
;
166 XSetWMHints( xdisplay
, (Window
) m_mainWindow
, &wm_hints
);
172 void wxPopupWindow::DoMoveWindow(int x
, int y
, int width
, int height
)
174 wxWindowX11::DoMoveWindow( x
, y
, width
, height
);
177 void wxPopupWindow::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
179 wxWindowX11::DoSetSize(x
, y
, width
, height
, sizeFlags
);
182 bool wxPopupWindow::Show( bool show
)
184 bool ret
= wxWindowX11::Show( show
);
191 #endif // wxUSE_POPUPWIN