summaryrefslogtreecommitdiffstats
path: root/libkdchart/KDFrame.h
blob: bbc4915582a31f9d679a7db5018334250b0b7e48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
/* -*- Mode: C++ -*-
   KDChart - a multi-platform charting engine
   */

/****************************************************************************
 ** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB.  All rights reserved.
 **
 ** This file is part of the KDChart library.
 **
 ** This file may be distributed and/or modified under the terms of the
 ** GNU General Public License version 2 as published by the Free Software
 ** Foundation and appearing in the file LICENSE.GPL included in the
 ** packaging of this file.
 **
 ** Licensees holding valid commercial KDChart licenses may use this file in
 ** accordance with the KDChart Commercial License Agreement provided with
 ** the Software.
 **
 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 **
 ** See http://www.klaralvdalens-datakonsult.se/?page=products for
 **   information about KDChart Commercial License Agreements.
 **
 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
 ** licensing are not clear to you.
 **
 **********************************************************************/
#ifndef __KDFRAME_H__
#define __KDFRAME_H__

#include <qapplication.h>
#include <qfont.h>
#include <qcolor.h>
#include <qpixmap.h>
#include <qpen.h>
#include <qmap.h>
#include <qobject.h>
#include <qtextstream.h>
#include <qdom.h>

#include <KDFrameProfileSection.h>


/** \file KDFrame.h
  \brief Header of the KDFrame class providing highly configurable rectangular frame drawing.

  \ifnot v200
  This class is work in progress, at present only single line frame borders
  and (scaled/streched) background pictures are available.
  See KDChartParams::setSimpleFrame() to learn how to use them.
  \else
  A frame may consist of an (optional) border and/or an (optional) background.
  The border may consist of up to four edges and/or up to four border corners.

  \note Each of the edges and each of the corners may use their own user-definable profile.

  The frame corners ( see types defined in \c CornerStyle ) are set up via setCorner()

  Some commonly used frame profiles (e.g. raised box, sunken panel) are predefined in \c SimpleFrame, see setSimpleFrame().
  To learn how to specify your frame profiles have a look at example code given with setProfile()
  \endif
  */


/**
  \brief The main class of KDFrame.

  KDFrame is made for highly configurable rectangular frame drawing.

  A frame may consist of an (optional) border and/or an (optional) background.
  \ifndef v200
  This class is work in progress, at present only single line frame borders
  and (scaled/streched) background pictures are available.
  See KDChartParams::setSimpleFrame() to learn how to use them.
  \else
  The border may consist of up to four edges and/or up to four border corners.

  \note Each of the edges and each of the corners may use their own user-definable profile.

  The frame corners ( see types defined in CornerStyle ) are set up via setCorner()

  Some commonly used frame profiles (e.g. raised box, sunken panel) are predefined in SimpleFrame, see setSimpleFrame().
  To learn how to specify your frame profiles have a look at example code given with setProfile()
  \endif
  */
class KDCHART_EXPORT KDFrame : public QObject
{
    Q_OBJECT
    Q_ENUMS( BackPixmapMode )
    Q_ENUMS( SimpleFrame )
    Q_ENUMS( ProfileName )
    Q_ENUMS( CornerName )
    Q_ENUMS( CornerStyle )
    Q_ENUMS( KDFramePaintSteps )

public:
    //// GENERAL


    /**
    These are ways how to display a pixmap that might
    be painted into the inner area.

    \Note To have a 'tiled' background image do not use a background
    pixmap but use a background <b>brush</b> holding this pixmap.
    */
    enum BackPixmapMode { PixCentered, PixScaled, PixStretched };

public slots:

    /**
    Converts the specified background pixmap mode enum to a string
    representation.

    \param type the background pixmap mode to convert
    \return the string representation of the background pixmap mode enum
    */
    static QString backPixmapModeToString( BackPixmapMode type ) {
        switch( type ) {
            case PixCentered:
                return "Centered";
            case PixScaled:
                return "Scaled";
            case PixStretched:
                return "Stretched";
        }

        return "Stretched";
    }


