static int WndProcST(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event) { t_statictext *st; t_windata *win; int i, dy; if (dlgitem->type != edlgST) { gmx_incons("st processing"); } st = &(dlgitem->u.statictext); win = &(dlgitem->win); switch (event->type) { case Expose: dy = XTextHeight(x11->font)+OFFS_Y; for (i = 0; (i < st->nlines); i++) { TextInRect(x11, win->self, st->lines[i], 0, OFFS_Y+i*dy, win->width, dy, eXLeft, eYCenter); } break; default: return DefWndProc(x11, dlgitem, event); } return ITEMOK; }
static int WndProcGB(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event) { t_windata *win; int x, y; if (dlgitem->type != edlgGB) { gmx_incons("gb processing"); } win = &(dlgitem->win); x = XTextWidth(x11->font, win->text, strlen(win->text)); y = XTextHeight(x11->font); switch (event->type) { case Expose: XSetForeground(x11->disp, x11->gc, x11->fg); XDrawRoundRect(x11->disp, win->self, x11->gc, 0, y/2, win->width-1, win->height-y/2-1); XClearArea(x11->disp, win->self, OFFS_X, 0, x+OFFS_X, y, False); TextInRect(x11, win->self, win->text, 2*OFFS_X, 0, x, y, eXCenter, eYCenter); break; case EnterNotify: case LeaveNotify: break; default: return DefWndProc(x11, dlgitem, event); } return ITEMOK; }
static int WndProcBN(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event) { t_windata *win; int x, w, th; if (dlgitem->type != edlgBN) { gmx_incons("button processing"); } win = &(dlgitem->win); w = XTextWidth(x11->font, win->text, strlen(win->text)); x = (win->width-w)/2; th = XTextHeight(x11->font)+OFFS_Y; switch (event->type) { case Expose: RectWin(x11->disp, x11->gc, win, x11->fg); TextInRect(x11, win->self, win->text, 0, 0, win->width, th, eXCenter, eYCenter); break; case ButtonPress: return BNPRESSED; case EnterNotify: XDrawLine(x11->disp, win->self, x11->gc, x-1, th, x+w, th); break; case LeaveNotify: XSetForeground(x11->disp, x11->gc, x11->bg); XDrawLine(x11->disp, win->self, x11->gc, x-1, th, x+w, th); XSetForeground(x11->disp, x11->gc, x11->fg); break; default: return DefWndProc(x11, dlgitem, event); } return ITEMOK; }
/* Responds to an incoming BN_CLICKED message. If a Group has been specified for the TCheckBox, notifies the Group that the state of this TCheckBox has changed. */ void TCheckBox::BNClicked(TMessage& Msg) { DefWndProc(Msg); if ( Group ) Group->SelectionChanged(Attr.Id); DefNotificationProc(Msg); }
static int WndProcRB(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event) { t_radiobutton *rb; t_windata *win; int x, y, rad; if (dlgitem->type != edlgRB) { gmx_incons("radiobutton processing"); } rb = &(dlgitem->u.radiobutton); win = &(dlgitem->win); rad = win->height/3; x = rad; y = win->height/2; switch (event->type) { case Expose: XClearArea(x11->disp, win->self, x-rad, y-rad, x+rad, y+rad, False); if (rb->bSelect) { /* Filled */ XFillCircle(x11->disp, win->self, x11->gc, x, y, rad); } XDrawCircle(x11->disp, win->self, x11->gc, x, y, rad); x += rad+OFFS_X; TextInRect(x11, win->self, win->text, x, 0, win->width-x, win->height, eXLeft, eYCenter); break; case ButtonPress: if (!rb->bSelect) { return RBPRESSED; } XBell(x11->disp, 50); break; case EnterNotify: case LeaveNotify: break; default: return DefWndProc(x11, dlgitem, event); } return ITEMOK; }
static int WndProcCB(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event) { t_checkbox *cb; t_windata *win; int x, y, w, h; if (dlgitem->type != edlgCB) { gmx_incons("check box processing"); } cb = &(dlgitem->u.checkbox); win = &(dlgitem->win); x = 0; y = win->height/7; w = 5*y; h = 5*y; switch (event->type) { case Expose: XSetForeground(x11->disp, x11->gc, x11->fg); XClearArea(x11->disp, win->self, x, y, w, h, False); XDrawRectangle(x11->disp, win->self, x11->gc, x, y, w, h); if (cb->bChecked) { XDrawLine(x11->disp, win->self, x11->gc, x, y, x+w, y+h); XDrawLine(x11->disp, win->self, x11->gc, x+w, y, x, y+h); } x = w+OFFS_X; TextInRect(x11, win->self, win->text, x, 0, win->width-x, win->height, eXLeft, eYCenter); break; case ButtonPress: cb->bChecked = !cb->bChecked; return CBPRESSED; case EnterNotify: case LeaveNotify: break; default: return DefWndProc(x11, dlgitem, event); } return ITEMOK; }
LRESULT CStatic::MsgProc(UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_LBUTTONUP: if( isUrl ) { GoUrl(); return 0; } break; case WM_PAINT: if( isUrl ) { OnPaint(); return 0; } break; } return DefWndProc(msg, wParam, lParam); }
/*---------------------------------------------------------------------------------------------- Non-virtual window proc to call standard message handlers. All handlers should be virtual. WARNING: This method is also called for dialogs. Dialogs will always pass true for fRet. @param fRet Flag not to call the default window procedure. @param hwnd Handle of the window to which the message is directed. @param wm Windows message identifier. @param wp First message parameter. @param lp Second message parameter. @param lnRet Value to be returned to the system. (return value for window procedure) ----------------------------------------------------------------------------------------------*/ void AfWnd::WndProcPost(int fRet, HWND hwnd, uint wm, WPARAM wp, LPARAM lp, long & lnRet) { AssertObj(this); Assert(hwnd != NULL); switch (wm) { // Menu management. case WM_INITMENUPOPUP: // Ignore system menus. if (!HIWORD(lp)) AfApp::GetMenuMgr(&m_pmum)->OnInitMenuPopup((HMENU)wp, (int)LOWORD(lp)); break; } // Call the default window proc. if (!fRet) { if (hwnd != m_hwnd) lnRet = ::DefWindowProc(hwnd, wm, wp, lp); else lnRet = DefWndProc(wm, wp, lp); } switch (wm) { // AfWnd management. case WM_NCDESTROY: if (hwnd == m_hwnd) { OnReleasePtr(); DetachHwnd(hwnd); } break; } }
static int WndProcET(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event) { t_edittext *et; t_windata *win; KeySym keysym; char c[BUFSIZE+1], *bp; char scrbuf[STRLEN]; int i, xp, xtitle, ewidth; if (dlgitem->type != edlgET) { gmx_incons("st processing"); } et = &(dlgitem->u.edittext); win = &(dlgitem->win); /* Copy string part that is visible into screen buffer */ for (i = 0; (i < et->buflen); i++) { scrbuf[i] = et->buf[i+et->strbegin]; } scrbuf[i] = '\0'; switch (event->type) { case Expose: XSetForeground(x11->disp, x11->gc, x11->fg); xtitle = XTextWidth(x11->font, win->text, strlen(win->text)); ewidth = win->width-xtitle; TextInRect(x11, win->self, win->text, 0, 0, xtitle-1, win->height, eXLeft, eYCenter); XClearArea(x11->disp, win->self, xtitle, 0, ewidth+XCARET, win->height, False); TextInRect(x11, win->self, scrbuf, xtitle+XCARET, 0, ewidth, win->height, eXLeft, eYCenter); #ifdef DEBUG printf("Expose\n"); #endif if (win->bFocus) { ShowCaret(x11, dlgitem); } break; case ButtonPress: /* Calculate new position for caret */ et->pos = strlen(et->buf); bp = strdup(et->buf); xp = event->xbutton.x-XTextWidth(x11->font, win->text, strlen(win->text))- XCARET; while ((et->pos > 0) && (XTextWidth(x11->font, bp, strlen(bp)) > xp)) { et->pos--; bp[et->pos] = '\0'; } sfree(bp); et->bChanged = TRUE; return ETCHANGED; case KeyPress: /* Check for HelpKey */ if (HelpPressed(event)) { return DefWndProc(x11, dlgitem, event); } XLookupString(&(event->xkey), c, BUFSIZE, &keysym, NULL); #ifdef DEBUG printf("Keysym: %x\n", keysym); #endif switch (keysym) { case XK_Delete: if (my_delete(et->buf, &(et->pos))) { et->bChanged = TRUE; return ETCHANGED; } else { XBell(x11->disp, 50); } break; case XK_BackSpace: if (my_backspace(et->buf, &(et->pos))) { et->bChanged = TRUE; return ETCHANGED; } else { XBell(x11->disp, 50); } break; case XK_KP_Enter: case XK_Return: return ENTERPRESSED; case XK_Home: et->pos = 0; et->strbegin = 0; et->bChanged = TRUE; return ETCHANGED; case XK_End: if (strlen(et->buf) <= et->buflen) { et->pos = strlen(et->buf); } else { et->pos = et->buflen; et->strbegin = strlen(et->buf)-et->buflen; } et->bChanged = TRUE; return ETCHANGED; case XK_Left: et->pos = max(0, et->pos-1); et->strbegin = min(et->strbegin, et->pos); et->bChanged = TRUE; return ETCHANGED; case XK_Right: if ((et->pos < et->buflen) && (et->strbegin+et->buflen > strlen(et->buf))) { et->pos++; } else if ((et->buflen < strlen(et->buf)) && (et->strbegin < strlen(et->buf)-et->buflen)) { et->strbegin++; } else { break; } et->bChanged = TRUE; return ETCHANGED; default: if (keysym < 256) { if (insert(et->buf, c[0], &(et->pos))) { et->bChanged = TRUE; return ETCHANGED; } } XBell(x11->disp, 50); break; } break; case LeaveNotify: win->bFocus = FALSE; HideCaret(x11, dlgitem); if (et->bChanged) { et->bChanged = FALSE; } break; default: return DefWndProc(x11, dlgitem, event); } return ITEMOK; }
/*---------------------------------------------------------------------------------------------- Show the popup (using a modal loop) at the given location. *pival will contain the selected icon index when this method returns. If the icon selection is cancelled, pival will contain the previous selected index (the initial value of *pival). DoPopup returns false if the user cancels the color selection. @param cval number of buttons @param rid resource id of bitmap containing buttons. They are assumed to be 16 pixels wide and 15 high, as in a toolbar. Pink pixels are to be masked out. It is further assumed that rids from rid + 1 to rid + cval identify tooltip help for the buttons. @param prgfPressed is the button pressed ----------------------------------------------------------------------------------------------*/ bool IconComboPopup::DoPopup(WndCreateStruct & wcs, int * pival, POINT pt, int cval, int rid, int cColumns, bool * prgfPressed, HIMAGELIST himl) { AssertPtr(pival); m_cvals = cval; m_pival = pival; m_pt = pt; m_cColumns = cColumns; m_cRows = (cval + cColumns - 1) / cColumns; m_himl = himl; m_prgfPressed = prgfPressed; SuperClass::CreateAndSubclassHwnd(wcs); m_ivalOld = *m_pival; // Tooltip stuff UiToolTipPtr qwnd; qwnd.Create(); m_hwndToolTip = qwnd->Create(m_hwnd); Rect rc; TOOLINFO ti = { isizeof(ti) }; ti.hwnd = m_hwnd; ti.hinst = ModuleEntry::GetModuleHandle(); for (int i = 0; i < cval; i++) { GetCellRect(i, rc); ti.lpszText = reinterpret_cast<achar *>(rid + i + 1); ti.rect = rc; ::SendMessage(m_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); } // Find which cell corresponds to the initial color. m_fMouseDown = true; ::SetCapture(m_hwnd); MSG msg; bool fContinue = true; // Start a modal message loop. while (fContinue && ::GetMessage(&msg, NULL, 0, 0)) { if (msg.hwnd == m_hwnd) { ::SendMessage(m_hwndToolTip, TTM_RELAYEVENT, 0, (LPARAM)&msg); switch (msg.message) { case WM_LBUTTONDOWN: m_fMouseDown = true; ::InvalidateRect(m_hwnd, NULL, true); break; case WM_LBUTTONUP: fContinue = OnLButtonUp(msg.wParam, MakePoint(msg.lParam)); break; case WM_PAINT: OnPaint(); break; case WM_MOUSEMOVE: OnMouseMove(msg.wParam, LOWORD(msg.lParam), HIWORD(msg.lParam)); break; case WM_KEYDOWN: fContinue = OnKeyDown(msg.wParam, LOWORD(msg.lParam)); break; case WM_KILLFOCUS: fContinue = OnKillFocus((HWND)msg.wParam); break; default: DefWndProc(msg.message, msg.wParam, msg.lParam); break; } } else { // Dispatch the message the normal way. ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } ::ReleaseCapture(); return !m_fCanceled; }
LRESULT CDialog::MsgProc(UINT msg, WPARAM wParam, LPARAM lParam) { return DefWndProc(msg, wParam, lParam); }