X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2e2a55b22eebde25797bd030660d8c644bc7700b..8e1a5bf979fcdf82238b20cda1209a4f67f394c0:/src/motif/window.cpp diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 57aa52ecd5..88508d610d 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: windows.cpp +// Name: src/motif/windows.cpp // Purpose: wxWindow // Author: Julian Smart // Modified by: @@ -26,22 +26,24 @@ #define XtScreen XTSCREEN #endif -#include "wx/setup.h" -#include "wx/menu.h" -#include "wx/dc.h" -#include "wx/dcclient.h" -#include "wx/utils.h" -#include "wx/app.h" +#ifndef WX_PRECOMP + #include "wx/hash.h" + #include "wx/log.h" + #include "wx/app.h" + #include "wx/utils.h" + #include "wx/frame.h" + #include "wx/dc.h" + #include "wx/dcclient.h" + #include "wx/button.h" + #include "wx/menu.h" + #include "wx/settings.h" +#endif + #include "wx/layout.h" -#include "wx/button.h" -#include "wx/settings.h" -#include "wx/frame.h" #include "wx/scrolwin.h" #include "wx/module.h" #include "wx/menuitem.h" -#include "wx/log.h" #include "wx/evtloop.h" -#include "wx/hash.h" #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" @@ -200,7 +202,7 @@ void wxWindow::Init() m_winCaptured = false; m_isShown = true; - + m_hScrollBar = m_vScrollBar = m_borderWidget = @@ -352,7 +354,7 @@ wxWindow::~wxWindow() { if (g_captureWindow == this) g_captureWindow = NULL; - + m_isBeingDeleted = true; // Motif-specific actions first @@ -632,17 +634,17 @@ void wxWindow::Lower() XLowerWindow(XtDisplay(wTop), window); } -void wxWindow::SetTitle(const wxString& title) +void wxWindow::SetLabel(const wxString& label) { - XtVaSetValues((Widget)GetMainWidget(), XmNtitle, title.c_str(), NULL); + XtVaSetValues((Widget)GetMainWidget(), XmNtitle, label.c_str(), NULL); } -wxString wxWindow::GetTitle() const +wxString wxWindow::GetLabel() const { - char *title; - XtVaGetValues((Widget)GetMainWidget(), XmNtitle, &title, NULL); + char *label; + XtVaGetValues((Widget)GetMainWidget(), XmNtitle, &label, NULL); - return wxString(title); + return wxString(label); } void wxWindow::DoCaptureMouse() @@ -694,7 +696,7 @@ bool wxWindow::SetCursor(const wxCursor& cursor) // wxASSERT_MSG( m_cursor.Ok(), // wxT("cursor must be valid after call to the base version")); - wxCursor* cursor2 = NULL; + const wxCursor* cursor2 = NULL; if (m_cursor.Ok()) cursor2 = & m_cursor; else @@ -747,12 +749,12 @@ int wxWindow::GetScrollPos(int orient) const int wxWindow::GetScrollRange(int orient) const { Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient); - // CE scintilla windows don't always have these scrollbars + // CE scintilla windows don't always have these scrollbars // and it tends to pile up a whole bunch of asserts //wxCHECK_MSG( scrollBar, 0, "no such scrollbar" ); int range = 0; - if (scrollBar) + if (scrollBar) XtVaGetValues(scrollBar, XmNmaximum, &range, NULL); return range; } @@ -852,7 +854,7 @@ void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, // Adjusting scrollbars can resize the canvas accidentally if (newW != oldW || newH != oldH) - SetSize(-1, -1, oldW, oldH); + SetSize(wxDefaultCoord, wxDefaultCoord, oldW, oldH); } // Does a physical scroll @@ -1065,7 +1067,7 @@ void wxWindow::DoSetToolTip(wxToolTip * WXUNUSED(tooltip)) bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) { - if ( x == -1 && y == -1 ) + if ( x == wxDefaultCoord && y == wxDefaultCoord ) { wxPoint mouse = ScreenToClient(wxGetMousePosition()); x = mouse.x; y = mouse.y; @@ -1089,7 +1091,7 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) } menu->SetId(1); /* Mark as popped-up */ - menu->CreateMenu(NULL, widget, menu); + menu->CreateMenu(NULL, widget, menu, 0); menu->SetInvokingWindow(this); menu->UpdateUI(); @@ -1175,7 +1177,7 @@ void wxWindow::DoGetSize(int *x, int *y) const XmNwidth, &xx, XmNheight, &yy, NULL ); - if(x) *x = xx; + if(x) *x = xx; if(y) *y = yy; } @@ -1183,7 +1185,7 @@ void wxWindow::DoGetPosition(int *x, int *y) const { Widget widget = (Widget) ( m_drawingArea ? - ( m_borderWidget ? m_borderWidget : m_scrolledWindow ) : + ( m_borderWidget ? m_borderWidget : m_scrolledWindow ) : GetTopWidget() ); Position xx, yy; @@ -1194,8 +1196,8 @@ void wxWindow::DoGetPosition(int *x, int *y) const if (GetParent()) { wxPoint pt(GetParent()->GetClientAreaOrigin()); - xx -= pt.x; - yy -= pt.y; + xx = (Position)(xx - pt.x); + yy = (Position)(yy - pt.y); } if(x) *x = xx; @@ -1248,6 +1250,7 @@ void wxWindow::DoSetSizeIntr(int x, int y, int width, int height, { // A bit of optimization to help sort out the flickers. int oldX = -1, oldY = -1, oldW = -1, oldH = -1; + if( !fromCtor ) { GetSize(& oldW, & oldH); @@ -1262,7 +1265,7 @@ void wxWindow::DoSetSizeIntr(int x, int y, int width, int height, y = oldY; } - wxSize size(-1, -1); + wxSize size(wxDefaultSize); if ( width <= 0 ) { if ( ( sizeFlags & wxSIZE_AUTO_WIDTH ) && !fromCtor ) @@ -1455,7 +1458,7 @@ int wxWindow::GetCharHeight() const wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); int height; - + wxGetTextExtent (GetXDisplay(), m_font, 1.0, "x", NULL, &height, NULL, NULL); @@ -1467,7 +1470,7 @@ int wxWindow::GetCharWidth() const wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); int width; - + wxGetTextExtent (GetXDisplay(), m_font, 1.0, "x", &width, NULL, NULL, NULL); @@ -1894,9 +1897,8 @@ void wxWidgetResizeProc(Widget w, XConfigureEvent *WXUNUSED(event), if (win->PreResize()) { - int width, height; - win->GetSize(&width, &height); - wxSizeEvent sizeEvent(wxSize(width, height), win->GetId()); + wxSize newSize(win->GetSize()); + wxSizeEvent sizeEvent(newSize, win->GetId()); sizeEvent.SetEventObject(win); win->GetEventHandler()->ProcessEvent(sizeEvent); } @@ -2315,10 +2317,10 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, || (event_right_is_down (xevent) && (eventType != wxEVT_RIGHT_UP))); - wxevent.m_shiftDown = xevent->xbutton.state & ShiftMask; - wxevent.m_controlDown = xevent->xbutton.state & ControlMask; - wxevent.m_altDown = xevent->xbutton.state & Mod3Mask; - wxevent.m_metaDown = xevent->xbutton.state & Mod1Mask; + wxevent.m_shiftDown = (xevent->xbutton.state & ShiftMask) == ShiftMask; + wxevent.m_controlDown = (xevent->xbutton.state & ControlMask) == ControlMask; + wxevent.m_altDown = (xevent->xbutton.state & Mod3Mask) == Mod3Mask; + wxevent.m_metaDown = (xevent->xbutton.state & Mod1Mask) == Mod1Mask; wxevent.SetId(win->GetId()); wxevent.SetEventObject(win); @@ -2364,9 +2366,8 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, if (id > -1) return true; - else - return false; - break; + + return false; } default: break; @@ -2380,7 +2381,7 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, #define YAllocColor XAllocColor XColor g_itemColors[5]; -int wxComputeColours (Display *display, wxColour * back, wxColour * fore) +int wxComputeColours (Display *display, const wxColour * back, const wxColour * fore) { int result; static XmColorProc colorProc; @@ -2389,9 +2390,9 @@ int wxComputeColours (Display *display, wxColour * back, wxColour * fore) if (back) { - g_itemColors[0].red = (((long) back->Red ()) << 8); - g_itemColors[0].green = (((long) back->Green ()) << 8); - g_itemColors[0].blue = (((long) back->Blue ()) << 8); + g_itemColors[0].red = (unsigned short)(((long) back->Red ()) << 8); + g_itemColors[0].green = (unsigned short)(((long) back->Green ()) << 8); + g_itemColors[0].blue = (unsigned short)(((long) back->Blue ()) << 8); g_itemColors[0].flags = DoRed | DoGreen | DoBlue; if (colorProc == (XmColorProc) NULL) { @@ -2409,9 +2410,9 @@ int wxComputeColours (Display *display, wxColour * back, wxColour * fore) } if (fore) { - g_itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8); - g_itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8); - g_itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8); + g_itemColors[wxFORE_INDEX].red = (unsigned short)(((long) fore->Red ()) << 8); + g_itemColors[wxFORE_INDEX].green = (unsigned short)(((long) fore->Green ()) << 8); + g_itemColors[wxFORE_INDEX].blue = (unsigned short)(((long) fore->Blue ()) << 8); g_itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue; if (result == wxNO_COLORS) result = wxFORE_COLORS; @@ -2494,7 +2495,7 @@ void wxWindow::ChangeFont(bool keepOriginalSize) GetSize(& width1, & height1); if (keepOriginalSize && (width != width1 || height != height1)) { - SetSize(-1, -1, width, height); + SetSize(wxDefaultCoord, wxDefaultCoord, width, height); } } } @@ -2548,4 +2549,3 @@ wxPoint wxGetMousePosition() // ---------------------------------------------------------------------------- int wxNoOptimize::ms_count = 0; -