From e230f122275a28d1a07fd42872a8310e2aa35be8 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Mon, 26 May 2003 14:59:37 +0000 Subject: [PATCH] * modules/codec/quicktime.c: i had accidently upgraded this plugin to 100 * modules/demux/avi/avi.c: fixed a spelling error reported by emulynx * modules/gui/macosx/intf.?: added a wrapString:toWidth function * modules/gui/macosx/prefs.?: removed the use of vlc_wraptext, because it was ugly. now we use our own, osx method. This fixes tooltips in japanese I'm not sure, but i think src/extras/libc.c vlc_wraptext is now unused. --- modules/codec/quicktime.c | 4 ++-- modules/demux/avi/avi.c | 4 ++-- modules/gui/macosx/intf.h | 3 ++- modules/gui/macosx/intf.m | 45 +++++++++++++++++++++++++++++++++++++- modules/gui/macosx/prefs.h | 4 ++-- modules/gui/macosx/prefs.m | 28 ++++++++++++------------ 6 files changed, 66 insertions(+), 22 deletions(-) diff --git a/modules/codec/quicktime.c b/modules/codec/quicktime.c index 8ffb30b9a2..7cff47ab5b 100644 --- a/modules/codec/quicktime.c +++ b/modules/codec/quicktime.c @@ -2,7 +2,7 @@ * quicktime.c: a quicktime decoder that uses the QT library/dll ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: quicktime.c,v 1.5 2003/05/24 02:48:55 hartman Exp $ + * $Id: quicktime.c,v 1.6 2003/05/26 14:59:37 hartman Exp $ * * Authors: Laurent Aimar * Derk-Jan Hartman @@ -63,7 +63,7 @@ static int RunDecoderVideo( decoder_fifo_t * ); vlc_module_begin(); set_description( _("QuickTime library decoder") ); - set_capability( "decoder", 100 ); + set_capability( "decoder", 10 ); set_callbacks( OpenDecoder, NULL ); /* create a mutex */ diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c index 4bed2f83f9..4f950fb127 100644 --- a/modules/demux/avi/avi.c +++ b/modules/demux/avi/avi.c @@ -2,7 +2,7 @@ * avi.c : AVI file Stream input module for vlc ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: avi.c,v 1.48 2003/05/22 21:42:44 gbazin Exp $ + * $Id: avi.c,v 1.49 2003/05/26 14:59:37 hartman Exp $ * Authors: Laurent Aimar * * This program is free software; you can redistribute it and/or modify @@ -960,7 +960,7 @@ static int AVIInit( vlc_object_t * p_this ) p_input->pf_demux = AVIDemux_Seekable; if( AVI_TestFile( p_input ) ) { - msg_Warn( p_input, "avi module discarded (invalid headr)" ); + msg_Warn( p_input, "avi module discarded (invalid header)" ); return VLC_EGENERIC; } diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index 94626bf65a..067e398075 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -2,7 +2,7 @@ * intf.h: MacOS X interface plugin ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN - * $Id: intf.h,v 1.40 2003/05/20 18:53:03 hartman Exp $ + * $Id: intf.h,v 1.41 2003/05/26 14:59:37 hartman Exp $ * * Authors: Jon Lech Johansen * Christophe Massiot @@ -43,6 +43,7 @@ - (NSString *)localizedString:(char *)psz; - (char *)delocalizeString:(NSString *)psz; - (NSStringEncoding)getEncoding; +- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width; - (void)setIntf:(intf_thread_t *)p_intf; - (intf_thread_t *)getIntf; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index 886959a926..3ad9323420 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -2,7 +2,7 @@ * intf.m: MacOS X interface plugin ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN - * $Id: intf.m,v 1.86 2003/05/25 17:27:13 massiot Exp $ + * $Id: intf.m,v 1.87 2003/05/26 14:59:37 hartman Exp $ * * Authors: Jon Lech Johansen * Christophe Massiot @@ -169,6 +169,49 @@ static void Run( intf_thread_t *p_intf ) return i_encoding; } +/* i_width is in pixels */ +- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int) i_width +{ + NSMutableString *o_wrapped; + NSString *o_out_string; + NSRange glyphRange, effectiveRange, charRange; + NSRect lineFragmentRect; + unsigned glyphIndex, breaksInserted = 0; + + NSTextStorage *o_storage = [[NSTextStorage alloc] initWithString: o_in_string + attributes: [NSDictionary dictionaryWithObjectsAndKeys: + [NSFont labelFontOfSize: 0.0], NSFontAttributeName, nil]]; + NSLayoutManager *o_layout_manager = [[NSLayoutManager alloc] init]; + NSTextContainer *o_container = [[NSTextContainer alloc] + initWithContainerSize: NSMakeSize(i_width, 2000)]; + + [o_layout_manager addTextContainer: o_container]; + [o_container release]; + [o_storage addLayoutManager: o_layout_manager]; + [o_layout_manager release]; + + o_wrapped = [o_in_string mutableCopy]; + glyphRange = [o_layout_manager glyphRangeForTextContainer: o_container]; + + for( glyphIndex = glyphRange.location ; glyphIndex < NSMaxRange(glyphRange) ; + glyphIndex += effectiveRange.length) { + lineFragmentRect = [o_layout_manager lineFragmentRectForGlyphAtIndex: glyphIndex + effectiveRange: &effectiveRange]; + charRange = [o_layout_manager characterRangeForGlyphRange: effectiveRange + actualGlyphRange: &effectiveRange]; + if ([o_wrapped lineRangeForRange: + NSMakeRange(charRange.location + breaksInserted, charRange.length)].length > charRange.length) { + [o_wrapped insertString: @"\n" atIndex: NSMaxRange(charRange) + breaksInserted]; + breaksInserted++; + } + } + o_out_string = [NSString stringWithString: o_wrapped]; + [o_wrapped release]; + [o_storage release]; + + return o_out_string; +} + - (void)setIntf:(intf_thread_t *)_p_intf { p_intf = _p_intf; diff --git a/modules/gui/macosx/prefs.h b/modules/gui/macosx/prefs.h index 0f4a9a1a10..75c834337b 100644 --- a/modules/gui/macosx/prefs.h +++ b/modules/gui/macosx/prefs.h @@ -2,7 +2,7 @@ * prefs.h: MacOS X plugin for vlc ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN - * $Id: prefs.h,v 1.8 2003/05/26 01:25:12 hartman Exp $ + * $Id: prefs.h,v 1.9 2003/05/26 14:59:37 hartman Exp $ * * Authors: Jon Lech Johansen * @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ -#define PREFS_WRAP 60 +#define PREFS_WRAP 300 @interface VLCTreeItem : NSObject { diff --git a/modules/gui/macosx/prefs.m b/modules/gui/macosx/prefs.m index fe40e0d67a..c428864a48 100644 --- a/modules/gui/macosx/prefs.m +++ b/modules/gui/macosx/prefs.m @@ -2,7 +2,7 @@ * prefs.m: MacOS X plugin for vlc ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN - * $Id: prefs.m,v 1.29 2003/05/26 02:03:10 hartman Exp $ + * $Id: prefs.m,v 1.30 2003/05/26 14:59:37 hartman Exp $ * * Authors: Jon Lech Johansen * Derk-Jan Hartman @@ -254,7 +254,7 @@ { \ char * psz_duptip = NULL; \ if ( p_item->psz_longtext != NULL ) \ - psz_duptip = vlc_wraptext( strdup( p_item->psz_longtext ), PREFS_WRAP ); \ + psz_duptip = strdup( p_item->psz_longtext ); \ s_rc.size.height = 25; \ s_rc.size.width = w; \ s_rc.origin.y += 10; \ @@ -265,8 +265,8 @@ [o_text_field msg: param]; \ if ( psz_duptip != NULL ) \ { \ - [o_text_field setToolTip: [NSApp localizedString: \ - psz_duptip]]; \ + [o_text_field setToolTip: [NSApp wrapString: [NSApp localizedString: \ + psz_duptip] toWidth: PREFS_WRAP ]]; \ free(psz_duptip);\ } \ [o_view addSubview: [o_text_field autorelease]]; \ @@ -323,7 +323,7 @@ char * psz_duptip = NULL; if ( p_item->psz_longtext != NULL ) - psz_duptip = vlc_wraptext( strdup( p_item->psz_longtext ), PREFS_WRAP ); + psz_duptip = strdup( p_item->psz_longtext ); s_rc.size.height = 30; s_rc.size.width = 200; @@ -340,7 +340,7 @@ if ( psz_duptip != NULL ) { - [o_modules setToolTip: [NSApp localizedString: psz_duptip]]; + [o_modules setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]]; free( psz_duptip ); } [o_view addSubview: [o_modules autorelease]]; @@ -398,7 +398,7 @@ VLCComboBox *o_combo_box; char * psz_duptip = NULL; if ( p_item->psz_longtext != NULL ) - psz_duptip = vlc_wraptext( strdup( p_item->psz_longtext ), PREFS_WRAP ); + psz_duptip = strdup( p_item->psz_longtext ); s_rc.size.height = 27; s_rc.size.width = 200; @@ -415,7 +415,7 @@ if ( psz_duptip != NULL ) { - [o_combo_box setToolTip: [NSApp localizedString: psz_duptip]]; + [o_combo_box setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]]; free( psz_duptip ); } [o_view addSubview: [o_combo_box autorelease]]; @@ -450,7 +450,7 @@ VLCSlider *o_slider; char * psz_duptip = NULL; if ( p_item->psz_longtext != NULL ) - psz_duptip = vlc_wraptext( strdup( p_item->psz_longtext ), PREFS_WRAP ); + psz_duptip = strdup( p_item->psz_longtext ); s_rc.size.height = 27; s_rc.size.width = 200; @@ -465,7 +465,7 @@ if ( psz_duptip != NULL ) { - [o_slider setToolTip: [NSApp localizedString: psz_duptip]]; + [o_slider setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]]; free( psz_duptip ); } [o_slider setTarget: self]; @@ -495,7 +495,7 @@ VLCSlider *o_slider; char * psz_duptip = NULL; if ( p_item->psz_longtext != NULL ) - psz_duptip = vlc_wraptext( strdup( p_item->psz_longtext ), PREFS_WRAP ); + psz_duptip = strdup( p_item->psz_longtext ); s_rc.size.height = 27; s_rc.size.width = 200; @@ -510,7 +510,7 @@ if ( psz_duptip != NULL ) { - [o_slider setToolTip: [NSApp localizedString: psz_duptip]]; + [o_slider setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]]; free( psz_duptip ); } [o_slider setTarget: self]; @@ -533,7 +533,7 @@ char * psz_duptip = NULL; if ( p_item->psz_longtext != NULL ) - psz_duptip = vlc_wraptext( strdup( p_item->psz_longtext ), PREFS_WRAP ); + psz_duptip = strdup( p_item->psz_longtext ); s_rc.size.height = 27; s_rc.size.width = s_vrc.size.width - X_ORIGIN * 2 - 20; @@ -547,7 +547,7 @@ [o_btn_bool setTitle: [NSApp localizedString: p_item->psz_text]]; if ( psz_duptip != NULL ) { - [o_btn_bool setToolTip: [NSApp localizedString: psz_duptip]]; + [o_btn_bool setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]]; free( psz_duptip ); } [o_btn_bool setTarget: self]; -- 2.39.5