Reverse color table appearance in popup menu
jtigor
Fri, 09/04/2015 - 12:47 pm
Is there a relatively simple way (such as a keyword) to reverse the color range for a color table displayed in a popup menu control? For example, to show the grays color table ranging from white to black instead of black to white in a popup menu control.
Thanks,
Jeff
What is your use case here?
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
September 8, 2015 at 11:32 am - Permalink
I had hoped to be able to display the color table on the panel in the same "orientation" as it would appear in use. That is, the rainbow color table in the popupmenu should display running from a low of blue to a high of red if the Invert CTab checkbox were selected.
September 8, 2015 at 12:20 pm - Permalink
STRUCT WMPopupAction &pa
switch( pa.eventCode )
case 2: // mouse up
String ColorTableName = pa.popStr
ControlInfo/W=Panel0 ReverseCheck
Variable checked=V_value
ModifyImage/W=Panel0#G0 dummyColors ctab={*,*,$ColorTableName,checked}
break
case -1: // control being killed
break
endswitch
return 0
End
Function ReverseCheckProc(cba) : CheckBoxControl
STRUCT WMCheckboxAction &cba
switch( cba.eventCode )
case 2: // mouse up
ControlInfo/W=Panel0 ColorTablePop
String ColorTableName = S_value
ModifyImage/W=Panel0#G0 dummyColors ctab={*,*,$ColorTableName,cba.checked}
break
case -1: // control being killed
break
endswitch
return 0
End
Function MakeThePanel()
if (WinType("Panel0") != 7)
Make/N=(500,2)/O dummyColors = p
NewPanel /W=(144,50,456,250)
PopupMenu ColorTablePop,pos={16.00,23.00},size={256.00,23.00},proc=PopMenuProc,title="Color Table:"
PopupMenu ColorTablePop,mode=4,value= #"\"*COLORTABLEPOPNONAMES*\""
CheckBox ReverseCheck,pos={100.00,59.00},size={51.00,16.00},proc=ReverseCheckProc,title="Reverse"
CheckBox ReverseCheck,value= 0
DefineGuide UGH0={FT,91},UGH1={UGH0,19},UGV0={FL,78},UGV1={UGV0,173}
Display/W=(54,50,225,150)/FG=(UGV0,UGH0,UGV1,UGH1)/HOST=#
AppendImage dummyColors
ModifyImage dummyColors ctab= {*,*,BlueHot,0}
ModifyGraph margin(left)=-1,margin(bottom)=-1,margin(top)=-1,margin(right)=-1
ModifyGraph mirror=0
ModifyGraph noLabel=2
ModifyGraph axThick=0
RenameWindow #,G0
SetActiveSubwindow ##
else
DoWindow/F Panel0
endif
end
Execute MakeThePanel() to try it out.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
September 9, 2015 at 10:18 am - Permalink
Your example works very nicely. This will be a simple addition to my panel.
Maybe this capability will be present in a forthcoming major platform upgrade.
Thanks for the quick code example.
Jeff
September 9, 2015 at 12:01 pm - Permalink
I've incorporated your ideas into my panel.
Thanks.
Jeff
September 11, 2015 at 01:44 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
September 14, 2015 at 10:02 am - Permalink