2010-10-12 08:59:03 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-02-14 07:28:01 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 10:42:41 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-02-14 07:28:01 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-02-14 07:28:01 -06:00
|
|
|
*
|
2008-04-10 10:42:41 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-02-14 07:28:01 -06:00
|
|
|
*
|
2008-04-10 10:42:41 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-02-14 07:28:01 -06:00
|
|
|
*
|
2008-04-10 10:42:41 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-02-14 07:28:01 -06:00
|
|
|
*
|
2008-04-10 10:42:41 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-02-14 07:28:01 -06:00
|
|
|
*
|
2008-04-10 10:42:41 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-02-14 07:28:01 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 01:30:40 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
|
|
|
|
2001-02-14 07:28:01 -06:00
|
|
|
#include "TableFieldDescWin.hxx"
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include "FieldDescriptions.hxx"
|
2002-08-19 02:01:32 -05:00
|
|
|
#include "dbu_tbl.hrc"
|
2001-02-14 07:28:01 -06:00
|
|
|
#include "FieldDescriptions.hxx"
|
|
|
|
#include "TableDesignHelpBar.hxx"
|
|
|
|
#include <vcl/fixed.hxx>
|
|
|
|
#include "dbaccess_helpid.hrc"
|
2007-07-06 02:43:52 -05:00
|
|
|
#include "moduledbu.hxx"
|
2002-05-31 01:50:01 -05:00
|
|
|
#include <memory>
|
2001-02-14 07:28:01 -06:00
|
|
|
|
|
|
|
#define STANDARD_MARGIN 6
|
|
|
|
#define DETAILS_HEADER_HEIGHT 25
|
|
|
|
#define CONTROL_SPACING_X 18 // 6
|
|
|
|
#define CONTROL_SPACING_Y 5
|
|
|
|
#define CONTROL_HEIGHT 20
|
|
|
|
#define CONTROL_WIDTH_1 140 // 100
|
|
|
|
#define CONTROL_WIDTH_2 100 // 60
|
|
|
|
#define CONTROL_WIDTH_3 250
|
|
|
|
#define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - CONTROL_HEIGHT - 5)
|
|
|
|
#define DETAILS_OPT_PAGE_WIDTH (CONTROL_WIDTH_1 + CONTROL_SPACING_X + CONTROL_WIDTH_4 + 50)
|
|
|
|
#define DETAILS_OPT_PAGE_HEIGHT ((CONTROL_HEIGHT + CONTROL_SPACING_Y) * 5)
|
|
|
|
#define DETAILS_MIN_HELP_WIDTH 100
|
|
|
|
#define DETAILS_OPT_HELP_WIDTH 200
|
|
|
|
#define DETAILS_MIN_HELP_HEIGHT 50
|
|
|
|
#define DETAILS_OPT_HELP_HEIGHT 100
|
|
|
|
|
|
|
|
|
|
|
|
using namespace dbaui;
|
|
|
|
//==================================================================
|
|
|
|
// class OTableFieldDescWin
|
|
|
|
//==================================================================
|
2006-06-19 21:33:20 -05:00
|
|
|
DBG_NAME(OTableFieldDescWin)
|
2001-02-14 07:28:01 -06:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OTableFieldDescWin::OTableFieldDescWin( Window* pParent)
|
|
|
|
:TabPage(pParent, WB_3DLOOK)
|
|
|
|
{
|
|
|
|
DBG_CTOR(OTableFieldDescWin,NULL);
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Header
|
|
|
|
m_pHeader = new FixedText( this, WB_CENTER | WB_INFO ); // | WB_3DLOOK
|
|
|
|
m_pHeader->SetText( String(ModuleRes(STR_TAB_PROPERTIES)) );
|
|
|
|
m_pHeader->Show();
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// HelpBar
|
|
|
|
m_pHelpBar = new OTableDesignHelpBar( this );
|
|
|
|
m_pHelpBar->SetHelpId(HID_TAB_DESIGN_HELP_TEXT_FRAME);
|
|
|
|
m_pHelpBar->Show();
|
|
|
|
|
|
|
|
m_pGenPage = new OFieldDescGenWin( this, m_pHelpBar );
|
2003-03-19 10:57:12 -06:00
|
|
|
getGenPage()->SetHelpId( HID_TABLE_DESIGN_TABPAGE_GENERAL );
|
|
|
|
getGenPage()->Show();
|
2001-02-14 07:28:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OTableFieldDescWin::~OTableFieldDescWin()
|
|
|
|
{
|
|
|
|
DBG_DTOR(OTableFieldDescWin,NULL);
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Childs zerstoeren
|
|
|
|
m_pHelpBar->Hide();
|
2003-03-19 10:57:12 -06:00
|
|
|
getGenPage()->Hide();
|
2001-02-14 07:28:01 -06:00
|
|
|
m_pHeader->Hide();
|
|
|
|
|
2002-05-31 01:50:01 -05:00
|
|
|
{
|
|
|
|
::std::auto_ptr<Window> aTemp(m_pGenPage);
|
|
|
|
m_pGenPage = NULL;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
::std::auto_ptr<Window> aTemp(m_pHeader);
|
|
|
|
m_pHeader = NULL;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
::std::auto_ptr<Window> aTemp(m_pHelpBar);
|
|
|
|
m_pHelpBar = NULL;
|
|
|
|
}
|
2001-02-14 07:28:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableFieldDescWin::Init()
|
|
|
|
{
|
2003-03-19 10:57:12 -06:00
|
|
|
DBG_ASSERT(getGenPage() != NULL, "OTableFieldDescWin::Init : ups ... no GenericPage ... this will crash ...");
|
|
|
|
getGenPage()->Init();
|
2001-02-14 07:28:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableFieldDescWin::SetReadOnly( sal_Bool bRead )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OTableFieldDescWin,NULL);
|
2003-03-19 10:57:12 -06:00
|
|
|
getGenPage()->SetReadOnly( bRead );
|
2001-02-14 07:28:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableFieldDescWin::DisplayData( OFieldDescription* pFieldDescr )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OTableFieldDescWin,NULL);
|
2003-03-19 10:57:12 -06:00
|
|
|
getGenPage()->DisplayData( pFieldDescr );
|
2001-02-14 07:28:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableFieldDescWin::SaveData( OFieldDescription* pFieldDescr )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OTableFieldDescWin,NULL);
|
2003-03-19 10:57:12 -06:00
|
|
|
getGenPage()->SaveData( pFieldDescr );
|
2001-02-14 07:28:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2006-06-19 21:33:20 -05:00
|
|
|
void OTableFieldDescWin::Paint( const Rectangle& /*rRect*/ )
|
2001-02-14 07:28:01 -06:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OTableFieldDescWin,NULL);
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// 3D-Linie am oberen Fensterrand
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
SetLineColor( rStyleSettings.GetLightColor() );
|
|
|
|
DrawLine( Point(0,0), Point(GetSizePixel().Width(),0) );
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// 3D-Linie zum Abtrennen des Headers
|
|
|
|
DrawLine( Point(3, DETAILS_HEADER_HEIGHT), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT) );
|
|
|
|
SetLineColor( rStyleSettings.GetShadowColor() );
|
|
|
|
DrawLine( Point(3, DETAILS_HEADER_HEIGHT-1), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT-1) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableFieldDescWin::Resize()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OTableFieldDescWin,NULL);
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Abmessungen parent window
|
|
|
|
Size aOutputSize( GetOutputSizePixel() );
|
|
|
|
long nOutputWidth = aOutputSize.Width();
|
|
|
|
long nOutputHeight = aOutputSize.Height();
|
|
|
|
|
|
|
|
// da die GenPage scrollen kann, ich selber aber nicht, positioniere ich das HelpFenster, wenn ich zu schmal werde,
|
|
|
|
// _unter_ der Genpage, nicht rechts daneben. Zuvor versuche ich aber noch, es etwas schmaler zu machen
|
|
|
|
|
|
|
|
long nHelpX, nHelpY;
|
|
|
|
long nHelpWidth, nHelpHeight;
|
|
|
|
long nPageWidth, nPageHeight;
|
|
|
|
|
|
|
|
// passen beide nebeneinander (Rand + Page + Rand + Help) ?
|
|
|
|
if (STANDARD_MARGIN + DETAILS_OPT_PAGE_WIDTH + STANDARD_MARGIN + DETAILS_MIN_HELP_WIDTH <= nOutputWidth)
|
|
|
|
{ // ja -> dann ist die Frage, ob man der Hilfe ihre Optimal-Breite geben kann
|
|
|
|
nHelpWidth = DETAILS_OPT_HELP_WIDTH;
|
|
|
|
nPageWidth = nOutputWidth - nHelpWidth - STANDARD_MARGIN - STANDARD_MARGIN;
|
|
|
|
if (nPageWidth < DETAILS_OPT_PAGE_WIDTH)
|
|
|
|
{ // dann doch lieber die Hilfe von ihrer optimalen in Richtung auf die minimale Groesse
|
|
|
|
long nTransfer = DETAILS_OPT_PAGE_WIDTH - nPageWidth;
|
|
|
|
nPageWidth += nTransfer;
|
|
|
|
nHelpWidth -= nTransfer;
|
|
|
|
}
|
|
|
|
nHelpX = nOutputWidth - nHelpWidth;
|
|
|
|
// die Hoehen sind dann einfach ...
|
|
|
|
nHelpY = DETAILS_HEADER_HEIGHT + 1;
|
|
|
|
nHelpHeight = nOutputHeight - nHelpY;
|
|
|
|
nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // nebeneinander geht nicht, also untereinander (Rand + Header + Page + Help)
|
|
|
|
if (STANDARD_MARGIN + DETAILS_HEADER_HEIGHT + DETAILS_OPT_PAGE_HEIGHT + DETAILS_MIN_HELP_HEIGHT <= nOutputHeight)
|
|
|
|
{ // es reicht zumindest, um beide untereinander (Page optimal, Help minimal) unterzubringen
|
|
|
|
nHelpHeight = DETAILS_OPT_HELP_HEIGHT;
|
|
|
|
nPageHeight = nOutputHeight - nHelpHeight - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
|
|
|
|
if (nPageHeight < DETAILS_OPT_PAGE_HEIGHT)
|
|
|
|
{ // wie oben : Page optimal, Hilfe soviel wie eben bleibt (das ist groesser/gleich ihrem Minimum)
|
|
|
|
long nTransfer = DETAILS_OPT_PAGE_HEIGHT - nPageHeight;
|
|
|
|
nPageHeight += nTransfer;
|
|
|
|
nHelpHeight -= nTransfer;
|
|
|
|
}
|
|
|
|
nHelpY = nOutputHeight - nHelpHeight;
|
|
|
|
// und ueber die ganze Breite
|
|
|
|
nHelpX = 0; // ohne Margin, da das HelpCtrl einen eigenen hat
|
|
|
|
nHelpWidth = nOutputWidth; // dito
|
|
|
|
nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // dummerweise reicht es nicht mal, um Page optimal und Help minimal zu zeigen
|
|
|
|
nHelpX = nHelpY = nHelpWidth = nHelpHeight = 0; // -> kein Help-Fenster
|
|
|
|
nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN;
|
|
|
|
nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pHeader->SetPosSizePixel( Point(0, STANDARD_MARGIN), Size(nOutputWidth, 15) );
|
|
|
|
|
2003-03-19 10:57:12 -06:00
|
|
|
getGenPage()->SetPosSizePixel(Point ( STANDARD_MARGIN,
|
2001-02-14 07:28:01 -06:00
|
|
|
STANDARD_MARGIN + DETAILS_HEADER_HEIGHT
|
|
|
|
),
|
|
|
|
Size ( nPageWidth,
|
|
|
|
nPageHeight
|
|
|
|
)
|
|
|
|
);
|
|
|
|
if (nHelpHeight)
|
|
|
|
{
|
|
|
|
m_pHelpBar->Show();
|
|
|
|
m_pHelpBar->SetPosSizePixel(Point ( nHelpX,
|
|
|
|
nHelpY
|
|
|
|
),
|
|
|
|
Size ( nHelpWidth,
|
|
|
|
nHelpHeight
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pHelpBar->Hide();
|
|
|
|
}
|
|
|
|
Invalidate();
|
|
|
|
}
|
2001-03-22 00:54:07 -06:00
|
|
|
// -----------------------------------------------------------------------------
|
2003-03-19 10:57:12 -06:00
|
|
|
IClipboardTest* OTableFieldDescWin::getActiveChild() const
|
|
|
|
{
|
|
|
|
IClipboardTest* pTest = NULL;
|
|
|
|
switch(m_eChildFocus)
|
|
|
|
{
|
|
|
|
case DESCRIPTION:
|
|
|
|
pTest = getGenPage();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pTest = getHelpBar();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return pTest;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-07-16 01:55:35 -05:00
|
|
|
sal_Bool OTableFieldDescWin::isCopyAllowed()
|
|
|
|
{
|
2003-03-19 10:57:12 -06:00
|
|
|
return getActiveChild() && getActiveChild()->isCopyAllowed();
|
2001-07-16 01:55:35 -05:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-03-22 00:54:07 -06:00
|
|
|
sal_Bool OTableFieldDescWin::isCutAllowed()
|
|
|
|
{
|
2003-03-19 10:57:12 -06:00
|
|
|
return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isCutAllowed());
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OTableFieldDescWin::isPasteAllowed()
|
|
|
|
{
|
|
|
|
return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isPasteAllowed());
|
2001-03-22 00:54:07 -06:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OTableFieldDescWin::cut()
|
|
|
|
{
|
2003-03-19 10:57:12 -06:00
|
|
|
if ( getGenPage() && getGenPage()->HasChildPathFocus() )
|
|
|
|
getGenPage()->cut();
|
2001-03-22 00:54:07 -06:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OTableFieldDescWin::copy()
|
|
|
|
{
|
2003-03-19 10:57:12 -06:00
|
|
|
if ( getActiveChild() )
|
|
|
|
getActiveChild()->copy();
|
2001-03-22 00:54:07 -06:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OTableFieldDescWin::paste()
|
|
|
|
{
|
2003-03-19 10:57:12 -06:00
|
|
|
if ( getGenPage() && getGenPage()->HasChildPathFocus() )
|
|
|
|
getGenPage()->paste();
|
2001-03-22 00:54:07 -06:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2002-07-05 07:22:55 -05:00
|
|
|
void OTableFieldDescWin::GetFocus()
|
|
|
|
{
|
2003-03-19 10:57:12 -06:00
|
|
|
if ( getGenPage() )
|
|
|
|
getGenPage()->GetFocus();
|
2002-07-05 07:22:55 -05:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OTableFieldDescWin::LoseFocus()
|
|
|
|
{
|
2003-03-19 10:57:12 -06:00
|
|
|
if ( getGenPage() )
|
|
|
|
getGenPage()->LoseFocus();
|
2002-07-05 07:22:55 -05:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2003-03-19 10:57:12 -06:00
|
|
|
long OTableFieldDescWin::PreNotify( NotifyEvent& rNEvt )
|
|
|
|
{
|
|
|
|
BOOL bHandled = FALSE;
|
|
|
|
switch(rNEvt.GetType())
|
|
|
|
{
|
|
|
|
case EVENT_GETFOCUS:
|
|
|
|
if( getGenPage() && getGenPage()->HasChildPathFocus() )
|
|
|
|
m_eChildFocus = DESCRIPTION;
|
|
|
|
else
|
|
|
|
m_eChildFocus = HELP;
|
|
|
|
break;
|
|
|
|
}
|
2001-03-22 00:54:07 -06:00
|
|
|
|
2003-03-19 10:57:12 -06:00
|
|
|
return bHandled ? 1L : TabPage::PreNotify(rNEvt);
|
|
|
|
}
|
2001-03-22 00:54:07 -06:00
|
|
|
|
2010-10-12 08:59:03 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|