예제 #1
0
bool CWinGlkWndTextGrid::MouseClick(CPoint& Click)
{
  // First check if the mouse is over a hyperlink
  if (m_bLinksActive)
  {
    unsigned int iLink = GetLinkAtPoint(Click);
    if (iLink != 0)
    {
      ((CGlkApp*)AfxGetApp())->AddEvent(evtype_Hyperlink,(winid_t)this,iLink,0);
      m_bLinksActive = false;
      return true;
    }
  }

  // Now check if a mouse event is requested
  if (m_bMouseActive)
  {
    CWinGlkGridDC dc(this,GetStyle(style_Normal)->m_Size);
    CDC* pWndDC = GetDC();
    dc.Attach(*pWndDC);
    InitDC(dc);

    int iWidth = dc.m_FontMetrics.tmAveCharWidth;
    int iHeight = dc.m_FontMetrics.tmHeight;

    ReleaseDC(pWndDC);

    ((CGlkApp*)AfxGetApp())->AddEvent(evtype_MouseInput,(winid_t)this,
      Click.x/iWidth,Click.y/iHeight);
    m_bMouseActive = false;
    return true;
  }
  return false;
}
예제 #2
0
void CWinGlkWndTextGrid::GetNeededSize(int iSize, int& iWidth, int& iHeight)
{
  CWinGlkGridDC dc(this,GetStyle(style_Normal)->m_Size);
  CDC* pWndDC = GetDC();
  dc.Attach(*pWndDC);
  InitDC(dc);

  iWidth = dc.m_FontMetrics.tmAveCharWidth*iSize;
  iHeight = dc.m_FontMetrics.tmHeight*iSize;

  ReleaseDC(pWndDC);

  static int iBorderWidth = 0;
  static int iBorderHeight = 0;

  CRect WindowArea, ClientArea;
  GetWindowRect(WindowArea);
  GetClientRect(ClientArea);

  // Add enough space for the window borders. If the window is
  // being restored from the minimized state, use the previous
  // border sizes.
  if (WindowArea.Width() > 0)
  {
    iBorderWidth = WindowArea.Width() - ClientArea.Width();
    iBorderHeight = WindowArea.Height() - ClientArea.Height();
  }
  
  iWidth += iBorderWidth;
  iHeight += iBorderHeight;
}
예제 #3
0
int CWinGlkWndTextGrid::GetCaretHeight(void)
{
  CWinGlkGridDC dc(this,GetStyle(style_Normal)->m_Size);
  CDC* pWndDC = GetDC();
  dc.Attach(*pWndDC);
  InitDC(dc);

  int iHeight = dc.m_FontMetrics.tmHeight;
  ReleaseDC(pWndDC);
  return iHeight;
}
예제 #4
0
wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) :
   wxMSWDCImpl( owner )
{
    wxCHECK_RET( window, wxT("invalid window in wxWindowDCImpl") );

    m_window = window;
    m_hDC = (WXHDC) ::GetWindowDC(GetHwndOf(m_window));

    // m_bOwnsDC was already set to false in the base class ctor, so the DC
    // will be released (and not deleted) in ~wxDC
    InitDC();
}
예제 #5
0
파일: status.cpp 프로젝트: firewood/sdkdiff
void
StatusPaint(HWND hWnd, PILIST iplistp)
{
    RECT rc;
    HDC hDC;
    PAINTSTRUCT ps;
    int i;
    PSTATEL ip;
    HPEN hpenOld;

    GetClientRect(hWnd, &rc);
    hDC = BeginPaint(hWnd, &ps);
    InitDC(hDC);

    RaiseRect(hDC, &rc);
    if (iplistp == NULL) {
        EndPaint(hWnd, &ps);
        return;
    }
    for (i =0; i < iplistp->nitems; i++) {
        ip = &iplistp->statels[i];

        if (ip->rc.left == ip->rc.right) {
            continue;
        }
        if (ip->type == SF_STATIC) {
            if (ip->flags & SF_RAISE) {
                RaiseRect(hDC, &ip->rc);
            } else if (ip->flags & SF_LOWER) {
                LowerRect(hDC, &ip->rc);
            }
            rc = ip->rc;
            rc.left += (status_charwidth / 2);
            rc.right--;
            rc.top++;
            rc.bottom--;
            hpenOld = (HPEN)SelectObject(hDC, hpenNeutral);
            Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
            SelectObject(hDC, hpenOld);
            DrawText(hDC, ip->text, lstrlen(ip->text), &rc,
                     DT_LEFT | DT_VCENTER);
        } else {
            StatusButtonUp(hDC, ip);
        }
    }

    EndPaint(hWnd, &ps);
}
예제 #6
0
void CWinGlkWndTextGrid::GetSize(int& iWidth, int& iHeight)
{
  // Measure the size of the new window
  CRect ClientArea;
  GetClientRect(ClientArea);

  CWinGlkGridDC dc(this,GetStyle(style_Normal)->m_Size);
  CDC* pWndDC = GetDC();
  dc.Attach(*pWndDC);
  InitDC(dc);

  iWidth = ClientArea.Width() / dc.m_FontMetrics.tmAveCharWidth;
  iHeight = ClientArea.Height() / dc.m_FontMetrics.tmHeight;

  ReleaseDC(pWndDC);
}
예제 #7
0
파일: status.cpp 프로젝트: firewood/sdkdiff
/*
 * calculate the width of a given field. This is the width in characters
 * multiplied by the average character width, plus a few units for
 * borders.
 *
 * if SF_VAR is set, this field size varies depending on the text, so
 * we use GetTextExtent for the field size. If SF_VAR is selected, the caller
 * can specify that the size is not to exceed the (width * avecharwidth)
 * size (using SF_SZMAX) or that it is not be less than it (SF_SZMIN).
 */
