/ATF2/FlightSim/coreApps/timeZoneGui.m

http://atf2flightsim.googlecode.com/ · MATLAB · 140 lines · 52 code · 26 blank · 62 comment · 5 complexity · 361db2828ee4eb234d7300639fd8245b MD5 · raw file

  1. function varargout = timeZoneGui(varargin)
  2. % TIMEZONEGUI M-file for timeZoneGui.fig
  3. % TIMEZONEGUI, by itself, creates a new TIMEZONEGUI or raises the existing
  4. % singleton*.
  5. %
  6. % H = TIMEZONEGUI returns the handle to a new TIMEZONEGUI or the handle to
  7. % the existing singleton*.
  8. %
  9. % TIMEZONEGUI('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in TIMEZONEGUI.M with the given input arguments.
  11. %
  12. % TIMEZONEGUI('Property','Value',...) creates a new TIMEZONEGUI or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before timeZoneGui_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to timeZoneGui_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22. % Edit the above text to modify the response to help timeZoneGui
  23. % Last Modified by GUIDE v2.5 10-Aug-2009 16:33:46
  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name', mfilename, ...
  27. 'gui_Singleton', gui_Singleton, ...
  28. 'gui_OpeningFcn', @timeZoneGui_OpeningFcn, ...
  29. 'gui_OutputFcn', @timeZoneGui_OutputFcn, ...
  30. 'gui_LayoutFcn', [] , ...
  31. 'gui_Callback', []);
  32. if nargin && ischar(varargin{1})
  33. gui_State.gui_Callback = str2func(varargin{1});
  34. end
  35. if nargout
  36. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38. gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT
  41. % --- Executes just before timeZoneGui is made visible.
  42. function timeZoneGui_OpeningFcn(hObject, eventdata, handles, varargin)
  43. % This function has no output args, see OutputFcn.
  44. % hObject handle to figure
  45. % eventdata reserved - to be defined in a future version of MATLAB
  46. % handles structure with handles and user data (see GUIDATA)
  47. % varargin command line arguments to timeZoneGui (see VARARGIN)
  48. global FL
  49. % Choose default command line output for timeZoneGui
  50. handles.output = handles;
  51. % Update handles structure
  52. guidata(hObject, handles);
  53. % UIWAIT makes timeZoneGui wait for user response (see UIRESUME)
  54. % uiwait(handles.figure1);
  55. tzp=textscan(evalc('FL.tzfunc.places()'),'%s','Delimiter','\n');
  56. set(handles.listbox1,'String',tzp{1})
  57. set(handles.listbox1,'Value',find(ismember(tzp{1},FL.timezoneName),1))
  58. set(handles.checkbox1,'Value',FL.timezoneDST)
  59. % --- Outputs from this function are returned to the command line.
  60. function varargout = timeZoneGui_OutputFcn(hObject, eventdata, handles) %#ok<*INUSL>
  61. % varargout cell array for returning output args (see VARARGOUT);
  62. % hObject handle to figure
  63. % eventdata reserved - to be defined in a future version of MATLAB
  64. % handles structure with handles and user data (see GUIDATA)
  65. % Get default command line output from handles structure
  66. varargout{1} = handles.output;
  67. % --- Executes on selection change in listbox1.
  68. function listbox1_Callback(hObject, eventdata, handles) %#ok<*INUSD,*DEFNU>
  69. % hObject handle to listbox1 (see GCBO)
  70. % eventdata reserved - to be defined in a future version of MATLAB
  71. % handles structure with handles and user data (see GUIDATA)
  72. global FL
  73. try
  74. contents = get(hObject,'String');
  75. FL.timezone=FL.tzfunc.zone(contents{get(hObject,'Value')})+get(handles.checkbox1,'Value');
  76. FL.timezoneName=contents{get(hObject,'Value')};
  77. catch
  78. errordlg('Error setting timezone','timezone error')
  79. end
  80. % --- Executes during object creation, after setting all properties.
  81. function listbox1_CreateFcn(hObject, eventdata, handles)
  82. % hObject handle to listbox1 (see GCBO)
  83. % eventdata reserved - to be defined in a future version of MATLAB
  84. % handles empty - handles not created until after all CreateFcns called
  85. % Hint: listbox controls usually have a white background on Windows.
  86. % See ISPC and COMPUTER.
  87. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  88. set(hObject,'BackgroundColor','white');
  89. end
  90. % --- Executes on button press in pushbutton1.
  91. function pushbutton1_Callback(hObject, eventdata, handles)
  92. % hObject handle to pushbutton1 (see GCBO)
  93. % eventdata reserved - to be defined in a future version of MATLAB
  94. % handles structure with handles and user data (see GUIDATA)
  95. guiCloseFn('timeZoneGui',handles);
  96. % --- Executes when user attempts to close figure1.
  97. function figure1_CloseRequestFcn(hObject, eventdata, handles)
  98. % hObject handle to figure1 (see GCBO)
  99. % eventdata reserved - to be defined in a future version of MATLAB
  100. % handles structure with handles and user data (see GUIDATA)
  101. guiCloseFn('timeZoneGui',handles);
  102. % --- Executes on button press in checkbox1.
  103. function checkbox1_Callback(hObject, eventdata, handles)
  104. % hObject handle to checkbox1 (see GCBO)
  105. % eventdata reserved - to be defined in a future version of MATLAB
  106. % handles structure with handles and user data (see GUIDATA)
  107. global FL
  108. try
  109. contents = get(handles.listbox1,'String');
  110. FL.timezone=FL.tzfunc.zone(contents{get(handles.listbox1,'Value')})+get(hObject,'Value');
  111. FL.timezoneDST=get(hObject,'Value');
  112. catch
  113. errordlg('Error Setting Timezone','timezone error')
  114. end