    /**
    Converts the specified string to a background pixmap mode enum value.

    \param string the string to convert
    \return the background pixmap mode enum value
    */
    static BackPixmapMode stringToBackPixmapMode( const QString& string ) {
        if( string == "Centered" )
            return PixCentered;
        else if( string == "Scaled" )
            return PixScaled;
        else if( string == "Stretched" )
            return PixStretched;

        return PixStretched;
    }


public:


    /**
    These simple frames are pre-defined for your convenience

    \li \c FrameFlat a flat rectangular frame
    \li \c FrameElegance a flat frame consisting of three lines
    \li \c FrameBoxRaized a raised box
    \li \c FrameBoxSunken a sunken box
    \li \c FramePanelRaized a raised panel
    \li \c FramePanelSunken a sunken panel
    \li \c FrameSemicircular a raised box with round edges

    \ifnot v200
    All pre-defined frames have normal corners.
    \else
    All pre-defined frames have normal corners but
    of course you may specify differently looking corners by
    calling setCorners() (or setCorner(), resp.) after having
    called setSimpleFrame()

    \sa setSimpleFrame
    \endif
    */
    enum SimpleFrame { FrameFlat,        FrameElegance,
        FrameBoxRaized,   FrameBoxSunken,
        FramePanelRaized, FramePanelSunken,
        FrameSemicircular };

public slots:

    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Select a pre-defined frame.
    This methode is provided for convenience, the same results can be obtained by calling
    addProfileSection multiple times specifying the appropriate parameters and finally
    setting the corners to \c CornerNormal

    \note When using FrameElegance the midLineWidth value will be ignored since
    in this special case the lineValue will indicate the <b>total width</b> of the frame.
    FrameElegance frames look best when lineWidth is 16 or the multiple of 16.

    \Note To have a 'tiled' background image do not use a background
    pixmap but use a background <b>brush</b> holding this pixmap.

    See setProfile for a short example using this method.

    \param frame one of the values defined for enum \c SimpleFrame
    \param lineWidth for FrameFlat and FrameElegance: the complete frame width;
        for frames with 2-line edges (FramePanelRaized, FramePanelSunken): the width of each of the lines;
        for frames with 3-line edges (FrameBoxRaized, FrameBoxSunken, FrameSemicircular): the width of the outer and the
        width of the inner line.
    \param midLineWidth only used for frames with 3-line edges: the width
        of the middle line.
    \param pen the basic pen to be used for this frame's lines
    \param background the brush to be used for the frame's background or QBrush() if the background is not to be filled by a brush
    \param backPixmap if not zero points to a pixmap to be used for the background
    \param backPixmapMode determines how the size pixmap is adjusted to the frame size,
        see \c BackPixmapMode for the possible values.

    \sa SimpleFrame, BackPixmapMode, addProfileSection, setProfile, profile, setCorners, setCorner, cornerStyle, cornerWidth
    \endif
    */
    void setSimpleFrame( SimpleFrame    frame,
            int            lineWidth,
            int            midLineWidth,
            QPen           pen,
            QBrush         background     = QBrush(),
            const QPixmap* backPixmap     = 0,
            BackPixmapMode backPixmapMode = PixStretched );

public:
    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Names of the four frame edges

    \li \c ProfileTop
    \li \c ProfileRight
    \li \c ProfileBottom
    \li \c ProfileLeft

    \sa setSimpleFrame, clearProfile, addProfileSection, setProfile, profile
    \endif
    */
    enum ProfileName { ProfileTop,    ProfileRight,
        ProfileBottom, ProfileLeft };

public slots:
    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Add another section to one of the frames profiles.

    \note The sections will be drawn in the order in which they were added to the profile
    beginning at the outside and ending with the inner section of the frame

    See setProfile for a short example using this method.

    \sa ProfileName, setSimpleFrame, addProfileSection, setProfile, profile
    \endif
    */
    void clearProfile( ProfileName name );

    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Add another section to one of the frames profiles.

    \note The sections will be drawn in the order in which they were added to the profile
    beginning at the outside and ending with the inner section of the frame.

    Adding a gap between two sections can be done by specifying a <b>QPen( Qt::NoPen )</b>.

    See setProfile for a short example using this method.