int
StatusCalcWidth(HWND hWnd, PSTATEL ip)
{
    int ch_size, t_size;
    SIZE sz = {0};
    HDC hDC;

    ch_size = ip->width * status_charwidth;
    if (ip->flags & SF_VAR) {
        hDC = GetDC(hWnd);
        if (hDC)
        {
            InitDC(hDC);
            GetTextExtentPoint(hDC, ip->text, lstrlen(ip->text), &sz);
            ReleaseDC(hWnd, hDC);
        }
        t_size = sz.cx;

        /*
         * check this size against min/max size if
         * requested
         */

        if (ip->flags & SF_SZMIN) {
            if (ch_size > t_size) {
                t_size = ch_size;
            }
        }
        if (ip->flags & SF_SZMAX) {
            if (ch_size < t_size) {
                t_size = ch_size;
            }
        }
        ch_size = t_size;
    }

    if (ch_size != 0) {
        if (ip->type == SF_BUTTON) {
            return(ch_size+6);
        } else {
            return(ch_size+4);
        }
    } else {
        return(0);
    }
}
예제 #8
0
unsigned int CWinGlkWndTextGrid::GetLinkAtPoint(const CPoint& Point)
{
  CWinGlkGridDC dc(this,GetStyle(style_Normal)->m_Size);
  CDC* pWndDC = GetDC();
  dc.Attach(*pWndDC);
  InitDC(dc);

  int x = Point.x / dc.m_FontMetrics.tmAveCharWidth;
  int y = Point.y / dc.m_FontMetrics.tmHeight;

  if ((y >= 0) && (y < m_TextGrid.GetSize()))
  {
    const CGridRow& Row = m_TextGrid[y];
    if ((x >= 0) && (x < Row.GetLength()))
      return Row.GetLink(x);
  }
  return 0;
}
예제 #9
0
파일: status.cpp 프로젝트: firewood/sdkdiff
/* StatusInit
 *
 * - create window class
 */
