Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / source / app / dbggui.cxx
blobd3ef95a5525c88ac995df1024e0313b00fa80797
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include <sal/config.h>
24 #ifdef DBG_UTIL
26 #include <cstdio>
27 #include <cstring>
28 #include <cmath>
29 #include <limits.h>
31 #include <tools/debug.hxx>
32 #include <tools/lineend.hxx>
33 #include "sal/log.hxx"
35 #include "vcl/svapp.hxx"
36 #include "vcl/event.hxx"
37 #include "vcl/lstbox.hxx"
38 #include "vcl/button.hxx"
39 #include "vcl/edit.hxx"
40 #include "vcl/fixed.hxx"
41 #include "vcl/group.hxx"
42 #include "vcl/field.hxx"
43 #include "vcl/layout.hxx"
44 #include "vcl/settings.hxx"
45 #include "vcl/wrkwin.hxx"
46 #include "vcl/threadex.hxx"
48 #include "svdata.hxx"
49 #include "dbggui.hxx"
51 #include "vcl/unohelp.hxx"
52 #include "vcl/unohelp2.hxx"
54 #include "salinst.hxx"
55 #include "svsys.h"
57 #include "com/sun/star/i18n/XCharacterClassification.hpp"
59 #include <algorithm>
60 #include <boost/scoped_array.hpp>
62 using namespace ::com::sun::star;
64 static const sal_Char* pDbgHelpText[] =
66 "Object Test\n",
67 "------------------------------------------\n",
68 "\n",
69 "--- Macros ---\n",
70 "\n",
71 "Function\n",
72 "When a function is passed with macros, it will be called.\n",
73 "\n",
74 "Exit\n",
75 "This- and Func-Test will also run when exiting the function.\n",
76 "\n",
77 "\n",
78 "\nOther tests and macros\n",
79 "------------------------------------------\n",
80 "\n",
81 "Resources\n",
82 "In case of resource errors an error dialog is produced before the "
83 "exception handler is called.\n",
84 "\n",
85 "Dialog\n",
86 "FixedTexts, CheckBoxes, TriStateBoxes and RadioButtons are equipped with "
87 "a different background color to determine the size of the controls. This "
88 "test also shows whether controls overlap, whether the tab order is correct "
89 "and whether the mnemonic characters are correctly assigned. With dialogs "
90 "it is indicated when no default button or no OK/CancelButton is present. "
91 "These tests are not 100% correct (e.g. too many warnings are given) and "
92 "do not form any guarantee that all problematic cases are covered. For "
93 "example only initial and only visible controls are tested. No errors are "
94 "found which will occur during the use of a dialog.\n",
95 "\n",
96 "Bold AppFont\n",
97 "The application font is set to bold to see if the position of texts is "
98 "sufficient for other systems or other system settings. With very narrow "
99 "fonts the dialogs are made wider because they otherwise appear too narrow.\n",
100 "\n",
101 "\n",
102 "Output\n",
103 "------------------------------------------\n",
104 "\n",
105 "You can indicate where the data will be output:\n",
106 "\n",
107 "None\n",
108 "Output is suppressed.\n",
109 "\n",
110 "File\n",
111 "Outputi n debug file. Filename can be entered in the Editfield.\n",
112 "\n",
113 "Window\n",
114 "Output to a small debug window. The window size is stored if the debug "
115 "dialog is closed with OK and if the window is visible. Each assertion text can "
116 "be copied to the clipboard via the context menu of the respective entry.\n",
117 "\n",
118 "Shell\n",
119 "Output to a debug system (Windows debug window) when available or under "
120 "Unix in the shell window. Otherwise the same as Window.\n",
121 "\n",
122 "MessageBox\n",
123 "Output to a MessageBox. In this case you can select whether the program "
124 "must be continued, terminated (Application::Abort) or interrupted with "
125 "CoreDump. Additionally on some systems you get a \"Copy\" button pressing which "
126 "copies the text of the MessageBox to the clipboard. Because a MessageBox allows "
127 "further event processing other errors caused by Paint, Activate/Deactivate, "
128 "GetFocus/LoseFocus can cause more errors or incorrect errors and messages. "
129 "Therefore the message should also be directed to a file/debugger in case of "
130 "problems in order to produce the (right) error messages.\n",
131 "\n",
132 "TestTool\n",
133 "When the TestTool runs messages will be redirected inside the TestTool.\n",
134 "\n",
135 "Debugger\n",
136 "Attempt to activate the debugger and produce the message there, in order to "
137 "always obtain the corresponding stack trace in the debugger.\n",
138 "\n",
139 "Abort\n",
140 "Aborts the application\n",
141 "\n",
142 "\n",
143 "Reroute osl messages - Checkbox\n",
144 "OSL_ASSERT and similar messages can be intercepted by the general DBG GUI\n",
145 "or handled system specific as per normal handling in the sal library.\n",
146 "default is to reroute osl assertions\n",
147 "\n",
148 "\n",
149 "Settings\n",
150 "------------------------------------------\n",
151 "\n",
152 "Where by default the INI file is read and written the following "
153 "can be set:\n",
154 "\n",
155 "WIN/WNT (WIN.INI, Group SV, Default: dbgsv.ini):\n",
156 "INI: dbgsv\n",
157 "\n",
158 "OS2 (OS2.INI, Application SV, Default: dbgsv.ini):\n",
159 "INI: DBGSV\n",
160 "\n",
161 "UNIX (Environment variable, Default: .dbgsv.init):\n",
162 "INI: DBGSV_INIT\n",
163 "\n",
164 "MAC (Default: dbgsv.ini):\n",
165 "INI: not possible\n",
166 "\n",
167 "The path and file name must always be specified.\n",
168 "\n",
169 "\n",
170 "Example\n",
171 "------------------------------------------\n",
172 "\n",
173 "\n",
174 "#ifdef DBG_UTIL\n",
175 "const sal_Char* DbgCheckString( const void* pString )\n",
176 "{\n",
177 " String* p = (String*)pString;\n",
178 "\n",
179 " if ( p->mpData->maStr[p->mpData->mnLen] != 0 )\n",
180 " return \"String damaged: aStr[nLen] != 0\";\n",
181 "\n",
182 " return NULL;\n",
183 "}\n",
184 "#endif\n",
185 "\n",
186 "String::String()\n",
187 "{\n",
188 " // ...\n",
189 "}\n",
190 "\n",
191 "String::~String()\n",
192 "{\n",
193 " //...\n",
194 "}\n",
195 "\n",
196 "char& String::operator [] ( sal_uInt16 nIndex )\n",
197 "{\n",
198 " DBG_ASSERT( nIndex <= pData->nLen, \"String::[] : nIndex > Len\" );\n",
199 "\n",
200 " //...\n",
201 "}\n",
202 "\n",
203 "\n",
204 NULL
207 class DbgInfoDialog : public ModalDialog
209 private:
210 VclPtr<ListBox> maListBox;
211 VclPtr<OKButton> maOKButton;
212 bool mbHelpText;
214 public:
215 DbgInfoDialog( vcl::Window* pParent, bool bHelpText = false );
217 void SetInfoText( const OUString& rStr );
218 private:
219 virtual void dispose() SAL_OVERRIDE;
220 virtual ~DbgInfoDialog() { disposeOnce(); }
223 class DbgDialog : public ModalDialog
225 private:
226 VclPtr<CheckBox> maRes;
227 VclPtr<CheckBox> maDialog;
228 VclPtr<CheckBox> maBoldAppFont;
229 VclPtr<GroupBox> maBox3;
231 VclPtr<OKButton> maOKButton;
232 VclPtr<CancelButton> maCancelButton;
233 VclPtr<HelpButton> maHelpButton;
235 public:
236 DbgDialog();
238 DECL_LINK( ClickHdl, Button* );
239 void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
240 private:
241 virtual void dispose() SAL_OVERRIDE;
242 virtual ~DbgDialog() { disposeOnce(); }
245 DbgDialog::DbgDialog() :
246 ModalDialog( NULL, WB_STDMODAL | WB_SYSTEMWINDOW ),
247 maRes(VclPtr<CheckBox>::Create(this)),
248 maDialog(VclPtr<CheckBox>::Create(this)),
249 maBoldAppFont(VclPtr<CheckBox>::Create(this)),
250 maBox3(VclPtr<GroupBox>::Create(this)),
251 maOKButton(VclPtr<OKButton>::Create(this, WB_DEFBUTTON)),
252 maCancelButton(VclPtr<CancelButton>::Create(this)),
253 maHelpButton(VclPtr<HelpButton>::Create(this))
255 DbgData* pData = DbgGetData();
256 MapMode aAppMap( MAP_APPFONT );
257 Size aButtonSize = LogicToPixel( Size( 60, 12 ), aAppMap );
260 maRes->Show();
261 maRes->SetText("~Resourcen");
262 if ( pData->nTestFlags & DBG_TEST_RESOURCE )
263 maRes->Check( true );
264 maRes->SetPosSizePixel( LogicToPixel( Point( 75, 95 ), aAppMap ),
265 aButtonSize );
269 maDialog->Show();
270 maDialog->SetText("~Dialog");
271 if ( pData->nTestFlags & DBG_TEST_DIALOG )
272 maDialog->Check( true );
273 maDialog->SetPosSizePixel( LogicToPixel( Point( 140, 95 ), aAppMap ),
274 aButtonSize );
278 maBoldAppFont->Show();
279 maBoldAppFont->SetText("~Bold AppFont");
280 if ( pData->nTestFlags & DBG_TEST_BOLDAPPFONT )
281 maBoldAppFont->Check( true );
282 maBoldAppFont->SetPosSizePixel( LogicToPixel( Point( 205, 95 ), aAppMap ),
283 aButtonSize );
284 maBoldAppFont->SaveValue();
288 maBox3->Show();
289 maBox3->SetText("Test Options");
290 maBox3->SetPosSizePixel( LogicToPixel( Point( 5, 85 ), aAppMap ),
291 LogicToPixel( Size( 330, 30 ), aAppMap ) );
295 maOKButton->Show();
296 maOKButton->SetClickHdl( LINK( this, DbgDialog, ClickHdl ) );
297 maOKButton->SetPosSizePixel( LogicToPixel( Point( 10, 260 ), aAppMap ),
298 LogicToPixel( Size( 50, 15 ), aAppMap ) );
301 maCancelButton->Show();
302 maCancelButton->SetPosSizePixel( LogicToPixel( Point( 70, 260 ), aAppMap ),
303 LogicToPixel( Size( 50, 15 ), aAppMap ) );
306 maHelpButton->Show();
307 maHelpButton->SetPosSizePixel( LogicToPixel( Point( 190, 260 ), aAppMap ),
308 LogicToPixel( Size( 50, 15 ), aAppMap ) );
312 SetText("VCL Debug Options");
313 SetOutputSizePixel( LogicToPixel( Size( 340, 280 ), aAppMap ) );
317 IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton )
319 if ( pButton == maOKButton )
321 DbgData aData;
323 memcpy( &aData, DbgGetData(), sizeof( DbgData ) );
324 aData.nTestFlags = 0;
326 if ( maRes->IsChecked() )
327 aData.nTestFlags |= DBG_TEST_RESOURCE;
329 if ( maDialog->IsChecked() )
330 aData.nTestFlags |= DBG_TEST_DIALOG;
332 if ( maBoldAppFont->IsChecked() )
333 aData.nTestFlags |= DBG_TEST_BOLDAPPFONT;
335 // Daten speichern
336 DbgSaveData( aData );
338 DbgData* pData = DbgGetData();
339 #define IMMEDIATE_FLAGS (DBG_TEST_RESOURCE | DBG_TEST_DIALOG | DBG_TEST_BOLDAPPFONT)
340 pData->nTestFlags &= ~IMMEDIATE_FLAGS;
341 pData->nTestFlags |= aData.nTestFlags & IMMEDIATE_FLAGS;
342 if ( maBoldAppFont->IsValueChangedFromSaved() )
344 AllSettings aSettings = Application::GetSettings();
345 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
346 vcl::Font aFont = aStyleSettings.GetAppFont();
347 if ( maBoldAppFont->IsChecked() )
348 aFont.SetWeight( WEIGHT_BOLD );
349 else
350 aFont.SetWeight( WEIGHT_NORMAL );
351 aStyleSettings.SetAppFont( aFont );
352 aSettings.SetStyleSettings( aStyleSettings );
353 Application::SetSettings( aSettings );
355 if( (aData.nTestFlags & ~IMMEDIATE_FLAGS) != (pData->nTestFlags & ~IMMEDIATE_FLAGS) )
357 ScopedVclPtrInstance<MessageDialog> aBox(this, OUString(
358 "Some of the changed settings will only be active after "
359 "restarting the process"), VCL_MESSAGE_INFO);
360 aBox->Execute();
362 EndDialog( RET_OK );
365 return 0;
368 void DbgDialog::RequestHelp( const HelpEvent& rHEvt )
370 if ( rHEvt.GetMode() & HelpEventMode::CONTEXT )
372 ScopedVclPtrInstance< DbgInfoDialog > aInfoDialog( this, true );
373 OUString aHelpText;
374 const sal_Char** pHelpStrs = pDbgHelpText;
375 while ( *pHelpStrs )
377 aHelpText += OUString::createFromAscii(*pHelpStrs);
378 pHelpStrs++;
380 aInfoDialog->SetText( "Debug Hilfe" );
381 aInfoDialog->SetInfoText( aHelpText );
382 aInfoDialog->Execute();
386 void DbgDialog::dispose()
388 maRes.disposeAndClear();
389 maDialog.disposeAndClear();
390 maBoldAppFont.disposeAndClear();
391 maBox3.disposeAndClear();
392 maOKButton.disposeAndClear();
393 maCancelButton.disposeAndClear();
394 maHelpButton.disposeAndClear();
395 ModalDialog::dispose();
398 DbgInfoDialog::DbgInfoDialog( vcl::Window* pParent, bool bHelpText ) :
399 ModalDialog( pParent, WB_STDMODAL ),
400 maListBox(VclPtr<ListBox>::Create( this, WB_BORDER | WB_AUTOHSCROLL )),
401 maOKButton(VclPtr<OKButton>::Create(this, WB_DEFBUTTON))
403 mbHelpText = bHelpText;
405 if ( !bHelpText )
407 vcl::Font aFont = GetDefaultFont( DefaultFontType::FIXED, LANGUAGE_ENGLISH_US, GetDefaultFontFlags::NONE );
408 aFont.SetHeight( 8 );
409 aFont.SetPitch( PITCH_FIXED );
410 maListBox->SetControlFont( aFont );
412 maListBox->SetPosSizePixel( Point( 5, 5 ), Size( 630, 380 ) );
413 maListBox->Show();
415 maOKButton->SetPosSizePixel( Point( 290, 390 ), Size( 60, 25 ) );
416 maOKButton->Show();
418 SetOutputSizePixel( Size( 640, 420 ) );
421 void DbgInfoDialog::SetInfoText( const OUString& rStr )
423 maListBox->SetUpdateMode( false );
424 maListBox->Clear();
425 OUString aStr = convertLineEnd(rStr, LINEEND_LF);
426 sal_Int32 nStrIndex = 0;
427 sal_Int32 nFoundIndex;
430 nFoundIndex = aStr.indexOf( '\n', nStrIndex );
431 OUString aTextParagraph = aStr.copy( nStrIndex, nFoundIndex-nStrIndex );
432 if ( mbHelpText )
434 long nMaxWidth = maListBox->GetOutputSizePixel().Width()-30;
435 sal_Int32 nLastIndex = 0;
436 sal_Int32 nIndex = aTextParagraph.indexOf( ' ' );
437 while ( nIndex != -1 )
439 if ( maListBox->GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth )
441 if ( !nLastIndex )
442 nLastIndex = nIndex+1;
443 OUString aTempStr = aTextParagraph.copy( 0, nLastIndex );
444 aTextParagraph = aTextParagraph.replaceAt( 0, nLastIndex, "" );
445 maListBox->InsertEntry( aTempStr );
446 nLastIndex = 0;
448 else
449 nLastIndex = nIndex+1;
450 nIndex = aTextParagraph.indexOf( ' ', nLastIndex );
453 if ( maListBox->GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth )
455 if ( !nLastIndex )
456 nLastIndex = nIndex+1;
457 OUString aTempStr = aTextParagraph.copy( 0, nLastIndex );
458 aTextParagraph = aTextParagraph.replaceAt( 0, nLastIndex, "" );
459 maListBox->InsertEntry( aTempStr );
462 maListBox->InsertEntry( aTextParagraph );
463 nStrIndex = nFoundIndex+1;
465 while ( nFoundIndex != -1 );
466 maListBox->SetUpdateMode( true );
469 void DbgInfoDialog::dispose()
471 maListBox.disposeAndClear();
472 maOKButton.disposeAndClear();
473 ModalDialog::dispose();
476 void DbgDialogTest( vcl::Window* pWindow )
478 bool aAccelBuf[65536] = {false};
479 sal_uInt16 nChildCount = pWindow->GetChildCount();
480 vcl::Window* pGetChild = pWindow->GetWindow( GetWindowType::FirstChild );
481 vcl::Window* pChild;
482 Point aTabPos;
484 if ( !pGetChild )
485 return;
487 boost::scoped_array<Rectangle> pRectAry(reinterpret_cast<Rectangle*>(new long[(sizeof(Rectangle)*nChildCount)/sizeof(long)]));
488 memset( pRectAry.get(), 0, sizeof(Rectangle)*nChildCount );
490 if ( pWindow->IsDialog() )
492 bool bOKCancelButton = false;
493 bool bDefPushButton = false;
494 bool bButton = false;
495 pGetChild = pWindow->GetWindow( GetWindowType::FirstChild );
496 while ( pGetChild )
498 pChild = pGetChild->ImplGetWindow();
500 if ( pChild->ImplIsPushButton() )
502 bButton = true;
503 if ( (pChild->GetType() == WINDOW_OKBUTTON) || (pChild->GetType() == WINDOW_CANCELBUTTON) )
504 bOKCancelButton = true;
505 if ( pChild->GetStyle() & WB_DEFBUTTON )
506 bDefPushButton = true;
509 pGetChild = pGetChild->GetWindow( GetWindowType::Next );
512 if ( bButton )
514 SAL_WARN_IF(
515 !bOKCancelButton, "vcl",
516 "Dialogs should have a OK- or CancelButton");
517 SAL_WARN_IF(
518 !bDefPushButton, "vcl",
519 "Dialogs should have a Button with WB_DEFBUTTON");
523 sal_uInt16 i = 0;
524 pGetChild = pWindow->GetWindow( GetWindowType::FirstChild );
525 while ( pGetChild )
527 pChild = pGetChild->ImplGetWindow();
529 if ( (pChild->GetType() != WINDOW_TABCONTROL) &&
530 (pChild->GetType() != WINDOW_TABPAGE) &&
531 (pChild->GetType() != WINDOW_GROUPBOX) )
533 OUString aText = pChild->GetText();
534 OUString aErrorText = aText;
535 sal_Int32 nAccelPos = -1;
536 sal_Unicode cAccel = 0;
537 if ( aErrorText.getLength() > 128 )
539 aErrorText = aErrorText.replaceAt( 128, aErrorText.getLength()-128, "" );
540 aErrorText += "...";
542 if ( !aText.isEmpty() && (aText.getLength() < 1024) )
544 nAccelPos = aText.indexOf( '~' );
545 if ( nAccelPos != -1 )
547 const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale();
548 uno::Reference < i18n::XCharacterClassification > xCharClass = vcl::unohelper::CreateCharacterClassification();
549 OUString aUpperText = xCharClass->toUpper( aText, 0, aText.getLength(), rLocale );
550 cAccel = aUpperText[nAccelPos+1];
551 if ( pChild->IsVisible() )
553 if ( aAccelBuf[cAccel] )
554 SAL_WARN(
555 "vcl.app", "Double mnemonic char: " << cAccel);
556 else
557 aAccelBuf[cAccel] = true;
562 if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
563 (pChild->GetType() == WINDOW_CHECKBOX) ||
564 (pChild->GetType() == WINDOW_TRISTATEBOX) ||
565 (pChild->GetType() == WINDOW_PUSHBUTTON) )
567 if ( !aText.isEmpty() && aText != "..." )
569 const char* pClass;
570 if ( pChild->GetType() == WINDOW_RADIOBUTTON )
571 pClass = "RadioButton";
572 else if ( pChild->GetType() == WINDOW_CHECKBOX )
573 pClass = "CheckBox";
574 else if ( pChild->GetType() == WINDOW_TRISTATEBOX )
575 pClass = "TriStateBox";
576 else if ( pChild->GetType() == WINDOW_PUSHBUTTON )
577 pClass = "PushButton";
578 else
579 pClass = "Dontknow";
580 SAL_WARN_IF(
581 !cAccel, "vcl.app",
582 pClass << " should have a mnemonic char (~): "
583 << aErrorText);
585 // check text width
586 int aWidth=0;
587 switch( pChild->GetType() )
589 case WINDOW_RADIOBUTTON:
590 aWidth = static_cast<RadioButton*>(pChild)->CalcMinimumSize(0).Width();
591 break;
592 case WINDOW_CHECKBOX:
593 case WINDOW_TRISTATEBOX:
594 aWidth = static_cast<CheckBox*>(pChild)->CalcMinimumSize(0).Width();
595 break;
596 case WINDOW_PUSHBUTTON:
597 aWidth = static_cast<PushButton*>(pChild)->CalcMinimumSize(0).Width();
598 break;
599 default: break;
601 SAL_WARN_IF(
602 pChild->IsVisible() && pChild->GetSizePixel().Width() < aWidth,
603 "vcl.app",
604 pClass << " exceeds window width: " << aErrorText);
608 SAL_WARN_IF(
609 (pChild->GetType() == WINDOW_FIXEDLINE
610 && pChild->GetSizePixel().Width() < pChild->GetTextWidth( aText )),
611 "vcl.app", "FixedLine exceeds window width: " << aErrorText);
613 if ( pChild->GetType() == WINDOW_FIXEDTEXT )
615 SAL_WARN_IF(
616 (pChild->GetSizePixel().Height() >= pChild->GetTextHeight()*2) && !(pChild->GetStyle() & WB_WORDBREAK),
617 "vcl.app",
618 "FixedText greater than one line, but WordBreak is not set: "
619 << aErrorText);
621 if ( pChild->IsVisible() )
623 int aWidth=0;
624 if( nAccelPos != -1 )
626 aWidth = pChild->GetTextWidth( aText, 0, nAccelPos ) +
627 pChild->GetTextWidth( aText, nAccelPos+1, aText.getLength() - nAccelPos - 1);
629 else
630 aWidth = pChild->GetTextWidth( aText );
632 SAL_WARN_IF(
633 pChild->GetSizePixel().Width() < aWidth && !(pChild->GetStyle() & WB_WORDBREAK),
634 "vcl.app",
635 "FixedText exceeds window width: " << aErrorText);
638 if ( (i+1 < nChildCount) && !aText.isEmpty() )
640 vcl::Window* pTempChild = pGetChild->GetWindow( GetWindowType::Next )->ImplGetWindow();
641 if ( (pTempChild->GetType() == WINDOW_EDIT) ||
642 (pTempChild->GetType() == WINDOW_MULTILINEEDIT) ||
643 (pTempChild->GetType() == WINDOW_SPINFIELD) ||
644 (pTempChild->GetType() == WINDOW_PATTERNFIELD) ||
645 (pTempChild->GetType() == WINDOW_NUMERICFIELD) ||
646 (pTempChild->GetType() == WINDOW_METRICFIELD) ||
647 (pTempChild->GetType() == WINDOW_CURRENCYFIELD) ||
648 (pTempChild->GetType() == WINDOW_DATEFIELD) ||
649 (pTempChild->GetType() == WINDOW_TIMEFIELD) ||
650 (pTempChild->GetType() == WINDOW_LISTBOX) ||
651 (pTempChild->GetType() == WINDOW_MULTILISTBOX) ||
652 (pTempChild->GetType() == WINDOW_COMBOBOX) ||
653 (pTempChild->GetType() == WINDOW_PATTERNBOX) ||
654 (pTempChild->GetType() == WINDOW_NUMERICBOX) ||
655 (pTempChild->GetType() == WINDOW_METRICBOX) ||
656 (pTempChild->GetType() == WINDOW_CURRENCYBOX) ||
657 (pTempChild->GetType() == WINDOW_DATEBOX) ||
658 (pTempChild->GetType() == WINDOW_TIMEBOX) )
660 SAL_WARN_IF(
661 !cAccel, "vcl.app",
662 "Labels before Fields (Edit,ListBox,...) should have a mnemonic char (~): "
663 << aErrorText);
664 SAL_WARN_IF(
665 !pTempChild->IsEnabled() && pChild->IsEnabled(),
666 "vcl.app",
667 "Labels before Fields (Edit,ListBox,...) should be disabled, when the field is disabled: "
668 << aErrorText);
673 SAL_WARN_IF(
674 (pChild->GetType() == WINDOW_MULTILINEEDIT
675 && (pChild->GetStyle() & (WB_IGNORETAB | WB_READONLY)) == 0),
676 "vcl",
677 ("editable MultiLineEdits in Dialogs should have the Style"
678 " WB_IGNORETAB"));
680 if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
681 (pChild->GetType() == WINDOW_CHECKBOX) ||
682 (pChild->GetType() == WINDOW_TRISTATEBOX) ||
683 (pChild->GetType() == WINDOW_FIXEDTEXT) )
685 pChild->SetBackground( Wallpaper( Color( COL_LIGHTGREEN ) ) );
688 if ( pChild->IsVisible() )
690 bool bMaxWarning = false;
691 if ( pChild->GetType() == WINDOW_NUMERICFIELD )
693 NumericField* pField = static_cast<NumericField*>(pChild);
694 if ( pField->GetMax() == LONG_MAX )
695 bMaxWarning = true;
697 else if ( pChild->GetType() == WINDOW_METRICFIELD )
699 MetricField* pField = static_cast<MetricField*>(pChild);
700 if ( pField->GetMax() == LONG_MAX )
701 bMaxWarning = true;
703 else if ( pChild->GetType() == WINDOW_CURRENCYFIELD )
705 CurrencyField* pField = static_cast<CurrencyField*>(pChild);
706 if ( pField->GetMax() == LONG_MAX )
707 bMaxWarning = true;
709 else if ( pChild->GetType() == WINDOW_TIMEFIELD )
711 TimeField* pField = static_cast<TimeField*>(pChild);
712 if ( pField->GetMax() == tools::Time( 23, 59, 59, 99 ) )
713 bMaxWarning = true;
715 else if ( pChild->GetType() == WINDOW_DATEFIELD )
717 DateField* pField = static_cast<DateField*>(pChild);
718 if ( pField->GetMax() == Date( 31, 12, 9999 ) )
719 bMaxWarning = true;
721 else if ( pChild->GetType() == WINDOW_NUMERICBOX )
723 NumericBox* pBox = static_cast<NumericBox*>(pChild);
724 if ( pBox->GetMax() == LONG_MAX )
725 bMaxWarning = true;
727 else if ( pChild->GetType() == WINDOW_METRICBOX )
729 MetricBox* pBox = static_cast<MetricBox*>(pChild);
730 if ( pBox->GetMax() == LONG_MAX )
731 bMaxWarning = true;
733 else if ( pChild->GetType() == WINDOW_CURRENCYBOX )
735 CurrencyBox* pBox = static_cast<CurrencyBox*>(pChild);
736 if ( pBox->GetMax() == LONG_MAX )
737 bMaxWarning = true;
739 else if ( pChild->GetType() == WINDOW_TIMEBOX )
741 TimeBox* pBox = static_cast<TimeBox*>(pChild);
742 if ( pBox->GetMax() == tools::Time( 23, 59, 59, 99 ) )
743 bMaxWarning = true;
745 else if ( pChild->GetType() == WINDOW_DATEBOX )
747 DateBox* pBox = static_cast<DateBox*>(pChild);
748 if ( pBox->GetMax() == Date( 31, 12, 9999 ) )
749 bMaxWarning = true;
751 SAL_WARN_IF(
752 bMaxWarning, "vcl.app",
753 "No Max-Value is set: " << aErrorText);
755 if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
756 (pChild->GetType() == WINDOW_CHECKBOX) ||
757 (pChild->GetType() == WINDOW_TRISTATEBOX) ||
758 (pChild->GetType() == WINDOW_PUSHBUTTON) ||
759 (pChild->GetType() == WINDOW_OKBUTTON) ||
760 (pChild->GetType() == WINDOW_CANCELBUTTON) ||
761 (pChild->GetType() == WINDOW_HELPBUTTON) ||
762 (pChild->GetType() == WINDOW_IMAGEBUTTON) ||
763 (pChild->GetType() == WINDOW_FIXEDTEXT) ||
764 (pChild->GetType() == WINDOW_EDIT) ||
765 (pChild->GetType() == WINDOW_MULTILINEEDIT) ||
766 (pChild->GetType() == WINDOW_SPINFIELD) ||
767 (pChild->GetType() == WINDOW_PATTERNFIELD) ||
768 (pChild->GetType() == WINDOW_NUMERICFIELD) ||
769 (pChild->GetType() == WINDOW_METRICFIELD) ||
770 (pChild->GetType() == WINDOW_CURRENCYFIELD) ||
771 (pChild->GetType() == WINDOW_DATEFIELD) ||
772 (pChild->GetType() == WINDOW_TIMEFIELD) ||
773 (pChild->GetType() == WINDOW_LISTBOX) ||
774 (pChild->GetType() == WINDOW_MULTILISTBOX) ||
775 (pChild->GetType() == WINDOW_COMBOBOX) ||
776 (pChild->GetType() == WINDOW_PATTERNBOX) ||
777 (pChild->GetType() == WINDOW_NUMERICBOX) ||
778 (pChild->GetType() == WINDOW_METRICBOX) ||
779 (pChild->GetType() == WINDOW_CURRENCYBOX) ||
780 (pChild->GetType() == WINDOW_DATEBOX) ||
781 (pChild->GetType() == WINDOW_TIMEBOX) )
783 Point aNewPos = pChild->GetPosPixel();
784 Rectangle aChildRect( aNewPos, pChild->GetSizePixel() );
786 if ( cAccel || (pChild->GetStyle() & WB_TABSTOP) ||
787 (pChild->GetType() == WINDOW_RADIOBUTTON) )
789 SAL_WARN_IF(
790 (aNewPos.X() <= aTabPos.X()) && (aNewPos.Y() <= aTabPos.Y()),
791 "vcl.app",
792 "Possible wrong childorder for dialogcontrol: "
793 << aErrorText);
794 aTabPos = aNewPos;
797 for ( sal_uInt16 j = 0; j < i; j++ )
799 SAL_WARN_IF(
800 ((pRectAry[j].Right() != 0) || (pRectAry[j].Bottom() != 0)) && aChildRect.IsOver( pRectAry[j] ),
801 "vcl.app",
802 "Window overlaps with sibling window: "
803 << aErrorText);
805 pRectAry[i] = aChildRect;
810 pGetChild = pGetChild->GetWindow( GetWindowType::Next );
811 i++;
815 void ImplDbgTestSolarMutex()
817 assert(ImplGetSVData()->mpDefInst->CheckYieldMutex() && "SolarMutex not locked");
820 void DbgGUIInitSolarMutexCheck()
822 DbgSetTestSolarMutex( ImplDbgTestSolarMutex );
825 void DbgGUIDeInitSolarMutexCheck()
827 DbgSetTestSolarMutex( NULL );
830 void DbgGUIStart()
832 DbgData* pData = DbgGetData();
834 if ( pData )
836 ScopedVclPtrInstance< DbgDialog > xDialog;
837 // we switch off dialog tests for the debug dialog
838 sal_uLong nOldFlags = pData->nTestFlags;
839 pData->nTestFlags &= ~DBG_TEST_DIALOG;
840 if (!xDialog->Execute())
841 pData->nTestFlags |= (nOldFlags & DBG_TEST_DIALOG);
843 else
845 ScopedVclPtrInstance<MessageDialog>::Create(nullptr, OUString("TOOLS Library has no Debug-Routines"))->Execute();
849 #endif // DBG_UTIL
851 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */