Prog::Prog(const Theme & theme, ALLEGRO_DISPLAY *display) :
   d(Dialog(theme, display, 20, 30)),
   source_label(Label("Source")),
   dest_label(Label("Destination")),
   source_list(List()),
   dest_list(List()),
   true_formats(Label("")),
   use_memory_button(ToggleButton("Use memory bitmaps")),
   enable_timing_button(ToggleButton("Enable timing")),
   time_label(Label(""))
{
   d.add(source_label, 11, 0, 4,  1);
   d.add(source_list,  11, 1, 4, 27);
   d.add(dest_label,   15, 0, 4,  1);
   d.add(dest_list,    15, 1, 4, 27);
   d.add(true_formats, 0, 15, 10, 1);
   d.add(use_memory_button,  0, 17, 10, 2);
   d.add(enable_timing_button,  0, 19, 10, 2);
   d.add(time_label,  0, 21, 10, 1);

   for (unsigned i = 0; i < NUM_FORMATS; i++) {
      source_list.append_item(formats[i].name);
      dest_list.append_item(formats[i].name);
   }
}
Ejemplo n.º 2
0
void wxRibbonButtonBar::UpdateWindowUI(long flags)
{
    wxWindowBase::UpdateWindowUI(flags);

    // don't waste time updating state of tools in a hidden toolbar
    if ( !IsShown() )
        return;

    size_t btn_count = m_buttons.size();
    bool rerealize = false;
    for ( size_t btn_i = 0; btn_i < btn_count; ++btn_i )
    {
        wxRibbonButtonBarButtonBase& btn = *m_buttons.Item(btn_i);
        int id = btn.id;

        wxUpdateUIEvent event(id);
        event.SetEventObject(this);

        if ( ProcessWindowEvent(event) )
        {
            if ( event.GetSetEnabled() )
                EnableButton(id, event.GetEnabled());
            if ( event.GetSetChecked() )
                ToggleButton(id, event.GetChecked());
            if ( event.GetSetText() )
            {
                btn.label = event.GetText();
                rerealize = true;
            }
        }
    }

    if ( rerealize )
        Realize();
}
Ejemplo n.º 3
0
void
SelectableList::addListItem(std::string item) {

  // TODO Do not add item that already exists.
  int x{m_xCoordinate + 5};
  int y = m_yCoordinate + m_height - (5 + 30 * (1 + m_buttons.size()));
  int width{m_width - 10};
  int height{30};
  auto func = [&](int id) {
    ToggleButton* button = getButtonWithId(id);
    if (button->isToggled()) {
      // If there already is a button toggled, untoggle it.
      if (m_currentlyToggled)
        m_currentlyToggled->toggle();

      m_currentlyToggled = button;
    } else {
      // No button is toggled.
      m_currentlyToggled = nullptr;
    }
  };

  ToggleButton button = ToggleButton(
    ++idCounter, x, y, width, height, m_graphicsManager, func, item, m_layer);
  m_buttons.push_back(std::move(button));
}
Ejemplo n.º 4
0
/*
** Handle 5-way navigation (right).
*/
static Boolean ThumbnailViewHandleFiveWayNavLeft(void) {
  if (!d.fiveWayNavigation) {
    FrmGotoForm(DiddleListForm);
  } else {
    /* Deselect previous item */     
    ToggleButton(d.thumbnailX, d.thumbnailY, false);
    
    /* Select new item, scroll if necessary */
    if (ThumbnailViewMoveCursorLeft())
      ThumbnailViewScroll(-1);        
    UpdateButtonAndIndex();
  }

  return true;
}
Ejemplo n.º 5
0
bool CSDKBot::ThinkReload() {
	//Spam the reload button - the reload only happens when the button changes
	ToggleButton(IN_RELOAD);

	//if we're capturing a flag, don't do anything
	if (m_PlayerSearchInfo.CloseFriend() && IsCapturingEnemyFlagAttempt()) {
		StopMoving();
	} else if (m_PlayerSearchInfo.CloseEnemy() && m_PlayerSearchInfo.OutNumbered() > 0.35) {
		MoveAwayFromEnemy();
	} else if (m_PlayerSearchInfo.CloseFriend() && !m_PlayerSearchInfo.CloseFriend()->Weapon_InReload()) {
		MoveToNearestTeammate();
	} else {
		MoveToWaypoint();
	}
	return true;
}
Ejemplo n.º 6
0
/* 
** Handle 5-way navigation select.
*/
static Boolean ThumbnailViewHandleFiveWayNavSelect(void) {
  if (d.records_in_cat) {
    if (!d.fiveWayNavigation) {
      d.fiveWayNavigation = true;
      
      if (p.dbI == noRecordSelected)
    p.dbI = d.top_visible_record;
      
      MapIndexToCoordinates(&p.dbI, &d.thumbnailX, &d.thumbnailY);
      ToggleButton(d.thumbnailX, d.thumbnailY, true);       
    } else {
      d.fiveWayNavigation = false;
      p.dbI = MapCoordinatesToIndex(d.thumbnailX, d.thumbnailY);
      FrmGotoForm(p.flags & PFLAGS_WITH_TITLEBAR ? DiddleTForm : DiddleForm);
    }
  }
  
  return true;
}
Ejemplo n.º 7
0
/***********************************************************************
 *
 * FUNCTION:    ThumbnailViewHandleEvent
 *
 * DESCRIPTION: This routine is the event handler for the "Thumbnail View"
 *              of the Record application.
 *
 * PARAMETERS:  event  - a pointer to an EventType structure
 *
 * RETURNED:    true if the event was handled and should not be passed
 *              to a higher level handler.
 *
 ***********************************************************************/
