xref: /trunk/main/toolkit/source/layout/core/vcl.cxx (revision b0724fc6)
1*b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b0724fc6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b0724fc6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b0724fc6SAndrew Rist  * distributed with this work for additional information
6*b0724fc6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b0724fc6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b0724fc6SAndrew Rist  * "License"); you may not use this file except in compliance
9*b0724fc6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b0724fc6SAndrew Rist  *
11*b0724fc6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b0724fc6SAndrew Rist  *
13*b0724fc6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b0724fc6SAndrew Rist  * software distributed under the License is distributed on an
15*b0724fc6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b0724fc6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b0724fc6SAndrew Rist  * specific language governing permissions and limitations
18*b0724fc6SAndrew Rist  * under the License.
19*b0724fc6SAndrew Rist  *
20*b0724fc6SAndrew Rist  *************************************************************/
21*b0724fc6SAndrew Rist 
22*b0724fc6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <vcl.hxx>
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <sal/types.h>
27cdf0e10cSrcweir #include <vcl/button.hxx>
28cdf0e10cSrcweir 
get_button(Dialog const * dialog,sal_uInt32 type)29cdf0e10cSrcweir static PushButton* get_button (Dialog const* dialog, sal_uInt32 type)
30cdf0e10cSrcweir {
31cdf0e10cSrcweir     Window* child = dialog->GetWindow (WINDOW_FIRSTCHILD);
32cdf0e10cSrcweir     while (child)
33cdf0e10cSrcweir     {
34cdf0e10cSrcweir         if (child->GetType () == type)
35cdf0e10cSrcweir             return static_cast <PushButton*> (child);
36cdf0e10cSrcweir         child = child->GetWindow (WINDOW_NEXT);
37cdf0e10cSrcweir     }
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     return 0;
40cdf0e10cSrcweir }
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #define IMPLEMENT_CLOSING_DIALOG(cls)\
43cdf0e10cSrcweir     Closing##cls::Closing##cls (Window* parent, WinBits bits)\
44cdf0e10cSrcweir     : cls (parent, bits)\
45cdf0e10cSrcweir         , mClosing (false)\
46cdf0e10cSrcweir     {\
47cdf0e10cSrcweir     }\
48cdf0e10cSrcweir     sal_Bool Closing##cls::Close ()\
49cdf0e10cSrcweir     {\
50cdf0e10cSrcweir         if (mClosing)\
51cdf0e10cSrcweir             EndDialog (false);\
52cdf0e10cSrcweir         else if (PushButton *cancel = get_button (this, WINDOW_CANCELBUTTON))\
53cdf0e10cSrcweir             cancel->Click ();\
54cdf0e10cSrcweir         else if (PushButton *ok = get_button (this, WINDOW_OKBUTTON))\
55cdf0e10cSrcweir             ok->Click ();\
56cdf0e10cSrcweir         mClosing = true;\
57cdf0e10cSrcweir         return false;\
58cdf0e10cSrcweir     }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir IMPLEMENT_CLOSING_DIALOG (Dialog);
61cdf0e10cSrcweir IMPLEMENT_CLOSING_DIALOG (ModelessDialog);
62cdf0e10cSrcweir IMPLEMENT_CLOSING_DIALOG (ModalDialog);
63