/// Function name : onDependenciesPage_ContextMenu // Description : Display the ScriptDependencies or VariableDependencies Popup Menu // // SCRIPT_DOCUMENT* pDocument : [in] Script document data // HWND hCtrl : [in] Window handle of the control sending the message // CONST UINT iCursorX : [in] Screen co-ordinate cursor X position // CONST UINT iCursorY : [in] Screen co-ordinate cursor Y position // // Return Value : TRUE // BOOL onDependenciesPage_ContextMenu(SCRIPT_DOCUMENT* pDocument, HWND hCtrl, CONST UINT iCursorX, CONST UINT iCursorY) { CUSTOM_MENU* pCustomMenu; // Custom Popup menu UINT iSubMenuID; // Popup submenu ID // [TRACK] CONSOLE_ACTION(); // Determine submenu switch (GetWindowID(hCtrl)) { /// [LISTVIEW] Display the appropriate popup menu case IDC_DEPENDENCIES_LIST: iSubMenuID = IDM_DEPENDENCIES_POPUP; CONSOLE("Displaying dependencies menu"); break; case IDC_VARIABLES_LIST: iSubMenuID = IDM_VARIABLES_POPUP; CONSOLE("Displaying variables menu"); break; case IDC_STRINGS_LIST: iSubMenuID = IDM_STRINGS_POPUP; CONSOLE("Displaying strings menu"); break; default: return FALSE; } // Create Dependencies Custom Popup menu pCustomMenu = createCustomMenu(TEXT("SCRIPT_MENU"), TRUE, iSubMenuID); /// [DEPENDENCIES] Disable 'Load script' if no item is selected if (GetWindowID(hCtrl) == IDC_DEPENDENCIES_LIST) EnableMenuItem(pCustomMenu->hPopup, IDM_DEPENDENCIES_LOAD, (ListView_GetSelectedCount(hCtrl) > 0 ? MF_ENABLED : MF_DISABLED)); /// Display context menu TrackPopupMenu(pCustomMenu->hPopup, TPM_TOPALIGN WITH TPM_LEFTALIGN, iCursorX, iCursorY, NULL, GetParent(hCtrl), NULL); // Cleanup and return TRUE deleteCustomMenu(pCustomMenu); return TRUE; }
WindowIdentifier::WindowIdentifier(const nsTArray<uint64> &id, nsIDOMWindow *window) : mID(id) , mWindow(window) , mIsEmpty(false) { mID.AppendElement(GetWindowID()); }
// Someone pressed the help key void help_get_help(short x,short y,unsigned short qual) { struct Window *window=0; struct Layer *layer; IPCData *ipc=0; // Lock screen layer LockLayerInfo(&GUI->screen_pointer->LayerInfo); // Find which layer the mouse is over if ((layer=WhichLayer(&GUI->screen_pointer->LayerInfo,x,y))) { // Get window pointer window=layer->Window; // Get window ID if (GetWindowID(window)!=WINDOW_UNKNOWN) { // Forbid to get port Forbid(); // Get port if (!(ipc=(IPCData *)GetWindowAppPort(window))) Permit(); } } // Unlock layer UnlockLayerInfo(&GUI->screen_pointer->LayerInfo); // Got a port? if (ipc) { ULONG coords; // Convert coordinates to window-relative x-=window->LeftEdge; y-=window->TopEdge; // Pack into longword coords=((unsigned short)x<<16)|(unsigned short)y; // Send help command IPC_Command(ipc,IPC_HELP,qual,(APTR)coords,0,0); // Enable multitasking now that message has been sent Permit(); } // Otherwise, show generic help else help_show_help(HELP_MAIN,0); }
HWND WINAPI GetDlgItem(HWND hDlg, int nIDDlgItem) { HWND hWnd; APISTR((LF_APICALL, "GetDlgItem(%x,%x)\n",hDlg,nIDDlgItem)); for( hWnd = GetWindow(hDlg,GW_CHILD); hWnd && IsWindow(hWnd); hWnd = GetWindow(hWnd,GW_HWNDNEXTSIB)) { if ((short)GetWindowID(hWnd) == (short)nIDDlgItem) break; } APISTR((LF_APIRET, "GetDlgItem: returns HWND %x\n",hWnd)); return hWnd; }
static void notifyParent( HWND hwnd, UINT code = 0 ) { // NM_ code TODO NMRANGESLIDER nm = { { 0 } }; nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetWindowID( hwnd ); nm.hdr.code = code; nm.rsInfo._lower = getLower ( hwnd ); nm.rsInfo._upper = getUpper ( hwnd ); nm.rsInfo._start = getStart ( hwnd ); nm.rsInfo._end = getEnd ( hwnd ); nm.rsInfo._minRange = getMinRange ( hwnd ); nm.rsInfo._granularity = getGranularity( hwnd ); FORWARD_WM_NOTIFY( GetParent( hwnd ), nm.hdr.idFrom, &nm, SNDMSG ); }
void WINAPI CheckRadioButton(HWND hDlg, int nIDFirst,int nIDLast,int nIDCheckButton) { HWND hWndCheck,hWndTemp; WORD wID; DWORD dwStyle; ATOM atmClassName; if (!(hWndCheck = GetDlgItem(hDlg,nIDCheckButton))) return; hWndTemp = GetNextDlgGroupItem(hDlg,hWndCheck,FALSE); while(hWndTemp && (hWndCheck != hWndTemp)) { wID = GetWindowID(hWndTemp); dwStyle = GetWindowLong(hWndTemp,GWL_STYLE); atmClassName = GetClassWord(hWndTemp,GCW_ATOM); if ((wID >= (WORD)nIDFirst) && (wID <= (WORD)nIDLast) && (atmClassName == atmGlobalLookup[LOOKUP_BUTTON]) && ((LOWORD(dwStyle) == BS_RADIOBUTTON) || (LOWORD(dwStyle) == BS_AUTORADIOBUTTON))) SendMessage(hWndTemp,BM_SETCHECK,FALSE,0); hWndTemp = GetNextDlgGroupItem(hDlg,hWndTemp,FALSE); } SendMessage(hWndCheck,BM_SETCHECK,TRUE,0); }
WindowIdentifier::WindowIdentifier(nsIDOMWindow *window) : mWindow(window) , mIsEmpty(false) { mID.AppendElement(GetWindowID()); }
DisplayInfo MythDisplay::GetDisplayInfo(int video_rate) { DisplayInfo ret; #if defined(Q_WS_MAC) CGDirectDisplayID disp = GetOSXDisplay(GetWindowID()); if (!disp) return ret; CFDictionaryRef ref = CGDisplayCurrentMode(disp); float rate = 0.0f; if (ref) rate = get_float_CF(ref, kCGDisplayRefreshRate); if (VALID_RATE(rate)) ret.rate = 1000000.0f / rate; else ret.rate = fix_rate(video_rate); CGSize size_in_mm = CGDisplayScreenSize(disp); ret.size = QSize((uint) size_in_mm.width, (uint) size_in_mm.height); uint width = (uint)CGDisplayPixelsWide(disp); uint height = (uint)CGDisplayPixelsHigh(disp); ret.res = QSize(width, height); #elif defined(Q_WS_WIN) HDC hdc = GetDC(GetWindowID()); int rate = 0; if (hdc) { rate = GetDeviceCaps(hdc, VREFRESH); int width = GetDeviceCaps(hdc, HORZSIZE); int height = GetDeviceCaps(hdc, VERTSIZE); ret.size = QSize((uint)width, (uint)height); width = GetDeviceCaps(hdc, HORZRES); height = GetDeviceCaps(hdc, VERTRES); ret.res = QSize((uint)width, (uint)height); } if (VALID_RATE(rate)) { // see http://support.microsoft.com/kb/2006076 switch (rate) { case 23: ret.rate = 41708; break; // 23.976Hz case 29: ret.rate = 33367; break; // 29.970Hz case 47: ret.rate = 20854; break; // 47.952Hz case 59: ret.rate = 16683; break; // 59.940Hz case 71: ret.rate = 13903; break; // 71.928Hz case 119: ret.rate = 8342; break; // 119.880Hz default: ret.rate = 1000000.0f / (float)rate; } } else ret.rate = fix_rate(video_rate); #elif USING_X11 MythXDisplay *disp = OpenMythXDisplay(); if (!disp) return ret; float rate = disp->GetRefreshRate(); if (VALID_RATE(rate)) ret.rate = 1000000.0f / rate; else ret.rate = fix_rate(video_rate); ret.res = disp->GetDisplaySize(); ret.size = disp->GetDisplayDimensions(); delete disp; #endif return ret; }
HWND InternalCreateDialog(HINSTANCE hInst, LPSTR lpDlg, HWND hWnd, DLGPROC lpFunc, LPARAM lParam) { DIALOGDATA *dp = (DIALOGDATA *) lpDlg; CONTROLDATA *cp; HWND hDlg; int i; HWND hCtl; HWND hFirst = 0,hFirstButton; int X,Y; HFONT hFont = (HFONT)0; HFONT ctlFont; DWORD dwBaseUnits; DWORD dwRet; WORD wDialogWidth, wDialogHeight; WORD wDlgCode; int nWidth, nHeight; int nXBorder = 0, nYBorder = 0; int cyCaption; LOGFONT LogFont; BOOL bVisible; DWORD dwStyle; #if 0 HDC hDC; HCURSOR hCursOld, hCursHourGlass; #endif dwBaseUnits = GetDialogFontUnits(hFont); wDialogWidth = LOWORD(dwBaseUnits); wDialogHeight = HIWORD(dwBaseUnits); dwStyle = dp->lStyle; /* force WS_POPUP style for top-level dialogs */ if (!(dwStyle & WS_CHILD)) dwStyle |= WS_POPUP; if (dwStyle & DS_SETFONT && dp->szFaceName != NULL && strlen(dp->szFaceName)) { memset((LPVOID)&LogFont,0,sizeof(LOGFONT)); /* dp->wPointSize is defined as the typographical point size,*/ /* it must be converted to the logical font size. */ #if 0 LogFont.lfHeight = -1 * MulDiv(dp->wPointSize, GetDeviceCaps (hDC, LOGPIXELSY), 72); #else /* dp->wPointSize is NOT a typographical point size. It is * the font height in dialog base units. It was misnamed. */ LogFont.lfHeight = (dp->wPointSize * wDialogHeight / 8); #endif LogFont.lfWeight = 700; strcpy(LogFont.lfFaceName,dp->szFaceName); hFont = CreateFontIndirect(&LogFont); } /* NOTE: * the coordinates here are from the resource file * we should not change them here, but in Windows.c. * this was converted from a straight muliply then * divide, to MulDiv, this will round up both the x,y * and the width. */ X = MulDiv(dp->x,wDialogWidth,4); Y = MulDiv(dp->y,wDialogHeight,8); nWidth = MulDiv(dp->cx,wDialogWidth,4); nHeight = MulDiv(dp->cy,wDialogHeight,8); /* final window size and coordinates should be adjusted by */ /* border and caption size depending on the style */ if (dwStyle & WS_DLGFRAME) { nXBorder = GetSystemMetrics(SM_CXDLGFRAME); nYBorder = GetSystemMetrics(SM_CYDLGFRAME); } else if (dwStyle & WS_BORDER) { nXBorder = GetSystemMetrics(SM_CXBORDER); nYBorder = GetSystemMetrics(SM_CYBORDER); } if (dwStyle & WS_THICKFRAME) { nXBorder = GetSystemMetrics(SM_CXFRAME); nYBorder = GetSystemMetrics(SM_CYFRAME); } X -= nXBorder; Y -= nYBorder; nWidth += 2*nXBorder; nHeight += 2*nYBorder; if ((dwStyle & WS_CAPTION) == WS_CAPTION) { cyCaption = GetSystemMetrics(SM_CYCAPTION); Y -= cyCaption; nHeight += cyCaption; } if (dwStyle & WS_VISIBLE) { bVisible = TRUE; dwStyle &= ~WS_VISIBLE; } else bVisible = FALSE; hDlg = CreateWindow( (!HIWORD(dp->szClassName) || !strlen(dp->szClassName))? TWIN_DIALOGCLASS:dp->szClassName, (HIWORD(dp->szCaption) && strlen(dp->szCaption))? dp->szCaption:" ", dwStyle, X,Y,nWidth,nHeight, hWnd, (HMENU)0, (hInst)?hInst: (hWnd?GetWindowInstance(hWnd):0), NULL ); if(hDlg == 0) { return 0; } /* * The following code was removed because it needlessly leaves * an hour glass on all of the applications windows while the dialog * box is up. Another call to SetCursor() was also commented out * at the end of this function. */ #if 0 hCursHourGlass = LoadCursor((HINSTANCE)0, IDC_WAIT); hCursOld = SetCursor(hCursHourGlass); #endif SetWF(hDlg,WFDIALOGWINDOW); SetWindowWord(hDlg,DWW_STATUS,0); SetWindowWord(hDlg,DWW_PARENT,hWnd); SetWindowLong(hDlg,DWL_DLGPROC,(LONG)lpFunc); SetWindowLong(hDlg,DWL_LPARAM,lParam); SetWindowWord(hDlg,DWW_DEFID,(WORD)0L); if (hFont) SendMessage(hDlg, WM_SETFONT, (WPARAM)hFont, (LPARAM)MAKELONG(FALSE,0)); for(i=0,cp=dp->controlinfo; i<(int)(dp->bNumberOfItems); i++,cp++) { hCtl = CreateWindow( cp->szClass?cp->szClass:"STATIC", ((!cp->szClass || !lstrcmpi(cp->szClass,"STATIC")) && ((cp->lStyle & 0xf) == SS_ICON))? NULL:cp->szText, cp->lStyle, (int)(cp->x*wDialogWidth)/4, (int)(cp->y*wDialogHeight)/8, (int)(cp->cx*wDialogWidth)/4, (int)(cp->cy*wDialogHeight)/8, hDlg, cp->wID, hWnd?GetWindowInstance(hWnd):hInst, NULL ); if(!hFirst && (cp->lStyle & WS_TABSTOP)) hFirst = hCtl; if ((!cp->szClass || !lstrcmpi(cp->szClass,"STATIC")) && ((cp->lStyle & 0xf) == SS_ICON)) { /* icon for the SS_ICON control comes from the same place, as dialog template, note, only send message if we actually have one */ if(cp->szText) SendMessage(hCtl, STM_SETICON, (WPARAM)LoadIcon(hInst,cp->szText), (LPARAM)0); } /* if a dialog class font was specified, and the control */ /* has not done a WM_SETFONT, then set this font. */ if(hFont) { ctlFont = (HFONT)SendMessage(hCtl, WM_GETFONT, 0, 0); if(ctlFont == 0) SendMessage( hCtl, WM_SETFONT, (WPARAM)hFont, (LPARAM)MAKELONG(FALSE,0) ); } } dwRet = SendMessage(hDlg,WM_INITDIALOG,(WPARAM)hFirst,lParam); for (hCtl = GetWindow(hDlg,GW_CHILD),hFirstButton = 0; hCtl; hCtl = GetWindow(hCtl,GW_HWNDNEXTSIB)) { wDlgCode = (WORD)SendMessage(hCtl,WM_GETDLGCODE,0,0L); if (wDlgCode & DLGC_DEFPUSHBUTTON) break; if ((wDlgCode & DLGC_UNDEFPUSHBUTTON) && (hFirstButton == 0)) hFirstButton = hCtl; } if (hCtl != 0) SetWindowWord(hDlg,DWW_DEFID,GetWindowID(hCtl)); else if (hFirstButton != 0) SetWindowWord(hDlg,DWW_DEFID,GetWindowID(hFirstButton)); else SetWindowWord(hDlg,DWW_DEFID,0); if (dwRet) { DlgSetFocus(hFirst); if ((WORD)SendMessage(hFirst,WM_GETDLGCODE,0,0L) & DLGC_HASSETSEL) Edit_SetSel(hFirst, 0, -1); } hCtl = GetFocus(); if(hCtl == 0) { hCtl = GetFirstDlgTabItem(hDlg); if(hCtl) { DlgSetFocus(hCtl); if ((WORD)SendMessage(hCtl,WM_GETDLGCODE,0,0L) & DLGC_HASSETSEL) Edit_SetSel(hCtl, 0, -1); } } if (bVisible) { ShowWindow(hDlg,SW_SHOWNORMAL); } if (bVisible) { UpdateWindow(hDlg); } #ifdef CURSORWARPING /* this will warp the cursor to the default button */ /* it only should be activated by a user preference */ /* and not automatically */ { HWND hWnd; int width ,height; RECT rcDlg; hWnd = hCtl; GetWindowRect(hWnd,&rcDlg); width = (rcDlg.left + rcDlg.right)/2; height = (rcDlg.bottom + rcDlg.top)/2; SetCursorPos(width,height); } #endif /* SetCursor(hCursOld); */ return hDlg; }
void Twindow::resizeDialog(HWND hwnd, bool relative, int scale) { RECT dlgRect; if(!GetWindowRect(hwnd,&dlgRect)) { return; } HWND parentHwnd=GetParent(hwnd); if (relative) { ScreenToClient(parentHwnd,(LPPOINT)&dlgRect.left); ScreenToClient(parentHwnd,(LPPOINT)&dlgRect.right); } int dlgWidth=(dlgRect.right-dlgRect.left); int dlgHeight=(dlgRect.bottom-dlgRect.top); if (relative) { dlgRect.left=dlgRect.left*scale/100; } else { dlgRect.left-=dlgWidth*(scale-100)/200; } int id=GetWindowID(hwnd); char_t className[32]; GetClassName(hwnd,className,32); if (stricmp(className,_l("EDIT")) == 0 && parentHwnd) { // Don't resize edit controls that have a combobox as their parent - // those have already been resized when the combobox was resized char_t parentClassName[32]; GetClassName(parentHwnd,parentClassName,32); if (stricmp(parentClassName,_l("COMBOBOX")) == 0) { return; } } bool isStatic=(stricmp(className,_l("STATIC")) == 0); if (isStatic && id == IDC_BMP_LEVELS_CURVES) // Curves diagram looks bad when stretched { ; } else if (isStatic && (id == IDC_STATIC && SendMessage(hwnd,STM_GETIMAGE,IMAGE_BITMAP,0))) // Center static bitmaps without scaling { dlgRect.left+=dlgWidth*(scale-100)/200; } else { dlgWidth=dlgWidth*scale/100; } SetWindowPos( hwnd, 0, dlgRect.left, dlgRect.top, dlgWidth, dlgHeight, SWP_NOZORDER); }
// Check that a screen can close if Opus disappears BOOL check_closescreen(struct Screen *screen) { ULONG lock; struct Window *window=0; TimerHandle *timer=0; short a; // Try this four times for (a=0;a<4;a++) { // Lock IntuitionBase lock=LockIBase(0); // Go through window list for (window=screen->FirstWindow; window; window=window->NextWindow) { // Not a Workbench tool window? if (!(window->Flags&WFLG_WBENCHWINDOW)) { // If this is one of Opus', GetWindowID() should know about it if (GetWindowID(window)==WINDOW_UNKNOWN) { BOOL ok=0; struct Task *task=0; // Special case for IPrefs requester - get window's task if (window->UserPort) task=(struct Task *)window->UserPort->mp_SigTask; // Valid name? if (task && task->tc_Node.ln_Name) { // Owned by IPrefs? if (strcmp(task->tc_Node.ln_Name,"« IPrefs »")==0) ok=1; } // If not ok, fail if (!ok) break; } } } // Unlock IntuitionBase UnlockIBase(lock); // Ok to shut? if (!window) break; // Allocate timer if don't already have it if (!timer && !(timer=AllocTimer(UNIT_VBLANK,0))) break; // Start timer and wait for it StartTimer(timer,0,250000); while (!CheckTimer(timer)) WaitPort(timer->port); } // Free timer FreeTimer(timer); // If window==NULL we can shut return (BOOL)(!window); }
// Stop dragging a button void buttons_stop_drag(Buttons *buttons,short x,short y) { struct Layer *layer; struct Window *window; ULONG id=0; BOOL swap_local=0; IPCData *ipc=0; BOOL ok=0; // Free drag info FreeDragInfo(buttons->drag_info); buttons->drag_info=0; // Nothing selected now buttons->editor_sel_col=-1; buttons->editor_sel_row=-1; buttons->button_sel_button=0; IPC_Command( buttons->editor, BUTTONEDIT_SELECT_BUTTON, -1, (APTR)-1, 0, 0); // Invalid coordinates? if (x==-1 || y==-1) return; // Lock layer LockScreenLayer(buttons->window->WScreen); // Find which layer we dropped it on if (layer=WhichLayer( &buttons->window->WScreen->LayerInfo, x+buttons->window->LeftEdge, y+buttons->window->TopEdge)) { // Does layer have a window? if ((window=layer->Window)) { // Is it our own window? if (window==buttons->window) { // Set flag to swap with local button swap_local=1; } else { // Get window ID id=GetWindowID(window); // Forbid to get IPC Forbid(); if (!(ipc=(IPCData *)GetWindowAppPort(window))) Permit(); } } } // Unlock layer UnlockScreenLayer(buttons->window->WScreen); // Got an IPC port? if (ipc) { // Button editor or another button bank? if (id==WINDOW_BUTTON_CONFIG || id==WINDOW_BUTTONS || id==WINDOW_FUNCTION_EDITOR) { Cfg_Button *button; Point *pos; // Store position (screen relative) if (pos=AllocVec(sizeof(Point),0)) { pos->x=x+buttons->window->LeftEdge; pos->y=y+buttons->window->TopEdge; } // Copy current button if (button=CopyButton(buttons->button_drag_button,0,-1)) { // Send button IPC_Command(ipc,BUTTONEDIT_CLIP_BUTTON,0,button,pos,0); ok=1; } } // Permit now we've sent the message Permit(); } // Swapping local buttons? else if (swap_local) { Cfg_Button *swap; // Lock bank GetSemaphore(&buttons->bank->lock,SEMF_SHARED,0); // Get swap button if (swap=button_from_point(buttons,&x,&y)) { // Different button? if (swap!=buttons->button_drag_button) { // Swap buttons SwapListNodes( &buttons->bank->buttons, (struct Node *)buttons->button_drag_button, (struct Node *)swap); // Redraw buttons buttons_show_button( buttons, swap, buttons->drag_col, buttons->drag_row, swap->current,0); buttons_show_button( buttons, buttons->button_drag_button, x, y, buttons->button_drag_button->current,0); buttons->flags|=BUTTONF_CHANGED; } } // Unlock bank FreeSemaphore(&buttons->bank->lock); ok=1; } // Failed? if (!ok) DisplayBeep(buttons->window->WScreen); }