Boolean ThumbnailViewHandleEvent (EventPtr event) {
  FormPtr frm = NULL;
  Boolean handled = false;

  switch (event->eType) {
  case keyDownEvent:
    /* Hardware button pressed? */
    if (TxtCharIsHardKey(event->data.keyDown.modifiers, event->data.keyDown.chr)) {
      if (!(event->data.keyDown.modifiers & poweredOnKeyMask))
    ThumbnailViewNextCategory();
      handled = true;
    } else if (EvtKeydownIsVirtual(event)) {
      switch (event->data.keyDown.chr) {
      case vchrPageUp:
      case vchrRockerUp:
    if (d.fiveWayNavigation) {
      /* Deselect previous item */
      ToggleButton(d.thumbnailX, d.thumbnailY, false);
      
      /* Select new item, scroll if necessary */
      if (ThumbnailViewMoveCursorUp())
        ThumbnailViewScroll(-1);
      UpdateButtonAndIndex();
    } else {
      ThumbnailViewPageScroll(winUp);
    }
    handled = true;
    break;

      case vchrPageDown:
      case vchrRockerDown:
    if (d.fiveWayNavigation) {
      /* Deselect previous item */
      ToggleButton(d.thumbnailX, d.thumbnailY, false);
      
      /* Select new item, scroll if necessary */
      if (ThumbnailViewMoveCursorDown())
        ThumbnailViewScroll(1);
      UpdateButtonAndIndex();
    } else {
      ThumbnailViewPageScroll(winDown);
    }
    handled = true;
    break;
    
    /* Treo 600 5-way navigation */
      case vchrRockerCenter:
    handled = ThumbnailViewHandleFiveWayNavSelect();
    break;
      case vchrRockerLeft:
    handled = ThumbnailViewHandleFiveWayNavLeft();
    break;
      case vchrRockerRight:
    handled = ThumbnailViewHandleFiveWayNavRight();
    break;

    /* Tungsten 5-way navigation */
      case vchrNavChange:
    if (NavDirectionPressed(event, Left))
      handled = ThumbnailViewHandleFiveWayNavLeft();
    else if (NavDirectionPressed(event, Right))
      handled = ThumbnailViewHandleFiveWayNavRight();
    else if (NavSelectPressed(event))
      handled = ThumbnailViewHandleFiveWayNavSelect();
    break;

/*       case vchrSendData: */
/*  ThumbnailViewDoCommand(ThumbnailRecordBeamCategoryCmd); */
/*  handled = true; */
/*  break; */

      default:
    /* ignore */
      }
    }
    break;

  case ctlSelectEvent:
    switch (event->data.ctlSelect.controlID) {
    case NewButton:
      /* Create new sketch after all existing ones */
      p.dbI = DmNumRecords(d.dbR);

      AllocImage();
      FrmGotoForm(p.flags & PFLAGS_WITH_TITLEBAR ? DiddleTForm : DiddleForm);
      handled = true;
      break;

    case CategoryPop:
      ThumbnailViewSelectCategory();
      handled = true;
      break;

    case TextListButton:
      FrmGotoForm(DiddleListForm);
      handled = true;
      break;

    case ThumbnailDetailListButton:
      FrmGotoForm(DiddleThumbnailDetailForm);
      handled = true;
      break;
    }
    break;

  case frmGotoEvent:
    p.dbI = event->data.frmGoto.recordNum;
    SwitchCategoryForGoto();
    FrmGotoForm(p.flags & PFLAGS_WITH_TITLEBAR ? DiddleTForm : DiddleForm);
    event->eType = dbOpenRecordFieldEvent;
    EvtAddEventToQueue(event);

    handled = true;
    break;

  case menuEvent:
    {
      Char chr = 0;

      switch(event->data.menu.itemID) {
      case menuitemID_CmdAbout:
    DoAboutDialog();
    handled = true;
    break;

      case menuitemID_CmdSecurity:
    ThumbnailDoCmdSecurity();
    handled = true;
    break;

      case menuitemID_CmdSortByAlarm:      
      case menuitemID_CmdSortByName:
    if (event->data.menu.itemID == menuitemID_CmdSortByAlarm)
      DmInsertionSort(d.dbR, &SortByAlarmTime, 0);
    else
      DmInsertionSort(d.dbR, &SortByName, 0);

        SetTopVisibleRecord(0);
    ThumbnailViewLoadRecords(FrmGetActiveForm());
    handled = true;
    break;

      case menuitemID_CmdPref: chr=cmdPref; break;
      case menuitemID_CmdExtPref: chr=cmdExtPref; break;
      case menuitemID_CmdHWPref: chr=cmdHWPref; break;
      case menuitemID_CmdAlarmPref: chr=cmdAlarmPref; break;
      case menuitemID_CmdHelp: chr=cmdHelp; break;
      }

      if (!handled)
    handled = KeyDown(chr);
    }
    break;

  case frmOpenEvent:
    frm = FrmGetActiveForm();
    ThumbnailViewInit(frm);
    FrmDrawForm(frm);

    /* Disable 5-way navigation initially */
    d.fiveWayNavigation = false;

    /* Clean up */
    if (d.record_name) MemHandleFree(d.record_name);
    d.record_name = NULL;
    if (d.record_note) MemHandleFree(d.record_note);
    d.record_note = NULL;

    handled = true;
    break;

  case frmUpdateEvent:
    handled = ThumbnailViewUpdateDisplay(event->data.frmUpdate.updateCode);
    break;

  case menuCmdBarOpenEvent:
    MenuCmdBarAddButton(menuCmdBarOnLeft, BarSecureBitmap,
            menuCmdBarResultMenuItem, menuitemID_CmdSecurity, 0);

    /* Tell the field package to not add buttons automatically; */
    /* we've done it all ourselves.                             */
    event->data.menuCmdBarOpen.preventFieldButtons = true;

    /* don't set handled to true; this event must fall through to the system. */
    break;

  case sclRepeatEvent:
    ThumbnailViewScroll (event->data.sclRepeat.newValue - event->data.sclRepeat.value);
    break;

  case dbNonKeyCommandEvent:
    handled = HandleNonKeyCommandCode(event->data.menu.itemID);
    break;

/*   case frmObjectFocusTakeEvent: */
/*     { */
/*       RectangleType r; */
/*       FormType* frm = FrmGetFormPtr(event->data.frmObjectFocusTake.formID); */
/*       const UInt16 id = event->data.frmObjectFocusTake.objectID; */
/*       const UInt16 idx = FrmGetObjectIndex(frm, id); */

/*       if (id >= Thumb1 && id <= Thumb30) { */
/*  FrmGetObjectBounds(frm, idx, &r); */
/*  FrmSetFocus(frm, idx); */
/*  HsNavDrawFocusRing(frm, id, hsNavFocusRingNoExtraInfo, &r, */
/*             hsNavFocusRingStyleObjectTypeDefault, false); */
/*  handled = true; */
/*       } */
/*     } */
/*     break; */

  default:
    /* do nothing */
  }

  return handled;
}
Ejemplo n.º 8
0
/*
** Highlight the cursor position and update the record index.
*/
static void UpdateButtonAndIndex(void) {
  ToggleButton(d.thumbnailX, d.thumbnailY, true);
  p.dbI = MapCoordinatesToIndex(d.thumbnailX, d.thumbnailY);
}
Ejemplo n.º 9
0
short PDClick(DialogPtr dialog, short itemNum, long lParam, VOIDPTR data)
{
	short oldScreen;
	long menuID_menuItem;
	long newMode = ADVANCEDMODE;
	Boolean closeFile = false, bOkToChange, disableDST;
	
#pragma unused(lParam)
#pragma unused(data)
	
	switch (itemNum) {
		case M1OK:

			if (GetButton(dialog, M1USERWIZARD)) newMode = NOVICEMODE;
			//else if (GetButton(dialog, M1USERINTERMEDIATE)) newMode = INTERMEDIATEMODE;
			else if (GetButton(dialog, M1USERADVANCED)) newMode = ADVANCEDMODE;

			// if they are switching to modes, we must check with the wizard
			// if there is a wizard file, we must close it because they may have changed stuff
			// if they are switching to advanced mode and have have a wizard file open
			//	we need to tell them they cannot get back
			// without starting all over
			bOkToChange = model->fWizard->OKToChangeWizardMode(model -> GetModelMode (),newMode,&closeFile);
			if(!bOkToChange) break;
			if(closeFile) 
			{
				OSErr err = CloseSaveFile(FALSE,FALSE);// wizard gave them a chance to back out
				if(err == USERCANCEL) break;
			}
			
			// point of no return
			///////////
			settings.backgroundColor = 1; // white JLM ???
				
			settings.showLatLongLines = GetButton(dialog, D1SHOWLATLONG);
			if (GetButton(dialog, D1DEG)) settings.latLongFormat = DEGREES;
			if (GetButton(dialog, D1DEGMIN)) settings.latLongFormat = DEGMIN;
			if (GetButton(dialog, D1DEGMINSEC)) settings.latLongFormat = DMS;
			if (GetButton(dialog, D1ABOVE)) settings.llPosition = LL_ABOVE;
			if (GetButton(dialog, D1BELOW)) settings.llPosition = LL_BELOW;
			settings.showIntermediateLines = GetButton(dialog, D1INTERMEDIATELINES);
			settings.customGrid = GetButton(dialog, D1CUSTOM);
			settings.longLineSpace = GetGridValue(dialog, D1LONGLINE);
			settings.longLabelSpace = GetGridValue(dialog, D1LONGLABEL);
			settings.latLineSpace = GetGridValue(dialog, D1LATLINE);
			settings.latLabelSpace = GetGridValue(dialog, D1LATLABEL);
			settings.longLineUnits = GetPopSelection(dialog, D1LONGLINEUNITSPOPUP) - 1;
			settings.longLabelUnits = GetPopSelection(dialog, D1LONGLABELUNITSPOPUP) - 1;
			settings.latLineUnits = GetPopSelection(dialog, D1LATLINEUNITSPOPUP) - 1;
			settings.latLabelUnits = GetPopSelection(dialog, D1LATLABELUNITSPOPUP) - 1;
			
//			settings.massUnits = GetPopSelection(dialog, E1MASSPOPUP);
//			settings.areaUnits = GetPopSelection(dialog, E1AREAPOPUP);
		
			if (GetButton(dialog, M1USERWIZARD)) model -> SetModelMode (NOVICEMODE);
			//if (GetButton(dialog, M1USERINTERMEDIATE)) model -> SetModelMode (INTERMEDIATEMODE);
			if (GetButton(dialog, M1USERADVANCED)) model -> SetModelMode (ADVANCEDMODE);
			if (GetButton(dialog, M1STARTUPWIZARD)) settings.modelStartMode = NOVICEMODE;
			//if (GetButton(dialog, M1STARTUPINTERMEDIATE)) settings.modelStartMode = INTERMEDIATEMODE;
			if (GetButton(dialog, M1STARTUPADVANCED)) settings.modelStartMode = ADVANCEDMODE;
			
			disableDST = GetButton(dialog, C1DSTCHECKBOX);
			if (disableDST) settings.daylightSavingsTimeFlag = DAYLIGHTSAVINGSOFF;
			else settings.daylightSavingsTimeFlag = DAYLIGHTSAVINGSON;

			return M1OK;
		
		case M1CANCEL: return M1CANCEL;
		
		case M1TAB1:
		case M1TAB2:
		case M1TAB3:
		case M1TAB4:
		case M1TAB5:
			if (settings.preferencesScreen == itemNum)
				break;
			oldScreen = settings.preferencesScreen;
			settings.preferencesScreen = itemNum;
			DrawTab(dialog, oldScreen, FALSE);
			DrawTab(dialog, settings.preferencesScreen, TRUE);
			ShowPreferenceScreen(dialog, oldScreen);
			break;
		
		
		
		case D1SHOWLATLONG:
			ToggleButton(dialog, D1SHOWLATLONG);
			EnableLatLongControls(dialog);
			break;
		
		case D1DEG:
		case D1DEGMIN:
		case D1DEGMINSEC:
			SetButton(dialog, D1DEG, itemNum == D1DEG);
			SetButton(dialog, D1DEGMIN, itemNum == D1DEGMIN);
			SetButton(dialog, D1DEGMINSEC, itemNum == D1DEGMINSEC);
			break;
		
		case D1ABOVE:
		case D1BELOW:
			SetButton(dialog, D1ABOVE, itemNum == D1ABOVE);
			SetButton(dialog, D1BELOW, itemNum == D1BELOW);
			break;
		
		case D1INTERMEDIATELINES:
			ToggleButton(dialog, D1INTERMEDIATELINES);
			break;
		
		case D1CUSTOM:
			ToggleButton(dialog, D1CUSTOM);
			EnableLatLongControls(dialog);
			break;
		
		case D1LONGLINE:
		case D1LONGLABEL:
		case D1LATLINE:
		case D1LATLABEL:
			CheckNumberTextItem(dialog, itemNum, FALSE);
			break;
		
		//case M1BACKCOLORPOPUP:
		case D1LONGLINEUNITSPOPUP:
		case D1LONGLABELUNITSPOPUP:
		case D1LATLINEUNITSPOPUP:
		case D1LATLABELUNITSPOPUP:
//		case E1MASSPOPUP:
//		case E1AREAPOPUP:
			PopClick(dialog, itemNum, &menuID_menuItem);
			break;

		case M1USERWIZARD:
		//case M1USERINTERMEDIATE:
		case M1USERADVANCED:
			SetButton(dialog, M1USERWIZARD, itemNum == M1USERWIZARD);
			//SetButton(dialog, M1USERINTERMEDIATE, itemNum == M1USERINTERMEDIATE);
			SetButton(dialog, M1USERADVANCED, itemNum == M1USERADVANCED);
			break;
		
		case M1STARTUPWIZARD:
		//case M1STARTUPINTERMEDIATE:
		case M1STARTUPADVANCED:
			SetButton(dialog, M1STARTUPWIZARD, itemNum == M1STARTUPWIZARD);
			//SetButton(dialog, M1STARTUPINTERMEDIATE, itemNum == M1STARTUPINTERMEDIATE);
			SetButton(dialog, M1STARTUPADVANCED, itemNum == M1STARTUPADVANCED);
			break;
		
		case C1DSTCHECKBOX:
			ToggleButton(dialog, C1DSTCHECKBOX);
			break;
		
	}
	
	return 0;
}
Ejemplo n.º 10
0
short GridWindClick(DialogPtr dialog, short itemNum, long lParam, VOIDPTR data)
{	
	long menuID_menuItem;
	switch (itemNum) {
		case M18OK:
		{	
			short timeZone = GetPopSelection(dialog, M18bTIMEZONEPOPUP);
			Seconds timeShift = sharedWMover->timeGrid->fTimeShift;
			long timeShiftInHrs;
			
			short angleUnits = GetPopSelection(dialog, M18ANGLEUNITSPOPUP);
			
			timeShiftInHrs = EditText2Long(dialog, M18bTIMESHIFT);
			if (timeShiftInHrs < -12 || timeShiftInHrs > 14)	// what should limits be?
			{
				printError("Time offsets must be in the range -12 : 14");
				MySelectDialogItemText(dialog, M18bTIMESHIFT,0,100);
				break;
			}
			
			//mygetitext(dialog, M18bFILENAME, sharedWMover->fFileName, kPtCurUserNameLen-1);
			mygetitext(dialog, M18bFILENAME, sharedWMover->timeGrid->fVar.userName, kPtCurUserNameLen-1);
			sharedWMover -> bActive = GetButton(dialog, M18ACTIVE);
			sharedWMover->bShowArrows = GetButton(dialog, M18bSHOWARROWS);
			sharedWMover->fArrowScale = EditText2Float(dialog, M18bARROWSCALE);
			
			sharedWMover -> fAngleScale = EditText2Float(dialog,M18ANGLESCALE);
			if (angleUnits==2) sharedWMover->fAngleScale *= PI/180.;		
			sharedWMover -> fSpeedScale = EditText2Float(dialog,M18SPEEDSCALE);
			sharedWMover -> fUncertainStartTime = (long) round(EditText2Float(dialog,M18UNCERTAINSTARTTIME)*3600);
			
			sharedWMover -> fDuration = EditText2Float(dialog, M18DURATION) * 3600;
			
			if (timeZone>1) sharedWMover->timeGrid->fTimeShift =(long)( EditText2Float(dialog, M18bTIMESHIFT)*3600);
			else sharedWMover->timeGrid->fTimeShift = 0;	// file is in local time
			
			//if (model->GetStartTime() != startTime || model->GetModelTime()!=model->GetStartTime())
			//if (timeShift != sharedWMover->fTimeShift || sharedWMover->GetTimeValue(0) != model->GetStartTime())
			// code goes here, if decide to use this check GetTimeValue is using new fTimeShift...
			//{
			//Seconds timeValZero = sharedWMover->GetTimeValue(0), startTime = model->GetStartTime();
			if (timeShift != sharedWMover->timeGrid->fTimeShift && sharedWMover->timeGrid->GetTimeValue(0) != model->GetStartTime())
			{
				model->SetStartTime(model->GetStartTime() + (sharedWMover->timeGrid->fTimeShift-timeShift));
				//model->SetStartTime(sharedWMover->GetTimeValue(0));
				//sNetCDFDialogMover->SetInterval(errmsg);
				model->NewDirtNotification(DIRTY_RUNBAR); // must reset the runbar
			}
			//}
			sharedWMover->timeGrid->fAllowExtrapolationInTime = GetButton(dialog, M18bEXTRAPOLATECHECKBOX);
			// code goes here, check interval?
			return M18OK;
		}
		case M18CANCEL: return M18CANCEL;
			
		case M18ACTIVE:
		case M18bSHOWARROWS:
		case M18bEXTRAPOLATECHECKBOX:
			ToggleButton(dialog, itemNum);
			break;
			
		case M18bARROWSCALE:
		case M18DURATION:
		case M18UNCERTAINSTARTTIME:
		case M18ANGLESCALE:
		case M18SPEEDSCALE:
			CheckNumberTextItem(dialog, itemNum, TRUE);
			break;
			
		case M18ANGLEUNITSPOPUP:
			PopClick(dialog, itemNum, &menuID_menuItem);
			break;
			
		case M18bTIMESHIFT:
			CheckNumberTextItemAllowingNegative(dialog, itemNum, TRUE);	// decide whether to allow half hours
			break;
			
		case M18bTIMEZONEPOPUP:
			PopClick(dialog, itemNum, &menuID_menuItem);
			ShowGridWindMoverDialogItems(dialog);
			if (GetPopSelection(dialog, M18bTIMEZONEPOPUP) == 2) MySelectDialogItemText(dialog, M18bTIMESHIFT, 0, 100);
			break;
			
		case M18bGMTOFFSETS:
		{
			char gmtStr[512], gmtStr2[512];
			strcpy(gmtStr,"Standard time offsets from GMT\n\nHawaiian Standard -10 hrs\nAlaska Standard -9 hrs\n");
			strcat(gmtStr,"Pacific Standard -8 hrs\nMountain Standard -7 hrs\nCentral Standard -6 hrs\nEastern Standard -5 hrs\nAtlantic Standard -4 hrs\n");
			strcpy(gmtStr2,"Daylight time offsets from GMT\n\nHawaii always in standard time\nAlaska Daylight -8 hrs\n");
			strcat(gmtStr2,"Pacific Daylight -7 hrs\nMountain Daylight -6 hrs\nCentral Daylight -5 hrs\nEastern Daylight -4 hrs\nAtlantic Daylight -3 hrs");
			//printNote(gmtStr);
			short buttonSelected  = MULTICHOICEALERT2(1691,gmtStr,gmtStr2,TRUE);
			switch(buttonSelected){
				case 1:// ok
					//return -1;// 
					break;  
				case 3: // cancel
					//return -1;// 
					break;
			}
			break;
		}
	}
	
	return noErr;
}
Ejemplo n.º 11
0
short GridCurrentMoverSettingsClick(DialogPtr dialog, short itemNum, long lParam, VOIDPTR data)
{
	long menuID_menuItem;
	switch (itemNum) {
		case M33OK:
		{
			char errmsg[256];
			short timeZone = GetPopSelection(dialog, M33TIMEZONEPOPUP);
			Seconds timeShift = sGridCurrentDialogMover->timeGrid->fTimeShift;
			float arrowDepth = EditText2Float(dialog, M33ARROWDEPTH), maxDepth=0;
			float maxDepthForExtrapolation = EditText2Float(dialog, M33EXTRAPOLATETOVALUE);
			double tempAlong, tempCross, tempDuration, tempStart;
			long timeShiftInHrs;
			Boolean extrapolateVertically = GetButton(dialog, M33EXTRAPOLATEVERTCHECKBOX);
			//Boolean extrapolateVertically = false;
			Boolean showBottomVel = GetButton(dialog, M33VELOCITYATBOTTOMCHECKBOX);
			TMap *map = sGridCurrentDialogMover -> GetMoverMap();
			
			if (showBottomVel) arrowDepth = -2;	//check maxDepth>0
			if (map)
			{
				maxDepth = map -> GetMaxDepth2();	// 2D vs 3D ?
				//arrowDepth = EditText2Float(dialog, M33ARROWDEPTH);
				if (arrowDepth > maxDepth)
				{
					char errStr[64];
					sprintf(errStr,"The maximum depth of the region is %g meters.",maxDepth);
					printError(errStr);
					break;
				}
			}
			else
			{	// only need this if doing something 3D
				maxDepth = ((TimeGridVelRect*) (sGridCurrentDialogMover -> timeGrid)) -> GetMaxDepth();
				//maxDepth = 1000;
				if (arrowDepth > maxDepth)
				{
					char errStr[64];
					sprintf(errStr,"The maximum depth of the region is %g meters.",maxDepth);
					printError(errStr);
					break;
				}
			}
			
			strcpy(errmsg,"");
			tempAlong = EditText2Float(dialog, M33ALONG);
			tempCross = EditText2Float(dialog, M33CROSS);
			tempDuration = EditText2Float(dialog, M33DURATION);
			tempStart = EditText2Float(dialog, M33STARTTIME);
			if(tempAlong <= 0 || tempCross <= 0) strcpy(errmsg,"The uncertainty must be greater than zero.");	
			else if(tempAlong > 100 || tempCross > 100)	strcpy(errmsg,"The uncertainty cannot exceed 100%.");
			
			if(errmsg[0])
			{
				printError(errmsg);
				if (tempAlong <= 0 || (tempAlong > 100 && tempCross > 0)) MySelectDialogItemText(dialog, M33ALONG,0,100);
				else MySelectDialogItemText(dialog, M33CROSS,0,100);
				break;
			}
			
			if(tempDuration < 1) strcpy(errmsg,"The uncertainty duration must be at least 1 hour.");	// maximum?
			if(errmsg[0])
			{
				printError(errmsg);
				MySelectDialogItemText(dialog, M33DURATION,0,100);
				break;
			}
			
			timeShiftInHrs = EditText2Long(dialog, M33TIMESHIFT);
			if (timeShiftInHrs < -12 || timeShiftInHrs > 14)	// what should limits be?
			{
				printError("Time offsets must be in the range -12 : 14");
				MySelectDialogItemText(dialog, M33TIMESHIFT,0,100);
				break;
			}
			
			if (extrapolateVertically)
			{
				if (maxDepthForExtrapolation==0)
				{
					if (maxDepth>0) 
						sprintf(errmsg,"Either set a max depth for extrapolation or turn off option. The maximum depth of the region is %g meters.",maxDepth);
					else
						sprintf(errmsg,"Either set a max depth for extrapolation or turn off option");
					printNote(errmsg);
					break;
				}
				if (maxDepth>0 && maxDepthForExtrapolation>maxDepth)
				{
					sprintf(errmsg,"The maximum depth of the region is %g meters.",maxDepth);
					printNote(errmsg);
					break;
				}
			}
			mygetitext(dialog, M33NAME, sGridCurrentDialogMover->timeGrid->fVar.userName, kPtCurUserNameLen-1);
			sGridCurrentDialogMover->bActive = GetButton(dialog, M33ACTIVE);
			sGridCurrentDialogMover->fVar.bShowArrows = GetButton(dialog, M33SHOWARROWS);
			sGridCurrentDialogMover->fVar.arrowScale = EditText2Float(dialog, M33ARROWSCALE);
			sGridCurrentDialogMover->fVar.arrowDepth = arrowDepth;
			//sGridCurrentDialogMover->timeGrid->fVar.fileScaleFactor = EditText2Float(dialog, M33SCALE);
			sGridCurrentDialogMover->fVar.curScale = EditText2Float(dialog, M33SCALE);
			
			if (sGridCurrentDialogMover->fVar.alongCurUncertainty != tempAlong || sGridCurrentDialogMover->fVar.crossCurUncertainty != tempCross
				|| sGridCurrentDialogMover->fVar.startTimeInHrs != tempStart || sGridCurrentDialogMover->fVar.durationInHrs != tempDuration)
				sDialogUncertaintyChanged2 = true;
			sGridCurrentDialogMover->fVar.alongCurUncertainty = EditText2Float(dialog, M33ALONG)/100;
			sGridCurrentDialogMover->fVar.crossCurUncertainty = EditText2Float(dialog, M33CROSS)/100;
			//sNetCDFDialogMover->fVar.uncertMinimumInMPS = EditText2Float(dialog, M33MINCURRENT);
			sGridCurrentDialogMover->fVar.startTimeInHrs = EditText2Float(dialog, M33STARTTIME);
			sGridCurrentDialogMover->fVar.durationInHrs = EditText2Float(dialog, M33DURATION);
			
			sGridCurrentDialogMover->fDownCurUncertainty = -sGridCurrentDialogMover->fVar.alongCurUncertainty; 
			sGridCurrentDialogMover->fUpCurUncertainty = sGridCurrentDialogMover->fVar.alongCurUncertainty; 	
			sGridCurrentDialogMover->fRightCurUncertainty = sGridCurrentDialogMover->fVar.crossCurUncertainty;  
			sGridCurrentDialogMover->fLeftCurUncertainty = -sGridCurrentDialogMover->fVar.crossCurUncertainty; 
			sGridCurrentDialogMover->fDuration = sGridCurrentDialogMover->fVar.durationInHrs * 3600.;  
			sGridCurrentDialogMover->fUncertainStartTime = (long) (sGridCurrentDialogMover->fVar.startTimeInHrs * 3600.); 
			//if (timeZone>1) sNetCDFDialogMover->fTimeShift = EditText2Long(dialog, M33TIMESHIFT)*3600*-1;
			if (timeZone>1) sGridCurrentDialogMover->timeGrid->fTimeShift =(long)( EditText2Float(dialog, M33TIMESHIFT)*3600);
			else sGridCurrentDialogMover->timeGrid->fTimeShift = 0;	// file is in local time
			
			//if (model->GetStartTime() != startTime || model->GetModelTime()!=model->GetStartTime())
			// code goes here, should also check if start time has been shifted correctly already (if there is another current)
			//if (timeShift != sNetCDFDialogMover->fTimeShift || sNetCDFDialogMover->GetTimeValue(0) != model->GetStartTime())
			// GetTImeValue adds in the time shift
			// What if time zone hasn't changed but start time has from loading in a different file??
			if ((timeShift != sGridCurrentDialogMover->timeGrid->fTimeShift && sGridCurrentDialogMover->timeGrid->GetTimeValue(0) != model->GetStartTime()))
			{
				//model->SetModelTime(model->GetModelTime() - (sNetCDFDialogMover->fTimeShift-timeShift));
				if (model->GetStartTime() + sGridCurrentDialogMover->timeGrid->fTimeShift - timeShift == sGridCurrentDialogMover->timeGrid->GetTimeValue(0))
					model->SetStartTime(model->GetStartTime() + (sGridCurrentDialogMover->timeGrid->fTimeShift-timeShift));
				//model->SetStartTime(sNetCDFDialogMover->GetTimeValue(0));	// just in case a different file has been loaded in the meantime, but what if user doesn't want start time to change???
				//sNetCDFDialogMover->SetInterval(errmsg);
				model->NewDirtNotification(DIRTY_RUNBAR); // must reset the runbar
			}
			sGridCurrentDialogMover->timeGrid->fAllowExtrapolationInTime = GetButton(dialog, M33EXTRAPOLATECHECKBOX);
			((TimeGridVelRect*) (sGridCurrentDialogMover->timeGrid))->fAllowVerticalExtrapolationOfCurrents = GetButton(dialog, M33EXTRAPOLATEVERTCHECKBOX);
			// code goes here, add box to dialog to input desired depth to extrapolate to 
			if (((TimeGridVelRect*) (sGridCurrentDialogMover->timeGrid))-> fAllowVerticalExtrapolationOfCurrents) ((TimeGridVelRect*) (sGridCurrentDialogMover->timeGrid))->fMaxDepthForExtrapolation = EditText2Float(dialog, M33EXTRAPOLATETOVALUE); 
			else ((TimeGridVelRect*) (sGridCurrentDialogMover->timeGrid))->fMaxDepthForExtrapolation = 0.;
			
			return M33OK;
		}
			
		case M33CANCEL: 
			return M33CANCEL;
			
		case M33ACTIVE:
		case M33SHOWARROWS:
		case M33EXTRAPOLATECHECKBOX:
			ToggleButton(dialog, itemNum);
			break;
			
		case M33VELOCITYATBOTTOMCHECKBOX:	// code goes here, showhide the M33ARROWDEPTH, M33ARROWDEPTHUNITS
			ToggleButton(dialog, itemNum);
			ShowHideVerticalExtrapolationDialogItems2(dialog);
			if (!GetButton(dialog,M33VELOCITYATBOTTOMCHECKBOX))
			Float2EditText(dialog, M33ARROWDEPTH, 0, 6);
			break;
			
		case M33EXTRAPOLATEVERTCHECKBOX:
			ToggleButton(dialog, itemNum);
			ShowHideVerticalExtrapolationDialogItems2(dialog);
			break;
			
		case M33ARROWSCALE:
		case M33ARROWDEPTH:
			//case M33SCALE:
		case M33ALONG:
		case M33CROSS:
			//case M33MINCURRENT:
		case M33STARTTIME:
		case M33DURATION:
			//case M33TIMESHIFT:
		case M33EXTRAPOLATETOVALUE:
			CheckNumberTextItem(dialog, itemNum, TRUE);
			break;
		case M33SCALE:
		case M33TIMESHIFT:
			CheckNumberTextItemAllowingNegative(dialog, itemNum, TRUE);	// decide whether to allow half hours
			break;
			
		case M33TIMEZONEPOPUP:
			PopClick(dialog, itemNum, &menuID_menuItem);
			ShowGridCurrentMoverDialogItems(dialog);
			if (GetPopSelection(dialog, M33TIMEZONEPOPUP) == 2) MySelectDialogItemText(dialog, M33TIMESHIFT, 0, 100);
			break;
			
		case M33GMTOFFSETS:
		{
			char gmtStr[512], gmtStr2[512];
			strcpy(gmtStr,"Standard time offsets from GMT\n\nHawaiian Standard -10 hrs\nAlaska Standard -9 hrs\n");
			strcat(gmtStr,"Pacific Standard -8 hrs\nMountain Standard -7 hrs\nCentral Standard -6 hrs\nEastern Standard -5 hrs\nAtlantic Standard -4 hrs\n");
			strcpy(gmtStr2,"Daylight time offsets from GMT\n\nHawaii always in standard time\nAlaska Daylight -8 hrs\n");
			strcat(gmtStr2,"Pacific Daylight -7 hrs\nMountain Daylight -6 hrs\nCentral Daylight -5 hrs\nEastern Daylight -4 hrs\nAtlantic Daylight -3 hrs");
			//printNote(gmtStr);
			short buttonSelected  = MULTICHOICEALERT2(1691,gmtStr,gmtStr2,TRUE);
			switch(buttonSelected){
				case 1:// ok
					//return -1;// 
					break;  
				case 3: // cancel
					//return -1;// 
					break;
			}
			break;
		}
			
		case M33REPLACEMOVER:
		{
			//sGridCurrentDialogMover->ReplaceMover();
			//mysetitext(dialog, M33NAME, sGridCurrentDialogMover->fVar.userName); // use short file name for now		
		}
	}
	
	return 0;
}
Ejemplo n.º 12
0
short M28bClick (DialogPtr dialog, short itemNum, long lParam, VOIDPTR data)
// old random diffusion dialog
{
	char	name [kMaxNameLen];
	double uncertaintyFactor,vertStep; 
	double U=0,W=0,botKZ=0;
	short typeOfInput;
	long menuID_menuItem;
	
	switch (itemNum) {
		case M28bOK:
		{
			PtCurMap *map = GetPtCurMap();
			//PtCurMap *map = (PtCurMap*) (sharedRMover3D -> GetMoverMap());
			// uncertaintyFactor enforce >= 1.0
			uncertaintyFactor = EditText2Float(dialog, M28bUFACTOR);
			if(uncertaintyFactor <1.0)
			{
				printError("The uncertainty factor must be >= 1.0");
				MySelectDialogItemText (dialog, M28bUFACTOR, 0, 255);
				break;
			}
			mygetitext(dialog, M28bNAME, name, kMaxNameLen - 1);		// get the mover's nameStr
			sharedRMover3D -> SetClassName (name);
			sharedRMover3D -> SetActive (GetButton(dialog, M28bACTIVE));
			sharedRMover3D -> bUseDepthDependentDiffusion = GetButton(dialog, M28bDEPTHDEPENDENT);
			
			typeOfInput = GetPopSelection(dialog, M28bINPUTTYPE);
			if (sharedRMover3D -> bUseDepthDependentDiffusion) 
			{
				typeOfInput = 2;	// why??
				/*botKZ = EditText2Float(dialog,M28bBOTKZ);
				 if (botKZ == 0)
				 {
				 printError("You must enter a value for the vertical diffusion coefficient on the bottom");
				 MySelectDialogItemText(dialog, M28bBOTKZ,0,255);
				 break;
				 }*/
				//sharedRMover3D -> fVerticalBottomDiffusionCoefficient = EditText2Float(dialog, M28bBOTKZ);
			}
			sharedRMover3D -> fVerticalBottomDiffusionCoefficient = EditText2Float(dialog, M28bBOTKZ);
			
			if (typeOfInput==1)
			{
				//sharedRMover3D -> fDiffusionCoefficient = EditText2Float(dialog, M28DIFFUSION);
				sharedRMover3D -> fHorizontalDiffusionCoefficient = EditText2Float(dialog, M28bDIFFUSION);
				sharedRMover3D -> fUncertaintyFactor = uncertaintyFactor;
				sharedRMover3D -> fVerticalDiffusionCoefficient = EditText2Float(dialog, M28bVERTDIFFUSION);
				//sharedRMover3D -> fVerticalUncertaintyFactor = uncertaintyFactor;
			}
			else if (typeOfInput==2)
			{
				//sharedRMover3D -> fDiffusionCoefficient = EditText2Float(dialog, M28DIFFUSION);
				sharedRMover3D -> fHorizontalDiffusionCoefficient = EditText2Float(dialog, M28bDIFFUSION);
				sharedRMover3D -> fUncertaintyFactor = uncertaintyFactor;
				sharedRMover3D -> fVerticalDiffusionCoefficient = sharedRMover3D -> fHorizontalDiffusionCoefficient/6.88;
				//sharedRMover3D -> fVerticalUncertaintyFactor = uncertaintyFactor;
			}
			else if (typeOfInput==3)
			{
				U = EditText2Float(dialog,M28bCURRENTSPEED);
				if (U == 0)
				{
					printError("You must enter a value for the current velocity");
					MySelectDialogItemText(dialog, M28bCURRENTSPEED,0,255);
					break;
				}
				W = EditText2Float(dialog,M28bWINDSPEED);
				if (W == 0)
				{
					printError("You must enter a value for the wind velocity");
					MySelectDialogItemText(dialog, M28bWINDSPEED,0,255);
					break;
				}
				sharedRMover3D -> fHorizontalDiffusionCoefficient = (272.8*U + 21.1*W); //cm^2/s - Note the conversion from m^2/s is done by leaving out a 10^-4 factor
				sharedRMover3D -> fVerticalDiffusionCoefficient = (39.7*U + 3.1*W);	//cm^2/s
			}
			vertStep = sqrt(6*(sharedRMover3D -> fVerticalDiffusionCoefficient/10000)*model->GetTimeStep()); // in meters
			// compare to mixed layer depth and warn if within a certain percentage - 
			if (map && vertStep > map->fMixedLayerDepth)
				printNote("The combination of large vertical diffusion coefficient and choice of timestep will likely result in particles moving vertically on the order of the size of the mixed layer depth. They will be randomly placed in the mixed layer if reflection fails.");
			
			
			return M28bOK;
		}
			
		case M28bCANCEL: return M28bCANCEL;
			
		case M28bACTIVE:
			ToggleButton(dialog, M28bACTIVE);
			break;
			
		case M28bDEPTHDEPENDENT:
			ToggleButton(dialog, M28bDEPTHDEPENDENT);
			sharedRMover3D -> bUseDepthDependentDiffusion = GetButton(dialog,M28bDEPTHDEPENDENT);
			ShowHideRandomDialogItems(dialog);
			break;
			
		case M28bDIFFUSION:
			CheckNumberTextItem(dialog, itemNum, false); //  don't allow decimals
			break;
			
		case M28bWINDSPEED:
		case M28bCURRENTSPEED:
		case M28bBOTKZ:
			CheckNumberTextItem(dialog, itemNum, true); //   allow decimals
			break;
			
		case M28bUFACTOR:
			CheckNumberTextItem(dialog, itemNum, true); //   allow decimals
			break;
			
		case M28bVERTDIFFUSION:
			CheckNumberTextItem(dialog, itemNum, true); //  allow decimals
			break;
			
		case M28bVERTUFACTOR:
			CheckNumberTextItem(dialog, itemNum, true); //   allow decimals
			break;
			
		case M28bINPUTTYPE:
			PopClick(dialog, itemNum, &menuID_menuItem);
			ShowHideRandomDialogItems(dialog);
			if (GetPopSelection(dialog, M28bINPUTTYPE)==3)
				MySelectDialogItemText(dialog, M28bCURRENTSPEED,0,255);
			else
				MySelectDialogItemText(dialog, M28bDIFFUSION,0,255);
			break;
			
	}
	
	return 0;
}