/* Gets user clicked button */ DialogBoxButton Dialog::GetUserClick() { int x, y, oldX = 0, oldY = 0; while (1) { if (pWind->GetButtonState(LEFT_BUTTON, x, y) == BUTTON_UP) { if (IsButton(x, y) && !IsButton(oldX, oldY)) { if (x > UI.DialogMargin && x < UI.ButtonWidht + UI.DialogMargin) { pWind->DrawRectangle(UI.DialogMargin, UI.ButtonStartY, UI.DialogMargin + UI.ButtonWidht, UI.ButtonStartY + UI.ButtonHeight); pWind->DrawString(UI.DialogMargin + 34, UI.ButtonStartY + 5, "YES"); } if (x > UI.ButtonWidht + 2 * UI.DialogMargin && x < 2 * UI.ButtonWidht + 2 * UI.DialogMargin) { pWind->DrawRectangle(2 * UI.DialogMargin + UI.ButtonWidht, UI.ButtonStartY, 2 * UI.DialogMargin + 2 * UI.ButtonWidht, UI.ButtonStartY + UI.ButtonHeight); if (mType == Type_A) pWind->DrawString(UI.ButtonWidht + 2 * UI.DialogMargin + 38, UI.ButtonStartY + 5, "NO"); else pWind->DrawString(UI.ButtonWidht + 2 * UI.DialogMargin + 38, UI.ButtonStartY + 5, "OK"); } if (x > 2 * UI.ButtonWidht + 3 * UI.DialogMargin && x < 3 * UI.ButtonWidht + 2 * UI.DialogMargin) { pWind->DrawRectangle(3 * UI.DialogMargin + 2 * UI.ButtonWidht, UI.ButtonStartY, 3 * UI.DialogMargin + 3 * UI.ButtonWidht, UI.ButtonStartY + UI.ButtonHeight); pWind->DrawString(2 * UI.ButtonWidht + 3 * UI.DialogMargin + 17, UI.ButtonStartY + 5, "CANCEL"); } } else if (!IsButton(x, y) && IsButton(oldX, oldY)) { DrawDialog(); } oldX = x; oldY = y; } else { if (IsButton(x, y)) { if (x > UI.DialogMargin && x < UI.ButtonWidht + UI.DialogMargin) { return YES; } if (x > UI.ButtonWidht + 2 * UI.DialogMargin && x < 2 * UI.ButtonWidht + 2 * UI.DialogMargin) { if (mType == Type_A) return NO; else return OK; } if (x > 2 * UI.ButtonWidht + 3 * UI.DialogMargin && x < 3 * UI.ButtonWidht + 2 * UI.DialogMargin) { return CANCEL; } } } } }
HGLOBAL GetDlgOutlineText(HWND hDlg,const int *staticWndArray,const int *editWndArray,const CString &strFileName) { CString strTmp; CWnd wnd; CString strData = strFileName; strData += _T("\r\n"); wnd.Attach(hDlg); for(int i=0; editWndArray[i]!=0; i++) { if(staticWndArray[i] != -1) { wnd.GetDlgItemText(staticWndArray[i],strTmp); strData += strTmp + _T("\t"); } if(!IsButton(GetDlgItem(hDlg,editWndArray[i]))) { // editbox if(editWndArray[i] != -1) { wnd.GetDlgItemText(editWndArray[i],strTmp); strData += strTmp; if(staticWndArray[i+1] != -1) // トラック番号など第二値を / 区切りする { strData += _T("\r\n"); } else { strData += _T(" / "); } } } else { // checkbox if(IsDlgButtonChecked(hDlg,editWndArray[i])) { strData += _T("Yes"); } else { strData += _T("No"); } strData += _T("\r\n"); } } wnd.Detach(); HGLOBAL hg = GlobalAlloc(GHND,(strData.GetLength()+1)*sizeof(TCHAR)); TCHAR *txtData = (TCHAR *)GlobalLock(hg); lstrcpy(txtData,strData); GlobalUnlock(hg); return hg; }
HGLOBAL GetDlgOutlineTextSp(HWND hDlg,const int *idArray,const int *editWndArray) { CString strTmp; CWnd wnd; int totalLen = 0; int i=0; for(; idArray[i]!=0; i++) { totalLen += 4/*ID*/ + 4/*Size*/; // The following size is not accurate for a checkbox, but it would be enough. totalLen += (GetWindowTextLength(GetDlgItem(hDlg,editWndArray[i]))+1)*sizeof(TCHAR); } totalLen += 4; // end mark HGLOBAL hg = GlobalAlloc(GHND,totalLen); char *txtData = (char *)GlobalLock(hg); int writeOffset = 0; wnd.Attach(hDlg); for(i=0; idArray[i]!=0; i++) { *(int *)(&(txtData[writeOffset])) = idArray[i]; writeOffset += sizeof(int); if(!IsButton(GetDlgItem(hDlg,editWndArray[i]))) { // editbox wnd.GetDlgItemText(editWndArray[i],strTmp); } else { // checkbox if(IsDlgButtonChecked(hDlg,editWndArray[i])) { strTmp = _T("1"); } else { strTmp = _T("0"); } } *(int *)(&(txtData[writeOffset])) = strTmp.GetLength(); writeOffset += sizeof(int); lstrcpy((LPTSTR)&(txtData[writeOffset]),strTmp); writeOffset += (strTmp.GetLength() + 1) * sizeof(TCHAR); } wnd.Detach(); *(int *)(&(txtData[writeOffset])) = 0; // end mark writeOffset += sizeof(int); ASSERT(totalLen >= writeOffset); GlobalUnlock(hg); return hg; }
void CUIMMShniaga::SendMessage(CUIWindow* pWnd, s16 msg, void* pData){ CUIWindow::SendMessage(pWnd, msg, pData); if (IsButton(pWnd)){ switch (msg){ case STATIC_FOCUS_RECEIVED: SelectBtn(pWnd); break; } } }
void wxToolBarTool::SetPosition(const wxPoint& position) { m_x = position.x; m_y = position.y; int x , y ; x = y = 0 ; int mac_x = position.x ; int mac_y = position.y ; if ( ! GetToolBar()->MacGetTopLevelWindow()->MacUsesCompositing() ) { GetToolBar()->MacWindowToRootWindow( &x , &y ) ; mac_x += x; mac_y += y; } if ( IsButton() ) { Rect contrlRect ; GetControlBounds( m_controlHandle , &contrlRect ) ; int former_mac_x = contrlRect.left ; int former_mac_y = contrlRect.top ; GetToolBar()->GetToolSize() ; if ( mac_x != former_mac_x || mac_y != former_mac_y ) { UMAMoveControl( m_controlHandle , mac_x , mac_y ) ; } } else if ( IsControl() ) { GetControl()->Move( position ) ; } else { // separator #ifdef __WXMAC_OSX__ Rect contrlRect ; GetControlBounds( m_controlHandle , &contrlRect ) ; int former_mac_x = contrlRect.left ; int former_mac_y = contrlRect.top ; if ( mac_x != former_mac_x || mac_y != former_mac_y ) { UMAMoveControl( m_controlHandle , mac_x , mac_y ) ; } #endif } }
wxSize GetSize() const { if ( IsControl() ) { return GetControl()->GetSize() ; } else if ( IsButton() ) { return GetToolBar()->GetToolSize() ; } else { // separator size wxSize sz = GetToolBar()->GetToolSize() ; if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL ) sz.y /= 4 ; else sz.x /= 4 ; return sz ; } }
bool wxToolBarTool::DoEnable(bool enable) { if ( IsControl() ) { GetControl()->Enable( enable ) ; } else if ( IsButton() ) { #if TARGET_API_MAC_OSX if ( enable ) EnableControl( m_controlHandle ) ; else DisableControl( m_controlHandle ) ; #else if ( enable ) ActivateControl( m_controlHandle ) ; else DeactivateControl( m_controlHandle ) ; #endif } return true ; }
void SetDlgOutlineTextSp(HWND hDlg,const int *idArray,const int *editWndArray) { if(!OpenClipboard(hDlg)) { AfxMessageBox(_T("clipboard fail!")); return; } UINT cfMp3Infp = RegisterClipboardFormat(CF_MP3INFP); HANDLE hText = GetClipboardData(cfMp3Infp); if(!hText) { return; } char *txtData = (char *)GlobalLock(hText); if(!txtData) { return; } int readOffset = 0; while(*(int *)(&(txtData[readOffset]))) { int id = *(int *)(&(txtData[readOffset])); readOffset += sizeof(int); int len = *(int *)(&(txtData[readOffset])); readOffset += sizeof(int); if(id != -1) { for(int i=0; idArray[i]!=0; i++) { if(idArray[i] == id) { HWND hwnd = GetDlgItem(hDlg,editWndArray[i]); LPCTSTR szTxt = (LPCTSTR)&(txtData[readOffset]); if(!IsButton(hwnd)) { // Edit or ComboBox if(GetWindowStyle(hwnd) & CBS_DROPDOWNLIST) { // TODO: Do we need to check the window class? ComboBox_SelectString(hwnd, 0, szTxt); } else { SetWindowText(hwnd, szTxt); } } else { // Checkbox int val = _ttoi(szTxt) ? 1 : 0; CheckDlgButton(hDlg,editWndArray[i],val); } break; } } } readOffset += (len + 1) * sizeof(TCHAR); } GlobalUnlock(hText); CloseClipboard(); }
// is this a radio button? // // unlike GetKind(), can be called for any kind of tools, not just buttons bool IsRadio() const { return IsButton() && GetKind() == wxITEM_RADIO; }