void Window::getCursorExtent( int &width, int &height ) { POINTERINFO pInfo; WinQueryPointerInfo( WinQueryPointer( HWND_DESKTOP ), &pInfo ); width = pInfo.xHotspot; height = /*WinQuerySysValue( HWND_DESKTOP, SV_CYPOINTER ) - */pInfo.yHotspot; }
MRESULT EXPENTRY MimeDlgProc(HWND hwndDlg,ULONG msg,MPARAM mp1,MPARAM mp2) { HPOINTER hptrOrig, hptrWait; static int num_entries; static int entry; static FILE *in; static Container *list; static MimeSet *mimes; UserData *ud; char buffer[1024]; int i; switch(msg) { case WM_INITDLG: hptrWait = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ); hptrOrig = WinQueryPointer( HWND_DESKTOP ); WinSetPointer( HWND_DESKTOP, hptrWait ); WinSendMsg(WinWindowFromID(hwndDlg,MIME_NAME),EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0)); WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXT), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0)); WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXE), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0)); mimes = (MimeSet*)mp2; list = new Container(); list->initialise(hwndDlg,MIME_CONT); num_entries = mimes->getSetNum(); for (i=0; i<num_entries; i++) { sprintf(buffer,"%s: %s",mimes->getName(i),mimes->getExtensions(i)); // message("%d/%d %s is %s",i,num_entries,mimes->getName(i),mimes->getExtensions(i)); list->insert(buffer,(UserData*)NULL,8888L,8888L); } WinFocusChange(HWND_DESKTOP,WinWindowFromID(hwndDlg,MIME_CONT),0); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(mimes->getSetNum()-1)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(mimes->getSetNum()-1)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(mimes->getSetNum()-1)); list->setItemFocus(list->getLastInsert()); WinSetPointer( HWND_DESKTOP, hptrOrig ); entry = -1; break; case WM_HELP: showHelpWindow(HELP_MIMES); break; case WM_CLOSE: mimes->reload(); delete list; return WinDefDlgProc(hwndDlg,msg,mp1,mp2); case WM_USER: list->arrange(); break; case WM_CONTROL: switch(SHORT2FROMMP(mp1)) { case CN_HELP: WinSendMsg(hwndDlg,WM_HELP,0,0); break; // sent every time emphasis of an object is changed, so if // change from A to B, get deselect on A, and select on B case CN_EMPHASIS: { PNOTIFYRECORDEMPHASIS nre = (PNOTIFYRECORDEMPHASIS)mp2; ud = (UserData*)nre->pRecord; if (ud != NULL) { char *buffer = new char[4096]; strcpy(buffer,ud->getName()); char *ptr = buffer+strlen(buffer)-1; while (ptr>buffer && *ptr!='.') ptr--; if (*ptr == '.') { int index = mimes->find(ptr); if (index > -1) { entry = index; WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(index)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(index)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(index)); } } delete[] buffer; } } break; case EN_CHANGE: { if (SHORT1FROMMP(mp1) == MIME_EXE) { ud = list->findSelectedRecord(NULL); static int lastindex = 0; if (ud && entry != -1) { if (lastindex == entry) { char *buffer = new char[4096]; WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer); mimes->setCommand(entry,buffer); delete[] buffer; } lastindex = entry; } } } break; } break; case WM_COMMAND: switch( SHORT1FROMMP( mp1 ) ) { case IDM_DELETE: // message("delete"); break; case DID_OK: // all OK, close dialog, return if (entry != -1) { WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer); mimes->setCommand(entry,buffer); } mimes->save(); delete list; WinDismissDlg( hwndDlg, TRUE); return (MRESULT) TRUE; case DID_CANCEL: mimes->reload(); delete list; WinDismissDlg( hwndDlg, TRUE); return (MRESULT) FALSE; } break; default: return WinDefDlgProc(hwndDlg,msg,mp1,mp2); } return (MRESULT) TRUE; }
unsigned int CallDosDebug( dos_debug __far *buff ) { QMSG qmsg; int num_paints; int i; struct { RECTL rcl; HWND hwnd; } paints[MAX_PAINTS]; HPS ps; char class_name[80]; TID tid; if( !IsPMDebugger() ) { return( Call32BitDosDebug( buff ) ); } switch( buff->Cmd ) { case DBG_C_ClearWatch: case DBG_C_Freeze: case DBG_C_LinToSel: case DBG_C_NumToAddr: case DBG_C_ReadCoRegs: case DBG_C_ReadMemBuf: case DBG_C_ReadMem_D: case DBG_C_ReadReg: case DBG_C_SelToLin: case DBG_C_SetWatch: case DBG_C_ThrdStat: case DBG_C_WriteCoRegs: case DBG_C_WriteMemBuf: case DBG_C_WriteMem_D: case DBG_C_WriteReg: return( Call32BitDosDebug( buff ) ); } switch( buff->Cmd ) { case DBG_C_Go: case DBG_C_SStep: case DBG_C_Term: ReleaseQueue( buff->Pid, buff->Tid ); } DebugReqBuff = buff; StopBuff = *buff; DosSemSet( &DebugDoneSem ); DosSemClear( &DebugReqSem ); num_paints = 0; if( IsPMDebugger() ) { while( WinGetMsg( HabDebugger, &qmsg, 0L, 0, 0 ) || InDosDebug ) { WinQueryClassName( qmsg.hwnd, MAX_CLASS_NAME, class_name ); switch( qmsg.msg ) { case WM_CHAR: if( ( SHORT1FROMMP( qmsg.mp1 ) & KC_VIRTUALKEY ) && ( SHORT2FROMMP( qmsg.mp2 ) == VK_BREAK ) ) { SetBrkPending(); DosCreateThread( StopApplication, &tid, stack2 + STACK_SIZE ); DosSetPrty( PRTYS_THREAD, PRTYC_TIMECRITICAL, 10, tid ); WakeThreads( StopBuff.Pid ); DosSemWait( &StopDoneSem, SEM_INDEFINITE_WAIT ); DosSemSet( &StopDoneSem ); } break; case WM_COMMAND: CantDoIt(); break; default: if( strcmp( class_name, "GUIClass" ) == 0 || strcmp( class_name, "WTool" ) == 0 ) { switch( qmsg.msg ) { case WM_PAINT: if( num_paints >= MAX_PAINTS ) --num_paints; paints[num_paints].hwnd = qmsg.hwnd; ps = WinBeginPaint( qmsg.hwnd, 0, &paints[ num_paints ].rcl ); GpiErase( ps ); WinEndPaint( ps ); num_paints++; break; case WM_BUTTON1DOWN: case WM_BUTTON2DOWN: case WM_BUTTON3DOWN: CantDoIt(); break; case WM_MOUSEMOVE: { HPOINTER hourglass = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ); if( WinQueryPointer( HWND_DESKTOP ) != hourglass ) { WinSetPointer( HWND_DESKTOP, hourglass ); } break; } default: WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 ); } } else { WinDispatchMsg( HabDebugger, &qmsg ); } } } } else { DosSemWait( &DebugDoneSem, SEM_INDEFINITE_WAIT ); } switch( buff->Cmd ) { case DBG_N_Exception: case DBG_N_AsyncStop: case DBG_N_Watchpoint: AssumeQueue( buff->Pid, buff->Tid ); break; } for( i = 0; i < num_paints; ++i ) { WinInvalidateRect( paints[i].hwnd, &paints[i].rcl, FALSE ); } return( DebugReqResult ); }
VOID MP3DISPLAY :: RemoveAll (VOID) { #ifdef _DEBUGLOG_ fputs ("\nRemoveAll ()\n", pfileLog); #endif if (! hwnd || ! FilesInList ()) return; // confirm operation if (WinMessageBox (HWND_DESKTOP, hwnd, #ifdef _MULTILANGUAGES_ RSTR (IDS_REALLYREMOVETAGS), RSTR (IDS_REALLYREMOVETAGSHEADING), #else "Really remove the tags of all selected files?", "REALLY REMOVE?", #endif 0L, MB_OKCANCEL | MB_QUERY | MB_DEFBUTTON2 | MB_MOVEABLE) != MBID_OK) return; if (QueryMP3 ()) { delete QueryMP3 (); SetMP3 (NULL); } // set mouse-ptr to "wait" shape HPOINTER hptr = WinQueryPointer (HWND_DESKTOP); WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT, FALSE)); // do the thing CHAR ach[_MAX_PATH], ach2[_MAX_PATH+31]; ULONG c = 0L; for (ULONG i = 0; i < CountFilesInList (); i++) { QueryFile (ach, sizeof (ach), i); if ((pmp3 = new MP3 (ach))) { if (pmp3->IsTagged ()) { #ifdef _MULTILANGUAGES_ sprintf (ach2, RSTR (IDS_REMOVINGFORMAT), ach); #else sprintf (ach2, "Removing - %s", ach); #endif if (pmp3->RemoveTag ()) c++; } else #ifdef _MULTILANGUAGES_ sprintf (ach2, RSTR (IDS_IGNORINGFORMAT), ach); #else sprintf (ach2, "Ignoring - %s", ach); #endif delete pmp3; } WinSetWindowText (hwnd, ach2); } if (pset->NotifyRemove ()) { #ifdef _MULTILANGUAGES_ // tell user what has been done if (c < CountFilesInList ()) Notify (RSTR (IDS_TAGSREMOVEDHEADING), RSTR (IDS_SOMETAGSREMOVED), c); else Notify (RSTR (IDS_TAGSREMOVEDHEADING), RSTR (IDS_ALLTAGSREMOVED)); #else // tell user what has been done if (c < CountFilesInList ()) Notify ("SOME TAGS REMOVED", "Tags have been removed from %ld selected files (The " "others probably were read only or had no tag)", c); else Notify ("ALL TAGS REMOVED", "Tags have been removed from all selected files."); #endif } // reload the current file and refresh the display SetMP3 (NULL); Refresh (); // set mouse-ptr to normal shape WinSetPointer (HWND_DESKTOP, hptr); WinSetWindowText (hwnd, PSZ_NAMEVERSION); }
VOID MP3DISPLAY :: SaveAll (VOID) { #ifdef _DEBUGLOG_ fputs ("\nSaveAll ()\n", pfileLog); #endif if (! hwnd || ! FilesInList ()) return; // confirm operation if (WinMessageBox (HWND_DESKTOP, hwnd, #ifdef _MULTILANGUAGES_ RSTR (IDS_REALLYSAVETAGS), RSTR (IDS_REALLYSAVETAGSHEADING), #else "Attach the current tag to all selected files?", "REALLY SAVE?", #endif 0L, MB_OKCANCEL | MB_QUERY | MB_DEFBUTTON2 | MB_MOVEABLE) != MBID_OK) return; if (QueryMP3 ()) { delete QueryMP3 (); SetMP3 (NULL); } // set mouse-ptr to "wait" shape HPOINTER hptr = WinQueryPointer (HWND_DESKTOP); WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT, FALSE)); // do the thing ULONG c = 0L; #ifdef _STATUSDISPLAY_ pstatd = new STATD ( #ifdef _MULTILANGUAGES_ RSTR (IDS_SAVEALL), #else "Save all", #endif CountFilesInList (), hwnd, FALSE, &fBreak); pc = &c; fBreak = FALSE; _beginthread (SaveAllThread, NULL, 32L*1024L, this); pstatd->Process (); delete pstatd; #else CHAR ach[_MAX_PATH]; CHAR ach2[_MAX_PATH+31]; for (ULONG i = 0; i < CountFilesInList (); i++) { QueryFile (ach, sizeof (ach), i); if ((pmp3 = new MP3 (ach))) { #ifdef _MULTILANGUAGES_ sprintf (ach2, RSTR (IDS_SAVINGFORMAT), ach); #else sprintf (ach2, "Saving - %s", ach); #endif AdjustCurrent (FALSE); if (QueryMP3 ()->SaveTag ()) c++; delete pmp3; } WinSetWindowText (hwnd, ach2); } #endif if (pset->NotifySave ()) { #ifdef _MULTILANGUAGES_ // tell user what has been done if (c < CountFilesInList ()) Notify (RSTR (IDS_TAGSSAVEDHEADING), RSTR (IDS_SOMETAGSSAVED), c); else Notify (RSTR (IDS_TAGSSAVEDHEADING), RSTR (IDS_ALLTAGSSAVED)); #else // tell user what has been done if (c < CountFilesInList ()) Notify ("SOME TAGS SAVED", "Tags have been saved for %ld selected files (The " "others probably were read only)", c); else Notify ("ALL TAGS SAVED", "Tags have been saved for all selected files."); #endif } // reload the current file and refresh the display SetMP3 (NULL); Refresh (); // set mouse-ptr to normal shape WinSetPointer (HWND_DESKTOP, hptr); #ifndef _STATUSDISPLAY_ WinSetWindowText (hwnd, PSZ_NAMEVERSION); #endif }
VOID MP3DISPLAY :: RenameAll (VOID) { #ifdef _DEBUGLOG_ fputs ("\nRenameAll ()\n", pfileLog); #endif if (! hwnd || ! FilesInList ()) return; /* // confirm operation if (WinMessageBox (HWND_DESKTOP, hwnd, #ifdef _MULTILANGUAGES_ RSTR (IDS_REALLYRENAMEALL), RSTR (IDS_REALLYRENAMEALLHEADING), #else "Rename all files (with tag) to their Title?", "REALLY RENAME?", #endif 0L, MB_OKCANCEL | MB_QUERY | MB_DEFBUTTON2 | MB_MOVEABLE) != MBID_OK) return; */ if (QueryMP3 ()) { delete QueryMP3 (); SetMP3 (NULL); } // set mouse-ptr to "wait" shape HPOINTER hptr = WinQueryPointer (HWND_DESKTOP); WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT, FALSE)); // do the thing CHAR ach[_MAX_PATH], ach2[_MAX_PATH+31]; ULONG c = 0L; // FIXME perhaps ... = strlen ("Filename"); plist->usMaxLen[TAG_FILENAME] = 0; for (ULONG i = 0; i < CountFilesInList (); i++) { QueryFile (ach, sizeof (ach), i); if ((pmp3 = new MP3 (ach))) { // if (pmp3->IsTagged ()) { #ifdef _MULTILANGUAGES_ sprintf (ach2, RSTR (IDS_RENAMINGFORMAT), ach); #else sprintf (ach2, "Renaming - %s", ach); #endif WinSetWindowText (hwnd, ach2); USHORT cb = GETSETTINGS->QueryLong (SEI_RENAMELENGTH); if (! GETSETTINGS->QueryFlag (SEI_RENAMELIMITLENGTH)) cb = 0; if (pren->Rename (pmp3, GETSETTINGS->QueryString (SEI_RENAMETEMPLATE), GETSETTINGS->QueryFlag (SEI_RENAMEREPLACESPACES), cb)) { c ++; strcpy (ach2, pmp3->QueryFilename ().c_str ()); WinSetLboxItemText (WinWindowFromID (hwnd, WID_DDL_FILES), i, ach2); WinSendDlgItemMsg (hwnd, WID_DDL_FILES, EM_SETFIRSTCHAR, 0L, 0L); // if this MP3's filename is longer than current maximum // in list adjust maximum (needed for outputing lists) plist->usMaxLen[TAG_FILENAME] = max (plist->usMaxLen[TAG_FILENAME], USHORT (strlen (pmp3->QueryFilename ().c_str ()))); } else { #ifdef _MULTILANGUAGES_ DisplayError (RSTR (IDS_ERROR_GENERALHEADING), RSTR (IDS_ERROR_RENAMINGFAILED), ach, errno); #else DisplayError ("ERROR", "Renaming file '%s' failed: " "Error %d.", ach, errno); #endif plist->usMaxLen[TAG_FILENAME] = max (plist->usMaxLen[TAG_FILENAME], USHORT (strlen (ach))); } } delete pmp3; } } if (pset->NotifyRename ()) { #ifdef _MULTILANGUAGES_ // tell user what has been done if (c < CountFilesInList ()) Notify (RSTR (IDS_FILESRENAMEDHEADING), RSTR (IDS_SOMEFILESRENAMED), c); else Notify (RSTR (IDS_FILESRENAMEDHEADING), RSTR (IDS_ALLFILESRENAMED)); #else // tell user what has been done if (c < CountFilesInList ()) Notify ("SOME FILES RENAMED", "%ld selected files have been renamed (The " "others probably had no tag)", c); else Notify ("ALL FILES SAVED", "All selected files have been renamed."); #endif } // reload the current file and refresh the display SetMP3 (NULL); Refresh (); QueryFile (ach, sizeof (ach)); WinSetWindowText (WinWindowFromID (hwnd, WID_DDL_FILES), ach); // set mouse-ptr to normal shape WinSetPointer (HWND_DESKTOP, hptr); WinSetWindowText (hwnd, PSZ_NAMEVERSION); }
static void draw_stuff( HWND hwnd ) { HPS win_dc; RECTL paint; RECTL intersect; #ifdef DRAW_ALL_AT_ONCE int old_top; int width, height; SIZEL sizl = { 0, 0 }; BITMAPINFOHEADER2 bmih; LONG formats[24]; POINTL pts[3]; LONG old_cursor; LONG hour_glass_cur; RECTL interior; DEVOPENSTRUC dop = { 0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L }; #endif win_dc = WinBeginPaint( hwnd, 0, &paint ); GpiCreateLogColorTable( win_dc, 0L, LCOLF_RGB, 0L, 0L, NULL ); #ifdef DRAW_ALL_AT_ONCE old_top = paint.yBottom; paint.yBottom = Draw_area.yTop; #endif WinFillRect( win_dc, &paint, SYSCLR_WINDOW ); #ifdef DRAW_ALL_AT_ONCE paint.yBottom = old_top; #endif if( WinIntersectRect( Main_hab, &intersect, &paint, &Draw_area ) ) { #ifdef DRAW_ALL_AT_ONCE width = Draw_area.xRight - Draw_area.xLeft; height = Draw_area.yTop - Draw_area.yBottom; interior.xLeft = 0; interior.yBottom = 0; interior.xRight = width; interior.yTop = height; if( Draw_bitmap == NULLHANDLE ) { Hdc = DevOpenDC( Main_hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE ); Mem_dc = GpiCreatePS( Main_hab, Hdc, &sizl, PU_PELS | GPIA_ASSOC ); memset( &bmih, 0, sizeof( BITMAPINFOHEADER2 ) ); GpiQueryDeviceBitmapFormats( Mem_dc, 24L, formats ); bmih.cbFix = sizeof( BITMAPINFOHEADER2 ); bmih.cx = width; bmih.cy = height; bmih.cPlanes = (USHORT) formats[0]; bmih.cBitCount = (USHORT) formats[1]; Draw_bitmap = GpiCreateBitmap( Mem_dc, &bmih, 0L, NULL, NULL ); Old_bitmap = GpiSetBitmap( Mem_dc, Draw_bitmap ); GpiCreateLogColorTable( Mem_dc, 0, LCOLF_RGB, 0, 0, NULL ); WinFillRect( Mem_dc, &interior, SYSCLR_WINDOW ); hour_glass_cur = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ); old_cursor = WinQueryPointer( HWND_DESKTOP ); WinSetPointer( HWND_DESKTOP, hour_glass_cur ); hThree_d = three_d_begin( Mem_dc, &interior ); draw_room(); three_d_draw( hThree_d ); three_d_end( hThree_d ); WinSetPointer( HWND_DESKTOP, old_cursor ); } pts[0].x = Draw_area.xLeft; pts[0].y = Draw_area.yBottom; pts[1].x = Draw_area.xLeft + width; pts[1].y = Draw_area.yBottom + height; pts[2].x = 0; pts[2].y = 0; GpiBitBlt( win_dc, Mem_dc, 3, pts, ROP_SRCCOPY, BBO_IGNORE ); #else hThree_d = three_d_begin( win_dc, &Draw_area ); draw_room(); three_d_draw( hThree_d ); three_d_end( hThree_d ); #endif } WinEndPaint( win_dc ); }