    \sa ProfileName, setSimpleFrame, clearProfile, setProfile, profile
    \endif
    */
    void addProfileSection( ProfileName      name,
            int              wid,
            QPen             pen,
            KDFrameProfileSection::Direction dir  = KDFrameProfileSection::DirPlain, // PENDING(blackie) possible enum problem
            KDFrameProfileSection::Curvature curv = KDFrameProfileSection::CvtPlain );

    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Specify one of the frames profiles by copying another KDFrameProfile.
    Use this function if a profile shall look the same as another one.

    <b>Example:</b>

    \verbatim
    // instantiate a frame around an inner rectangle 50/20, 250/20
    KDFrame myFrame( 50,20, 250,120 );

    // select a very simple rectangular frame with normal corners, black border, white background
    myFrame.setSimpleFrame( KDFrame::FrameFlat, 1, 0, QPen( Qt::Black ), QBrush( Qt::White ) );

    // make the top profile look more nice
    myFrame.clearProfile(      KDFrame::ProfileTop );
    myFrame.addProfileSection( KDFrame::ProfileTop, 2, QPen( Qt::Black ),
    KDFrameProfileSection::DirPlain,
    KDFrameProfileSection::CvtPlain );
    myFrame.addProfileSection( KDFrame::ProfileTop, 5, QPen( Qt::NoPen ),
    KDFrameProfileSection::DirPlain,
    KDFrameProfileSection::CvtPlain );
    myFrame.addProfileSection( KDFrame::ProfileTop, 1, QPen( Qt::Black ),
    KDFrameProfileSection::DirPlain,
    KDFrameProfileSection::CvtPlain );

    // copy the top profile settings into the bottom profile
    myFrame.setProfile( KDFrame::ProfileBottom,
    myFrame.profile( KDFrame::ProfileTop ) );
    \endverbatim


    \sa ProfileName, setSimpleFrame, clearProfile, addProfileSection, profile
    \endif
    */
    void setProfile( ProfileName name, const KDFrameProfile& profile );

    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Return one of the frames profiles.

    \sa ProfileName, setSimpleFrame, clearProfile, addProfileSection, setProfile
    \endif
    */
    const KDFrameProfile& profile( ProfileName name ) const;

public:

    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Names of the frame corners:

    \li \c CornerTopLeft
    \li \c CornerTopRight
    \li \c CornerBottomLeft
    \li \c CornerBottomRight

    \sa setCorners, setCorner, setSunPos, cornerStyle, cornerWidth, sunPos
    \endif
    */
    enum CornerName { CornerTopLeft,
        CornerTopRight,
        CornerBottomLeft,
        CornerBottomRight,
        CornerUNKNOWN };

public slots:
    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Converts the specified corner name enum to a string representation.

    \param type the corner name to convert
    \return the string representation of the corner name enum
    \endif
    */
    static QString cornerNameToString( CornerName type ) {
        switch( type ) {
            case CornerTopLeft:
                return "TopLeft";
            case CornerTopRight:
                return "TopRight";
            case CornerBottomLeft:
                return "BottomLeft";
            case CornerBottomRight:
                return "BottomRight";
            case CornerUNKNOWN:
                return "UNKNOWN";
        }

        return "UNKNOWN";
    }


    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Converts the specified string to a corner name enum value.

    \param string the string to convert
    \return the corner name enum value
    \endif
    */
    static CornerName stringToCornerName( const QString& string ) {
        if( string == "TopLeft" )
            return CornerTopLeft;
        else if( string == "TopRight" )
            return CornerTopRight;
        else if( string == "BottomLeft" )
            return CornerBottomLeft;
        else if( string == "BottomRight" )
            return CornerBottomRight;
        else if( string == "UNKNOWN" )
            return CornerUNKNOWN;

        return CornerUNKNOWN;
    }

public:


    /**
    \ifnot v200
    \deprecated Feature scheduled for future release, at present not implemented.
    \else
    Look of the frame corners:

    \li \c CornerNormal  a square angle corner.
    \li \c CornerRound   a quarter of a circle.
    \li \c CornerOblique corner cut-off by 45 degrees.

    \sa setCorners, setCorner, cornerStyle, cornerWidth
    \endif
    */
    enum CornerStyle { CornerNormal,
        CornerRound,
        CornerOblique };

public slots:
        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Converts the specified corner style enum to a string representation.

