BEGIN_NCBI_SCOPE CChoicePointerTypeInfo::CChoicePointerTypeInfo(TTypeInfo pointerType) : CParent(pointerType->GetSize(), "", TConstObjectPtr(0), &CVoidTypeFunctions::Create, typeid(bool), &GetPtrIndex, &SetPtrIndex, &ResetPtrIndex) { SetPointerType(pointerType); }
/*--------------------------------------------------------------------------*/ SIGNED PegStatusBar::Message(const PegMessage &Mesg) { switch(Mesg.wType) { case PM_SHOW: case PM_PARENTSIZED: // make myself the right size: SizeToParent(); PegThing::Message(Mesg); break; case PM_POINTER_MOVE: if (Parent()->StatusIs(PSF_SIZEABLE)) { PegRect DragRect = mReal; DragRect.wTop = DragRect.wBottom - PEG_SCROLL_WIDTH; DragRect.wLeft = DragRect.wRight - PEG_SCROLL_WIDTH; if (DragRect.Contains(Mesg.Point)) { if (!mbShowPointer) { mbShowPointer = TRUE; SetPointerType(PPT_NWSE_SIZE); } } else { if (mbShowPointer) { mbShowPointer = FALSE; SetPointerType(PPT_NORMAL); } } } break; case PM_POINTER_EXIT: if (mbShowPointer) { SetPointerType(PPT_NORMAL); mbShowPointer = FALSE; } break; case PM_LBUTTONDOWN: if (mbShowPointer) { mbShowPointer = FALSE; PegMessage SizeMesg(Parent(), PM_BEGIN_MOVE); SizeMesg.iData = PMM_MOVELR; SizeMesg.Point = Mesg.Point; Parent()->Message(SizeMesg); } else { return (Parent()->Message(Mesg)); } break; default: PegThing::Message(Mesg); break; } return(0); }
/*--------------------------------------------------------------------------*/ SIGNED PegWindow::Message(const PegMessage &Mesg) { SIGNED Result = 0; PegMessage NewMessage; switch(Mesg.wType) { case PM_POINTER_MOVE: if (muMoveMode) { if (Mesg.Point.x != mMovePoint.x || Mesg.Point.y != mMovePoint.y) { DrawMoveFrame(TRUE); mMovePoint = Mesg.Point; DrawMoveFrame(FALSE); } } else { if (StatusIs(PSF_SIZEABLE) && !mbMaximized) { UCHAR uTemp = BorderContains(Mesg.Point); if (uTemp != mbShowPointer) { mbShowPointer = uTemp; switch(uTemp) { case PMM_MOVELEFT: case PMM_MOVERIGHT: SetPointerType(PPT_HSIZE); break; case PMM_MOVETOP: case PMM_MOVEBOTTOM: SetPointerType(PPT_VSIZE); break; case PMM_MOVEUR: case PMM_MOVELL: SetPointerType(PPT_NESW_SIZE); break; case PMM_MOVEUL: case PMM_MOVELR: SetPointerType(PPT_NWSE_SIZE); break; default: SetPointerType(PPT_NORMAL); break; } } } } break; case PM_SHOW: PegThing::Message(Mesg); #if defined(PEG_KEYBOARD_SUPPORT) && defined(PEG_TAB_KEY_SUPPORT) SetDefaultTabLinks(); #endif if (muScrollMode & WSM_AUTOSCROLL) { CheckAutoScroll(); } break; #if defined(PEG_KEYBOARD_SUPPORT) case PM_GAINED_KEYBOARD: if (!StatusIs(PSF_KEEPS_CHILD_FOCUS)) { MoveFocusToFirstClientChild(); } break; #else case PM_CURRENT: PegThing::Message(Mesg); if (Presentation()->GetCurrentThing() == this && !StatusIs(PSF_KEEPS_CHILD_FOCUS)) { MoveFocusToFirstClientChild(); } break; #endif case PM_ADDICON: AddIcon((PegIcon *) Mesg.pData); break; case PM_BEGIN_MOVE: if (!muMoveMode && StatusIs(PSF_MOVEABLE)) { muMoveMode = (UCHAR) Mesg.iData; mbMoveFrame = FALSE; CapturePointer(); mStartMove = Mesg.Point; mMovePoint = mStartMove; if (muMoveMode == PMM_MOVELR) { SetPointerType(PPT_NWSE_SIZE); mbShowPointer = TRUE; } } break; case PM_POINTER_EXIT: if (mbShowPointer) { SetPointerType(PPT_NORMAL); mbShowPointer = 0; } PegThing::Message(Mesg); break; case PM_LBUTTONDOWN: if (!muMoveMode && StatusIs(PSF_SIZEABLE) && !mbMaximized) { muMoveMode = BorderContains(Mesg.Point); if (muMoveMode) { mbMoveFrame = FALSE; CapturePointer(); mStartMove = Mesg.Point; mMovePoint = mStartMove; } } break; case PM_LBUTTONUP: if (muMoveMode) { DrawMoveFrame(TRUE); SetPointerType(PPT_NORMAL); ReleasePointer(); PegRect OldSize = mReal; if (mStartMove.x == mMovePoint.x && mStartMove.y == mMovePoint.y) { muMoveMode = 0; break; // didn't really move or size anything } PegRect NewSize = mReal; int xShift = mMovePoint.x - mStartMove.x; int yShift = mMovePoint.y - mStartMove.y; switch(muMoveMode) { case PMM_MOVEALL: NewSize.Shift(xShift, yShift); break; case PMM_MOVERIGHT: NewSize.wRight += xShift; break; case PMM_MOVELEFT: NewSize.wLeft += xShift; break; case PMM_MOVETOP: NewSize.wTop += yShift; break; case PMM_MOVEBOTTOM: NewSize.wBottom += yShift; break; case PMM_MOVEUL: NewSize.wLeft += xShift; NewSize.wTop += yShift; break; case PMM_MOVELL: NewSize.wLeft += xShift; NewSize.wBottom += yShift; break; case PMM_MOVEUR: NewSize.wRight += xShift; NewSize.wTop += yShift; break; case PMM_MOVELR: NewSize.wRight += xShift; NewSize.wBottom += yShift; break; } CheckResizeRect(NewSize); NewMessage.wType = PM_SIZE; NewMessage.Rect = NewSize; Message(NewMessage); if (StatusIs(PSF_VISIBLE)) { if (mReal.Contains(OldSize)) { Draw(); } else { Parent()->Draw(); } } muMoveMode = 0; } break; case PM_VSCROLL: MoveClientObjects(0, Mesg.iData - (SIGNED) Mesg.lData); break; case PM_HSCROLL: MoveClientObjects(Mesg.iData - (SIGNED) Mesg.lData, 0); break; case PM_MAXIMIZE: if (StatusIs(PSF_SIZEABLE)) { mbMaximized = TRUE; mRestore = mReal; NewMessage.wType = PM_SIZE; NewMessage.Rect = Parent()->mClient; Message(NewMessage); Draw(); } break; case PM_MINIMIZE: if (StatusIs(PSF_SIZEABLE) && !IsModal()) { NewMessage.wType = PM_ADDICON; PegIcon *pIcon = new PegIcon(this, mpIconMap); pIcon->Id(Id()); NewMessage.pData = pIcon; NewMessage.pTarget = Parent(); MessageQueue()->Push(NewMessage); Parent()->Remove(this); } break; case PM_RESTORE: if (StatusIs(PSF_SIZEABLE)) { if (mbMaximized) { mbMaximized = FALSE; NewMessage.wType = PM_SIZE; NewMessage.Rect = mRestore; Message(NewMessage); Parent()->Draw(); } } break; #ifdef PEG_KEYBOARD_SUPPORT case PM_KEY: if (Parent() == Presentation() && Mesg.iData == PK_F4 && (Mesg.lData & KF_CTRL)) { NewMessage.wType = PM_CLOSE; NewMessage.pTarget = this; MessageQueue()->Push(NewMessage); } else { return PegThing::Message(Mesg); } break; #endif case PM_CLOSE: Destroy(this); return(IDB_CLOSE); case PEG_SIGNAL(IDB_CLOSE, PSF_CLICKED): case PEG_SIGNAL(IDB_OK, PSF_CLICKED): case PEG_SIGNAL(IDB_CANCEL, PSF_CLICKED): case PEG_SIGNAL(IDB_YES, PSF_CLICKED): case PEG_SIGNAL(IDB_NO, PSF_CLICKED): case PEG_SIGNAL(IDB_RETRY, PSF_CLICKED): case PEG_SIGNAL(IDB_ABORT, PSF_CLICKED): case PEG_SIGNAL(IDB_APPLY, PSF_CLICKED): Destroy(this); return(Mesg.iData); default: return (PegThing::Message(Mesg)); } return (Result); }
/*--------------------------------------------------------------------------*/ SIGNED PegWindow::Execute(void) { PegMessage pSend; mbModal = TRUE; SIGNED iReturn; #ifdef PEG_MULTITHREAD if (CURRENT_TASK != PEG_TASK_PTR) { Presentation()->BeginSubTaskExecute(this); } #endif if (!StatusIs(PSF_VISIBLE)) { Presentation()->Add(this); } while(1) { MessageQueue()->Pop(&pSend); switch (pSend.wType) { case PM_LBUTTONDOWN: case PM_RBUTTONDOWN: case PM_LBUTTONUP: case PM_RBUTTONUP: #ifdef PEG_MULTITHREAD if (CURRENT_TASK == PEG_TASK_PTR) { if (Presentation()->RouteMessageToTask(&pSend)) { break; } } #endif if (mReal.Contains(pSend.Point) || Presentation()->IsPointerCaptured()) { //Presentation()->DispatchMessage(this, &pSend); Presentation()->DispatchMessage(Presentation(), &pSend); } break; case PM_POINTER_MOVE: #ifdef PEG_MULTITHREAD if (CURRENT_TASK == PEG_TASK_PTR) { if (Presentation()->RouteMessageToTask(&pSend)) { break; } } #endif if (mReal.Contains(pSend.Point) || Presentation()->IsPointerCaptured()) { //Presentation()->DispatchMessage(this, &pSend); Presentation()->DispatchMessage(Presentation(), &pSend); } else { if (mbShowPointer) { SetPointerType(PPT_NORMAL); mbShowPointer = 0; } Screen()->SetPointer(pSend.Point); } break; #ifdef PEGWIN32 // When running under Windows, the user might close the development // window, without first closing the modal PEG window. There seems to be // no way to prevent this. In order to terminate correctly, we push // a couple of PM_EXIT messages, to be sure that all modal windows are // terminated, and PegPresentationManager returns. case PM_EXIT: { PegMessage NewMessage; NewMessage.wType = PM_EXIT; NewMessage.pTarget = Presentation(); NewMessage.pSource = NULL; MessageQueue()->Push(NewMessage); MessageQueue()->Push(NewMessage); return(PM_EXIT); } #endif #ifdef PEG_KEYBOARD_SUPPORT case PM_KEY: if (pSend.iData == PK_TAB && (pSend.lData & KF_CTRL)) { break; } // fall throught to the default case: #endif default: #ifdef PEG_MULTITHREAD if (CURRENT_TASK == PEG_TASK_PTR) { if (Presentation()->RouteMessageToTask(&pSend)) { break; } } #endif iReturn = Presentation()->DispatchMessage(this, &pSend); if (iReturn) { #ifdef PEG_MULTITHREAD Presentation()->EndSubTaskExecute(this); #endif return(iReturn); } } } }