! 
! @OPENGROUP_COPYRIGHT@
! COPYRIGHT NOTICE
! Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
! Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
! ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
! the full copyright text.
! 
! This software is subject to an open license. It may only be
! used on, with or for operating systems which are themselves open
! source systems. You must contact The Open Group for a license
! allowing distribution and sublicensing of this software on, with,
! or for operating systems which are not Open Source programs.
! 
! See http://www.opengroup.org/openmotif/license for full
! details of the license agreement. Any use, reproduction, or
! distribution of the program constitutes recipient's acceptance of
! this agreement.
! 
! EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
! PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
! KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
! WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
! OR FITNESS FOR A PARTICULAR PURPOSE
! 
! EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
! NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
! INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
! AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
! ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
! EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
! POSSIBILITY OF SUCH DAMAGES.
! 
! 
! HISTORY
! 
!   $XConsortium: ColorM1.uil /main/6 1995/07/13 18:35:18 drk $
!******************************************************************************
module color
    version = 'v1.0'
    names = case_sensitive


! the major procedures used within this module.
! note that other procedures can be (and are) defined near the widget(s)
! which use them.
procedure
    load_rgb_text();
    setcolor_button_pressed();
    toggle_button_pressed(string);
    scale_value_changed(string);
    exit_color();

! icons for use in main window buttons, and associated color info
value black  : color('black',foreground);
value white  : color('white',background);
value green  : color('green',background);
value blue   : color('blue',background);
value yellow : color('yellow',background);
value orange : color('orange',background);
value violet : color('violet',background);
value red    : color('red',background);

value color_h_offset: 15;
value color_v_offset: 10;
value scales_left_offset: 60;

value variable: font('variable');

procedure destroy_colorform();
procedure color_selection_made();

object color_main : XmMainWindow {
        controls {
        };
	arguments {
		XmNwidth = 10;
		XmNheight = 10;
	};
};

object
    color_form : XmFormDialog {
	arguments {
	    XmNx = 0;
	    XmNy = 0;
	    XmNdialogTitle = 'Color View';
	    XmNdialogStyle = XmDIALOG_MODELESS;
	    XmNwidth = 450;
	    XmNheight = 775;
	    XmNautoUnmanage = false;
	    XmNresizable = true;
	    XmNrubberPositioning = true;
	    XmNresizePolicy = XmRESIZE_ANY;
	    XmNdefaultPosition = false;
	};
	controls {
	    XmBulletinBoard	color_change_BB;
	    XmPushButton	color_patch;
	    XmPushButton	do_it;
	    XmRadioBox		color_choices;
	    XmSelectionBox 	color_sb;
	    XmForm		slider_box;
	};
	callbacks {
	    XmNdestroyCallback = procedure destroy_colorform();
	};
};

object color_change_BB: XmBulletinBoard {
	arguments {
		XmNborderWidth = 1;
		XmNrightAttachment = XmATTACH_FORM;
		XmNrightOffset = color_h_offset;
		XmNtopAttachment = XmATTACH_FORM;
		XmNtopOffset = color_h_offset*2;
		XmNbottomAttachment = XmATTACH_POSITION;
		XmNbottomPosition = 30;
		XmNbottomOffset = color_h_offset;
	};
	controls{
		XmPushButton 	color_change;
	};
};

object color_change: XmPushButton {
	arguments {
		XmNfontList = variable;
		XmNshadowThickness = 5;
		XmNtraversalOn = false;
		XmNwidth = 190;
		XmNheight = 165;
		XmNlabelString = compound_string('Change PushButton');
	};
};

! the bottom of the color patch button is attached to a position
! 30% into the form; the top is attached to a fixed offset from
! the top of the form.
object color_patch: XmPushButton {
	arguments {
		XmNfontList = variable;
		XmNtraversalOn = false;
		XmNleftAttachment = XmATTACH_FORM;
		XmNleftOffset = color_h_offset;
		XmNrightAttachment = XmATTACH_WIDGET;
		XmNrightWidget = XmBulletinBoard color_change_BB;
		XmNrightOffset = color_h_offset;
		XmNtopAttachment = XmATTACH_FORM;
		XmNtopOffset = color_h_offset*2;
		XmNbottomAttachment = XmATTACH_POSITION;
		XmNbottomPosition = 30;
		XmNbottomOffset = color_h_offset;
		XmNlabelString = compound_string('Current Color Value');
	};
};