        \param type the corner style enum to convert
        \return the string representation of the corner style enum
        \endif
        */
        static QString cornerStyleToString( CornerStyle type ) {
            switch( type ) {
                case CornerNormal:
                    return "Normal";
                case CornerRound:
                    return "Round";
                case CornerOblique:
                    return "Oblique";
            }

            return "Normal";
        }


        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Converts the specified string to a corner stylye enum value.

        \param string the string to convert
        \return the corner style enum value
        \endif
        */
        static CornerStyle stringToCornerStyle( const QString& string ) {
            if( string == "Normal" )
                return CornerNormal;
            else if( string == "Round" )
                return CornerRound;
            else if( string == "Oblique" )
                return CornerOblique;

            return CornerNormal;
        }


public:

// MOC_SKIP_BEGIN
        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Helper class storing settings for one corner of the frame.

        To set/retrieve information stored in this class please use
        the appropriate methods of the KDFrame class.

        \sa setCorners, setCorner, cornerStyle, cornerWidth, cornerProfile, CornerName, CornerStyle
        \endif
        */
    class KDCHART_EXPORT KDFrameCorner
        {
            friend class KDFrame;
            public:
            KDFrameCorner( CornerStyle           style   = CornerNormal,
                    int                   width   = 0,
                    KDFrameProfile* const profile = 0 )
                : _style( style ),
            _width( width )
            {
                if( profile )
                    _profile = *profile;
                else
                    _profile.clear();
            }
            /**
            Destructor. Only defined to have it virtual.
            */
            virtual ~KDFrameCorner();

            /**
            \ifnot v200
            \deprecated Feature scheduled for future release, at present not implemented.
            \else
            Creates a DOM element node that represents a frame corner for use
            in a DOM document.

            \param document the DOM document to which the node will belong
            \param parent the parent node to which the new node will be appended
            \param elementName the name of the new node
            \param corner the corner to be represented
            \endif
            */
            static void createFrameCornerNode( QDomDocument& document,
                    QDomNode& parent,
                    const QString& elementName,
                    const KDFrameCorner& corner );

            /**
            \ifnot v200
            \deprecated Feature scheduled for future release, at present not implemented.
            \else
            Reads data from a DOM element node that represents a frame
            corner and fills a KDFrameCorner object with the data.

            \param element the DOM element to read from
            \param corner the frame corner object to read the data into
            \endif
            */
            static bool readFrameCornerNode( const QDomElement& element,
                    KDFrameCorner& corner );

            protected:
            void setAll( CornerStyle           style,
                    int                   width,
                    KDFrameProfile* const profile = 0 )
            {
                _style = style;
                _width = width;
                if( profile )
                    _profile = *profile;
                else
                    _profile.clear();
            }
            CornerStyle style() const
            {
                return _style;
            }
            int width() const
            {
                return _width;
            }
            const KDFrameProfile& profile() const
            {
                return _profile;
            }
            private:
            CornerStyle  _style;
            int          _width;
            KDFrameProfile _profile;
        };

// MOC_SKIP_END

public slots:
        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Specify the look and the width and (optionally) the profile
        of one of the frame corners.

        \sa setCorners, cornerStyle, cornerWidth, cornerWidth, CornerName, CornerStyle
        \endif
        */
        void setCorner( CornerName name,
                CornerStyle style,
                int width,
                KDFrameProfile* const profile = 0 )
        {
            switch( name ) {
                case CornerTopLeft:     _cornerTL.setAll( style, width, profile );
                                        break;
                case CornerTopRight:    _cornerTR.setAll( style, width, profile );
                                        break;
                case CornerBottomLeft:  _cornerBL.setAll( style, width, profile );
                                        break;
                case CornerBottomRight: _cornerBR.setAll( style, width, profile );
                                        break;
                case CornerUNKNOWN:
                                        break;
            }
        }

        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Specify the look and the width and (optionally) the profile
        of all of the frame corners.

        \sa setCorner, cornerStyle, cornerWidth, CornerName, CornerStyle
        \endif
        */
        void setCorners( CornerStyle style,
                int width,
                KDFrameProfile* const profile = 0 )
        {
            _cornerTL.setAll( style, width, profile );
            _cornerTR.setAll( style, width, profile );
            _cornerBL.setAll( style, width, profile );
            _cornerBR.setAll( style, width, profile );
        }


        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Returns the look of one of the frame corners.

        \sa setCorners, cornerWidth, CornerName, CornerStyle
        \endif
        */
        CornerStyle cornerStyle( CornerName name ) const
        {
            switch( name ) {
                case CornerTopLeft:     return _cornerTL.style();
                case CornerTopRight:    return _cornerTR.style();
                case CornerBottomLeft:  return _cornerBL.style();
                case CornerBottomRight: return _cornerBR.style();
                case CornerUNKNOWN:
                default:                return CornerNormal;
            }
        }

        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Returns the width of one of the frame corners.

        \sa setCorners, cornerStyle, CornerName, CornerStyle
        \endif
        */
        int cornerWidth( CornerName name ) const
        {
            switch( name ) {
                case CornerTopLeft:     return _cornerTL.width();
                case CornerTopRight:    return _cornerTR.width();
                case CornerBottomLeft:  return _cornerBL.width();
                case CornerBottomRight: return _cornerBR.width();
                case CornerUNKNOWN:
                default:                return 0;
            }
        }

        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Returns the profile of one of the frame corners.

        \sa setCorners, cornerStyle, CornerName, CornerStyle
        \endif
        */
        const KDFrameProfile& cornerProfile( CornerName name ) const
        {
            switch( name ) {
                case CornerUNKNOWN:
                case CornerTopLeft:     return _cornerTL.profile();
                case CornerTopRight:    return _cornerTR.profile();
                case CornerBottomLeft:  return _cornerBL.profile();
                case CornerBottomRight: return _cornerBR.profile();
                default: return _cornerTL.profile();
            }
        }


        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Specifies the position of the sun, normally this is the upper left corner.

        \sa sunPos
        \endif
        */
        void setSunPos( CornerName sunPos )
        {
            _sunPos = sunPos;
        }

        /**
        \ifnot v200
        \deprecated Feature scheduled for future release, at present not implemented.
        \else
        Returns the position of the sun.

        \sa setSunPos
        \endif
        */
        CornerName sunPos() const
        {
            return _sunPos;
        }


        /**
        Specifies the brush to be used to fill the inner area of this frame,
        calling this methode without passing in a parameter re-sets the background brush
        to \c QBrush( \cQt::NoBrush \c).

        \Note To have a 'tiled' background image just use a brush
        holding this pixmap - for other ways to show background
        images please use setBackPixmap.

        \sa setBackPixmap, background
        */
        void setBackground( QBrush background = QBrush( Qt::NoBrush ) )
        {
            _background = background;
        }

        /**
        Specifies a pixmap to be used to fill the inner area of this frame,
        calling this methode without passing in a parameter removes the background pixmap.

        \Note To have a 'tiled' background image do not use setBackPixmap
        but use setBackground specifying a brush holding the pixmap.

        \sa setBackground, background
        */
        void setBackPixmap( const QPixmap* backPixmap     = 0,
                BackPixmapMode backPixmapMode = PixStretched )
        {
            _backPixmap     = backPixmap ? *backPixmap : QPixmap();
            _backPixmapMode = backPixmapMode;
        }

        /**
        Returns the brush that is used to fill the inner area of this frame,
        or a QBrush( \cNoBrush \c) if no background is to be drawn.

        \param backPixmap receives the pixmap used for drawing the background or
        a null pixmap, test this by calling backPixmap.isNull()

        \Note If a 'tiled' background image is shown the respective pixmap
        may be found by calling the <b>brush's</b> pixmap() function.

        \sa setBackground, setBackPixmap
        */
        const QBrush& background( const QPixmap*& backPixmap,
                BackPixmapMode& backPixmapMode ) const
        {
            backPixmap     = &_backPixmap;
            backPixmapMode =  _backPixmapMode;
            return _background;
        }


