コード例 #1
0
ファイル: WindowProc.cpp プロジェクト: ElusiveMind/ballistic
long XGAppCore::ProcKeyboardCommon(UINT msg, WPARAM wp, LPARAM lp)
{
    short mods;
    short c;

    switch (msg) {
    case WM_KEYDOWN:
        mods = GetStateFlags();
        c = GetExtendedKeyCode(wp,lp);
        if (c != -1) {
            mods |= KSpecialKey;
            XGDispatch::SendDispatch(KXGKeyEvent,MAKEDWORD(mods,c),NULL);
            return 0;			// always marked 'handled.'
        } else {
            if (wp == VK_TAB) {
                XGDispatch::SendDispatch(KXGKeyEvent,MAKEDWORD(mods,c),NULL);
                return 0;
            }
        }
        return -1;
    case WM_CHAR:
        mods = GetStateFlags();
        return XGDispatch::SendDispatch(KXGKeyEvent,MAKEDWORD(mods,wp),NULL);
    case WM_SYSCHAR:
        mods = GetStateFlags();
        return XGDispatch::SendDispatch(KXGMenuKey,MAKEDWORD(mods,wp),NULL);
    default:
        return -1;
    }
}
コード例 #2
0
ファイル: winuniv.cpp プロジェクト: iokto/newton-dynamics
void wxWindow::DoDrawBorder(wxDC& dc, const wxRect& rect)
{
    // draw outline unless the update region is enitrely inside it in which
    // case we don't need to do it
#if 0 // doesn't seem to work, why?
    if ( wxRegion(rect).Contains(GetUpdateRegion().GetBox()) != wxInRegion )
#endif
    {
        m_renderer->DrawBorder(dc, GetBorder(), rect, GetStateFlags());
    }
}
コード例 #3
0
ファイル: winuniv.cpp プロジェクト: iokto/newton-dynamics
void wxWindow::EraseBackground(wxDC& dc, const wxRect& rect)
{
    if ( GetBackgroundBitmap().IsOk() )
    {
        // Get the bitmap and the flags
        int alignment;
        wxStretch stretch;
        wxBitmap bmp = GetBackgroundBitmap(&alignment, &stretch);
        wxControlRenderer::DrawBitmap(dc, bmp, rect, alignment, stretch);
    }
    else
    {
        // Just fill it with bg colour if no bitmap

        m_renderer->DrawBackground(dc, wxTHEME_BG_COLOUR(this),
                                   rect, GetStateFlags());
    }
}
コード例 #4
0
bool wxButton::DoDrawBackground(wxDC& dc)
{
    wxRect rect;
    wxSize size = GetSize();
    rect.width = size.x;
    rect.height = size.y;

    if ( GetBackgroundBitmap().Ok() )
    {
        // get the bitmap and the flags
        int alignment;
        wxStretch stretch;
        wxBitmap bmp = GetBackgroundBitmap(&alignment, &stretch);
        wxControlRenderer::DrawBitmap(dc, bmp, rect, alignment, stretch);
    }
    else
    {
        m_renderer->DrawButtonSurface(dc, wxTHEME_BG_COLOUR(this),
                                      rect, GetStateFlags());
    }

    return true;
}
コード例 #5
0
ファイル: WindowProc.cpp プロジェクト: ElusiveMind/ballistic
long XGAppCore::ProcXGWindowCommon(XGWindow *tw, UINT msg, WPARAM wp, LPARAM lp)
{
    MINMAXINFO *mm;
    Point pt;
    static short gMods;
    PAINTSTRUCT ps;
    HWND control;

    switch (msg) {
    /*	WM_DESTROY
     *
     *		Destruction. There are two ways a window can
     *	be destroyed--either through the destructor of the
     *	XGWindow pointer, or through calling the WM_DESTROY
     *	message. This handles both cases by assuming the
     *	destruction happens in the XGWindow destructor.
     *
     *		By doing it this way, we don't care how in what
     *	order things are
     */

    case WM_DESTROY:
        if (tw) {
            /*
             *	If this is non-NULL, we're still associated with
             *	the window. (_GWindow is only set during
             *	construction.)
             */

            tw->fWindow = NULL;
            delete tw;
        }
        return 0;

    /*	WM_GETMINMAXINFO
     *
     *		Get the min/max info for this thing. The construction
     *	order of my window allows me to handle this call even
     *	though WM_CREATE hasn't been called yet...
     */

    case WM_GETMINMAXINFO:
        mm = (MINMAXINFO *)lp;
        if (tw) {
            pt = tw->MinWindowSize();
            XGWindow::ContentToSize(&pt);
            if (pt.h > 0) mm->ptMinTrackSize.x = pt.h;
            if (pt.v > 0) mm->ptMinTrackSize.y = pt.v;
            pt = tw->MaxWindowSize();
            XGWindow::ContentToSize(&pt);
            if (pt.h > 0) mm->ptMaxTrackSize.x = pt.h;
            if (pt.v > 0) mm->ptMaxTrackSize.y = pt.v;
            pt = tw->ZoomWindowSize();
            XGWindow::ContentToSize(&pt);
            if (pt.h > 0) mm->ptMaxSize.x = pt.h;
            if (pt.v > 0) mm->ptMaxSize.y = pt.v;
        } else {
            mm->ptMinTrackSize.x = 150;
            mm->ptMinTrackSize.y = 100;
        }
        return -1;

    /*	WM_SIZE
     *
     *		Handle the reisze
     */

    case WM_SIZE:
        XGInline::Close();
        if (!::IsIconic(tw->GetHWND())) {
            if ((tw != _GWindow) && tw && tw->fWindow) {
                tw->ProcessSizeWindow();
            }
        }
        return -1;				// -1 indicates passing message through

    /*	WM_CTLCOLORBTN
     *
     *		This returns the face color, making sure that the
     *	background of a button matches the background of a dialog box
     */

    case WM_CTLCOLORBTN:
        ::SetBkColor((HDC)wp,::GetSysColor(COLOR_BTNFACE));
        return (long)::GetSysColorBrush(COLOR_BTNFACE);

    /*	WM_NCACTIVATE
     *
     *		Handle activation/deactivation
     */

    case WM_NCACTIVATE:
        if (!wp) {
            if (XGPopWindow::GetPopCount()) {
                return FALSE;
            }
        }
        return -1;

    /*	WM_LBUTTONDOWN et al
     *
     *		Mouse click processing
     */

    case WM_LBUTTONDBLCLK:
    case WM_RBUTTONDBLCLK:
    case WM_MBUTTONDBLCLK:
    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
    case WM_MBUTTONDOWN:
        if (tw->GetHWND() == GetCapture()) return 0;

        gMods = GetStateFlags();
        if ((msg == WM_LBUTTONDBLCLK) ||
                (msg == WM_RBUTTONDBLCLK) ||
                (msg == WM_MBUTTONDBLCLK))
            gMods |= KDoubleClick;

        pt.h = LOWORD(lp);
        pt.v = HIWORD(lp);
        if (tw) {
            if (NULL != (XGAppCore::gCaptureView = tw->ProcessMouseDown(pt,gMods))) {
                ::SetCapture(tw->GetHWND());
            }
        }
        return 0;

    /*	WM_MOUSEMOVE:
     *
     *		Handle mouse move events
     */

    case WM_MOUSEMOVE:
        if (tw->GetHWND() == ::GetCapture()) {
            gMods |= KCapturedMouse;
        } else {
            gMods = GetStateFlags();
            XGAppCore::gCaptureView = NULL;
        }

        if (tw) {
            pt.h = LOWORD(lp);
            pt.v = HIWORD(lp);
            tw->ProcessMouseMove(pt,gMods,XGAppCore::gCaptureView);
        }
        return 0;

    /*	WM_LBUTTONUP et al
     *
     *		The mouse up event
     */

    case WM_LBUTTONUP:
    case WM_MBUTTONUP:
    case WM_RBUTTONUP:
        if (tw->GetHWND() == ::GetCapture()) {
            gMods |= KCapturedMouse;
            pt.h = LOWORD(lp);
            pt.v = HIWORD(lp);
            ::ReleaseCapture();
            if (tw->ProcessMouseUp(pt,gMods,XGAppCore::gCaptureView)) {
                // get capture back
                ::SetCapture(tw->GetHWND());
            }
        }
        return 0;

    case WM_ERASEBKGND:
        return TRUE;				// don't erase background...

    /*	WM_PAINT
     *
     *		Handle display update
     */

    case WM_PAINT:
        if (::IsIconic(tw->GetHWND())) {
            return -1;
        } else {
            /*
             *	Draw the contents
             */

            ::BeginPaint(tw->GetHWND(),&ps);
            if (tw) {
                XGDraw::UpdateRect(&ps.rcPaint);
                tw->ProcessDraw(ps.rcPaint);
                XGDraw::UpdateRect();
            }
            ::EndPaint(tw->GetHWND(),&ps);
        }
        return 0;

    /*	WM_COMMAND
     *
     *		Menu processing
     */

    case WM_COMMAND:
        control = (HWND)lp;
        if (control) {
            /*
             *	This is a control message. Simply package the
             *	message and punt it up to the owner view
             */

            XGView *v;

            v = (XGView *)::GetProp(control,_GControlClass);
            if (v) {
                XGSWInternalRecord i;

                i.w = tw->GetHWND();
                i.msg = msg;
                i.wp = wp;
                i.lp = lp;
                return v->DoDispatch(KXGWInternal,0,(void *)&i);
            }
        } else {
            /*
             *	Menu dispatch
             */

            XGMenuBar *m;

            m = XGAppCore::GetApplication()->GetCurMenu();
            if (!m->MenuCommand(LOWORD(wp))) return -1;
        }
        return 0;

    /*	WM_HSCROLL, WM_VSCROLL
     *
     *		Handle scroll bar manipulation
     */

    case WM_HSCROLL:
    case WM_VSCROLL:
        control = (HWND)lp;
        if (control) {
            XGView *v;

            v = (XGView *)::GetProp(control,_GControlClass);
            if (v) {
                XGSWInternalRecord i;

                i.w = tw->GetHWND();
                i.msg = msg;
                i.wp = wp;
                i.lp = lp;
                return v->DoDispatch(KXGWInternal,0,(void *)&i);
            }
        }
        return 0;

    default:
        return -1;
    }
}