void editorChanged() { reloadMenu(); for(int *p=toolEditItems; p<endA(toolEditItems); p++){ SendMessage(toolbar, TB_HIDEBUTTON, *p, MAKELONG(editor ? FALSE : TRUE, 0)); } SetWindowText(hWin, editor ? titleEdit : title); }
//--------------------------------------------------------------------------- void parseScore(BYTE *data, int len) { int i, n, Nname; WCHAR *w, **nameA=0; BYTE b; WORD d; TscoreTab *t; TScore *r; BYTE *p=data; if(!strncmp((char*)data, "Color Sudoku score 2", 20)){ try { p+=20; //names Nname= *(WORD*)p; p+=2; nameA= new WCHAR*[Nname]; w=(WCHAR*)p; for(i=0; i<Nname; i++){ nameA[i]=w; w=wcschr(w, 0)+1; } p=(BYTE*)w; //score tables for(; p<data+len;){ b=p[2]; t=getScoreTab(p[0], p[1], (BYTE)(b&1), (BYTE)((b>>1)&1), (BYTE)((b>>2)&1), (BYTE)((b>>3)&1), (BYTE)((b>>4)&1), (BYTE)(b&0xe0)); memset(t->score, 0, sizeof(t->score)); p+=3; n=*p++; for(i=0; i<n; i++){ r=&t->score[i]; if(r<endA(t->score)){ //name r->name[0]=0; d= *(WORD*)p; if(d<Nname) wcsncpy(r->name, nameA[d], sizeA(r->name)); r->name[sizeA(r->name)-1]=0; //time and date r->playtime= *(WORD*)(p+2); memcpy(&r->date, p+4, 6); //if(r->date.wYear<1990 || r->date.wYear>3000) r->playtime=0; } p+=10; } } } catch(...) { msg("Score table is damaged"); } delete[] nameA; } else if(len%(Dscore*sizeof(TScore))==0){
//------------------------------------------------------------------ void checkMenus() { symbol= symbol0; if(killer) symbol=0; HMENU m=GetMenu(hWin); CheckMenuRadioItem(m, ID_SIZE+4, ID_SIZE+Msize, ID_SIZE+size, MF_BYCOMMAND); CheckMenuRadioItem(m, 350, 352, 350+symbol0, MF_BYCOMMAND); CheckMenuRadioItem(m, ID_MULTI, ID_MULTI+sizeA(gameTypeA)-1, ID_MULTI+gameType, MF_BYCOMMAND); for(Toption *to=optionA; to<endA(optionA); to++){ CheckMenuItem(m, to->menu, *to->value ? MF_BYCOMMAND|MF_CHECKED : MF_BYCOMMAND|MF_UNCHECKED); } //CheckMenuItem(m,ID_SHOWERR,showErr ? MF_BYCOMMAND|MF_CHECKED:MF_BYCOMMAND|MF_UNCHECKED); HMENU m1=GetSubMenu(m, 2); EnableMenuItem(m1, GetMenuItemCount(m1)-2, killer ? MF_BYPOSITION|MF_GRAYED : MF_BYPOSITION|MF_ENABLED); }
void DUpdateVisitor::visitMAssociation(const MAssociation *association) { auto dassociation = dynamic_cast<DAssociation *>(m_target); QMT_CHECK(dassociation); DAssociationEnd endA; endA.setName(association->endA().name()); endA.setCardinatlity(association->endA().cardinality()); endA.setNavigable(association->endA().isNavigable()); endA.setKind(association->endA().kind()); if (isUpdating(endA != dassociation->endA())) dassociation->setEndA(endA); DAssociationEnd endB; endB.setName(association->endB().name()); endB.setCardinatlity(association->endB().cardinality()); endB.setNavigable(association->endB().isNavigable()); endB.setKind(association->endB().kind()); if (isUpdating(endB != dassociation->endB())) dassociation->setEndB(endB); visitMRelation(association); }
EDA_RECT EDA_RECT::Common( const EDA_RECT& aRect ) const { EDA_RECT r; if( Intersects( aRect ) ) { wxPoint originA( std::min( GetOrigin().x, GetEnd().x ), std::min( GetOrigin().y, GetEnd().y ) ); wxPoint originB( std::min( aRect.GetOrigin().x, aRect.GetEnd().x ), std::min( aRect.GetOrigin().y, aRect.GetEnd().y ) ); wxPoint endA( std::max( GetOrigin().x, GetEnd().x ), std::max( GetOrigin().y, GetEnd().y ) ); wxPoint endB( std::max( aRect.GetOrigin().x, aRect.GetEnd().x ), std::max( aRect.GetOrigin().y, aRect.GetEnd().y ) ); r.SetOrigin( wxPoint( std::max( originA.x, originB.x ), std::max( originA.y, originB.y ) ) ); r.SetEnd ( wxPoint( std::min( endA.x, endB.x ), std::min( endA.y, endB.y ) ) ); } return r; }
//--------------------------------------------------------------------------- BOOL CALLBACK ScoreProc(HWND hWnd, UINT msg, WPARAM wP, LPARAM) { const int colX[]={105, 127, 186}; int cmd; RECT rc; POINT p; Toption *to; switch(msg){ case WM_INITDIALOG: setDlgTexts(hWnd, 14); for(to=optionA; to<endA(optionA); to++){ if(to->scoreTabValue){ CheckDlgButton(hWnd, to->dialog, (*to->scoreTabValue=*to->value)!=0 ? BST_CHECKED : BST_UNCHECKED); } } tabSize=size; CheckRadioButton(hWnd, 200, 200+Msize, size+200); tabGameType=gameType; initGameTypeCombo(hWnd); return TRUE; case WM_COMMAND: cmd=LOWORD(wP); if(cmd==IDOK) EndDialog(hWnd, cmd); if(cmd==IDCANCEL) EndDialog(hWnd, cmd); if(cmd>=200 && cmd<300 || cmd==IDC_DIAG || cmd==IDC_KILLER || cmd==IDC_GREATER || cmd==IDC_CONS || cmd==IDC_ODDEVEN || cmd==170 && HIWORD(wP)==CBN_SELCHANGE){ if(cmd>=200 && cmd<300) tabSize=cmd-200; for(to=optionA; to<endA(optionA); to++){ if(to->scoreTabValue){ *to->scoreTabValue=IsDlgButtonChecked(hWnd, to->dialog); } } tabGameType=getGameType(hWnd); p.x=p.y=0; MapWindowPoints(GetDlgItem(hWnd, 206), hWnd, &p, 1); GetClientRect(hWnd, &rc); rc.bottom=p.y; InvalidateRect(hWnd, &rc, TRUE); SetFocus(GetDlgItem(hWnd, tabSize+200)); } break; case WM_PAINT: { static const int Mbuf=64; TCHAR *buf=(TCHAR*)_alloca(sizeof(TCHAR)*Mbuf); static PAINTSTRUCT ps; BeginPaint(hWnd, &ps); TscoreTab *curScoreTab= findScoreTab((BYTE)tabGameType, (BYTE)tabSize, (BYTE)tabDiag, (BYTE)tabKiller, (BYTE)tabGreater, (BYTE)tabCons, (BYTE)tabOddEven); if(!curScoreTab){ /*GetClientRect(hWnd,&rc); rc.bottom-=120; MoveToEx(ps.hdc,0,50,0); LineTo(ps.hdc,rc.right,rc.bottom); MoveToEx(ps.hdc,rc.right,50,0); LineTo(ps.hdc,0,rc.bottom);*/ } else{ TScore *s= curScoreTab->score; SetBkMode(ps.hdc, TRANSPARENT); int dpi=GetDeviceCaps(ps.hdc, LOGPIXELSX); for(int i=0; i<Dscore; i++, s++){ if(!s->playtime) continue; int y=(24*i+35)*dpi/96; SetTextColor(ps.hdc, i==curScoreTab->lastScore ? colors[clLastScore] : 0); TextOutW(ps.hdc, 10, y, s->name, (int)wcslen(s->name)); //player name SetTextAlign(ps.hdc, TA_RIGHT); for(int j=0; j<3; j++){ rc.right=colX[j]; switch(j){ case 0: //date SYSTEMTIME t; t.wYear=s->date.wYear; t.wMonth=s->date.wMonth; t.wDay=s->date.wDay; t.wHour=s->date.wHour; t.wMinute=s->date.wMinute; t.wSecond=t.wMilliseconds=0; GetDateFormat(0, 0, &t, 0, buf, Mbuf); break; case 1: //time GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, 0, buf, Mbuf); if((int)_tcslen(buf) > 5) rc.right += 15; break; case 2: //game time printTime(buf, s->playtime); break; } rc.left=rc.top=rc.bottom=0; MapDialogRect(hWnd, &rc); TextOut(ps.hdc, rc.right, y, buf, (int)_tcslen(buf)); } SetTextAlign(ps.hdc, TA_LEFT); } } EndPaint(hWnd, &ps); break; } } return FALSE; }
//--------------------------------------------------------------------------- BOOL CALLBACK PdfProc(HWND hWnd, UINT msg, WPARAM wP, LPARAM) { struct PageSize { int w, h; TCHAR *s; }; static const PageSize P[]= {{595, 842, _T("A4")}, {421, 595, _T("A5")}, {842, 1190, _T("A3")}}; static const int L[]={1, 2, 3, 4, 6, 9, 12}; int i; HWND combo; Toption *to; TCHAR buf[4]; switch(msg){ case WM_INITDIALOG: setDlgTexts(hWnd, 26); SetDlgItemInt(hWnd, 160, pdfObject.count, FALSE); SetDlgItemInt(hWnd, 163, pdfObject.pageWidth, FALSE); SetDlgItemInt(hWnd, 164, pdfObject.pageHeight, FALSE); combo= GetDlgItem(hWnd, 162); for(i=0; i<sizeA(P); i++){ const PageSize *p = &P[i]; SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)p->s); if(pdfObject.pageWidth==p->w && pdfObject.pageHeight==p->h){ SendMessage(combo, CB_SETCURSEL, i, 0); } } combo= GetDlgItem(hWnd, 161); for(i=0; i<sizeA(L); i++){ _stprintf(buf, _T("%d"), L[i]); SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)buf); } initGameTypeCombo(hWnd); SetDlgItemInt(hWnd, 161, pdfObject.countPerPage, FALSE); SetDlgItemInt(hWnd, 168, pdfObject.border, FALSE); SetDlgItemInt(hWnd, 169, pdfObject.spacing, FALSE); CheckRadioButton(hWnd, 350, 352, 350+symbol0); for(to=optionA; to<endA(optionA); to++){ CheckDlgButton(hWnd, to->dialog, *to->value ? BST_CHECKED : BST_UNCHECKED); } SetDlgItemInt(hWnd, 165, level, FALSE); SetDlgItemText(hWnd, 166, pdfObject.fn); return TRUE; case WM_COMMAND: wP=LOWORD(wP); if(wP==IDOK){ pdfObject.count = 2 * GetDlgItemInt(hWnd, 160, 0, FALSE); //page properties pdfObject.pageWidth = GetDlgItemInt(hWnd, 163, 0, FALSE); pdfObject.pageHeight = GetDlgItemInt(hWnd, 164, 0, FALSE); pdfObject.countPerPage = GetDlgItemInt(hWnd, 161, 0, FALSE); pdfObject.border = GetDlgItemInt(hWnd, 168, 0, FALSE); pdfObject.spacing = GetDlgItemInt(hWnd, 169, 0, FALSE); //game options for(to=optionA; to<endA(optionA); to++){ *to->value= IsDlgButtonChecked(hWnd, to->dialog); } level= GetDlgItemInt(hWnd, 165, 0, FALSE); symbol0= getRadioButton(hWnd, 350, 352); gameType=getGameType(hWnd); GetDlgItemText(hWnd, 166, pdfObject.fn, sizeA(pdfObject.fn)); EnableWindow(GetDlgItem(hWnd, IDOK), FALSE); pdfObject.print(hWnd); EndDialog(hWnd, wP); } if(wP==IDCANCEL) EndDialog(hWnd, wP); if(wP==162){ i=SendDlgItemMessage(hWnd, 162, CB_GETCURSEL, 0, 0); if(i>=0 && i<sizeA(P)){ SetDlgItemInt(hWnd, 163, P[i].w, FALSE); SetDlgItemInt(hWnd, 164, P[i].h, FALSE); } } if(wP==167){ if(saveFileDlg(&pdfOfn, hWnd, 0)){ SetDlgItemText(hWnd, 166, pdfObject.fn); } } break; } return FALSE; }
//------------------------------------------------------------------ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int cmdShow) { int i; HDC dc; MSG mesg; RECT rc; inst = hInstance; //DPIAware typedef BOOL(WINAPI *TGetProcAddress)(); TGetProcAddress getProcAddress = (TGetProcAddress)GetProcAddress(GetModuleHandle(_T("user32")), "SetProcessDPIAware"); if(getProcAddress) getProcAddress(); memset(custom, 200, sizeof(custom)); _tcscpy(pdfObject.fn, _T("sudoku.pdf")); pdfObject.pageWidth=595; pdfObject.pageHeight=842; pdfObject.count=6; pdfObject.countPerPage=6; pdfObject.border=40; pdfObject.spacing=20; readini(); //load common controls #if _WIN32_IE >= 0x0300 INITCOMMONCONTROLSEX iccs; iccs.dwSize= sizeof(INITCOMMONCONTROLSEX); iccs.dwICC= ICC_BAR_CLASSES; InitCommonControlsEx(&iccs); #else InitCommonControls(); #endif // create the main window WNDCLASS wc; ZeroMemory(&wc, sizeof(wc)); wc.lpfnWndProc = WndMainProc; wc.hInstance = inst; wc.lpszClassName = CLASSNAME; wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON)); if(!RegisterClass(&wc)){ #ifdef UNICODE msg("This version cannot run on Windows 95/98/ME."); #else msg("RegisterClass failed"); #endif return 2; } scrW= GetSystemMetrics(SM_CXSCREEN); scrH= GetSystemMetrics(SM_CYSCREEN); aminmax(mainLeft, 0, scrW-50); aminmax(mainTop, 0, scrH-50); hWin = CreateWindow(CLASSNAME, title, WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPCHILDREN, mainLeft, mainTop, mainW, mainH, 0, 0, inst, 0); if(!hWin){ msg("CreateWindow failed"); return 3; } haccel= LoadAccelerators(inst, MAKEINTRESOURCE(IDR_ACCELERATOR)); Naccel= CopyAcceleratorTable(haccel, accel, sizeA(accel)); initLang(); //create status bar statusbar= CreateStatusWindow(WS_CHILD, 0, hWin, 1); static int parts[]={100, 140, 210, 230, -1}; dc=GetDC(hWin); for(i=0; i<sizeA(parts)-1; i++){ parts[i]=parts[i]*GetDeviceCaps(dc, LOGPIXELSX)/96; } ReleaseDC(hWin, dc); SendMessage(statusbar, SB_SETPARTS, sizeA(parts), (LPARAM)parts); ShowWindow(statusbar, SW_SHOW); //create tool bar i=sizeA(tbb); for(TBBUTTON *u=tbb; u<endA(tbb); u++){ if(u->fsStyle==TBSTYLE_SEP) i--; } toolbar = CreateToolbarEx(hWin, WS_CHILD|TBSTYLE_TOOLTIPS, 2, i, inst, IDB_TOOLBAR, tbb, sizeA(tbb), 16, 16, 16, 15, sizeof(TBBUTTON)); GetClientRect(toolbar, &rc); MapWindowPoints(toolbar, hWin, (POINT*)&rc, 2); toolH= rc.bottom; if(toolBarVisible) ShowWindow(toolbar, SW_SHOW); langChanged(); ShowWindow(hWin, cmdShow); initSquare(false); UpdateWindow(hWin); toolBitmap(); numButtons(); while(GetMessage(&mesg, NULL, 0, 0)==TRUE){ if(!TranslateAccelerator(hWin, haccel, &mesg)){ TranslateMessage(&mesg); DispatchMessage(&mesg); } } if(delreg) deleteini(HKEY_CURRENT_USER); return 0; }