LCOV - code coverage report
Current view: top level - dbaccess/source/ui/tabledesign - TableFieldDescWin.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 123 0.0 %
Date: 2014-04-14 Functions: 0 19 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "TableFieldDescWin.hxx"
      21             : #include <osl/diagnose.h>
      22             : #include "FieldDescriptions.hxx"
      23             : #include "dbu_tbl.hrc"
      24             : #include "TableDesignHelpBar.hxx"
      25             : #include <vcl/fixed.hxx>
      26             : #include <vcl/settings.hxx>
      27             : #include "dbaccess_helpid.hrc"
      28             : #include "moduledbu.hxx"
      29             : #include <boost/scoped_ptr.hpp>
      30             : 
      31             : #define STANDARD_MARGIN                  6
      32             : #define DETAILS_HEADER_HEIGHT           25
      33             : #define CONTROL_SPACING_X   18  // 6
      34             : #define CONTROL_SPACING_Y   5
      35             : #define CONTROL_HEIGHT      20
      36             : #define CONTROL_WIDTH_1     140 // 100
      37             : #define CONTROL_WIDTH_3     250
      38             : #define CONTROL_WIDTH_4     (CONTROL_WIDTH_3 - CONTROL_HEIGHT - 5)
      39             : #define DETAILS_OPT_PAGE_WIDTH          (CONTROL_WIDTH_1 + CONTROL_SPACING_X + CONTROL_WIDTH_4 + 50)
      40             : #define DETAILS_OPT_PAGE_HEIGHT         ((CONTROL_HEIGHT + CONTROL_SPACING_Y) * 5)
      41             : #define DETAILS_MIN_HELP_WIDTH          100
      42             : #define DETAILS_OPT_HELP_WIDTH          200
      43             : #define DETAILS_MIN_HELP_HEIGHT         50
      44             : #define DETAILS_OPT_HELP_HEIGHT         100
      45             : 
      46             : using namespace dbaui;
      47             : // class OTableFieldDescWin
      48           0 : OTableFieldDescWin::OTableFieldDescWin( Window* pParent)
      49             :     : TabPage(pParent, WB_3DLOOK)
      50           0 :     , m_eChildFocus(NONE)
      51             : {
      52             :     // Header
      53           0 :     m_pHeader = new FixedText( this, WB_CENTER | WB_INFO ); //  | WB_3DLOOK
      54           0 :     m_pHeader->SetText( OUString(ModuleRes(STR_TAB_PROPERTIES)) );
      55           0 :     m_pHeader->Show();
      56             : 
      57             :     // HelpBar
      58           0 :     m_pHelpBar = new OTableDesignHelpBar( this );
      59           0 :     m_pHelpBar->SetHelpId(HID_TAB_DESIGN_HELP_TEXT_FRAME);
      60           0 :     m_pHelpBar->Show();
      61             : 
      62           0 :     m_pGenPage = new OFieldDescGenWin( this, m_pHelpBar );
      63           0 :     getGenPage()->SetHelpId( HID_TABLE_DESIGN_TABPAGE_GENERAL );
      64           0 :     getGenPage()->Show();
      65           0 : }
      66             : 
      67           0 : OTableFieldDescWin::~OTableFieldDescWin()
      68             : {
      69             :     // destroy children
      70           0 :     m_pHelpBar->Hide();
      71           0 :     getGenPage()->Hide();
      72           0 :     m_pHeader->Hide();
      73             : 
      74             :     {
      75           0 :         boost::scoped_ptr<Window> aTemp(m_pGenPage);
      76           0 :         m_pGenPage = NULL;
      77             :     }
      78             :     {
      79           0 :         boost::scoped_ptr<Window> aTemp(m_pHeader);
      80           0 :         m_pHeader = NULL;
      81             :     }
      82             :     {
      83           0 :         boost::scoped_ptr<Window> aTemp(m_pHelpBar);
      84           0 :         m_pHelpBar = NULL;
      85             :     }
      86           0 : }
      87             : 
      88           0 : void OTableFieldDescWin::Init()
      89             : {
      90             :     OSL_ENSURE(getGenPage() != NULL, "OTableFieldDescWin::Init : ups ... no GenericPage ... this will crash ...");
      91           0 :     getGenPage()->Init();
      92           0 : }
      93             : 
      94           0 : void OTableFieldDescWin::SetReadOnly( sal_Bool bRead )
      95             : {
      96           0 :     getGenPage()->SetReadOnly( bRead );
      97           0 : }
      98             : 
      99           0 : void OTableFieldDescWin::DisplayData( OFieldDescription* pFieldDescr )
     100             : {
     101           0 :     getGenPage()->DisplayData( pFieldDescr );
     102           0 : }
     103             : 
     104           0 : void OTableFieldDescWin::SaveData( OFieldDescription* pFieldDescr )
     105             : {
     106           0 :     getGenPage()->SaveData( pFieldDescr );
     107           0 : }
     108             : 
     109           0 : void OTableFieldDescWin::Paint( const Rectangle& /*rRect*/ )
     110             : {
     111             :     // 3D-line at the top window border
     112           0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     113             : 
     114           0 :     SetLineColor( rStyleSettings.GetLightColor() );
     115           0 :     DrawLine( Point(0,0), Point(GetSizePixel().Width(),0) );
     116             : 
     117             :     // 3D-line for the separation of the header
     118           0 :     DrawLine( Point(3, DETAILS_HEADER_HEIGHT), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT) );
     119           0 :     SetLineColor( rStyleSettings.GetShadowColor() );
     120           0 :     DrawLine( Point(3, DETAILS_HEADER_HEIGHT-1), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT-1) );
     121           0 : }
     122             : 
     123           0 : void OTableFieldDescWin::Resize()
     124             : {
     125             :     // dimensions of the parent window
     126           0 :     Size aOutputSize( GetOutputSizePixel() );
     127           0 :     long nOutputWidth = aOutputSize.Width();
     128           0 :     long nOutputHeight = aOutputSize.Height();
     129             : 
     130             :     // since the GenPage can scroll, but I can't, I position the HelpWindow, in case I become too slim,
     131             :     // _below_ the Genpage, not on the right side. But before that I try to make it a bit smaller
     132             : 
     133             :     long nHelpX, nHelpY;
     134             :     long nHelpWidth, nHelpHeight;
     135             :     long nPageWidth, nPageHeight;
     136             : 
     137             :     // do both fit next to each other (margin + page + margin + help)?
     138           0 :     if (STANDARD_MARGIN + DETAILS_OPT_PAGE_WIDTH + STANDARD_MARGIN + DETAILS_MIN_HELP_WIDTH <= nOutputWidth)
     139             :     {   // yes -> then we wonder if can give the help its optimum width
     140           0 :         nHelpWidth = DETAILS_OPT_HELP_WIDTH;
     141           0 :         nPageWidth = nOutputWidth - nHelpWidth - STANDARD_MARGIN - STANDARD_MARGIN;
     142           0 :         if (nPageWidth < DETAILS_OPT_PAGE_WIDTH)
     143             :         {   // rather resize the help from its optimal width to its minimum width
     144           0 :             long nTransfer = DETAILS_OPT_PAGE_WIDTH - nPageWidth;
     145           0 :             nPageWidth += nTransfer;
     146           0 :             nHelpWidth -= nTransfer;
     147             :         }
     148           0 :         nHelpX = nOutputWidth - nHelpWidth;
     149             :         // the heights are simple in that case...
     150           0 :         nHelpY = DETAILS_HEADER_HEIGHT + 1;
     151           0 :         nHelpHeight = nOutputHeight - nHelpY;
     152           0 :         nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
     153             :     }
     154             :     else
     155             :     {   // doesn't work next to each other, thus below each other (margin + header + page + help)
     156           0 :         if (STANDARD_MARGIN + DETAILS_HEADER_HEIGHT + DETAILS_OPT_PAGE_HEIGHT + DETAILS_MIN_HELP_HEIGHT <= nOutputHeight)
     157             :         {   // it's at least enough, to fit both below each other (page optimal, help minimal)
     158           0 :             nHelpHeight = DETAILS_OPT_HELP_HEIGHT;
     159           0 :             nPageHeight = nOutputHeight - nHelpHeight - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
     160           0 :             if (nPageHeight < DETAILS_OPT_PAGE_HEIGHT)
     161             :             {   // like above: page optimal, help gets whatever is left (which is bigger/equal to its minimum)
     162           0 :                 long nTransfer = DETAILS_OPT_PAGE_HEIGHT - nPageHeight;
     163           0 :                 nPageHeight += nTransfer;
     164           0 :                 nHelpHeight -= nTransfer;
     165             :             }
     166           0 :             nHelpY = nOutputHeight - nHelpHeight;
     167             :             // and across the entire width
     168           0 :             nHelpX = 0;                 // without margin, since the HelpCtrl has its own one
     169           0 :             nHelpWidth = nOutputWidth;  // dito
     170           0 :             nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN;
     171             :         }
     172             :         else
     173             :         {   // unfortunately that's not even enough, to show page at its optimum and help with minimum widthn
     174           0 :             nHelpX = nHelpY = nHelpWidth = nHelpHeight = 0; // thus no help window
     175           0 :             nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN;
     176           0 :             nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
     177             :         }
     178             :     }
     179             : 
     180           0 :     m_pHeader->SetPosSizePixel( Point(0, STANDARD_MARGIN), Size(nOutputWidth, 15) );
     181             : 
     182           0 :     getGenPage()->SetPosSizePixel(Point (   STANDARD_MARGIN,
     183             :                                         STANDARD_MARGIN + DETAILS_HEADER_HEIGHT
     184             :                                     ),
     185             :                               Size  (   nPageWidth,
     186             :                                         nPageHeight
     187             :                                     )
     188           0 :                              );
     189           0 :     if (nHelpHeight)
     190             :     {
     191           0 :         m_pHelpBar->Show();
     192             :         m_pHelpBar->SetPosSizePixel(Point   (   nHelpX,
     193             :                                             nHelpY
     194             :                                         ),
     195             :                                   Size  (   nHelpWidth,
     196             :                                             nHelpHeight
     197             :                                         )
     198           0 :                                  );
     199             :     }
     200             :     else
     201             :     {
     202           0 :         m_pHelpBar->Hide();
     203             :     }
     204           0 :     Invalidate();
     205           0 : }
     206             : 
     207           0 : IClipboardTest* OTableFieldDescWin::getActiveChild() const
     208             : {
     209           0 :     IClipboardTest* pTest = NULL;
     210           0 :     switch(m_eChildFocus)
     211             :     {
     212             :         case DESCRIPTION:
     213           0 :             pTest = getGenPage();
     214           0 :             break;
     215             :         default:
     216           0 :             pTest = getHelpBar();
     217           0 :             break;
     218             :     }
     219           0 :     return pTest;
     220             : }
     221             : 
     222           0 : sal_Bool OTableFieldDescWin::isCopyAllowed()
     223             : {
     224           0 :     return getActiveChild() && getActiveChild()->isCopyAllowed();
     225             : }
     226             : 
     227           0 : sal_Bool OTableFieldDescWin::isCutAllowed()
     228             : {
     229           0 :     return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isCutAllowed());
     230             : }
     231             : 
     232           0 : sal_Bool OTableFieldDescWin::isPasteAllowed()
     233             : {
     234           0 :     return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isPasteAllowed());
     235             : }
     236             : 
     237           0 : void OTableFieldDescWin::cut()
     238             : {
     239           0 :     if ( getGenPage() && getGenPage()->HasChildPathFocus() )
     240           0 :         getGenPage()->cut();
     241           0 : }
     242             : 
     243           0 : void OTableFieldDescWin::copy()
     244             : {
     245           0 :     if ( getActiveChild() )
     246           0 :         getActiveChild()->copy();
     247           0 : }
     248             : 
     249           0 : void OTableFieldDescWin::paste()
     250             : {
     251           0 :     if ( getGenPage() && getGenPage()->HasChildPathFocus() )
     252           0 :         getGenPage()->paste();
     253           0 : }
     254             : 
     255           0 : void OTableFieldDescWin::GetFocus()
     256             : {
     257           0 :     if ( getGenPage() )
     258           0 :         getGenPage()->GetFocus();
     259           0 : }
     260             : 
     261           0 : void OTableFieldDescWin::LoseFocus()
     262             : {
     263           0 :     if ( getGenPage() )
     264           0 :         getGenPage()->LoseFocus();
     265           0 : }
     266             : 
     267           0 : bool OTableFieldDescWin::PreNotify( NotifyEvent& rNEvt )
     268             : {
     269           0 :     sal_Bool bHandled = sal_False;
     270           0 :     switch(rNEvt.GetType())
     271             :     {
     272             :         case EVENT_GETFOCUS:
     273           0 :             if( getGenPage() && getGenPage()->HasChildPathFocus() )
     274           0 :                 m_eChildFocus = DESCRIPTION;
     275             :             else
     276           0 :                 m_eChildFocus = HELP;
     277           0 :             break;
     278             :     }
     279             : 
     280           0 :     return bHandled || TabPage::PreNotify(rNEvt);
     281             : }
     282             : 
     283             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10