1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10*96de5490SAndrew Rist * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*96de5490SAndrew Rist * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19*96de5490SAndrew Rist * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX 28cdf0e10cSrcweir #include "TableFieldDescWin.hxx" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX 31cdf0e10cSrcweir #include <tools/debug.hxx> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef DBAUI_FIELDDESCRIPTIONS_HXX 34cdf0e10cSrcweir #include "FieldDescriptions.hxx" 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _DBU_TBL_HRC_ 37cdf0e10cSrcweir #include "dbu_tbl.hrc" 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #ifndef DBAUI_FIELDDESCRIPTIONS_HXX 40cdf0e10cSrcweir #include "FieldDescriptions.hxx" 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #ifndef DBAUI_TABLEDESIGNHELPBAR_HXX 43cdf0e10cSrcweir #include "TableDesignHelpBar.hxx" 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #ifndef _SV_FIXED_HXX 46cdf0e10cSrcweir #include <vcl/fixed.hxx> 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_ 49cdf0e10cSrcweir #include "dbaccess_helpid.hrc" 50cdf0e10cSrcweir #endif 51cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_ 52cdf0e10cSrcweir #include "moduledbu.hxx" 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir #include <memory> 55cdf0e10cSrcweir 56cdf0e10cSrcweir #define STANDARD_MARGIN 6 57cdf0e10cSrcweir #define DETAILS_HEADER_HEIGHT 25 58cdf0e10cSrcweir #define CONTROL_SPACING_X 18 // 6 59cdf0e10cSrcweir #define CONTROL_SPACING_Y 5 60cdf0e10cSrcweir #define CONTROL_HEIGHT 20 61cdf0e10cSrcweir #define CONTROL_WIDTH_1 140 // 100 62cdf0e10cSrcweir #define CONTROL_WIDTH_2 100 // 60 63cdf0e10cSrcweir #define CONTROL_WIDTH_3 250 64cdf0e10cSrcweir #define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - CONTROL_HEIGHT - 5) 65cdf0e10cSrcweir #define DETAILS_OPT_PAGE_WIDTH (CONTROL_WIDTH_1 + CONTROL_SPACING_X + CONTROL_WIDTH_4 + 50) 66cdf0e10cSrcweir #define DETAILS_OPT_PAGE_HEIGHT ((CONTROL_HEIGHT + CONTROL_SPACING_Y) * 5) 67cdf0e10cSrcweir #define DETAILS_MIN_HELP_WIDTH 100 68cdf0e10cSrcweir #define DETAILS_OPT_HELP_WIDTH 200 69cdf0e10cSrcweir #define DETAILS_MIN_HELP_HEIGHT 50 70cdf0e10cSrcweir #define DETAILS_OPT_HELP_HEIGHT 100 71cdf0e10cSrcweir 72cdf0e10cSrcweir 73cdf0e10cSrcweir using namespace dbaui; 74cdf0e10cSrcweir //================================================================== 75cdf0e10cSrcweir // class OTableFieldDescWin 76cdf0e10cSrcweir //================================================================== 77cdf0e10cSrcweir DBG_NAME(OTableFieldDescWin) 78cdf0e10cSrcweir //------------------------------------------------------------------------------ 79cdf0e10cSrcweir OTableFieldDescWin::OTableFieldDescWin( Window* pParent) 80cdf0e10cSrcweir :TabPage(pParent, WB_3DLOOK) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir DBG_CTOR(OTableFieldDescWin,NULL); 83cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 84cdf0e10cSrcweir // Header 85cdf0e10cSrcweir m_pHeader = new FixedText( this, WB_CENTER | WB_INFO ); // | WB_3DLOOK 86cdf0e10cSrcweir m_pHeader->SetText( String(ModuleRes(STR_TAB_PROPERTIES)) ); 87cdf0e10cSrcweir m_pHeader->Show(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 90cdf0e10cSrcweir // HelpBar 91cdf0e10cSrcweir m_pHelpBar = new OTableDesignHelpBar( this ); 92cdf0e10cSrcweir m_pHelpBar->SetHelpId(HID_TAB_DESIGN_HELP_TEXT_FRAME); 93cdf0e10cSrcweir m_pHelpBar->Show(); 94cdf0e10cSrcweir 95cdf0e10cSrcweir m_pGenPage = new OFieldDescGenWin( this, m_pHelpBar ); 96cdf0e10cSrcweir getGenPage()->SetHelpId( HID_TABLE_DESIGN_TABPAGE_GENERAL ); 97cdf0e10cSrcweir getGenPage()->Show(); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir //------------------------------------------------------------------------------ 101cdf0e10cSrcweir OTableFieldDescWin::~OTableFieldDescWin() 102cdf0e10cSrcweir { 103cdf0e10cSrcweir DBG_DTOR(OTableFieldDescWin,NULL); 104cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 105cdf0e10cSrcweir // Childs zerstoeren 106cdf0e10cSrcweir m_pHelpBar->Hide(); 107cdf0e10cSrcweir getGenPage()->Hide(); 108cdf0e10cSrcweir m_pHeader->Hide(); 109cdf0e10cSrcweir 110cdf0e10cSrcweir { 111cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pGenPage); 112cdf0e10cSrcweir m_pGenPage = NULL; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir { 115cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pHeader); 116cdf0e10cSrcweir m_pHeader = NULL; 117cdf0e10cSrcweir } 118cdf0e10cSrcweir { 119cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pHelpBar); 120cdf0e10cSrcweir m_pHelpBar = NULL; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir //------------------------------------------------------------------------------ 125cdf0e10cSrcweir void OTableFieldDescWin::Init() 126cdf0e10cSrcweir { 127cdf0e10cSrcweir DBG_ASSERT(getGenPage() != NULL, "OTableFieldDescWin::Init : ups ... no GenericPage ... this will crash ..."); 128cdf0e10cSrcweir getGenPage()->Init(); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir //------------------------------------------------------------------------------ 132cdf0e10cSrcweir void OTableFieldDescWin::SetReadOnly( sal_Bool bRead ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir DBG_CHKTHIS(OTableFieldDescWin,NULL); 135cdf0e10cSrcweir getGenPage()->SetReadOnly( bRead ); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir //------------------------------------------------------------------------------ 139cdf0e10cSrcweir void OTableFieldDescWin::DisplayData( OFieldDescription* pFieldDescr ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir DBG_CHKTHIS(OTableFieldDescWin,NULL); 142cdf0e10cSrcweir getGenPage()->DisplayData( pFieldDescr ); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir //------------------------------------------------------------------------------ 146cdf0e10cSrcweir void OTableFieldDescWin::SaveData( OFieldDescription* pFieldDescr ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir DBG_CHKTHIS(OTableFieldDescWin,NULL); 149cdf0e10cSrcweir getGenPage()->SaveData( pFieldDescr ); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir //------------------------------------------------------------------------------ 153cdf0e10cSrcweir void OTableFieldDescWin::Paint( const Rectangle& /*rRect*/ ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir DBG_CHKTHIS(OTableFieldDescWin,NULL); 156cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 157cdf0e10cSrcweir // 3D-Linie am oberen Fensterrand 158cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 159cdf0e10cSrcweir 160cdf0e10cSrcweir SetLineColor( rStyleSettings.GetLightColor() ); 161cdf0e10cSrcweir DrawLine( Point(0,0), Point(GetSizePixel().Width(),0) ); 162cdf0e10cSrcweir 163cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 164cdf0e10cSrcweir // 3D-Linie zum Abtrennen des Headers 165cdf0e10cSrcweir DrawLine( Point(3, DETAILS_HEADER_HEIGHT), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT) ); 166cdf0e10cSrcweir SetLineColor( rStyleSettings.GetShadowColor() ); 167cdf0e10cSrcweir DrawLine( Point(3, DETAILS_HEADER_HEIGHT-1), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT-1) ); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir //------------------------------------------------------------------------------ 171cdf0e10cSrcweir void OTableFieldDescWin::Resize() 172cdf0e10cSrcweir { 173cdf0e10cSrcweir DBG_CHKTHIS(OTableFieldDescWin,NULL); 174cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 175cdf0e10cSrcweir // Abmessungen parent window 176cdf0e10cSrcweir Size aOutputSize( GetOutputSizePixel() ); 177cdf0e10cSrcweir long nOutputWidth = aOutputSize.Width(); 178cdf0e10cSrcweir long nOutputHeight = aOutputSize.Height(); 179cdf0e10cSrcweir 180cdf0e10cSrcweir // da die GenPage scrollen kann, ich selber aber nicht, positioniere ich das HelpFenster, wenn ich zu schmal werde, 181cdf0e10cSrcweir // _unter_ der Genpage, nicht rechts daneben. Zuvor versuche ich aber noch, es etwas schmaler zu machen 182cdf0e10cSrcweir 183cdf0e10cSrcweir long nHelpX, nHelpY; 184cdf0e10cSrcweir long nHelpWidth, nHelpHeight; 185cdf0e10cSrcweir long nPageWidth, nPageHeight; 186cdf0e10cSrcweir 187cdf0e10cSrcweir // passen beide nebeneinander (Rand + Page + Rand + Help) ? 188cdf0e10cSrcweir if (STANDARD_MARGIN + DETAILS_OPT_PAGE_WIDTH + STANDARD_MARGIN + DETAILS_MIN_HELP_WIDTH <= nOutputWidth) 189cdf0e10cSrcweir { // ja -> dann ist die Frage, ob man der Hilfe ihre Optimal-Breite geben kann 190cdf0e10cSrcweir nHelpWidth = DETAILS_OPT_HELP_WIDTH; 191cdf0e10cSrcweir nPageWidth = nOutputWidth - nHelpWidth - STANDARD_MARGIN - STANDARD_MARGIN; 192cdf0e10cSrcweir if (nPageWidth < DETAILS_OPT_PAGE_WIDTH) 193cdf0e10cSrcweir { // dann doch lieber die Hilfe von ihrer optimalen in Richtung auf die minimale Groesse 194cdf0e10cSrcweir long nTransfer = DETAILS_OPT_PAGE_WIDTH - nPageWidth; 195cdf0e10cSrcweir nPageWidth += nTransfer; 196cdf0e10cSrcweir nHelpWidth -= nTransfer; 197cdf0e10cSrcweir } 198cdf0e10cSrcweir nHelpX = nOutputWidth - nHelpWidth; 199cdf0e10cSrcweir // die Hoehen sind dann einfach ... 200cdf0e10cSrcweir nHelpY = DETAILS_HEADER_HEIGHT + 1; 201cdf0e10cSrcweir nHelpHeight = nOutputHeight - nHelpY; 202cdf0e10cSrcweir nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN; 203cdf0e10cSrcweir } 204cdf0e10cSrcweir else 205cdf0e10cSrcweir { // nebeneinander geht nicht, also untereinander (Rand + Header + Page + Help) 206cdf0e10cSrcweir if (STANDARD_MARGIN + DETAILS_HEADER_HEIGHT + DETAILS_OPT_PAGE_HEIGHT + DETAILS_MIN_HELP_HEIGHT <= nOutputHeight) 207cdf0e10cSrcweir { // es reicht zumindest, um beide untereinander (Page optimal, Help minimal) unterzubringen 208cdf0e10cSrcweir nHelpHeight = DETAILS_OPT_HELP_HEIGHT; 209cdf0e10cSrcweir nPageHeight = nOutputHeight - nHelpHeight - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN; 210cdf0e10cSrcweir if (nPageHeight < DETAILS_OPT_PAGE_HEIGHT) 211cdf0e10cSrcweir { // wie oben : Page optimal, Hilfe soviel wie eben bleibt (das ist groesser/gleich ihrem Minimum) 212cdf0e10cSrcweir long nTransfer = DETAILS_OPT_PAGE_HEIGHT - nPageHeight; 213cdf0e10cSrcweir nPageHeight += nTransfer; 214cdf0e10cSrcweir nHelpHeight -= nTransfer; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir nHelpY = nOutputHeight - nHelpHeight; 217cdf0e10cSrcweir // und ueber die ganze Breite 218cdf0e10cSrcweir nHelpX = 0; // ohne Margin, da das HelpCtrl einen eigenen hat 219cdf0e10cSrcweir nHelpWidth = nOutputWidth; // dito 220cdf0e10cSrcweir nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir else 223cdf0e10cSrcweir { // dummerweise reicht es nicht mal, um Page optimal und Help minimal zu zeigen 224cdf0e10cSrcweir nHelpX = nHelpY = nHelpWidth = nHelpHeight = 0; // -> kein Help-Fenster 225cdf0e10cSrcweir nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN; 226cdf0e10cSrcweir nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN; 227cdf0e10cSrcweir } 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir m_pHeader->SetPosSizePixel( Point(0, STANDARD_MARGIN), Size(nOutputWidth, 15) ); 231cdf0e10cSrcweir 232cdf0e10cSrcweir getGenPage()->SetPosSizePixel(Point ( STANDARD_MARGIN, 233cdf0e10cSrcweir STANDARD_MARGIN + DETAILS_HEADER_HEIGHT 234cdf0e10cSrcweir ), 235cdf0e10cSrcweir Size ( nPageWidth, 236cdf0e10cSrcweir nPageHeight 237cdf0e10cSrcweir ) 238cdf0e10cSrcweir ); 239cdf0e10cSrcweir if (nHelpHeight) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir m_pHelpBar->Show(); 242cdf0e10cSrcweir m_pHelpBar->SetPosSizePixel(Point ( nHelpX, 243cdf0e10cSrcweir nHelpY 244cdf0e10cSrcweir ), 245cdf0e10cSrcweir Size ( nHelpWidth, 246cdf0e10cSrcweir nHelpHeight 247cdf0e10cSrcweir ) 248cdf0e10cSrcweir ); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir else 251cdf0e10cSrcweir { 252cdf0e10cSrcweir m_pHelpBar->Hide(); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir Invalidate(); 255cdf0e10cSrcweir } 256cdf0e10cSrcweir // ----------------------------------------------------------------------------- 257cdf0e10cSrcweir IClipboardTest* OTableFieldDescWin::getActiveChild() const 258cdf0e10cSrcweir { 259cdf0e10cSrcweir IClipboardTest* pTest = NULL; 260cdf0e10cSrcweir switch(m_eChildFocus) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir case DESCRIPTION: 263cdf0e10cSrcweir pTest = getGenPage(); 264cdf0e10cSrcweir break; 265cdf0e10cSrcweir default: 266cdf0e10cSrcweir pTest = getHelpBar(); 267cdf0e10cSrcweir break; 268cdf0e10cSrcweir } 269cdf0e10cSrcweir return pTest; 270cdf0e10cSrcweir } 271cdf0e10cSrcweir // ----------------------------------------------------------------------------- 272cdf0e10cSrcweir sal_Bool OTableFieldDescWin::isCopyAllowed() 273cdf0e10cSrcweir { 274cdf0e10cSrcweir return getActiveChild() && getActiveChild()->isCopyAllowed(); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir // ----------------------------------------------------------------------------- 277cdf0e10cSrcweir sal_Bool OTableFieldDescWin::isCutAllowed() 278cdf0e10cSrcweir { 279cdf0e10cSrcweir return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isCutAllowed()); 280cdf0e10cSrcweir } 281cdf0e10cSrcweir // ----------------------------------------------------------------------------- 282cdf0e10cSrcweir sal_Bool OTableFieldDescWin::isPasteAllowed() 283cdf0e10cSrcweir { 284cdf0e10cSrcweir return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isPasteAllowed()); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir // ----------------------------------------------------------------------------- 287cdf0e10cSrcweir void OTableFieldDescWin::cut() 288cdf0e10cSrcweir { 289cdf0e10cSrcweir if ( getGenPage() && getGenPage()->HasChildPathFocus() ) 290cdf0e10cSrcweir getGenPage()->cut(); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir // ----------------------------------------------------------------------------- 293cdf0e10cSrcweir void OTableFieldDescWin::copy() 294cdf0e10cSrcweir { 295cdf0e10cSrcweir if ( getActiveChild() ) 296cdf0e10cSrcweir getActiveChild()->copy(); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir // ----------------------------------------------------------------------------- 299cdf0e10cSrcweir void OTableFieldDescWin::paste() 300cdf0e10cSrcweir { 301cdf0e10cSrcweir if ( getGenPage() && getGenPage()->HasChildPathFocus() ) 302cdf0e10cSrcweir getGenPage()->paste(); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir // ----------------------------------------------------------------------------- 305cdf0e10cSrcweir void OTableFieldDescWin::GetFocus() 306cdf0e10cSrcweir { 307cdf0e10cSrcweir if ( getGenPage() ) 308cdf0e10cSrcweir getGenPage()->GetFocus(); 309cdf0e10cSrcweir } 310cdf0e10cSrcweir // ----------------------------------------------------------------------------- 311cdf0e10cSrcweir void OTableFieldDescWin::LoseFocus() 312cdf0e10cSrcweir { 313cdf0e10cSrcweir if ( getGenPage() ) 314cdf0e10cSrcweir getGenPage()->LoseFocus(); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir // ----------------------------------------------------------------------------- 317cdf0e10cSrcweir long OTableFieldDescWin::PreNotify( NotifyEvent& rNEvt ) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir sal_Bool bHandled = sal_False; 320cdf0e10cSrcweir switch(rNEvt.GetType()) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir case EVENT_GETFOCUS: 323cdf0e10cSrcweir if( getGenPage() && getGenPage()->HasChildPathFocus() ) 324cdf0e10cSrcweir m_eChildFocus = DESCRIPTION; 325cdf0e10cSrcweir else 326cdf0e10cSrcweir m_eChildFocus = HELP; 327cdf0e10cSrcweir break; 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir return bHandled ? 1L : TabPage::PreNotify(rNEvt); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir 334