object color_choices: XmRadioBox {
	arguments{
		XmNleftAttachment = XmATTACH_FORM;
		XmNrightAttachment = XmATTACH_FORM;
		XmNleftOffset = color_h_offset;
		XmNrightOffset = color_h_offset;
		XmNtopAttachment = XmATTACH_WIDGET;
		XmNtopWidget = XmPushButton do_it;
		XmNtopOffset = 10;
		XmNpacking = XmPACK_COLUMN;
		XmNnumColumns = 2;
		};
	controls{
		XmToggleButton	fore;
		XmToggleButton	back;
		XmToggleButton	top;
		XmToggleButton	bottom;
		XmToggleButton	arm;
		XmToggleButton	calc_colors;
		};
};

object do_it: XmPushButton {
	arguments{
		XmNleftAttachment = XmATTACH_FORM;
		XmNleftOffset = color_h_offset;
		XmNrightAttachment = XmATTACH_FORM;
		XmNrightOffset = color_h_offset;
		XmNtopAttachment = XmATTACH_WIDGET;
		XmNtopOffset = 10;
		XmNtopWidget = XmBulletinBoard color_change_BB;
		XmNbottomOffset = 10;
		XmNheight = 40;
		XmNlabelString = 'Push To Change Color of Change PushButton';
		XmNfontList = variable;
		XmNbackground = yellow;
		};
	callbacks{
		XmNactivateCallback = procedure setcolor_button_pressed();
		};
};


object fore: XmToggleButton { 
	arguments{
		XmNselectColor = violet;
		XmNlabelString = 'Change Foreground Color';
		};
	callbacks {
		XmNvalueChangedCallback = 
		procedure toggle_button_pressed('F');
		};
};

object back: XmToggleButton {
	arguments{
		XmNselectColor = violet;
		XmNlabelString = 'Change Background Color';
		};
	callbacks {
		XmNvalueChangedCallback = 
		procedure toggle_button_pressed('B');
		};
};

object top: XmToggleButton {
	arguments{
		XmNselectColor = violet;
		XmNlabelString = 'Change Top Shadow Color';
		};
	callbacks {
		XmNvalueChangedCallback = 
		procedure toggle_button_pressed('T');
		};
};

object bottom: XmToggleButton {
	arguments{
		XmNselectColor = violet;
		XmNlabelString = 'Change Bottom Shadow Color';
		};
	callbacks {
		XmNvalueChangedCallback = 
		procedure toggle_button_pressed('X');
		};
};

object arm: XmToggleButton {
	arguments{
		XmNselectColor = violet;
		XmNlabelString = 'Change Arm Color';
		};
	callbacks {
		XmNvalueChangedCallback = 
		procedure toggle_button_pressed('A');
		};
};
object calc_colors: XmToggleButton {
	arguments{
		XmNselectColor = violet;
		XmNlabelString = 'Calculate Default Color';
		};
	callbacks {
		XmNvalueChangedCallback = 
		procedure toggle_button_pressed('D');
		};
};

! the top of the slider group is attached to the bottom of the color patch;
! this is equivalent to attaching it to the form's 30% position
object slider_box : XmForm {
	arguments {
	    XmNleftAttachment = XmATTACH_FORM;
	    XmNrightAttachment = XmATTACH_FORM;
	    XmNtopAttachment = XmATTACH_WIDGET;
	    XmNtopWidget = XmRadioBox color_choices;
	    XmNtopOffset = color_v_offset;
	    XmNbottomAttachment = XmATTACH_WIDGET;
	    XmNbottomWidget = XmSelectionBox color_sb;
	    XmNbottomOffset = color_v_offset;
	};
	controls {
	    XmScale       scale1;
	    XmScale       scale2;
	    XmScale       scale3;
	    XmForm      labelbox;   
	};
};

object color_sb : XmSelectionBox {
	arguments {
	    XmNleftAttachment = XmATTACH_FORM;
	    XmNrightAttachment = XmATTACH_FORM;
	    XmNbottomAttachment = XmATTACH_FORM;
	    XmNlistVisibleItemCount = 5;
	    XmNdialogType = XmDIALOG_SELECTION;
	    XmNokLabelString = compound_string("Exit");
	};
	callbacks {
	    MrmNcreateCallback = procedure load_rgb_text();
	    XmNokCallback = procedure exit_color();
	};
};

