📄 vboxc.c
字号:
} if ( This->vScrollInc > 1 ) { float dy = ((float)py*(float)This->vScrollInc) * 0.01; new_y += (int)(dy+0.5); } else if ( py > 0 ) { new_y += 1; } else if ( py < 0 ) { new_y -= 1; }//// Sanity check.// if ( new_x <= 0 ) new_x = 0; else if ( new_x > This->hScrollMaxValue ) new_x = This->hScrollMaxValue; if ( new_y <= 0 ) new_y = 0; else if ( new_y > This->vScrollMaxValue ) new_y = This->vScrollMaxValue;//// See if the position has changed.// int moved = 0; if ( new_x != This->hScrollValue ) { moved = 1; This->hScrollValue = new_x; if ( This->hScrollOn ) XtVaSetValues(This->hScrollBar, XmNvalue, This->hScrollValue, NULL); } if ( new_y != This->vScrollValue ) { moved = 1; This->vScrollValue = new_y; if ( This->vScrollOn ) XtVaSetValues(This->vScrollBar, XmNvalue, This->vScrollValue, NULL); }//// Redraw if necessary.// if ( moved || This->joyStick->State() == RELEASE_JOYSTICK ) { This->view->Redraw(); }} // End DoMoveJoyStick()/*----------------------------------------------------------------------- * Control access to popup menu */voidVBoxC::DisablePopupMenu(){ popupEnabled = False;}voidVBoxC::EnablePopupMenu(){ if ( !viewPopup ) return; popupEnabled = True;}/*----------------------------------------------------------------------- * Control visibility of status line */voidVBoxC::HideStatus(){ if ( !statusShown ) return;#if 1 WArgList args; args.BottomAttachment(XmATTACH_FORM); XtSetValues(scrollForm, ARGS);#endif XtUnmanageChild(statusForm); statusShown = False;} // End ShowStatusvoidVBoxC::ShowStatus(){ if ( statusShown ) return; XtManageChild(statusForm);#if 1 WArgList args; args.BottomAttachment(XmATTACH_WIDGET, statusForm); XtSetValues(scrollForm, ARGS);#endif statusShown = True;} // End HideStatus/*----------------------------------------------------------------------- * React to view item changes */voidVBoxC::ItemFieldChanged(VItemC *item, VBoxC *This){ if ( This->realized && This->view ) This->view->ChangeItemFields(*item);}voidVBoxC::ItemLabelChanged(VItemC *item, VBoxC *This){ if ( This->realized && This->view ) This->view->ChangeItemLabel(*item);}voidVBoxC::ItemPixmapChanged(VItemC *item, VBoxC *This){ if ( This->realized && This->view ) This->view->ChangeItemPixmaps(*item);}/*----------------------------------------------------------------------- * React to view item changes */voidVBoxC::SetSorted(Boolean val){//// Rebuild the visible items list// visItems.removeAll(); u_int count = items.size(); for (int i=0; i<count; i++) { VItemC *item = items[i];//// If it passes the filter, add it to the visible list// if ( !filtFunc ) { visItems.add(item); } else if ( filterOutput == DISPLAY_FILTER_OUTPUT ) { if ( (*filtFunc)(*item) ) visItems.add(item); } else /* if ( filterOutput == SELECT_FILTER_OUTPUT ) */ { visItems.add(item); } } // End for each view item visItems.SetSorted(val); changed = True;} // End SetSorted/*----------------------------------------------------------------------- * Change state of drag and drop handling */voidVBoxC::EnableDrag(Boolean val){ if ( dragEnabled == val ) return; dragEnabled = val;}voidVBoxC::EnableDrop(Boolean val){ if ( dropEnabled == val ) return; dropEnabled = val; ChangeDrop();}/*----------------------------------------------------------------------- * Method to set the types of items that can be dropped in this view box */voidVBoxC::SetDropAtoms(Atom *atoms, int count){ if ( count > dropAtomAlloc ) { delete dropAtoms; dropAtoms = new Atom[count]; dropAtomAlloc = count; } for (int i=0; i<count; i++) dropAtoms[i] = atoms[i]; dropAtomCount = count; ChangeDrop();}/*----------------------------------------------------------------------- * Method to update drag and drop status */voidVBoxC::ChangeDrop(){ if ( !realized ) return; WArgList args; args.Reset(); args.ImportTargets(dropAtoms); args.NumImportTargets(dropAtomCount); args.DropSiteActivity(dropEnabled ? XmDROP_SITE_ACTIVE : XmDROP_SITE_INACTIVE); XmDropSiteUpdate(viewDA, ARGS);}/*----------------------------------------------------------------------- * Handle drag over event */voidVBoxC::HandleDragOver(Widget w, XtPointer, XmDragProcCallbackStruct *dp){ if ( dp->reason == XmCR_DROP_SITE_MOTION_MESSAGE ) { VBoxC *This; XtVaGetValues(w, XmNuserData, &This, NULL); if ( This->view && This->dropCalls.size() > 0 ) This->view->HandleDragOver(dp); else dp->dropSiteStatus = XmINVALID_DROP_SITE; } // End if this is a motion message dp->animate = False;} // End HandleDragOver/*----------------------------------------------------------------------- * Handle drop event */voidVBoxC::HandleDropIn(Widget w, XtPointer, XmDropProcCallbackStruct *dp){ VBoxC *This; XtVaGetValues(w, XmNuserData, &This, NULL); if ( !This->view ) return;//// Call drop callbacks// if ( This->dropCalls.size()>0 && This->view->DropItem() ) { ViewDropDataT dropData; dropData.item = This->view->DropItem(); dropData.viewBox = This; dropData.procData = dp; This->CallDropCallbacks(&dropData); } else {//// Drop must be acknowledged// WArgList args; args.TransferStatus(XmTRANSFER_FAILURE); XmDropTransferStart(dp->dragContext, ARGS); } This->view->DropFinished();} // End HandleDropIn/*----------------------------------------------------------------------- * Handle horizontal scroll */voidVBoxC::HandleHScroll(Widget, VBoxC *This, XmScrollBarCallbackStruct *sb){//// If this is a drag scroll, see if there are any more scroll events coming.// If there are, ignore this one.// if ( sb->reason == XmCR_DRAG && sb->event->type == MotionNotify ) { XMotionEvent *ev = (XMotionEvent*)sb->event; XEvent next; if ( XCheckTypedEvent(ev->display, ev->type, &next) ) { XPutBackEvent(ev->display, &next); return; } } This->hScrollValue = sb->value; if ( This->realized && This->view ) This->view->Redraw();} // End HandleHScroll/*----------------------------------------------------------------------- * Handle vertical scroll */voidVBoxC::HandleVScroll(Widget, VBoxC *This, XmScrollBarCallbackStruct *sb){//// If this is a drag scroll, see if there are any more scroll events coming.// If there are, ignore this one.// if ( sb->reason == XmCR_DRAG && sb->event->type == MotionNotify ) { XMotionEvent *ev = (XMotionEvent*)sb->event; XEvent next; if ( XCheckTypedEvent(ev->display, ev->type, &next) ) { XPutBackEvent(ev->display, &next); return; } } This->vScrollValue = sb->value; if ( This->realized && This->view ) This->view->Redraw();} // End HandleVScroll/*----------------------------------------------------------------------- * Methods to turn scrollbars on */voidVBoxC::EnableHScroll(){ if ( hScrollOn ) return; hScrollValue = 0; hScrollOn = True; int val, size, inc, pinc; XmScrollBarGetValues(hScrollBar, &val, &size, &inc, &pinc); XmScrollBarSetValues(hScrollBar, hScrollValue, size, inc, pinc, False); Dimension ht; Dimension delta = scrollBoff - noScrollBoff; XtVaGetValues(viewFrame, XmNheight, &ht, NULL); XtVaSetValues(viewFrame, XmNheight, ht-delta, XmNbottomOffset, scrollBoff, NULL); XtMapWidget(hScrollBar); if ( vScrollOn && !joyStickOn ) { XtMapWidget(joyStickFrame); joyStickOn = True; }}voidVBoxC::EnableVScroll(){ if ( vScrollOn ) return; vScrollValue = 0; vScrollOn = True; int val, size, inc, pinc; XmScrollBarGetValues(vScrollBar, &val, &size, &inc, &pinc); XmScrollBarSetValues(vScrollBar, vScrollValue, size, inc, pinc, False);// XtVaSetValues(vScrollBar, XmNvalue, 0, NULL); Dimension wd; Dimension delta = scrollRoff - noScrollRoff; XtVaGetValues(viewFrame, XmNwidth, &wd, NULL); XtVaSetValues(viewFrame, XmNwidth, wd-delta, XmNrightOffset, scrollRoff, NULL); XtMapWidget(vScrollBar); if ( hScrollOn && !joyStickOn ) { XtMapWidget(joyStickFrame); joyStickOn = True; }}/*----------------------------------------------------------------------- * Methods to turn scrollbars off */voidVBoxC::DisableHScroll(){ if ( !hScrollOn ) return; hScrollValue = 0; hScrollOn = False; XtUnmapWidget(hScrollBar); Dimension ht; Dimension delta = scrollBoff - noScrollBoff; XtVaGetValues(viewFrame, XmNheight, &ht, NULL); XtVaSetValues(viewFrame, XmNheight, ht+delta, XmNbottomOffset, noScrollBoff, NULL); if ( joyStickOn ) { XtUnmapWidget(joyStickFrame); joyStickOn = False; }}voidVBoxC::DisableVScroll(){ if ( !vScrollOn ) return; vScrollValue = 0; vScrollOn = False; XtUnmapWidget(vScrollBar); Dimension wd; Dimension delta = scrollRoff - noScrollRoff; XtVaGetValues(viewFrame, XmNwidth, &wd, NULL); XtVaSetValues(viewFrame, XmNwidth, wd+delta, XmNrightOffset, noScrollRoff, NULL); if ( joyStickOn ) { XtUnmapWidget(joyStickFrame); joyStickOn = False; }}/*----------------------------------------------------------------------- * Method to set size of scrollbars */voidVBoxC::UpdateScrollBars(){ int wd, ht; view->GetSize(&wd, &ht); if ( wd < 1 ) wd = 1; if ( ht < 1 ) ht = 1;//// Set the scrollbars// if ( wd <= visRect.wd ) { DisableHScroll(); hScrollMaxValue = 0; } else { EnableHScroll(); // This can change visRect.wd if ( visRect.wd > wd ) wd = visRect.wd; int incr = wd/(int)10; hScrollMaxValue = wd - visRect.wd; if ( hScrollValue > hScrollMaxValue ) hScrollValue = hScrollMaxValue; XtVaSetValues(hScrollBar, XmNsliderSize, visRect.wd, XmNmaximum, wd, XmNincrement, incr, XmNvalue, hScrollValue, NULL); } if ( ht <= visRect.ht ) { DisableVScroll(); vScrollMaxValue = 0; } else { EnableVScroll(); // This can change visRect.ht if ( visRect.ht > ht ) ht = visRect.ht; int count = visItems.size(); int incr = (count > 0) ? ht/count : ht; vScrollMaxValue = ht - visRect.ht; if ( vScrollValue > vScrollMaxValue ) vScrollValue = vScrollMaxValue; XtVaSetValues(vScrollBar, XmNsliderSize, visRect.ht, XmNmaximum, ht, XmNincrement, incr, XmNvalue, vScrollValue, NULL); }} // End UpdateScrollBars/*----------------------------------------------------------------------- * Public method to set the font */voidVBoxC::SetFont(XFontStruct *newFont){ if ( freeFontList ) XmFontListFree(fontList); if ( freeFont ) XFreeFont(halApp->display, font); fontList = NULL; freeFontList = False; font = newFont; freeFont = False;//// Redraw the current view// if ( view ) { view->PlaceItems(); UpdateScrollBars(); view->Redraw(); }} // End SetFont/*----------------------------------------------------------------------- * Public method to set the fontList */voidVBoxC::SetFontList(XmFontList newFontList){ if ( freeFontList ) XmFontListFree(fontList); fontList = XmFontListCopy(newFontList);//// Redraw the current view// if ( view ) { view->PlaceItems(); UpdateScrollBars(); view->Redraw(); }} // End SetFont
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -