1 /* 2 * Copyright 2003-2015, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Adrian Oanca <adioanca@cotty.iren.ro> 7 * Axel Dörfler, axeld@pinc-software.de 8 */ 9 #ifndef VIEW_PRIVATE_H 10 #define VIEW_PRIVATE_H 11 12 13 #include <Font.h> 14 #include <InterfaceDefs.h> 15 #include <Point.h> 16 #include <Rect.h> 17 #include <Region.h> 18 #include <ServerProtocolStructs.h> 19 #include <View.h> 20 21 22 const static uint32 kDeleteReplicant = 'JAHA'; 23 24 const static uint32 kWorkspacesViewFlag = 0x40000000UL; 25 // was/is _B_RESERVED1_ in View.h 26 27 enum { 28 B_VIEW_FONT_BIT = 0x00000001, 29 B_VIEW_HIGH_COLOR_BIT = 0x00000002, 30 B_VIEW_DRAWING_MODE_BIT = 0x00000004, 31 B_VIEW_CLIP_REGION_BIT = 0x00000008, 32 B_VIEW_LINE_MODES_BIT = 0x00000010, 33 B_VIEW_BLENDING_BIT = 0x00000020, 34 B_VIEW_SCALE_BIT = 0x00000040, 35 B_VIEW_FONT_ALIASING_BIT = 0x00000080, 36 B_VIEW_FRAME_BIT = 0x00000100, 37 B_VIEW_ORIGIN_BIT = 0x00000200, 38 B_VIEW_PEN_SIZE_BIT = 0x00000400, 39 B_VIEW_PEN_LOCATION_BIT = 0x00000800, 40 B_VIEW_LOW_COLOR_BIT = 0x00008000, 41 B_VIEW_VIEW_COLOR_BIT = 0x00010000, 42 B_VIEW_PATTERN_BIT = 0x00020000, 43 B_VIEW_TRANSFORM_BIT = 0x00040000, 44 B_VIEW_FILL_RULE_BIT = 0x00080000, 45 B_VIEW_WHICH_VIEW_COLOR_BIT = 0x00100000, 46 B_VIEW_WHICH_LOW_COLOR_BIT = 0x00200000, 47 B_VIEW_WHICH_HIGH_COLOR_BIT = 0x00400000, 48 B_VIEW_PARENT_COMPOSITE_BIT = 0x00800000, 49 50 B_VIEW_ALL_BITS = 0x00ffffff, 51 52 // these used for archiving only 53 B_VIEW_RESIZE_BIT = 0x00001000, 54 B_VIEW_FLAGS_BIT = 0x00002000, 55 B_VIEW_EVENT_MASK_BIT = 0x00004000 56 }; 57 58 59 class BView::Private { 60 public: 61 Private(BView* view) 62 : 63 fView(view) 64 { 65 } 66 67 int16 ShowLevel() 68 { return fView->fShowLevel; } 69 70 // defined in View.cpp 71 bool WillLayout(); 72 bool MinMaxValid(); 73 74 BLayoutItem* LayoutItemAt(int32 index); 75 int32 CountLayoutItems(); 76 void RegisterLayoutItem(BLayoutItem* item); 77 void DeregisterLayoutItem(BLayoutItem* item); 78 79 bool RemoveSelf() 80 { return fView->_RemoveSelf(); } 81 82 private: 83 BView* fView; 84 }; 85 86 87 namespace BPrivate { 88 89 90 class PortLink; 91 92 93 class ViewState { 94 public: 95 ViewState(); 96 97 inline bool IsValid(uint32 bit) const; 98 inline bool IsAllValid() const; 99 100 void UpdateServerFontState(BPrivate::PortLink &link); 101 void UpdateServerState(BPrivate::PortLink &link); 102 103 void UpdateFrom(BPrivate::PortLink &link); 104 105 public: 106 BPoint pen_location; 107 float pen_size; 108 109 rgb_color high_color; 110 rgb_color low_color; 111 112 // This one is not affected by pop state/push state 113 rgb_color view_color; 114 color_which which_view_color; 115 float which_view_color_tint; 116 117 // these are cached values 118 color_which which_low_color; 119 float which_low_color_tint; 120 121 color_which which_high_color; 122 float which_high_color_tint; 123 124 ::pattern pattern; 125 126 ::drawing_mode drawing_mode; 127 BRegion clipping_region; 128 bool clipping_region_used; 129 130 // transformation 131 BPoint origin; 132 float scale; 133 BAffineTransform transform; 134 135 // composite transformation stack 136 BPoint parent_composite_origin; 137 float parent_composite_scale; 138 BAffineTransform parent_composite_transform; 139 140 // line modes 141 join_mode line_join; 142 cap_mode line_cap; 143 float miter_limit; 144 145 // fill rule 146 int32 fill_rule; 147 148 // alpha blending 149 source_alpha alpha_source_mode; 150 alpha_function alpha_function_mode; 151 152 // fonts 153 BFont font; 154 uint16 font_flags; 155 bool font_aliasing; 156 // font aliasing. Used for printing only! 157 158 // flags used for synchronization with app_server 159 uint32 valid_flags; 160 // flags used for archiving 161 uint32 archiving_flags; 162 163 // maintain our own rect as seen from the app while printing 164 BRect print_rect; 165 }; 166 167 168 inline bool 169 ViewState::IsValid(uint32 bit) const 170 { 171 return valid_flags & bit; 172 } 173 174 175 inline bool 176 ViewState::IsAllValid() const 177 { 178 return (valid_flags & B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT) 179 == (B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT); 180 } 181 182 183 } // namespace BPrivate 184 185 186 struct _array_data_{ 187 // the max number of points in the array 188 uint32 maxCount; 189 // the current number of points in the array 190 uint32 count; 191 // the array of points 192 ViewLineArrayInfo* array; 193 }; 194 195 196 #endif /* VIEW_PRIVATE_H */ 197