! arguments common to all 3 color scales (horizontal)
list scale_args : arguments {
	    XmNshowValue = true;
	    XmNtopAttachment = XmATTACH_POSITION;
	    XmNbottomAttachment = XmATTACH_POSITION;
	    XmNbottomOffset = 5;
	    XmNleftAttachment = XmATTACH_WIDGET;
	    XmNleftWidget = labelbox;
	    XmNrightAttachment = XmATTACH_FORM;
	    XmNorientation = XmHORIZONTAL;
	    XmNprocessingDirection = XmMAX_ON_RIGHT;
!	    XmNleftOffset = scales_left_offset;
	    XmNrightOffset = color_h_offset;
	    XmNheight = 100;
};

! arguments common to all 3 color scales (vertical)
list vscale_args : arguments {
	    XmNtopAttachment = XmATTACH_FORM;
	    XmNbottomAttachment = XmATTACH_FORM;
	    XmNleftOffset = color_h_offset;
	    XmNleftAttachment = XmATTACH_POSITION;
	    XmNrightAttachment = XmATTACH_POSITION;
	    XmNorientation = XmVERTICAL;
	    XmNprocessingDirection = XmMAX_ON_RIGHT;
};

object
    scale1 : XmScale {
	arguments { 
	    XmNbackground = color('red');
	    XmNtopPosition = 0;
	    XmNbottomPosition = 30;
	    XmNmaximum = 255;
	    arguments scale_args;
!	arguments below are for vertical scale orientation
!	    left_position = 0;
!	    right_position = 33;
!	    arguments vscale_args;
	};
	callbacks {
		XmNvalueChangedCallback = procedure scale_value_changed('r');
		XmNdragCallback = procedure scale_value_changed('r');
	};
    };

object
    scale2 : XmScale {
	arguments { 
	    XmNbackground = color('green');
	    XmNtopPosition = 35;
	    XmNbottomPosition = 65;
	    XmNmaximum = 255;
	    arguments scale_args;
!	arguments below are for vertical scale orientation
!	    left_position = 36;
!	    right_position = 70;
!	    arguments vscale_args;
	};
	callbacks {
		XmNvalueChangedCallback = procedure scale_value_changed('g');
		XmNdragCallback = procedure scale_value_changed('g');
	};
    };

object
    scale3 : XmScale {
	arguments { 
	    XmNbackground = color('blue');
	    XmNtopPosition = 70;
	    XmNbottomPosition = 100;
	    XmNmaximum = 255;
	    arguments scale_args;
!	arguments below are for vertical scale orientation
!	    left_position = 73;
!	    right_position = 100;
!	    arguments vscale_args;
	};
	callbacks {
		XmNvalueChangedCallback = procedure scale_value_changed('b');
		XmNdragCallback = procedure scale_value_changed('b');
	};
    };

! the labelbox resizes with its parent form, so that its children,
! which are anchored to positions in the labelbox, track their scales
! after resize.
object labelbox: XmForm {
	arguments { 
		XmNtopAttachment = XmATTACH_FORM;
		XmNbottomAttachment = XmATTACH_FORM;
!		XmNrightAttachment = XmATTACH_WIDGET;
		XmNleftAttachment = XmATTACH_FORM;
!		XmNrightOffset = 15;
!		XmNtopWidget = XmScale scale1;
!		XmNrightWidget = XmScale scale1;
	};
	controls {
		XmLabel  label1;
		XmLabel  label2;
		XmLabel  label3;
	};
};

object label1: XmLabel {
	arguments {
		XmNtopAttachment = XmATTACH_NONE;
		XmNlabelString = compound_string('Red');
		XmNforeground = white;
	};
};

object label2: XmLabel {
	arguments {
		XmNtopAttachment = XmATTACH_POSITION;
		XmNtopPosition = 35;
		XmNlabelString = compound_string('Green');
		XmNforeground = white;
	};
};

object label3: XmLabel  {
	arguments {
		XmNtopAttachment = XmATTACH_POSITION;
		XmNtopPosition = 70;
		XmNlabelString = compound_string('Blue');
		XmNforeground = white;
	};
};

end module;
