Пример #1
0
/* -------------------------
	 | Dialog window handler |
	 ------------------------- */
int dialog_window(int wind_id, OBJECT *dialog, int action, int ext)
{
    int x, y, w, h, s;
    int w_x, w_y, w_w, w_h;
    int hndl, sel;

    switch(action)
    {
    case CLS_DIA:
        wind_close(wind_id);
        wind_delete(wind_id);
        break;

    case OPN_DIA:
        form_center(dialog, &x, &y, &w, &h);
        wind_calc(WC_BORDER, MOVER|NAME, x, y, w, h, &w_x, &w_y, &w_w, &w_h);
        hndl = open_window(MOVER|NAME, w_x, w_y, w_w, w_h, "");
        return hndl;

    case RDW_DIA:
        s = first_rect(wind_id, 0);
        while(s)
        {
            objc_draw(dialog, ext, MAX_DEPTH, r_xy[0], r_xy[1], r_xy[2], r_xy[3]);
            s = next_rect(wind_id, 0);
        }
        break;

    case ACT_DIA:
        sel = win_formdo(dialog, ext, wind_id);
        if (dialog[sel].ob_flags & EXIT)
            dialog[sel].ob_state &= ~SELECTED;

        return sel;
    }
    return 0;
}
Пример #2
0
void CManageFiltersDlg::OnCustomDraw(NMHDR *pNotifyStruct, LRESULT *pLResult)
{
  NMLVCUSTOMDRAW *pLVCD = reinterpret_cast<NMLVCUSTOMDRAW *>(pNotifyStruct);

  *pLResult = CDRF_DODEFAULT;
  const int iItem = (int)pLVCD->nmcd.dwItemSpec;
  const int iSubItem = pLVCD->iSubItem;

  bool bCopy(false), bExport(false), bActive(false);
  st_FilterItemData *pflt_idata(NULL);

  switch(pLVCD->nmcd.dwDrawStage) {
    case CDDS_ITEMPREPAINT:
    case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
      pflt_idata = (st_FilterItemData *)m_FilterLC.GetItemData(iItem);

      bActive = (pflt_idata->flt_flags & MFLT_INUSE) == MFLT_INUSE;
      bCopy = (pflt_idata->flt_flags & MFLT_REQUEST_COPY_TO_DB) == MFLT_REQUEST_COPY_TO_DB;
      bExport = (pflt_idata->flt_flags & MFLT_REQUEST_EXPORT) == MFLT_REQUEST_EXPORT;
      break;
    default:
      break;
  }

  int ix, iy;
  const COLORREF crLightGreen = RGB(222, 255, 222);

  switch(pLVCD->nmcd.dwDrawStage) {
    case CDDS_PREPAINT:
      *pLResult = CDRF_NOTIFYITEMDRAW;
      break;
    case CDDS_ITEMPREPAINT:
      pLVCD->clrText = ::GetSysColor(COLOR_WINDOWTEXT);
      // Show selected item on light green background
      if (iItem == m_selectedfilter) {
        pLVCD->clrTextBk = crLightGreen;
      } else {
        pLVCD->clrTextBk = m_FilterLC.GetTextBkColor();
      }
      *pLResult = CDRF_NOTIFYSUBITEMDRAW;
      break;
    case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
      {
        CRect rect;
        m_FilterLC.GetSubItemRect(iItem, iSubItem, LVIR_BOUNDS, rect);
        if (rect.top < 0) {
          *pLResult = CDRF_SKIPDEFAULT;
          break;
        }
        if (iSubItem == 0) {
          CRect rect1;
          m_FilterLC.GetSubItemRect(iItem, 1, LVIR_BOUNDS, rect1);
          rect.right = rect1.left;
        }
        CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
        CRect inner_rect(rect), first_rect(rect);
        inner_rect.DeflateRect(2, 2);
        switch (iSubItem) {
          case MFLC_FILTER_NAME:
          case MFLC_FILTER_SOURCE:
            break;
          case MFLC_INUSE:
            // Make text 'invisible'
            pLVCD->clrText = pLVCD->clrTextBk;
            // Show selected item on light green background
            if (iItem == m_selectedfilter) {
              pDC->FillSolidRect(&first_rect, crLightGreen);
            }
            // Draw checked/unchecked image
            ix = inner_rect.CenterPoint().x;
            iy = inner_rect.CenterPoint().y;
            // The '7' below is ~ half the bitmap size of 13.
            inner_rect.SetRect(ix - 7, iy - 7, ix + 7, iy + 7);
            DrawImage(pDC, inner_rect, bActive ? CHECKED : EMPTY);
            *pLResult = CDRF_SKIPDEFAULT;
            break;
          case MFLC_COPYTODATABASE:
            // Make text 'invisible'
            pLVCD->clrText = pLVCD->clrTextBk;
            // Show selected item on light green background
            if (iItem == m_selectedfilter) {
              pDC->FillSolidRect(&first_rect, crLightGreen);
            }
            *pLResult = CDRF_SKIPDEFAULT;
            // If already a database filter - don't need any image
            if (pflt_idata->flt_key.fpool == FPOOL_DATABASE)
              break;
            // Draw checked/unchecked image
            ix = inner_rect.CenterPoint().x;
            iy = inner_rect.CenterPoint().y;
            // The '7' below is ~ half the bitmap size of 13.
            inner_rect.SetRect(ix - 7, iy - 7, ix + 7, iy + 7);
            // Set image according to DB being R-O or not
            CheckImage nImage;
            if (m_bDBReadOnly)
              nImage = bCopy ? CHECKED_DISABLED : EMPTY_DISABLED;
            else
              nImage = bCopy ? CHECKED : EMPTY;
            DrawImage(pDC, inner_rect, nImage);
            break;
          case MFLC_EXPORT:
            // Make text 'invisible'
            pLVCD->clrText = pLVCD->clrTextBk;
            // Show selected item on light green background
            if (iItem == m_selectedfilter) {
              pDC->FillSolidRect(&first_rect, crLightGreen);
            }
            // Draw checked/unchecked image
            ix = inner_rect.CenterPoint().x;
            iy = inner_rect.CenterPoint().y;
            // The '7' below is ~ half the bitmap size of 13.
            inner_rect.SetRect(ix - 7, iy - 7, ix + 7, iy + 7);
            DrawImage(pDC, inner_rect, bExport ? CHECKED : EMPTY);
            *pLResult = CDRF_SKIPDEFAULT;
            break;
          default:
            break;
        }
      }
      break;
    default:
      break;
  }
}