Blame view

src/idl_misc/coyote_for_Dustemwrap/mpi_axis.pro 5.83 KB
6db3528a   Jean-Philippe Bernard   adding librairies...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
;******************************************************************************************;
;  Copyright (c) 2008, by Fanning Software Consulting, Inc.                                ;
;  All rights reserved.                                                                    ;
;                                                                                          ;
;  Redistribution and use in source and binary forms, with or without                      ;
;  modification, are permitted provided that the following conditions are met:             ;
;                                                                                          ;
;      * Redistributions of source code must retain the above copyright                    ;
;        notice, this list of conditions and the following disclaimer.                     ;
;      * Redistributions in binary form must reproduce the above copyright                 ;
;        notice, this list of conditions and the following disclaimer in the               ;
;        documentation and/or other materials provided with the distribution.              ;
;      * Neither the name of Fanning Software Consulting, Inc. nor the names of its        ;
;        contributors may be used to endorse or promote products derived from this         ;
;        software without specific prior written permission.                               ;
;                                                                                          ;
;  THIS SOFTWARE IS PROVIDED BY FANNING SOFTWARE CONSULTING, INC. ''AS IS'' AND ANY        ;
;  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES    ;
;  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT     ;
;  SHALL FANNING SOFTWARE CONSULTING, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,             ;
;  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED    ;
;  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;         ;
;  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS           ;
;  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                            ;
;******************************************************************************************;
PRO MPI_Axis_Widget_Events, Event

; The main event handler for the compound widget. It should react only
; to the button events "Accept" or "Dismiss"


   Catch, theError
   IF theError NE 0 THEN BEGIN
      print, '%% Error diagnostics: widget event = '
      help,event,/stru
      ok = Dialog_Message('Error handling widget event!')
      RETURN
   ENDIF

   Widget_Control, event.ID, Get_UValue=theMessage
   IF theMessage.Button EQ 'Close' THEN  $
      Obj_Destroy, theMessage.KillObject  $
   ELSE $
      theMessage.Object->UpdateObject

   Widget_Control, event.top, /Destroy

END ;-----------------------------------------------------------------------------------------------------------------------------


FUNCTION MPI_Axis,  $
            Group_Leader=group_leader,  $
            XAxis=xaxis,  $
            YAxis=yaxis,  $
            Short=short,  $
            Only_Style=only_style,  $
            Only_Tick=only_tick,    $
            _Extra=e


   ON_Error, 2
   IF Keyword_Set(XAxis) EQ 0 AND Keyword_Set(YAxis) EQ 0 THEN BEGIN
      Message, 'You must specify either X axis or y axis!'
   ENDIF

   block = 1  ; always block this widget

   ; Set widget label font name.

   thisOS = StrUpCase(!Version.os_family)
   CASE thisOS OF
      'WINDOWS': BEGIN
         labelfont = 'Times*Bold'
         defaultfont = 'MS Sans Serif*10'
      END
      'MACOS': BEGIN
         labelfont = 'Times*Bold'
         defaultfont = 'Times*10'
      END
      ELSE: BEGIN
;;++mgs
;;   self.labelfont = '-adobe-times-bold-r-normal--10-100-75-75-p-57-iso8859-1'
         labelfont = '-*-times-bold-r-*-*-12-*'
;;   self.defaultfont = '8x13'
         defaultfont = '-*-times-medium-r-*-*-12-*'
;;--mgs
      END
   ENDCASE
   
   
   Widget_Control, Default_Font=defaultfont
   
   IF N_Elements(group_leader) EQ 0 THEN BEGIN
      tlb = Widget_Base(Column=1, Title='Axis Options...', Base_Align_Center=1)
   ENDIF ELSE BEGIN
      tlb = Widget_Base(Column=1, Title='Axis Options...', Base_Align_Center=1, $
                        Group_Leader=group_leader)
   ENDELSE
   
   mainbase = Widget_Base(tlb, Base_Align_Center=1, Column=1, Frame=1)
   
   
   IF Keyword_Set(Xaxis) THEN axis = Obj_New("MPI_Axis", /Xaxis, _Extra=e)
   IF Keyword_Set(Yaxis) THEN axis = Obj_New("MPI_Axis", /YAxis, _Extra=e)
   
   IF NOT Obj_Valid(axis) THEN BEGIN
      Message, 'Error initialising axis object!'
   ENDIF

   axisID = axis->GUI(tlb, short=short, only_style=only_style, only_tick=only_tick)

   buttonbase = Widget_Base(tlb, Row=1)
   button = Widget_Button(buttonbase, Value='Close', $
                          UValue={Button:'Close', KillObject:axis})
   IF Keyword_Set(block) THEN BEGIN
      button = Widget_Button(buttonbase, Value='Accept', $
                             UValue={Button:'Accept', Object:axis})
   ENDIF ELSE BEGIN
      button = Widget_Button(buttonbase, Value='Apply', $
                             UValue={Button:'Apply', object:axis})
   ENDELSE

   CenterTLB, tlb
   Widget_Control, tlb, /Realize

   XManager, 'mpi_axis', tlb, Event_Handler='MPI_Axis_Widget_Events', $
      No_Block = 1 - Keyword_Set(block)

   ;; If widget was cancelled, it will destroy the axis object. Hence,
   ;; a valid object reference means, the choices were accepted
   IF Obj_Valid(axis) THEN BEGIN
      keywords = axis->GetKeywords()
      Obj_Destroy, axis
   ENDIF ELSE BEGIN
      keywords = { dummy:''}
   ENDELSE

   RETURN, keywords
END