📄 vlcshell.cpp
字号:
} if( instance != NULL ) { /***** Insert NPP_Print code here *****\ PluginInstance* p_plugin = (PluginInstance*) instance->pdata; \**************************************/ if( printInfo->mode == NP_FULL ) { /* * PLUGIN DEVELOPERS: * If your plugin would like to take over * printing completely when it is in full-screen mode, * set printInfo->pluginPrinted to TRUE and print your * plugin as you see fit. If your plugin wants Netscape * to handle printing in this case, set * printInfo->pluginPrinted to FALSE (the default) and * do nothing. If you do want to handle printing * yourself, printOne is true if the print button * (as opposed to the print menu) was clicked. * On the Macintosh, platformPrint is a THPrint; on * Windows, platformPrint is a structure * (defined in npapi.h) containing the printer name, port, * etc. */ /***** Insert NPP_Print code here *****\ void* platformPrint = printInfo->print.fullPrint.platformPrint; NPBool printOne = printInfo->print.fullPrint.printOne; \**************************************/ /* Do the default*/ printInfo->print.fullPrint.pluginPrinted = FALSE; } else { /* If not fullscreen, we must be embedded */ /* * PLUGIN DEVELOPERS: * If your plugin is embedded, or is full-screen * but you returned false in pluginPrinted above, NPP_Print * will be called with mode == NP_EMBED. The NPWindow * in the printInfo gives the location and dimensions of * the embedded plugin on the printed page. On the * Macintosh, platformPrint is the printer port; on * Windows, platformPrint is the handle to the printing * device context. */ /***** Insert NPP_Print code here *****\ NPWindow* printWindow = &(printInfo->print.embedPrint.window); void* platformPrint = printInfo->print.embedPrint.platformPrint; \**************************************/ } }}/****************************************************************************** * Windows-only methods *****************************************************************************/#if XP_WINstatic LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar ){ VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(GetWindowLongPtr(p_hwnd, GWLP_USERDATA)); switch( i_msg ) { case WM_ERASEBKGND: return 1L; case WM_PAINT: { PAINTSTRUCT paintstruct; HDC hdc; RECT rect; hdc = BeginPaint( p_hwnd, &paintstruct ); GetClientRect( p_hwnd, &rect ); FillRect( hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) ); SetTextColor(hdc, RGB(255, 255, 255)); SetBkColor(hdc, RGB(0, 0, 0)); DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE); EndPaint( p_hwnd, &paintstruct ); return 0L; } default: /* delegate to default handler */ return CallWindowProc( p_plugin->getWindowProc(), p_hwnd, i_msg, wpar, lpar ); }}#endif /* XP_WIN *//****************************************************************************** * UNIX-only methods *****************************************************************************/#ifdef XP_UNIXstatic void Redraw( Widget w, XtPointer closure, XEvent *event ){ VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure); Window control = p_plugin->getControlWindow(); const NPWindow& window = p_plugin->getWindow(); GC gc; XGCValues gcv; unsigned int i_control_height, i_control_width; if( p_plugin->b_toolbar ) p_plugin->getToolbarSize( &i_control_width, &i_control_height ); else i_control_height = i_control_width = 0; Window video = p_plugin->getVideoWindow(); Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; gcv.foreground = BlackPixel( p_display, 0 ); gc = XCreateGC( p_display, video, GCForeground, &gcv ); XFillRectangle( p_display, video, gc, 0, 0, window.width, window.height - i_control_height); gcv.foreground = WhitePixel( p_display, 0 ); XChangeGC( p_display, gc, GCForeground, &gcv ); XDrawString( p_display, video, gc, window.width / 2 - 40, (window.height - i_control_height) / 2, WINDOW_TEXT, strlen(WINDOW_TEXT) ); XFreeGC( p_display, gc ); p_plugin->redrawToolbar();}static void ControlHandler( Widget w, XtPointer closure, XEvent *event ){ VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure); const NPWindow& window = p_plugin->getWindow(); int i_height = window.height; int i_width = window.width; int i_xPos = event->xbutton.x; int i_yPos = event->xbutton.y; if( p_plugin && p_plugin->b_toolbar ) { int i_playing; libvlc_exception_t ex; libvlc_exception_init( &ex ); libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex); if( libvlc_exception_raised(&ex) ) fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex ); if( libvlc_exception_raised(&ex) ) fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); vlc_toolbar_clicked_t clicked; clicked = p_plugin->getToolbarButtonClicked( i_xPos, i_yPos ); switch( clicked ) { case clicked_Play: case clicked_Pause: { if( i_playing == 1 ) libvlc_playlist_pause( p_plugin->getVLC(), &ex ); else libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex ); if( libvlc_exception_raised(&ex) ) fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); } break; case clicked_Stop: { libvlc_playlist_stop( p_plugin->getVLC(), &ex ); if( libvlc_exception_raised(&ex) ) fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); } break; case clicked_Fullscreen: { if( (i_playing == 1) && p_md ) { libvlc_set_fullscreen( p_md, 1, &ex ); if( libvlc_exception_raised(&ex) ) fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); } } break; case clicked_Mute: case clicked_Unmute: { libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex ); if( libvlc_exception_raised(&ex) ) fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); } break; case clicked_timeline: { /* if a movie is loaded */ if( p_md ) { int64_t f_length; f_length = libvlc_media_player_get_length( p_md, &ex ) / 100; libvlc_exception_clear( &ex ); f_length = (float)f_length * ( ((float)i_xPos-4.0 ) / ( ((float)i_width-8.0)/100) ); libvlc_media_player_set_time( p_md, f_length, &ex ); if( libvlc_exception_raised(&ex) ) fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex)); libvlc_exception_clear( &ex ); } } break; case clicked_Time: { /* Not implemented yet*/ } break; default: /* button_Unknown */ break; } if( p_md ) libvlc_media_player_release( p_md ); } Redraw( w, closure, event );}static void Resize ( Widget w, XtPointer closure, XEvent *event ){ VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure); Window control = p_plugin->getControlWindow(); const NPWindow& window = p_plugin->getWindow(); Window drawable = p_plugin->getVideoWindow(); Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; int i_ret; Window root_return, parent_return, * children_return; Window base_window; unsigned int i_nchildren; unsigned int i_control_height, i_control_width; if( p_plugin->b_toolbar ) { p_plugin->getToolbarSize( &i_control_width, &i_control_height ); } else { i_control_height = i_control_width = 0; }#ifdef X11_RESIZE_DEBUG XWindowAttributes attr; if( event && event->type == ConfigureNotify ) { fprintf( stderr, "vlcshell::Resize() ConfigureNotify %d x %d, " "send_event ? %s\n", event->xconfigure.width, event->xconfigure.height, event->xconfigure.send_event ? "TRUE" : "FALSE" ); }#endif /* X11_RESIZE_DEBUG */ if( ! p_plugin->setSize(window.width, (window.height - i_control_height)) ) { /* size already set */ return; } i_ret = XResizeWindow( p_display, drawable, window.width, (window.height - i_control_height) );#ifdef X11_RESIZE_DEBUG fprintf( stderr, "vlcshell::Resize() XResizeWindow(owner) returned %d\n", i_ret ); XGetWindowAttributes ( p_display, drawable, &attr ); /* X is asynchronous, so the current size reported here is not necessarily the requested size as the Resize request may not yet have been handled by the plugin host */ fprintf( stderr, "vlcshell::Resize() current (owner) size %d x %d\n", attr.width, attr.height );#endif /* X11_RESIZE_DEBUG */ XQueryTree( p_display, drawable, &root_return, &parent_return, &children_return, &i_nchildren ); if( i_nchildren > 0 ) { /* XXX: Make assumptions related to the window parenting structure in vlc/modules/video_output/x11/xcommon.c */ base_window = children_return[i_nchildren - 1];#ifdef X11_RESIZE_DEBUG fprintf( stderr, "vlcshell::Resize() got %d children\n", i_nchildren ); fprintf( stderr, "vlcshell::Resize() got base_window %p\n", base_window );#endif /* X11_RESIZE_DEBUG */ i_ret = XResizeWindow( p_display, base_window, window.width, ( window.height - i_control_height ) );#ifdef X11_RESIZE_DEBUG fprintf( stderr, "vlcshell::Resize() XResizeWindow(base) returned %d\n", i_ret ); XGetWindowAttributes( p_display, base_window, &attr ); fprintf( stderr, "vlcshell::Resize() new size %d x %d\n", attr.width, attr.height );#endif /* X11_RESIZE_DEBUG */ }}#endif /* XP_UNIX */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -