PtContainerHold, PtContainerRelease — prevent/allow updating of container-widget contents.
PtContainerHold (widget) PtContainerRelease (widget)
PtContainerHold prevents the updating of contents of the widget. PtContainerRelease allows updating to continue.
Successive calls to PtContainerHold increment a counter. An equal number of calls to PtContainerRelease are required to decrement the counter so the widget can be updated.
This example, ex_PtContainerHold.g, is included in the product distribution.
#!/usr/cogent/bin/phgamma /* This sample program puts two panes in a window. Each pane contains a label that is updated every second by a timer. A button toggles the Held and Released state for each pane. */ require_lisp("PhotonWidgets"); PtInit(nil); win=new(PtWindow); class_add_ivar(PtPane,#held,nil); but1 = new(PtButton); but1.text_string = "Released"; but1.SetPos(20,40); but2 = new(PtButton); but2.text_string = "Released"; but2.SetPos(20,140); pane1 = new(PtPane); pane1.fill_color = PgRGB(160,160,160); pane1.SetArea(100,0,200,100); time1 = new(PtLabel); time1.text_string = date(); PtSetParentWidget(win); pane2 = new(PtPane); pane2.fill_color = PgRGB(220,220,220); pane2.SetArea(100,100,200,100); time2 = new(PtLabel); time2.text_string = date(); every(1,#time1.text_string = date()); every(1,#time2.text_string = date()); function toggle_hold (pane) { if (pane.held) { PtContainerRelease(pane); pane.held = nil; widget.text_string = "Released"; } else { PtContainerHold(pane); pane.held = t; widget.text_string = "Held"; } } PtAttachCallback(but1,Pt_CB_RAW,#toggle_hold(pane1),Ph_EV_BUT_PRESS); PtAttachCallback(but2,Pt_CB_RAW,#toggle_hold(pane2),Ph_EV_BUT_PRESS); PtRealizeWidget(win); PtMainLoop();
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.