Kaydet (Commit) a819e9b6 authored tarafından gt's avatar gt

#98414# mnemonic-handling in hyperlink dialog including icon choice control

üst dc1f4abb
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: hyperdlg.hxx,v $ * $RCSfile: hyperdlg.hxx,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change: $Author: sj $ $Date: 2002-02-19 16:09:15 $ * last change: $Author: gt $ $Date: 2002-05-29 11:35:23 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -149,20 +149,21 @@ private: ...@@ -149,20 +149,21 @@ private:
DECL_LINK (ClickCloseHdl_Impl, void * ); DECL_LINK (ClickCloseHdl_Impl, void * );
protected: protected:
virtual BOOL Close(); virtual BOOL Close();
virtual void Move(); virtual void Move();
// virtual long PreNotify( NotifyEvent& rNEvt );
public: public:
SvxHpLinkDlg (Window* pParent, SfxBindings* pBindings ); SvxHpLinkDlg (Window* pParent, SfxBindings* pBindings );
~SvxHpLinkDlg (); ~SvxHpLinkDlg ();
USHORT SetPage( SvxHyperlinkItem* pItem ); USHORT SetPage( SvxHyperlinkItem* pItem );
void EnableInetBrowse( sal_Bool bEnable = sal_True ); void EnableInetBrowse( sal_Bool bEnable = sal_True );
void SetReadOnlyMode( sal_Bool bReadOnly = sal_False ); void SetReadOnlyMode( sal_Bool bReadOnly = sal_False );
const BOOL IsHTMLDoc() const { return mbIsHTMLDoc; } inline const BOOL IsHTMLDoc() const { return mbIsHTMLDoc; }
SfxBindings* GetBindings() const { return mpBindings; }; inline SfxBindings* GetBindings() const { return mpBindings; };
SfxDispatcher* GetDispatcher() const { return mpBindings->GetDispatcher(); } inline SfxDispatcher* GetDispatcher() const { return mpBindings->GetDispatcher(); }
}; };
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: hyperdlg.cxx,v $ * $RCSfile: hyperdlg.cxx,v $
* *
* $Revision: 1.9 $ * $Revision: 1.10 $
* *
* last change: $Author: sj $ $Date: 2001-10-01 15:25:27 $ * last change: $Author: gt $ $Date: 2002-05-29 11:40:11 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -211,6 +211,9 @@ SvxHpLinkDlg::SvxHpLinkDlg (Window* pParent, SfxBindings* pBindings) ...@@ -211,6 +211,9 @@ SvxHpLinkDlg::SvxHpLinkDlg (Window* pParent, SfxBindings* pBindings)
aImage = Image( SVX_RES ( RID_SVXBMP_HLDOCNTP ) ); aImage = Image( SVX_RES ( RID_SVXBMP_HLDOCNTP ) );
AddTabPage ( RID_SVXPAGE_HYPERLINK_NEWDOCUMENT, aStrTitle, aImage, SvxHyperlinkNewDocTp::Create ); AddTabPage ( RID_SVXPAGE_HYPERLINK_NEWDOCUMENT, aStrTitle, aImage, SvxHyperlinkNewDocTp::Create );
// all tab pages set -> create mnemonics
CreateIconTextAutoMnemonics();
// create itemset for tabpages // create itemset for tabpages
mpItemSet = new SfxItemSet( SFX_APP()->GetPool(), SID_HYPERLINK_GETLINK, mpItemSet = new SfxItemSet( SFX_APP()->GetPool(), SID_HYPERLINK_GETLINK,
SID_HYPERLINK_SETLINK ); SID_HYPERLINK_SETLINK );
...@@ -309,6 +312,26 @@ void SvxHpLinkDlg::Move() ...@@ -309,6 +312,26 @@ void SvxHpLinkDlg::Move()
Window::Move(); Window::Move();
} }
/*long SvxHpLinkDlg::PreNotify( NotifyEvent& rNEvt )
{
long nRet = 0;
if( rNEvt.GetType() == EVENT_KEYINPUT )
{
DBG_ASSERT( rNEvt.GetKeyEvent(), "-SvxHpLinkDlg::PreNotify(): no KeyEvent for key event?!" );
const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
if( KEY_MOD2 == pKEvt->GetKeyCode().GetModifier() && pKEvt->GetCharCode() && HandleShortCutKey( *pKEvt ) )
nRet = 1;
}
if( !nRet )
nRet = IconChoiceDialog::PreNotify( rNEvt );
return nRet;
}*/
/************************************************************************* /*************************************************************************
|* |*
|* Click on Apply-button |* Click on Apply-button
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: iconcdlg.cxx,v $ * $RCSfile: iconcdlg.cxx,v $
* *
* $Revision: 1.8 $ * $Revision: 1.9 $
* *
* last change: $Author: gt $ $Date: 2001-10-12 13:00:36 $ * last change: $Author: gt $ $Date: 2002-05-29 11:40:12 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -89,6 +89,12 @@ ...@@ -89,6 +89,12 @@
#ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX #ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX
#include <svtools/viewoptions.hxx> #include <svtools/viewoptions.hxx>
#endif #endif
#ifndef _SV_MNEMONIC_HXX
#include <vcl/mnemonic.hxx>
#endif
#ifndef _VCL_I18NHELP_HXX
#include <vcl/i18nhelp.hxx>
#endif
#ifdef WNT #ifdef WNT
int __cdecl IconcDlgCmpUS_Impl( const void* p1, const void* p2 ) int __cdecl IconcDlgCmpUS_Impl( const void* p1, const void* p2 )
...@@ -1405,3 +1411,110 @@ void IconChoiceDialog::FocusOnIcon( USHORT nId ) ...@@ -1405,3 +1411,110 @@ void IconChoiceDialog::FocusOnIcon( USHORT nId )
pEntry->SetFocus( FALSE ); pEntry->SetFocus( FALSE );
} }
} }
// -----------------------------------------------------------------------
long IconChoiceDialog::PreNotify( NotifyEvent& rNEvt )
{
const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
DBG_ASSERT( rNEvt.GetType() != EVENT_KEYINPUT || ( rNEvt.GetType() == EVENT_KEYINPUT && pKEvt ),
"-IconChoiceDialog::PreNotify(): no KeyEvent for key event?!" );
if( rNEvt.GetType() == EVENT_KEYINPUT && pKEvt->GetKeyCode().IsMod2() && pKEvt->GetCharCode() )
{ // catch only <ALT><something> for mnemonic-handling
long nRet = 0;
if( HasChildPathFocus() )
{ // focus is somewhere in the dialog
if( maIconCtrl.HasChildPathFocus() && maIconCtrl.HandleShortCutKey( *pKEvt ) )
nRet = 1;
else
nRet = ModalDialog::PreNotify( rNEvt );
/* TRY OF AN IMPLEMENTATION FOR 'CLEAN' HANDLING OF MNEMONICS... doesn't work at mark <---------
because Notify() is only handled on first page!
const Window* pActFocusedWin = Application::GetFocusWindow(); // first get actual focused window
DBG_ASSERT( GetTabPage( GetCurPageId() ), "-IconChoiceDialog::PreNotify(): current page is null!" );
#ifdef DBG_UTIL
ULONG nNotified =
#endif
GetTabPage( GetCurPageId() )->Notify( rNEvt );<--------- // try to handle key input in actual page
if( pActFocusedWin == Application::GetFocusWindow() )
{ // key not handled or only one mnemonic available for a control wich already has focus
// -> ignore result of Notify() and give the icon select control a chance
if( maIconCtrl.HandleShortCutKey( *pKEvt ) )
{
nRet = 1;
}
}
else
{ // key was handled -> try to detect overrun in mnemonic handling of dialog
DBG_ASSERT( nNotified != 0, "*IconChoiceDialog::PreNotify(): focus changed but nothing done in Notify()!?" );
nRet = 1; // no matter what happens afterwards, the key was handled
Window* pActWin = Application::GetFocusWindow(); //->GetWindow( WINDOW_PREV );
DBG_ASSERT( IsChild( pActWin ), "*IconChoiceDialog::PreNotify(): this is not my child!" );
xub_Unicode cMnem = pKEvt->GetCharCode();
UINT32 nMnemCnt = 0;
const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
while( pActWin )
{
switch( pActWin->GetType() )
{
case WINDOW_FIXEDTEXT:
case WINDOW_RADIOBUTTON:
case WINDOW_CHECKBOX:
case WINDOW_TRISTATEBOX:
case WINDOW_PUSHBUTTON:
if( rI18nHelper.MatchMnemonic( pActWin->GetText(), cMnem ) )
nMnemCnt++;
break;
}
pActWin = pActWin->GetWindow( WINDOW_PREV );
}
DBG_ASSERT( nMnemCnt, "+IconChoiceDialog::PreNotify(): no matching fixed text before focused control!" );
if( nMnemCnt < 2 )
// now the only possible scenario: handling of mnemonics wrapped at the end of childs
maIconCtrl.HandleShortCutKey( *pKEvt );
}*/
}
return nRet;
}
else
return ModalDialog::PreNotify( rNEvt );
}
// -----------------------------------------------------------------------
void IconChoiceDialog::CreateIconTextAutoMnemonics( void )
{
MnemonicGenerator aMnemonicGenerator;
const ULONG nEntryCount = maIconCtrl.GetEntryCount();
ULONG i;
for( i = 0 ; i < nEntryCount ; ++i )
{
DBG_ASSERT( maIconCtrl.GetEntry( i ), "-IconChoiceDialog::CreateIconTextAutoMnemonics(): NULL-entry found!" );
aMnemonicGenerator.RegisterMnemonic( maIconCtrl.GetEntry( i )->GetText() );
}
for( i = 0 ; i < nEntryCount ; ++i )
{
SvxIconChoiceCtrlEntry* pEntry = maIconCtrl.GetEntry( i );
DBG_ASSERT( pEntry, "-IconChoiceDialog::CreateIconTextAutoMnemonics(): NULL-entry found!" );
String aText = pEntry->GetText();
if( aMnemonicGenerator.CreateMnemonic( aText ) )
pEntry->SetText( aText );
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment