Ejemplo n.º 1
0
Archivo: mhcmd.c Proyecto: yzh/yzhack
/*-------------------------------------------------------------------------*/
void onMouseMove(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	PNHCmdWindow data;
	POINT mpt;
	int newActiveCell;

	/* get mouse coordinates */
	mpt.x = LOWORD(lParam);
	mpt.y = HIWORD(lParam);

	/* map mouse coordinates to the display cell */
	data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
	newActiveCell = CellFromPoint(data, mpt);
	if( data->active_cell == -1 ) return;

	/* if mouse is within orginal display cell - select the cell otherwise
	   clear the selection */
	switch( nhcmdlayout_cell_direct(data->layout_current, data->active_cell)->type ) {
	case NH_CELL_REG: 
		HighlightCell(hWnd, data->active_cell, 
			       (newActiveCell==data->active_cell) );
		break;

	case NH_CELL_CTRL:
		HighlightCell(hWnd, data->active_cell, 
			((newActiveCell==data->active_cell)? !data->is_ctrl : data->is_ctrl) );
		break;

	case NH_CELL_CAP:
		HighlightCell(hWnd, data->active_cell, 
			((newActiveCell==data->active_cell)? !data->is_caps : data->is_caps) );
		break;
	}
}
Ejemplo n.º 2
0
Archivo: mhcmd.c Proyecto: yzh/yzhack
/*-------------------------------------------------------------------------*/
void onMouseDown(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	PNHCmdWindow data;
	POINT mpt;

	/* get mouse coordinates */
	mpt.x = LOWORD(lParam);
	mpt.y = HIWORD(lParam);

	/* map mouse coordinates to the display cell */
	data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
	data->active_cell = CellFromPoint(data, mpt);
	if( data->active_cell==-1 ) return;

	/* set mouse focus to the current window */
	SetCapture(hWnd);

	/* invert the selection */
	HighlightCell(hWnd, data->active_cell, (data->cells[data->active_cell].state!=NH_CST_CHECKED) );
}
Ejemplo n.º 3
0
// Overridden method for building the data grids - these are substantially different from the CalReview base but the overall appearance and graph presence are the same
void CalSanityDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSizer, bool AO)
{
    wxString raSteps = wxString::Format("%d", m_calDetails.raStepCount);
    wxString decSteps = wxString::Format("%d", m_calDetails.decStepCount);
    wxString oldAngleDelta;
    double newRARate = m_newParams.xRate * 1000;                          // px per sec for UI purposes
    double newDecRate = m_newParams.yRate * 1000;
    double imageScale = m_calDetails.imageScale;
    bool oldValid = m_oldParams.isValid;

    if (!AO)                // AO calibration never triggers sanity check alerts, so don't show that data
    {
        // Compute the orthogonality stuff
        m_newAngleDelta = wxString::Format("%0.1f", m_calDetails.orthoError);
        if (oldValid)
        {
            oldAngleDelta = wxString::Format("%0.1f", m_oldDetails.orthoError);
        }
        else
            oldAngleDelta = NA_STR;

        if (m_newParams.yRate != 0. && m_oldParams.yRate != 0.)
            m_oldNewDifference = wxString::Format("%0.1f", fabs(1.0 - m_newParams.yRate / m_oldParams.yRate) * 100.0);
        else
            m_oldNewDifference = "";

        // Lay out the controls
        wxBoxSizer *pVSizer = new wxBoxSizer(wxVERTICAL);
        wxStaticBoxSizer *pMsgGrp = new wxStaticBoxSizer(wxVERTICAL, parentPanel, _("Explanation"));

        // Explanation area
        wxStaticText *pMsgArea = new wxStaticText(parentPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(450, -1), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
        BuildMessage(pMsgArea, m_issue);
        pMsgArea->SetSizeHints(wxSize(450, MESSAGE_HEIGHT));
        wxFont font = pMsgArea->GetFont();
        font.SetWeight(wxFONTWEIGHT_BOLD);
        pMsgArea->SetFont(font);
        pMsgGrp->Add(pMsgArea, wxSizerFlags().Border(wxALL, 5));
        pVSizer->Add(pMsgGrp, wxSizerFlags().Border(wxALL, 5));

        // Grid control for details
        wxStaticBoxSizer *pGridGrp = new wxStaticBoxSizer(wxVERTICAL, parentPanel, _("Details"));
        wxGrid *pGrid = new wxGrid(parentPanel, wxID_ANY);
        pGrid->CreateGrid(3, 4);
        pGrid->SetRowLabelSize(1);
        pGrid->SetColLabelSize(1);
        pGrid->EnableEditing(false);

        int col = 0;
        int row = 0;
        pGrid->SetCellValue(row, col++, _("Steps, RA:"));
        pGrid->SetCellValue(row, col++, raSteps);
        pGrid->SetCellValue(row, col++, _("Steps, Dec:"));
        pGrid->SetCellValue(row, col++, decSteps);
        if (m_issue == CI_Steps){
            if (raSteps <= decSteps)
                HighlightCell(pGrid, row, 1);
            else
                HighlightCell(pGrid, row, 3);
        }
        row++;
        col = 0;
        pGrid->SetCellValue(row, col++, _("Orthogonality error:"));
        pGrid->SetCellValue(row, col++, m_newAngleDelta);
        pGrid->SetCellValue(row, col++, _("Previous orthogonality error:"));
        pGrid->SetCellValue(row, col++, oldAngleDelta);
        if (m_issue == CI_Angle)
        {
            HighlightCell(pGrid, row, 1);
        }

        row++;
        col = 0;
        // Show either the new RA and Dec rates or the new and old Dec rates depending on the issue
        if (m_issue == CI_Different)
        {
            pGrid->SetCellValue(row, col++, _("This declination rate:"));
            if (newDecRate != CALIBRATION_RATE_UNCALIBRATED)
                pGrid->SetCellValue(row, col++, wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newDecRate * imageScale, newDecRate));
            else
                pGrid->SetCellValue(row, col++, NA_STR);
            pGrid->SetCellValue(row, col++, _("Previous declination rate:"));
            if (m_oldParams.yRate != CALIBRATION_RATE_UNCALIBRATED)
                pGrid->SetCellValue(row, col++, wxString::Format(_("\n%0.3f px/sec"), m_oldParams.yRate * 1000));
            else
                pGrid->SetCellValue(row, col++, NA_STR);
            HighlightCell(pGrid, row, 1);
            HighlightCell(pGrid, row, 3);
        }
        else
        {
            pGrid->SetCellValue(row, col++, _("RA rate:"));
            pGrid->SetCellValue(row, col++, wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newRARate * imageScale, newRARate));
            pGrid->SetCellValue(row, col++, _("Declination rate:"));
            if (newDecRate != CALIBRATION_RATE_UNCALIBRATED)
                pGrid->SetCellValue(row, col++, wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newDecRate * imageScale, newDecRate));
            else
                pGrid->SetCellValue(row, col++, NA_STR);
            if (m_issue == CI_Rates)
            {
                HighlightCell(pGrid, row, 1);
                HighlightCell(pGrid, row, 3);
            }
        }

        pGrid->AutoSize();
        pGrid->ClearSelection();
        pGridGrp->Add(pGrid);
        pVSizer->Add(pGridGrp, wxSizerFlags(0).Border(wxALL, 5));

        // Checkboxes for being quiet
        m_pBlockThis = new wxCheckBox(parentPanel, wxID_ANY, _("Don't show calibration alerts of this type"));
        pVSizer->Add(m_pBlockThis, wxSizerFlags(0).Border(wxALL, 15));
        parentHSizer->Add(pVSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
    }

}
Ejemplo n.º 4
0
Archivo: mhcmd.c Proyecto: yzh/yzhack
/*-------------------------------------------------------------------------*/
void ActivateCell(HWND hWnd, int cell)
{
	PNHCmdWindow data;
	PNHCmdPadCell p_cell_data;
	int i;

	data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
	if( !data ) return;
	p_cell_data = nhcmdlayout_cell_direct(data->layout_current, cell);

	/* act depending on the cell type:
		CAPS - change layout 
		CTRL - modify CTRL status
		REG  - place keyboard event on the nethack input queue
	*/
	switch( p_cell_data->type ) {
	case NH_CELL_REG: 
		if( data->is_ctrl ) {
			PushNethackCommand(p_cell_data->f_char, 1);

			data->is_ctrl = 0;
			for( i=0; i<nhcmdlayout_rows(data->layout_current)*nhcmdlayout_columns(data->layout_current); i++ ) {
				if( nhcmdlayout_cell_direct(data->layout_current, i)->type == NH_CELL_CTRL ) {
					HighlightCell(hWnd, i, data->is_ctrl);
				}
			}
		} else {
			PushNethackCommand(p_cell_data->f_char, 0);
		}
		HighlightCell(hWnd, cell, FALSE);

		// select a new layout if present
		i = (int)p_cell_data->data;
		if( i==-1 ) {
			if( data->layout_save ) SetCmdWindowLayout(hWnd, data->layout_save);
			data->layout_save = NULL;
		} else {
			if( !data->layout_save ) data->layout_save = data->layout_current;
			SetCmdWindowLayout(hWnd, nhcmdset_get(nhcmdset_current, i));
		}

		if( !data->is_shift ) break;
		// else fall through and reset the shift

	case NH_CELL_SHIFT:
		data->is_shift = !data->is_shift;
		SetCmdWindowLayout(
			hWnd,
			(data->is_shift ^ data->is_caps)? nhcmdset_get(nhcmdset_current, 1) : nhcmdset_get(nhcmdset_current, 0)
		);
		data->cells[cell].state = data->is_shift? NH_CST_CHECKED : 0;
		InvalidateRect(hWnd, NULL, TRUE);
		break;

	case NH_CELL_CTRL:
		data->is_ctrl = !data->is_ctrl;
		HighlightCell(hWnd, cell, data->is_ctrl);
		break;

	case NH_CELL_CAP:
		data->is_caps = !data->is_caps;
		SetCmdWindowLayout(
			hWnd,
			(data->is_shift ^ data->is_caps)? nhcmdset_get(nhcmdset_current, 1) : nhcmdset_get(nhcmdset_current, 0)
		);
		data->cells[cell].state = data->is_caps? NH_CST_CHECKED : 0;
		InvalidateRect(hWnd, NULL, TRUE);
		break;

	case NH_CELL_LAYOUT_NEW: {
		PNHCmdLayout pLayout;

		HighlightCell(hWnd, cell, FALSE);

		pLayout = (PNHCmdLayout)p_cell_data->data;
		if( pLayout ) {
			SetCmdWindowLayout(hWnd, pLayout);
		}
	} break;
	
	case NH_CELL_LAYOUT_MENU: {
		winid wid;
		int i;
		anything any;
		menu_item* selected = 0;
		PNHCmdSet pSet;

		HighlightCell(hWnd, cell, FALSE);

		pSet = (PNHCmdSet)p_cell_data->data;
		if( !pSet ) pSet = nhcmdset_default;

		wid = mswin_create_nhwindow(NHW_MENU);
		mswin_start_menu(wid);
		for( i=0; i<nhcmdset_count(pSet); i++ ) {
			any.a_void = nhcmdset_get(pSet, i);
			mswin_add_menu(wid, NO_GLYPH, &any, 'a'+i, 0, ATR_NONE, 
				nhcmdset_get_name(pSet, i), FALSE);
		}
		mswin_end_menu(wid, "Select keypad layout");
	    i = select_menu(wid, PICK_ONE, &selected);
	    mswin_destroy_nhwindow(wid);

		if( i==1 ) {
#if defined(WIN_CE_SMARTPHONE)
			data->layout_selected = (PNHCmdLayout)selected[0].item.a_void;
#endif
			SetCmdWindowLayout(hWnd, (PNHCmdLayout)selected[0].item.a_void );
		}
	} break;
	
	}
}
Ejemplo n.º 5
0
Archivo: mhcmd.c Proyecto: yzh/yzhack
/* special keypad input handling for SmartPhone
   the phone keypad maps to VK_* as shown below.
   some keys might not be present, e.g. VK_TFLIP
    sofkey1     softkey2    VK_TSOFT1, VK_TSOFT2
            ^               VK_TUP
        <   +   >           VK_TLEFT, VK_TACTION, VK_TRIGHT
            v               VK_TDOWN
    home        back        VK_THOME, VK_TBACK
    talk        end         VK_TTALK, VK_TEND
    1       2       3       VK_T0..VK_T9
    4       5       6       ...
    7       8       9       ...
    *       0       #       VK_TSTAR, VK_TPOUND
   other buttons include
    VK_TRECORD
    VK_TPOWER, VK_TVOLUMEUP, VK_TVOLUMEDOWN
    VK_TFLIP
*/
BOOL NHSPhoneTranslateKbdMessage(WPARAM wParam, LPARAM lParam, BOOL keyDown)
{
	PNHCmdWindow data;
	int index = -1;

	/* get window data */
	data = (PNHCmdWindow)GetWindowLong(GetNHApp()->hCmdWnd, GWL_USERDATA);
	if( !data ) return FALSE;

	switch (wParam) {
    case VK_T0: 
		index = 10; 
	break;

    case VK_T1: 
		index = 0; 
	break;

    case VK_T2: 
		index = 1; 
	break;

    case VK_T3: 
		index = 2; 
	break;

    case VK_T4: 
		index = 3; 
	break;

    case VK_T5: 
		index = 4; 
	break;

    case VK_T6: 
		index = 5; 
	break;

    case VK_T7: 
		index = 6; 
	break;

    case VK_T8: 
		index = 7; 
	break;

    case VK_T9: 
		index = 8; 
	break;

	case VK_TSTAR:
		index = 9; 
	break;
	
	case VK_TPOUND: 
		index = 11;
	break;
	}

	if( index>=0 ) {
		HighlightCell(GetNHApp()->hCmdWnd, index, keyDown);
		if( keyDown ) ActivateCell(GetNHApp()->hCmdWnd, index);
		return TRUE;
	} else {
		return FALSE;
	}
}