        /**
        Specifies the position and the size of area that is surrounded by the frame.

        \note The rectangle applies to the <b>inner</b> area of the frame.
        The Frame is drawn around this area: touching it but not covering it.
        The outer size of the frame and the position of its outer left corner
        depends from the frame profile width(s).

        \sa innerRect, setCorners, setSimpleFrame, setProfile
        */
        void setInnerRect( QRect innerRect )
        {
            _innerRect = innerRect;
        }

        /**
        Returns the position and the size of the frame.

        \note The rectangle returns to the <b>inner</b> area of the frame.
        The Frame is drawn around this area: touching it but not covering it.
        The outer size of the frame and the position of its outer left corner
        depends from the frame profile width.

        \sa setInnerRect, setProfile
        */
        QRect innerRect() const
        {
            return _innerRect;
        }


        /**
        Paint methode drawing the background (if any) of the frame.

        \note Under normal circumstances you will <b>never</b> have to
        call this methode since it is called internally by paint() if you
        start it with  \c PaintBackground (or with \c PaintAll, resp.) for the \c steps parameter.
        */
        virtual void paintBackground( QPainter& painter, const QRect& innerRect ) const;
        /**
        Paint methode drawing the edges (if any) of the frame.

        \note Under normal circumstances you will <b>never</b> have to
        call this methode since it is called internally by paint() if you
        start it with \c PaintEdges (or with \c PaintAll, \c PaintBorder, resp.) for the \c steps parameter.
        */
        virtual void paintEdges( QPainter& painter, const QRect& innerRect ) const;
        /**
        Paint methode drawing the corners (if any) of the frame.

        \note Under normal circumstances you will <b>never</b> have to
        call this methode since it is called internally by paint() if you
        start it with \c PaintCorners (or with \c PaintAll, \c PaintBorder, resp.) for the \c steps parameter.
        */
        virtual void paintCorners( QPainter& painter, const QRect& innerRect ) const;


public:
        /**
        The different steps taken to paint the frame:
        first paint the background then the edges then the corners.
        By choosing \c PaintAll all the parts of the frame will be drawn.

        \li \c PaintBackground -- first paints the brush, then paints the pixmap if any
        \li \c PaintEdges
        \li \c PaintCorners
        \li \c PaintBorder -- paint the edges and the corners but not the background
        \li \c PaintAll

        \sa paint
        */
        enum KDFramePaintSteps { PaintBackground, PaintEdges, PaintCorners, PaintBorder, PaintAll };

public slots:

        /**
        Paint methode actually drawing the frame.

        This method must be called from inside the \c paint() methode of your widget.

        In order not to override the inner contents of the frame you normally would
        first call <b>paint( painter, PaintBackground );</b> then do all the inside
        drawing and finally call <b>paint( painter, PaintBorder );</b>. In case the
        inner contents <b>are</b> allowed to (partially) override the frame border
        you could do the following: First call <b>paint( painter, PaintBackground );</b>
        immediately followed by <b>paint( painter, PaintEdges );</b> then do all your
        inside work and finally draw <b>paint( painter, PaintCorners );</b>.

        \param painter The QPainter to be used for drawing.
        \param steps The part of the frame to be drawn, use KDFrame::PaintAll to draw the entire frame and the background,
        use KDFrame::PaintBackground to draw only the background, use KDFrame::PaintEdges to draw just the edges,
        use KDFrame::PaintCorners to draw only the corners.
        \param innerRect The area inside the frame. Use this parameter to temporarily override the \c innerRect set by
        the constructor of KDFrame or by setInnerRect(). This approach can be usefull if you want to draw several
        frames that differ only regarding to their position and size but share the same edges/corners/background settings.
        In this case you could decide to instantiate only one KDFrame set up the desired settings and just call
        its paint() methode several time - giving it the appropriate innerRect for each frame. This would result in
        less memory usage since you could use that single KDFrame object as kind of a shared ressource.
        */
        virtual void paint( QPainter* painter,
                KDFramePaintSteps steps = PaintAll,
                QRect innerRect         = QRect(0,0,0,0) ) const;