BOOL
StatusInit(
           HANDLE hInstance
           )
{
    WNDCLASS    wc;
    BOOL resp;
    TEXTMETRIC tm = {0};
    HDC hDC;


    StatusCreateTools();

    wc.style = CS_HREDRAW|CS_VREDRAW|CS_GLOBALCLASS;
    wc.lpfnWndProc = (WNDPROC)StatusWndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = sizeof(HANDLE);
    wc.hInstance = (HINSTANCE)hInstance;
    wc.hIcon = NULL;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = hbrBackground;
    wc.lpszClassName = (LPSTR) "gdstatusclass";
    wc.lpszMenuName = NULL;

    resp = RegisterClass(&wc);

    hDC = GetDC(NULL);
    if (hDC)
    {
        InitDC(hDC);
        GetTextMetrics(hDC, &tm);
        ReleaseDC(NULL, hDC);
    }
    else
    {
        // arbitrary, whatever...
        tm.tmHeight = 14;
        tm.tmAveCharWidth = 5;
    }
    status_charheight = (int)(tm.tmHeight + tm.tmExternalLeading);
    status_charwidth = (int)tm.tmAveCharWidth;

    return(resp);
}
예제 #10
0
wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) :
   wxClientDCImpl( owner )
{
    wxCHECK_RET( window, wxT("NULL canvas in wxPaintDCImpl ctor") );

#ifdef wxHAS_PAINT_DEBUG
    if ( g_isPainting <= 0 )
    {
        wxFAIL_MSG( wxT("wxPaintDCImpl may be created only in EVT_PAINT handler!") );

        return;
    }
#endif // wxHAS_PAINT_DEBUG

    // see comments in src/msw/window.cpp where this is defined
    extern bool wxDidCreatePaintDC;

    wxDidCreatePaintDC = true;


    m_window = window;

    // do we have a DC for this window in the cache?
    m_hDC = FindDCInCache(m_window);
    if ( !m_hDC )
    {
        // not in cache, create a new one
        wxPaintDCInfoOur* const info = new wxPaintDCInfoOur(m_window);
        gs_PaintDCInfos[m_window] = info;
        m_hDC = info->GetHDC();
    }

    // Note: at this point m_hDC can be NULL under MicroWindows, when dragging.
    if (!GetHDC())
        return;

    // (re)set the DC parameters.
    InitDC();

    // the HDC can have a clipping box (which we didn't set), make sure our
    // DoGetClippingBox() checks for it
    m_clipping = true;
}
예제 #11
0
파일: status.cpp 프로젝트: firewood/sdkdiff
INT_PTR APIENTRY
StatusWndProc(
              HWND hWnd,
              UINT message,
              WPARAM wParam,
              LPARAM lParam
              )
{
    HANDLE hitems;
    PSTATEL ip;
    PILIST plist;
    CREATESTRUCT * cp;
    int i;
    HDC hDC;
    RECT rc;
    POINT pt;

    switch (message) {

        case WM_CREATE:
            cp = (CREATESTRUCT *) lParam;
            hitems = (HANDLE) cp->lpCreateParams;
            SetWindowLongPtr(hWnd, 0,  (LONG_PTR)hitems);
            plist = (PILIST) hitems;
            if (plist != NULL) {
                plist->selitem = -1;
            }
            break;

        case WM_SIZE:
            hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
            plist = (PILIST) hitems;
            if (plist != NULL) {
                StatusResize(hWnd, plist);
            }
            break;

        case WM_PAINT:
            hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
            plist = (PILIST) hitems;
            StatusPaint(hWnd, plist);

            break;

        case WM_LBUTTONUP:
            hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
            plist = (PILIST)hitems;
            pt.x = LOWORD(lParam);
            pt.y = HIWORD(lParam);

            if (plist == NULL) {
                break;
            }
            if (plist->selitem != -1) {
                ip = &plist->statels[plist->selitem];
                if (plist->isselected) {
                    hDC = GetDC(hWnd);
                    if (hDC)
                    {
                        InitDC(hDC);
                        StatusButtonUp(hDC, ip);
                        ReleaseDC(hWnd, hDC);
                    }
                }
                plist->selitem = -1;
                ReleaseCapture();
                if (PtInRect(&ip->rc, pt)) {
                    SendMessage(GetParent(hWnd), WM_COMMAND, MAKELONG(ip->id, WM_LBUTTONUP), (LPARAM)hWnd);
                }
            }
            break;

        case WM_LBUTTONDOWN:
            hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
            plist = (PILIST)hitems;
            if (plist == NULL) {
                break;
            }
            pt.x = LOWORD(lParam);
            pt.y = HIWORD(lParam);
            if (plist->selitem == -1) {
                for (i = 0; i< plist->nitems; i++) {
                    ip = &plist->statels[i];
                    if (PtInRect(&ip->rc, pt)) {
                        if (ip->type != SF_BUTTON) {
                            break;
                        }
                        plist->selitem = i;
                        SetCapture(hWnd);

                        plist->isselected = TRUE;
                        hDC = GetDC(hWnd);
                        if (hDC)
                        {
                            InitDC(hDC);
                            StatusButtonDown(hDC, ip);
                            ReleaseDC(hWnd, hDC);
                        }
                        break;
                    }
                }
            }
            break;

        case WM_MOUSEMOVE:
            hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
            plist = (PILIST) hitems;
            if (plist == NULL) {
                break;
            }
            pt.x = LOWORD(lParam);
            pt.y = HIWORD(lParam);
            if (plist->selitem != -1) {
                ip = &plist->statels[plist->selitem];
                if (PtInRect(&ip->rc, pt)) {
                    if (!plist->isselected) {
                        hDC = GetDC(hWnd);
                        if (hDC)
                        {
                            InitDC(hDC);
                            StatusButtonDown(hDC, ip);
                            ReleaseDC(hWnd, hDC);
                        }
                        plist->isselected = TRUE;
                    }
                } else {
                    if (plist->isselected) {
                        hDC = GetDC(hWnd);
                        if (hDC)
                        {
                            InitDC(hDC);
                            StatusButtonUp(hDC, ip);
                            ReleaseDC(hWnd, hDC);
                        }
                        plist->isselected = FALSE;
                    }
                }
            }
            break;


        case WM_DESTROY:

            hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
            HeapFree(GetProcessHeap(), NULL, hitems);
            SetWindowLongPtr(hWnd, 0, 0);
            break;

        case SM_NEW:
            hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
            if (hitems != NULL) {
                HeapFree(GetProcessHeap(), NULL, hitems);
            }
            hitems = (HANDLE) wParam;
            if (hitems == NULL) {
                SetWindowLongPtr(hWnd, 0, 0);
                InvalidateRect(hWnd, NULL, TRUE);
                break;
            }
            plist = (PILIST) hitems;
            if (plist == NULL) {
                SetWindowLongPtr(hWnd, 0, 0);
                InvalidateRect(hWnd, NULL, TRUE);
                break;
            }
            plist->selitem = -1;
            StatusResize(hWnd, plist);
            SetWindowLongPtr(hWnd, 0, (LONG_PTR)hitems);
            InvalidateRect(hWnd, NULL, TRUE);
            break;

        case SM_SETTEXT:
            hitems = (HANDLE) GetWindowLongPtr(hWnd, 0);
            if (hitems == NULL) {
                break;
            }
            plist = (PILIST) hitems;
            ip = StatusGetItem(plist, (int)wParam);
            if (ip != NULL) {
                if (lParam == 0) {
                    ip->text[0] = '\0';
                } else {
                    My_mbsncpy(ip->text, (LPSTR) lParam, SF_MAXLABEL);
                    ip->text[SF_MAXLABEL] = '\0';
                }

                /* if this is a variable width field, we need to redo
                 * all size calcs in case the field width has changed.
                 * in that case, we need to repaint the entire window
                 * and not just this field - so set rc to indicate the
                 * area to be redrawn.
                 */
                if (ip->flags & SF_VAR) {
                    StatusResize(hWnd, plist);
                    GetClientRect(hWnd, &rc);
                    RedrawWindow(hWnd, &rc, NULL,
                                 RDW_INVALIDATE|RDW_ERASE|RDW_UPDATENOW);
                } else {
                    /* instead of just invalidating the window, we can
                     * force the window to be repainted now. This is
                     * essential for status updates during a busy
                     * loop when no messages are being processed,
                     * but we should still update the user on what's
                     * happening.
                     */
                    RedrawWindow(hWnd, &ip->rc, NULL,
                                 RDW_INVALIDATE|RDW_NOERASE|RDW_UPDATENOW);
                }

            }
            break;

        default:
            return(DefWindowProc(hWnd, message, wParam, lParam));
    }
    return 0;
}