]> git.saurik.com Git - wxWidgets.git/blame - src/msw/statbox.cpp
Fix assorted typos in comments and other non-code.
[wxWidgets.git] / src / msw / statbox.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
f38924e8 2// Name: src/msw/statbox.cpp
2bda0e17
KB
3// Purpose: wxStaticBox
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
6c9a19aa 7// Copyright: (c) Julian Smart
65571936 8// Licence: wxWindows licence
2bda0e17
KB
9/////////////////////////////////////////////////////////////////////////////
10
3f2711d5
VZ
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
2bda0e17
KB
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
3f2711d5 23 #pragma hdrstop
2bda0e17
KB
24#endif
25
1e6feb95
VZ
26#if wxUSE_STATBOX
27
f38924e8
WS
28#include "wx/statbox.h"
29
2bda0e17 30#ifndef WX_PRECOMP
3f2711d5
VZ
31 #include "wx/app.h"
32 #include "wx/dcclient.h"
f38924e8 33 #include "wx/dcmemory.h"
155ecd4c 34 #include "wx/image.h"
18717b27 35 #include "wx/sizer.h"
2bda0e17
KB
36#endif
37
3ad70d31 38#include "wx/notebook.h"
9dabade2 39#include "wx/sysopt.h"
2bda0e17 40
72a55896 41#include "wx/msw/uxtheme.h"
3f2711d5 42#include "wx/msw/private.h"
7212d155 43#include "wx/msw/missing.h"
74052fe8 44#include "wx/msw/dc.h"
3f2711d5 45
95fab76b
VZ
46// the values coincide with those in tmschema.h
47#define BP_GROUPBOX 4
48
49#define GBS_NORMAL 1
50
51#define TMT_FONT 210
52
3f2711d5
VZ
53// ----------------------------------------------------------------------------
54// wxWin macros
55// ----------------------------------------------------------------------------
56
3f2711d5
VZ
57// ============================================================================
58// implementation
59// ============================================================================
60
61// ----------------------------------------------------------------------------
62// wxStaticBox
63// ----------------------------------------------------------------------------
64
65bool wxStaticBox::Create(wxWindow *parent,
66 wxWindowID id,
67 const wxString& label,
68 const wxPoint& pos,
69 const wxSize& size,
70 long style,
71 const wxString& name)
2bda0e17 72{
11b6a93b 73 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
57f4f925 74 return false;
2bda0e17 75
e31e6ea7 76 if ( !MSWCreateControl(wxT("BUTTON"), label, pos, size) )
57f4f925 77 return false;
2bda0e17 78
cf072997
VZ
79 // Always use LTR layout. Otherwise, the label would be mirrored.
80 SetLayoutDirection(wxLayout_LeftToRight);
81
9f769708 82#ifndef __WXWINCE__
5bf4788a 83 if (!wxSystemOptions::IsFalse(wxT("msw.staticbox.optimized-paint")))
5fff51b5 84 {
5bf4788a 85 Connect(wxEVT_PAINT, wxPaintEventHandler(wxStaticBox::OnPaint));
5fff51b5
VZ
86
87 // Our OnPaint() completely erases our background, so don't do it in
88 // WM_ERASEBKGND too to avoid flicker.
89 SetBackgroundStyle(wxBG_STYLE_PAINT);
90 }
c3732409 91#endif // !__WXWINCE__
3b6e5fb3 92
57f4f925 93 return true;
2bda0e17
KB
94}
95
e31e6ea7
VZ
96WXDWORD wxStaticBox::MSWGetStyle(long style, WXDWORD *exstyle) const
97{
98 long styleWin = wxStaticBoxBase::MSWGetStyle(style, exstyle);
99
eba99da4
JS
100 // no need for it anymore, must be removed for wxRadioBox child
101 // buttons to be able to repaint themselves
102 styleWin &= ~WS_CLIPCHILDREN;
103
e31e6ea7 104 if ( exstyle )
5bf4788a 105 {
a92e7f30 106#ifndef __WXWINCE__
4ea36674
VZ
107 // We may have children inside this static box, so use this style for
108 // TAB navigation to work if we ever use IsDialogMessage() to implement
109 // it (currently we don't because it's too buggy and implement TAB
110 // navigation ourselves, but this could change in the future).
111 *exstyle |= WS_EX_CONTROLPARENT;
112
5bf4788a 113 if (wxSystemOptions::IsFalse(wxT("msw.staticbox.optimized-paint")))
4ea36674 114 *exstyle |= WS_EX_TRANSPARENT;
a92e7f30 115#endif
5bf4788a 116 }
a83b5b74 117
cf072997
VZ
118 styleWin |= BS_GROUPBOX;
119
120 if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft )
121 {
122 // Make sure label is on the right
123 styleWin |= BS_RIGHT;
124 }
125
126 return styleWin;
e31e6ea7
VZ
127}
128
f68586e5 129wxSize wxStaticBox::DoGetBestSize() const
2bda0e17 130{
d18eb918
RD
131 wxSize best;
132
133 // Calculate the size needed by the label
4438caf4 134 int cx, cy;
7a5e53ab 135 wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
2bda0e17 136
4438caf4 137 int wBox;
32cd189d 138 GetTextExtent(GetLabelText(wxGetWindowText(m_hWnd)), &wBox, &cy);
2bda0e17 139
4438caf4
VZ
140 wBox += 3*cx;
141 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
2bda0e17 142
d18eb918
RD
143 // If there is a sizer then the base best size is the sizer's minimum
144 if (GetSizer() != NULL)
145 {
146 wxSize cm(GetSizer()->CalcMin());
147 best = ClientToWindowSize(cm);
148 // adjust for a long label if needed
149 best.x = wxMax(best.x, wBox);
150 }
151 // otherwise the best size falls back to the label size
152 else
153 {
154 best = wxSize(wBox, hBox);
155 }
31582e4e 156 return best;
4438caf4 157}
2bda0e17 158
c3732409 159void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
6aa01033 160{
c3732409
VZ
161 wxStaticBoxBase::GetBordersForSizer(borderTop, borderOther);
162
163 // need extra space, don't know how much but this seems to be enough
164 *borderTop += GetCharHeight()/3;
165}
166
167// all the hacks below are not necessary for WinCE
abf912c5 168#ifndef __WXWINCE__
c3732409
VZ
169
170WXLRESULT wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
171{
58385af0 172 if ( nMsg == WM_NCHITTEST )
6aa01033 173 {
58385af0
VZ
174 // This code breaks some other processing such as enter/leave tracking
175 // so it's off by default.
176
177 static int s_useHTClient = -1;
178 if (s_useHTClient == -1)
179 s_useHTClient = wxSystemOptions::GetOptionInt(wxT("msw.staticbox.htclient"));
180 if (s_useHTClient == 1)
181 {
c3732409
VZ
182 int xPos = GET_X_LPARAM(lParam);
183 int yPos = GET_Y_LPARAM(lParam);
58385af0
VZ
184
185 ScreenToClient(&xPos, &yPos);
186
187 // Make sure you can drag by the top of the groupbox, but let
188 // other (enclosed) controls get mouse events also
189 if ( yPos < 10 )
190 return (long)HTCLIENT;
191 }
6aa01033
JS
192 }
193
9705fbe9
VZ
194 if ( nMsg == WM_PRINTCLIENT )
195 {
196 // we have to process WM_PRINTCLIENT ourselves as otherwise child
197 // windows' background (eg buttons in radio box) would never be drawn
198 // unless we have a parent with non default background
199
200 // so check first if we have one
201 if ( !HandlePrintClient((WXHDC)wParam) )
202 {
203 // no, we don't, erase the background ourselves
204 // (don't use our own) - see PaintBackground for explanation
205 wxBrush brush(GetParent()->GetBackgroundColour());
206 wxFillRect(GetHwnd(), (HDC)wParam, GetHbrushOf(brush));
207 }
208
209 return 0;
210 }
211
2af006eb
VZ
212 if ( nMsg == WM_UPDATEUISTATE )
213 {
214 // DefWindowProc() redraws just the static box text when it gets this
215 // message and it does it using the standard (blue in standard theme)
216 // colour and not our own label colour that we use in PaintForeground()
217 // resulting in the label mysteriously changing the colour when e.g.
218 // "Alt" is pressed anywhere in the window, see #12497.
219 //
220 // To avoid this we simply refresh the window forcing our own code
221 // redrawing the label in the correct colour to be called. This is
222 // inefficient but there doesn't seem to be anything else we can do.
223 //
224 // Notice that the problem is XP-specific and doesn't arise under later
225 // systems.
226 if ( m_hasFgCol && wxGetWinVersion() == wxWinVersion_XP )
227 Refresh();
228 }
229
6aa01033
JS
230 return wxControl::MSWWindowProc(nMsg, wParam, lParam);
231}
232
c3732409
VZ
233// ----------------------------------------------------------------------------
234// static box drawing
235// ----------------------------------------------------------------------------
58385af0 236
c3732409
VZ
237/*
238 We draw the static box ourselves because it's the only way to prevent it
239 from flickering horribly on resize (because everything inside the box is
240 erased twice: once when the box itself is repainted and second time when
241 the control inside it is repainted) without using WS_EX_TRANSPARENT style as
242 we used to do and which resulted in other problems.
243 */
58385af0 244
3b6e5fb3
VZ
245// MSWGetRegionWithoutSelf helper: removes the given rectangle from region
246static inline void
247SubtractRectFromRgn(HRGN hrgn, int left, int top, int right, int bottom)
248{
249 AutoHRGN hrgnRect(::CreateRectRgn(left, top, right, bottom));
250 if ( !hrgnRect )
251 {
9a83f860 252 wxLogLastError(wxT("CreateRectRgn()"));
3b6e5fb3
VZ
253 return;
254 }
255
256 ::CombineRgn(hrgn, hrgn, hrgnRect, RGN_DIFF);
257}
258
259void wxStaticBox::MSWGetRegionWithoutSelf(WXHRGN hRgn, int w, int h)
eba99da4 260{
3b6e5fb3
VZ
261 HRGN hrgn = (HRGN)hRgn;
262
263 // remove the area occupied by the static box borders from the region
264 int borderTop, border;
265 GetBordersForSizer(&borderTop, &border);
eba99da4
JS
266
267 // top
3b6e5fb3 268 SubtractRectFromRgn(hrgn, 0, 0, w, borderTop);
eba99da4
JS
269
270 // bottom
3b6e5fb3 271 SubtractRectFromRgn(hrgn, 0, h - border, w, h);
eba99da4
JS
272
273 // left
3b6e5fb3 274 SubtractRectFromRgn(hrgn, 0, 0, border, h);
eba99da4
JS
275
276 // right
3b6e5fb3 277 SubtractRectFromRgn(hrgn, w - border, 0, w, h);
eba99da4
JS
278}
279
3b6e5fb3 280WXHRGN wxStaticBox::MSWGetRegionWithoutChildren()
eba99da4
JS
281{
282 RECT rc;
283 ::GetWindowRect(GetHwnd(), &rc);
284 HRGN hrgn = ::CreateRectRgn(rc.left, rc.top, rc.right + 1, rc.bottom + 1);
cec46079 285 bool foundThis = false;
3b6e5fb3 286
5fff51b5
VZ
287 // Iterate over all sibling windows as in the old wxWidgets API the
288 // controls appearing inside the static box were created as its siblings
289 // and not children. This is now deprecated but should still work.
290 //
291 // Also notice that we must iterate over all windows, not just all
292 // wxWindows, as there may be composite windows etc.
293 HWND child;
294 for ( child = ::GetWindow(GetHwndOf(GetParent()), GW_CHILD);
3b6e5fb3
VZ
295 child;
296 child = ::GetWindow(child, GW_HWNDNEXT) )
eba99da4 297 {
4249e334
RD
298 if ( ! ::IsWindowVisible(child) )
299 {
300 // if the window isn't visible then it doesn't need clipped
301 continue;
302 }
9705fbe9 303
4249e334
RD
304 LONG style = ::GetWindowLong(child, GWL_STYLE);
305 wxString str(wxGetWindowClass(child));
306 str.UpperCase();
5c17f6d3 307 if ( str == wxT("BUTTON") && (style & BS_GROUPBOX) == BS_GROUPBOX )
eba99da4 308 {
cec46079
JS
309 if ( child == GetHwnd() )
310 foundThis = true;
311
312 // Any static boxes below this one in the Z-order can't be clipped
313 // since if we have the case where a static box with a low Z-order
314 // is nested inside another static box with a high Z-order then the
315 // nested static box would be painted over. Doing it this way
316 // unfortunately results in flicker if the Z-order of nested static
317 // boxes is not inside (lowest) to outside (highest) but at least
318 // they are still shown.
319 if ( foundThis )
320 continue;
4249e334 321 }
9705fbe9 322
4249e334
RD
323 ::GetWindowRect(child, &rc);
324 if ( ::RectInRegion(hrgn, &rc) )
325 {
326 // need to remove WS_CLIPSIBLINGS from all sibling windows
327 // that are within this staticbox if set
328 if ( style & WS_CLIPSIBLINGS )
eba99da4 329 {
4249e334
RD
330 style &= ~WS_CLIPSIBLINGS;
331 ::SetWindowLong(child, GWL_STYLE, style);
9705fbe9 332
4249e334
RD
333 // MSDN: "If you have changed certain window data using
334 // SetWindowLong, you must call SetWindowPos to have the
335 // changes take effect."
336 ::SetWindowPos(child, NULL, 0, 0, 0, 0,
337 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
338 SWP_FRAMECHANGED);
eba99da4 339 }
4249e334
RD
340
341 AutoHRGN hrgnChild(::CreateRectRgnIndirect(&rc));
342 ::CombineRgn(hrgn, hrgn, hrgnChild, RGN_DIFF);
eba99da4 343 }
eba99da4 344 }
eba99da4 345
5fff51b5
VZ
346 // Also iterate over all children of the static box, we need to clip them
347 // out as well.
348 for ( child = ::GetWindow(GetHwnd(), GW_CHILD);
349 child;
350 child = ::GetWindow(child, GW_HWNDNEXT) )
351 {
352 if ( !::IsWindowVisible(child) )
353 {
354 // if the window isn't visible then it doesn't need clipped
355 continue;
356 }
357
358 ::GetWindowRect(child, &rc);
359 AutoHRGN hrgnChild(::CreateRectRgnIndirect(&rc));
360 ::CombineRgn(hrgn, hrgn, hrgnChild, RGN_DIFF);
361 }
362
3b6e5fb3
VZ
363 return (WXHRGN)hrgn;
364}
365
c3732409
VZ
366// helper for OnPaint(): really erase the background, i.e. do it even if we
367// don't have any non default brush for doing it (DoEraseBackground() doesn't
368// do anything in such case)
3b6e5fb3
VZ
369void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc)
370{
c3732409
VZ
371 // note that we do not use the box background colour here, it shouldn't
372 // apply to its interior for several reasons:
373 // 1. wxGTK doesn't do it
374 // 2. controls inside the box don't get correct bg colour because they
375 // are not our children so we'd have some really ugly colour mix if
376 // we did it
377 // 3. this is backwards compatible behaviour and some people rely on it,
378 // see http://groups.google.com/groups?selm=4252E932.3080801%40able.es
888dde65 379 wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
ebfee179 380 HBRUSH hbr = MSWGetBgBrush(impl->GetHDC());
c3732409
VZ
381
382 // if there is no special brush for painting this control, just use the
383 // solid background colour
384 wxBrush brush;
3b6e5fb3
VZ
385 if ( !hbr )
386 {
ebfee179 387 brush = wxBrush(GetParent()->GetBackgroundColour());
c3732409 388 hbr = GetHbrushOf(brush);
3b6e5fb3
VZ
389 }
390
888dde65 391 ::FillRect(GetHdcOf(*impl), &rc, hbr);
eba99da4
JS
392}
393
cf072997 394void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc)
21c6080d 395{
888dde65
RR
396 wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
397 MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(*impl), 0);
72a55896 398
ed72e195 399#if wxUSE_UXTHEME
72a55896
VZ
400 // when using XP themes, neither setting the text colour nor transparent
401 // background mode doesn't change anything: the static box def window proc
402 // still draws the label in its own colours, so we need to redraw the text
403 // ourselves if we have a non default fg colour
95fab76b 404 if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() )
72a55896
VZ
405 {
406 // draw over the text in default colour in our colour
888dde65 407 HDC hdc = GetHdcOf(*impl);
95fab76b 408 ::SetTextColor(hdc, GetForegroundColour().GetPixel());
cf072997
VZ
409
410 const bool rtl = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft;
411 if ( rtl )
412 ::SetTextAlign(hdc, TA_RTLREADING | TA_RIGHT);
413
414 // Get dimensions of the label
24e35cf8 415 const wxString label = GetLabel();
24e35cf8 416
95fab76b
VZ
417 // choose the correct font
418 AutoHFONT font;
419 SelectInHDC selFont;
420 if ( m_hasFont )
421 {
422 selFont.Init(hdc, GetHfontOf(GetFont()));
423 }
424 else // no font set, use the one set by the theme
425 {
426 wxUxThemeHandle hTheme(this, L"BUTTON");
427 if ( hTheme )
428 {
3120eccf 429 wxUxThemeFont themeFont;
95fab76b
VZ
430 if ( wxUxThemeEngine::Get()->GetThemeFont
431 (
432 hTheme,
433 hdc,
434 BP_GROUPBOX,
435 GBS_NORMAL,
436 TMT_FONT,
3120eccf 437 themeFont.GetPtr()
95fab76b
VZ
438 ) == S_OK )
439 {
3120eccf 440 font.Init(themeFont.GetLOGFONT());
95fab76b
VZ
441 if ( font )
442 selFont.Init(hdc, font);
443 }
444 }
445 }
446
441dfa1d
VZ
447 // Get the font extent
448 int width, height;
449 dc.GetTextExtent(wxStripMenuCodes(label, wxStrip_Mnemonics),
450 &width, &height);
451
452 int x;
453 int y = height;
454
455 // first we need to correctly paint the background of the label
456 // as Windows ignores the brush offset when doing it
457 //
458 // FIXME: value of x is hardcoded as this is what it is on my system,
459 // no idea if it's true everywhere
460 RECT dimensions = {0, 0, 0, y};
461 if ( !rtl )
462 {
463 x = 9;
464 dimensions.left = x;
465 dimensions.right = x + width;
466 }
467 else
468 {
469 x = rc.right - 7;
470 dimensions.left = x - width;
471 dimensions.right = x;
472 }
473
474 // need to adjust the rectangle to cover all the label background
475 dimensions.left -= 2;
476 dimensions.right += 2;
477 dimensions.bottom += 2;
478
b8ec69e8
VZ
479 if ( UseBgCol() )
480 {
481 // our own background colour should be used for the background of
482 // the label: this is consistent with the behaviour under pre-XP
483 // systems (i.e. without visual themes) and generally makes sense
484 wxBrush brush = wxBrush(GetBackgroundColour());
888dde65
RR
485 wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
486 ::FillRect(GetHdcOf(*impl), &dimensions, GetHbrushOf(brush));
b8ec69e8
VZ
487 }
488 else // paint parent background
489 {
490 PaintBackground(dc, dimensions);
491 }
441dfa1d 492
b4607e89
VZ
493 UINT drawTextFlags = DT_SINGLELINE | DT_VCENTER;
494
495 // determine the state of UI queues to draw the text correctly under XP
496 // and later systems
497 static const bool isXPorLater = wxGetWinVersion() >= wxWinVersion_XP;
498 if ( isXPorLater )
499 {
500 if ( ::SendMessage(GetHwnd(), WM_QUERYUISTATE, 0, 0) &
501 UISF_HIDEACCEL )
502 {
503 drawTextFlags |= DT_HIDEPREFIX;
504 }
505 }
506
24e35cf8 507 // now draw the text
cf072997
VZ
508 if ( !rtl )
509 {
ffabb347 510 RECT rc2 = { x, 0, x + width, y };
017dc06b 511 ::DrawText(hdc, label.t_str(), label.length(), &rc2,
b4607e89 512 drawTextFlags);
cf072997
VZ
513 }
514 else // RTL
515 {
516 RECT rc2 = { x, 0, x - width, y };
017dc06b 517 ::DrawText(hdc, label.t_str(), label.length(), &rc2,
b4607e89 518 drawTextFlags | DT_RTLREADING);
cf072997 519 }
72a55896 520 }
ed72e195 521#endif // wxUSE_UXTHEME
21c6080d
JS
522}
523
eba99da4
JS
524void wxStaticBox::OnPaint(wxPaintEvent& WXUNUSED(event))
525{
eba99da4
JS
526 RECT rc;
527 ::GetClientRect(GetHwnd(), &rc);
528
c3732409 529 // draw the entire box in a memory DC
eba99da4
JS
530 wxMemoryDC memdc;
531 wxBitmap bitmap(rc.right, rc.bottom);
532 memdc.SelectObject(bitmap);
533
3b6e5fb3 534 PaintBackground(memdc, rc);
21c6080d 535 PaintForeground(memdc, rc);
c3732409
VZ
536
537 // now only blit the static box border itself, not the interior, to avoid
538 // flicker when background is drawn below
539 //
540 // note that it seems to be faster to do 4 small blits here and then paint
541 // directly into wxPaintDC than painting background in wxMemoryDC and then
542 // blitting everything at once to wxPaintDC, this is why we do it like this
543 wxPaintDC dc(this);
3b6e5fb3
VZ
544 int borderTop, border;
545 GetBordersForSizer(&borderTop, &border);
546
eba99da4 547 // top
3b6e5fb3
VZ
548 dc.Blit(border, 0, rc.right - border, borderTop,
549 &memdc, border, 0);
eba99da4 550 // bottom
1d1b4862 551 dc.Blit(border, rc.bottom - border, rc.right - border, border,
3b6e5fb3 552 &memdc, border, rc.bottom - border);
eba99da4 553 // left
3b6e5fb3
VZ
554 dc.Blit(0, 0, border, rc.bottom,
555 &memdc, 0, 0);
1d1b4862
VZ
556 // right (note that upper and bottom right corners were already part of the
557 // first two blits so we shouldn't overwrite them here to avoi flicker)
558 dc.Blit(rc.right - border, borderTop,
559 border, rc.bottom - borderTop - border,
560 &memdc, rc.right - border, borderTop);
eba99da4 561
c3732409
VZ
562
563 // create the region excluding box children
3b6e5fb3
VZ
564 AutoHRGN hrgn((HRGN)MSWGetRegionWithoutChildren());
565 RECT rcWin;
566 ::GetWindowRect(GetHwnd(), &rcWin);
567 ::OffsetRgn(hrgn, -rcWin.left, -rcWin.top);
eba99da4 568
c3732409 569 // and also the box itself
3b6e5fb3 570 MSWGetRegionWithoutSelf((WXHRGN) hrgn, rc.right, rc.bottom);
888dde65
RR
571 wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
572 HDCClipper clipToBg(GetHdcOf(*impl), hrgn);
3b6e5fb3 573
c3732409 574 // paint the inside of the box (excluding box itself and child controls)
3b6e5fb3 575 PaintBackground(dc, rc);
eba99da4
JS
576}
577
c3732409
VZ
578#endif // !__WXWINCE__
579
1e6feb95 580#endif // wxUSE_STATBOX