        /**
        Remove all settings and specify no border, no edges, no background.
        */
        void clearAll()
        {
            _background     = QBrush();
            _backPixmap     = QPixmap();
            _backPixmapMode = PixStretched;
            _shadowWidth    = 0;
            _sunPos         = CornerTopLeft;
            _innerRect      = QRect( 0,0, 0,0 );
            _topProfile.clear();
            _rightProfile.clear();
            _bottomProfile.clear();
            _leftProfile.clear();
            _cornerTL.setAll( CornerNormal, 0, 0 );
            _cornerTR.setAll( CornerNormal, 0, 0 );
            _cornerBL.setAll( CornerNormal, 0, 0 );
            _cornerBR.setAll( CornerNormal, 0, 0 );
        }

public:

    /**
    Default Constructor. Defines default values.

    The constructor does *not* have a \c parent parameter since drawing
    of the frame is not done transparently but by (one or more) explicit
    calls of the frames paint() methode.  See explanation given there
    to learn about the why and how of this...

    \note The rectangle applies to the <b>inner</b> area of the frame.
    The Frame is drawn around this area: touching it but not covering it.
    The outer size of the frame and the position of its outer left corner
    depends from the frame profile width.

    \Note To have a 'tiled' background image do not specify a backPixmap
    but use a background <b>brush</b> holding this pixmap.

    \sa rect, setInnerRect, setProfile
    */
    KDFrame( QRect          innerRect      = QRect(0,0,0,0),
            SimpleFrame    frame          = FrameFlat,
            int            lineWidth      = 1,
            int            midLineWidth   = 0,
            QPen           pen            = QPen(),   // solid black line with 0 width
            QBrush         background     = QBrush(), // no brush
            const QPixmap* backPixmap     = 0,        // no pixmap
            BackPixmapMode backPixmapMode = PixStretched,
            int            shadowWidth    = 0,
            CornerName     sunPos         = CornerTopLeft )
    {
        _profileSections.setAutoDelete( true );
        _innerRect = innerRect;
        setSimpleFrame( frame,
                        lineWidth,
                        midLineWidth,
                        pen,
                        background,
                        backPixmap,
                        backPixmapMode );
        _shadowWidth = shadowWidth;
        _sunPos      = sunPos;
    }


/*
    Constructor. Set up a frame by copying settings of another frame.

    The constructor does *not* have a \c parent parameter since drawing
    of the frame is not done transparently but by (one or more) explicit
    calls of the frames paint() methode.  See explanation given there
    to learn about the why and how of this...

    \note The rectangle applies to the <b>inner</b> area of the frame.
    The Frame is drawn around this area: touching it but not covering it.
    The outer size of the frame and the position of its outer left corner
    depends from the frame profile width.

    \sa rect, setInnerRect, setProfile

    KDFrame( QRect innerRect,
            const KDFrame& R,
            CornerName sunPos = CornerUNKNOWN )
    {
        deepCopy( *this, R );
        if( innerRect.isValid() )
            _innerRect = innerRect;
        if( CornerUNKNOWN != sunPos )
            _sunPos = sunPos;

        _profileSections.setAutoDelete( true );
    }
*/
private:
    KDFrame( const KDFrame& ) : QObject(0) {}
    KDFrame& operator=( const KDFrame& ){return *this;}



public:
    /**
    Destructor. Only defined to have it virtual.
    */
    virtual ~KDFrame();

    /*
    Kopierroutine, aufgerufen im Copy-C'tor und im Zuweisungs-Operator
    */
    static void deepCopy( KDFrame& D, const KDFrame& R )
    {
        D._shadowWidth    = R._shadowWidth;
        D._sunPos         = R._sunPos;
        D._background     = R._background;
        D._backPixmap     = R._backPixmap;
        D._backPixmapMode = R._backPixmapMode;
        D._innerRect      = R._innerRect;
        D._topProfile     = R._topProfile;
        D._rightProfile   = R._rightProfile;
        D._bottomProfile  = R._bottomProfile;
        D._leftProfile    = R._leftProfile;
        D._cornerTL       = R._cornerTL;
        D._cornerTR       = R._cornerTR;
        D._cornerBL       = R._cornerBL;
        D._cornerBR       = R._cornerBR;
        D._profileSections= R._profileSections;
        D._profileSections.setAutoDelete( true );
        R.setProfileSectionsAutoDelete( false );
    }

