void CFindPanel::ShowMenu() { mn_KeyDown = 0; enum MenuCommands { idFindNext = 1, idFindPrev, idMatchCase, idMatchWhole, idFreezeCon, idHilightAll, }; HMENU hPopup = CreatePopupMenu(); AppendMenu(hPopup, MF_STRING, idFindNext, L"Find next" L"\t" L"F3"); AppendMenu(hPopup, MF_STRING, idFindPrev, L"Find prev" L"\t" L"Shift+F3"); AppendMenu(hPopup, MF_SEPARATOR, 0, L""); AppendMenu(hPopup, MF_STRING | (gpSet->FindOptions.bMatchCase?MF_CHECKED:0), idMatchCase, L"Match case" L"\t" L"Alt+C"); AppendMenu(hPopup, MF_STRING | (gpSet->FindOptions.bMatchWholeWords?MF_CHECKED:0), idMatchWhole, L"Match whole words" L"\t" L"Alt+W"); AppendMenu(hPopup, MF_STRING | (gpSet->FindOptions.bFreezeConsole?MF_CHECKED:0), idFreezeCon, L"Freeze console" L"\t" L"Alt+F"); #if 0 AppendMenu(hPopup, MF_STRING | (gpSet->FindOptions.bHighlightAll?MF_CHECKED:0), idHilightAll, L"Highlight all matches"); #endif bool bTabsAtBottom = (gpSet->nTabsLocation == 1); DWORD Align = TPM_LEFTALIGN | (bTabsAtBottom ? TPM_BOTTOMALIGN : TPM_TOPALIGN); RECT rcEdit = {}; GetWindowRect(mh_Edit, &rcEdit); POINT pt = {rcEdit.left, bTabsAtBottom ? rcEdit.top : rcEdit.bottom}; int nCmd = gpConEmu->mp_Menu->trackPopupMenu(tmp_SearchPopup, hPopup, Align|TPM_RETURNCMD, pt.x, pt.y, ghWnd); LRESULT lRc = 0; switch (nCmd) { case idFindNext: gpConEmu->DoFindText(1); break; case idFindPrev: gpConEmu->DoFindText(-1); break; case idMatchCase: OnKeyboard(WM_SYSKEYDOWN, 'C', 0, lRc); break; case idMatchWhole: OnKeyboard(WM_SYSKEYDOWN, 'W', 0, lRc); break; case idFreezeCon: OnKeyboard(WM_SYSKEYDOWN, 'F', 0, lRc); break; case idHilightAll: OnKeyboard(WM_SYSKEYDOWN, 'A', 0, lRc); break; } DestroyMenu(hPopup); }
int RotateViewMouseProc::proc( HWND hwnd, // handle of window to rotate int msg, // mouse event int point, // mouse click number int flag, // mouse button state IPoint2 screenPt ) // screen point clicked { switch ( msg ) { case MOUSE_POINT: return OnMousePoint(hwnd, point, flag, screenPt); case MOUSE_FREEMOVE: return OnMouseFreeMove(hwnd, point, flag, screenPt); case MOUSE_MOVE: return OnMouseMove(hwnd, point, flag, screenPt); case MOUSE_KEYBOARD: return OnKeyboard(hwnd, point, flag, screenPt); case MOUSE_ABORT: return OnMouseAbort(hwnd, point, flag, screenPt); } return (mStarted != false); }
bool CUIDialogWnd::IR_OnKeyboardRelease(int dik) { if(!IR_process()) return false; //mouse click if(dik==MOUSE_1 || dik==MOUSE_2 || dik==MOUSE_3) { Fvector2 cp = GetUICursor()->GetPos(); EUIMessages action = (dik==MOUSE_1)?WINDOW_LBUTTON_UP :(dik==MOUSE_2)?WINDOW_RBUTTON_UP:WINDOW_CBUTTON_UP; if (OnMouse(cp.x, cp.y, action)) return true; } if (OnKeyboard(dik, WINDOW_KEY_RELEASED)) return true; if( !StopAnyMove() && g_pGameLevel ){ CObject* O = Level().CurrentEntity(); if( O ){ IInputReceiver* IR = smart_cast<IInputReceiver*>( smart_cast<CGameObject*>(O) ); if (!IR) return (false); IR->IR_OnKeyboardRelease(get_binded_action(dik)); } } return false; }
/*! When dealing with mouse coordinates, we need to convert them to image coordinates, and so must consider the following things: 1) The mouse has the origin at top-left, but in all calculations we assume an origin at bottom-left, so when reading the mouse, we do mousePt.Set(Fl::event_x(), h() - Fl::event_y()). 2) In general, the relation between the (bottom-left-origin) mouse point $p_m$ and its corresponding image point $p_i$ is given by: \[ p_m = p_i * S + T \], where S is the scaling and T is the translation. Then, given a mouse point we get the image point by \[ p_i = (p_m - T) / S \] 3) When zooming, we want to end up at the same image point,. Then, given a requested new scaling factor, $S'$, we must find find the appropriate translation $T'$ for it that will make the mouse point, $p_m$, correspond to the same image point $p_i$. \[ p_m = p_i * S' + T' \], which means that from (2), we can get \[ T' = p_m - p_i * S' \]. We could replace $p_i$ and simplify things a bit, but that's not really necessary. 4) In the case of the y coordinate, we have it reflexed (multiplied by -1) and translated by the window hight, h, to make it agree with the top-left origin of the displayed images. So, thes coordinate needs some special treatment. Then, the image y-coordinate is given by \[ p_i = (p_m - T - h) / -S \], and the new translation dy is given by \[ dy = p_m - p_i * -S' - h \]. Agaim, some simplifycation could me made here, but that's not necessary, and the point realtion are seen clearer this way. */ int ImageView::handle(int eventId) { switch (eventId) { // case FL_KEYDOWN: // does not work case FL_KEYUP: OnKeyboard(Fl::event_key()); return 1; case FL_MOUSEWHEEL: OnZoom(Fl::event_dy()); return 1; case FL_PUSH: OnMousePush(); return 1; case FL_DRAG: OnMouseDrag(); return 1; //case FL_ENTER: // m_savedTitle = parent()->label(); // return 1; case FL_LEAVE: if (m_curImgInfo != parent()->label()) { parent()->label(m_curImgInfo.c_str()); parent()->redraw(); } return 1; case FL_MOVE: OnMouseMove(); return 1; } return BaseImageView::handle(eventId); }
// update the camera using gluLookAt void Camera::CamUpdate() { gluLookAt( m_pos.x, m_pos.y,m_pos.z, m_target.x +m_pos.x, m_target.y + m_pos.y, m_target.z + m_pos.z, m_up.x, m_up.y, m_up.z ); OnKeyboard(keys); }
LRESULT LayeredWindowBase::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_CREATE: //SetTimer(hWnd,1,100,NULL); if (Initialize()) return NULL; else return -1; case WM_SIZE: { UINT width = LOWORD(lParam); UINT height = HIWORD(lParam); //phLyricsScrollWindow->OnResize(width, height); if (width!=0 && height!=0) { if (SetSize(width,height)) { m_pWin.pAPI->OnSize(width,height); RECT rect; GetWindowRect(m_hWnd,&rect); m_info.m_windowPosition.x = rect.left; m_info.m_windowPosition.y = rect.top; RedrawWindow(m_hWnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE); } printf("WM_SIZE : %d %d -> %d %d\n",width,height,m_pWin.pAPI->GetWidth(),m_pWin.pAPI->GetHeight()); } //printf("onSize %d %d\n",width,height); } return 0; case WM_GETMINMAXINFO: //window size/position is going to change { MINMAXINFO* pInfo = (MINMAXINFO*)lParam; pInfo->ptMinTrackSize.x = (long)m_info.m_minsize.cx; //apply custom min width/height pInfo->ptMinTrackSize.y = (long)m_info.m_minsize.cy; } return 0; case WM_WINDOWPOSCHANGING: case WM_WINDOWPOSCHANGED: { RECT rect; GetWindowRect(m_hWnd,&rect); m_info.m_windowPosition.x = rect.left; m_info.m_windowPosition.y = rect.top; } return 0; case WM_ACTIVATE: UpdateLayeredWindow(); if (hWnd == m_hWnd) { //BeforeRender(); //m_pWin.pAPI->BeginDraw(); //Render(); //m_info.Update(m_hWnd,m_pWin.pAPI->GetDC()); //m_pWin.pAPI->ReleaseDC(); //m_pWin.pAPI->EndDraw(); //AfterRender(); } break; case WM_TIMER: case WM_PAINT: case WM_DISPLAYCHANGE: { //printf("Render!\n"); //if (m_vRenderCBList.size()) //{ // //((*m_pRanderCBClass).*m_pRanderCBFunc)(); // for (int i=0;i<m_vRenderCBList.size();i++) // { // (m_vRenderCBList[i].pClass->*(m_vRenderCBList[i].pCBFunc))(); // //(m_pRanderCBClass->*m_pRanderCBFunc)(); // } // //} //else if (hWnd == m_hWnd) { BeforeRender(); m_pWin.pAPI->BeginDraw(); Render(); m_info.Update(m_hWnd,m_pWin.pAPI->GetDC()); m_pWin.pAPI->ReleaseDC(); m_pWin.pAPI->EndDraw(); AfterRender(); } } return 0; case WM_DESTROY: { Uninitialize(); PostQuitMessage(0); } return 0; case WM_COMMAND: break; case WM_KEYDOWN: //printf("%X key down\n",wParam); OnKeyboard(wParam,true); break; case WM_KEYUP: //printf("%X key up\n",wParam); OnKeyboard(wParam,false); break; case WM_MOUSEWHEEL: case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_RBUTTONDBLCLK: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: { int x=(short)LOWORD(lParam); int y=(short)HIWORD(lParam); OnMouse(uMsg,x,y,GET_KEYSTATE_WPARAM(wParam),GET_WHEEL_DELTA_WPARAM(wParam)); //printf("mouse event : %x @ (%d,%d)\n",uMsg,x,y); } break; case WM_NCMOUSEMOVE : case WM_NCLBUTTONDOWN : case WM_NCLBUTTONUP : case WM_NCLBUTTONDBLCLK : case WM_NCRBUTTONDOWN : case WM_NCRBUTTONUP : case WM_NCRBUTTONDBLCLK : case WM_NCMBUTTONDOWN : case WM_NCMBUTTONUP : case WM_NCMBUTTONDBLCLK : { int x=(short)LOWORD(lParam); int y=(short)HIWORD(lParam); OnMouse(uMsg,x,y,0,0); //printf("NCmouse event : %x @ (%d,%d)\n",uMsg,x,y); } break; case WM_NCHITTEST: { //printf("Hit Test : %d\n",DefWindowProc( // //hwnd, // message, // wParam, // lParam // //dwMsgMapID // )); //break; /* #define BF_LEFT 0x0001 #define BF_TOP 0x0002 #define BF_RIGHT 0x0004 #define BF_BOTTOM 0x0008 */ int x=(short)LOWORD(lParam); int y=(short)HIWORD(lParam); unsigned char type = 0; if (x-m_info.m_windowPosition.x<m_info.m_border) type|=BF_LEFT; if (y-m_info.m_windowPosition.y<m_info.m_border) type|=BF_TOP; if (m_info.m_windowPosition.x+m_info.m_size.cx-x<m_info.m_border) type|=BF_RIGHT; if (m_info.m_windowPosition.y+m_info.m_size.cy-y<m_info.m_border) type|=BF_BOTTOM; //printf("WM_NCHITTEST (%d,%d): pos (%d,%d) size (%d,%d) border %d\n",x,y,m_info.m_windowPosition.x,m_info.m_windowPosition.y,m_info.m_size.cx,m_info.m_size.cy,m_info.m_border); switch (type) { case BF_LEFT: return HTLEFT; break; case BF_RIGHT: return HTRIGHT; break; case BF_TOP: return HTTOP; break; case BF_BOTTOM: return HTBOTTOM; break; case BF_LEFT|BF_TOP: return HTTOPLEFT; break; case BF_LEFT|BF_BOTTOM: return HTBOTTOMLEFT; break; case BF_RIGHT|BF_TOP: return HTTOPRIGHT; break; case BF_RIGHT|BF_BOTTOM: return HTBOTTOMRIGHT; break; default: return HTCAPTION; } //printf("hit test : %d\n",res); } return 0; case WM_MOVING: { RECT *pRect = (RECT*)lParam; //printf("%d %d\n",pRect->left,pRect->top); m_info.m_windowPosition.x = pRect->left; m_info.m_windowPosition.y = pRect->top; } return 0; case WM_SIZING: { RECT *pRect = (RECT*)lParam; UINT width = pRect->right-pRect->left; UINT height = pRect->bottom-pRect->top; bool isMove = true; printf("%d %d\n",width,height); if (SetSize(width,height)) { m_pWin.pAPI->OnSize(width,height); m_info.m_windowPosition.x = pRect->left; m_info.m_windowPosition.y = pRect->top; printf("WM_SIZING : %d %d -> %d %d\n",width,height,m_pWin.pAPI->GetWidth(),m_pWin.pAPI->GetHeight()); //Render(); // m_info.Update(m_hWnd,m_pWin.pAPI->GetDC()); //m_pWin.pAPI->ReleaseDC(); UpdateLayeredWindow(); //m_pWin.pAPI->BeginDraw(); //Render(); //m_info.Update(m_hWnd,m_pWin.pAPI->GetDC()); //m_pWin.pAPI->ReleaseDC(); //m_pWin.pAPI->EndDraw(); //RedrawWindow(m_hWnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE); } } return 0; default: break; //printf("msg %X\n",message); } // Call default window proc if we haven't handled the message return DefWindowProc(hWnd,uMsg,wParam,lParam); }
void Control::NotificationKeyboard(const SDL_KeyboardEvent& keyboardEvent) { OnKeyboard(keyboardEvent); }