    friend QTextStream& operator<<( QTextStream& s, const KDFrame& p );
    friend QTextStream& operator>>( QTextStream& s, KDFrame& p );

    /**
    Creates a DOM element node that represents a frame for use
    in a DOM document.

    \param document the DOM document to which the node will belong
    \param parent the parent node to which the new node will be appended
    \param elementName the name of the new node
    \param frame the frame to be represented
    */
    static void createFrameNode( QDomDocument& document, QDomNode& parent,
            const QString& elementName,
            const KDFrame& frame );

    /**
    Creates a DOM element node that represents a frame profile for use
    in a DOM document.

    \param document the DOM document to which the node will belong
    \param parent the parent node to which the new node will be appended
    \param elementName the name of the new node
    \param profile the profile to be represented
    */
    static void createFrameProfileNode( QDomDocument& document,
            QDomNode& parent,
            const QString& elementName,
            KDFrameProfile profile );

    /**
    Reads data from a DOM element node that represents a frame
    object and fills a KDFrame object with the data.

    \param element the DOM element to read from
    \param frame the frame object to read the data into
    */
    static bool readFrameNode( const QDomElement& element,
            KDFrame& frame );

    /**
    Reads data from a DOM element node that represents a frame
    profile and fills a KDFrameProfile object with the data.

    \param element the DOM element to read from
    \param profile the frame profile object to read the data into
    */
    static bool readFrameProfileNode( const QDomElement& element,
            KDFrameProfile& profile );

signals:
    /**
    This signal is emitted when any of the frame parameters has changed.
    */
    void changed();

private:
    void setProfileSectionsAutoDelete( bool on ) const
    {
        ((KDFrame*)this)->_profileSections.setAutoDelete( on );
    }

    /**
    Stores the width of the shadow.
    */
    int _shadowWidth;

    /**
    Stores the position of the sun.
    */
    CornerName _sunPos;

    /**
    Stores the brush to be used to fill the inner area.
    */
    QBrush _background;

    /**
    Stores the pixmap to be painted into the inner area.
    */
    QPixmap _backPixmap;

    /**
    Stores the way how to display the pixmap that is
    to be painted into the inner area.
    */
    BackPixmapMode _backPixmapMode;

    /**
    Stores the position and size of the frame.
    */
    QRect _innerRect;

    /**
    Stores all currently used profile settings for a controlled deletion.

    \note The other pointer lists (like _topProfile or _rightProfile)
    do NOT delete the objects that belong to their pointers,
    but all sections will be deleted via this extra _profileSections list:
    this allows for using the same KDFrameProfileSection* to be used
    by several lists - typically done for simple frames where all 4 sides
    are composed the same way.
    */
    KDFrameProfile _profileSections;

    /**
    Stores the profile settings for the top side of the frame.
    */
    KDFrameProfile _topProfile;
    /**
    Stores the profile settings for the right side of the frame.
    */
    KDFrameProfile _rightProfile;
    /**
    Stores the profile settings for the bottom side of the frame.
    */
    KDFrameProfile _bottomProfile;
    /**
    Stores the profile settings for the left side of the frame.
    */
    KDFrameProfile _leftProfile;

    /**
    Stores the settings for the top left corner of the frame.
    */
    KDFrameCorner _cornerTL;
    /**
    Stores the settings for the top right corner of the frame.
    */
    KDFrameCorner _cornerTR;
    /**
    Stores the settings for the bottom left corner of the frame.
    */
    KDFrameCorner _cornerBL;
    /**
    Stores the settings for the bottom right corner of the frame.
    */
    KDFrameCorner _cornerBR;
};


/**
  Writes the KDFrame object p as an XML document to the text stream s.

  \param s the text stream to write to
  \param p the KDFrame object to write
  \return the text stream after the write operation
  */
QTextStream& operator<<( QTextStream& s, const KDFrame& p );


/**
  Reads the an XML document from the text stream s into the
  KDFrame object p

  \param s the text stream to read from
  \param p the KDFrame object to read into
  \return the text stream after the read operation
  */
QTextStream& operator>>( QTextStream& s, KDFrame& p );


#endif