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 49 B_VIEW_ALL_BITS = 0x00ffffff, 50 51 // these used for archiving only 52 B_VIEW_RESIZE_BIT = 0x00001000, 53 B_VIEW_FLAGS_BIT = 0x00002000, 54 B_VIEW_EVENT_MASK_BIT = 0x00004000 55 }; 56 57 58 class BView::Private { 59 public: 60 Private(BView* view) 61 : 62 fView(view) 63 { 64 } 65 66 int16 ShowLevel() 67 { return fView->fShowLevel; } 68 69 // defined in View.cpp 70 bool WillLayout(); 71 bool MinMaxValid(); 72 73 BLayoutItem* LayoutItemAt(int32 index); 74 int32 CountLayoutItems(); 75 void RegisterLayoutItem(BLayoutItem* item); 76 void DeregisterLayoutItem(BLayoutItem* item); 77 78 bool RemoveSelf() 79 { return fView->_RemoveSelf(); } 80 81 private: 82 BView* fView; 83 }; 84 85 86 namespace BPrivate { 87 88 89 class PortLink; 90 91 92 class ViewState { 93 public: 94 ViewState(); 95 96 inline bool IsValid(uint32 bit) const; 97 inline bool IsAllValid() const; 98 99 void UpdateServerFontState(BPrivate::PortLink &link); 100 void UpdateServerState(BPrivate::PortLink &link); 101 102 void UpdateFrom(BPrivate::PortLink &link); 103 104 public: 105 BPoint pen_location; 106 float pen_size; 107 108 rgb_color high_color; 109 rgb_color low_color; 110 111 // This one is not affected by pop state/push state 112 rgb_color view_color; 113 color_which which_view_color; 114 float which_view_color_tint; 115 116 // these are cached values 117 color_which which_low_color; 118 float which_low_color_tint; 119 120 color_which which_high_color; 121 float which_high_color_tint; 122 123 ::pattern pattern; 124 125 ::drawing_mode drawing_mode; 126 BRegion clipping_region; 127 bool clipping_region_used; 128 129 // transformation 130 BPoint origin; 131 float scale; 132 BAffineTransform transform; 133 134 // line modes 135 join_mode line_join; 136 cap_mode line_cap; 137 float miter_limit; 138 139 // fill rule 140 int32 fill_rule; 141 142 // alpha blending 143 source_alpha alpha_source_mode; 144 alpha_function alpha_function_mode; 145 146 // fonts 147 BFont font; 148 uint16 font_flags; 149 bool font_aliasing; 150 // font aliasing. Used for printing only! 151 152 // flags used for synchronization with app_server 153 uint32 valid_flags; 154 // flags used for archiving 155 uint32 archiving_flags; 156 157 // maintain our own rect as seen from the app while printing 158 BRect print_rect; 159 }; 160 161 162 inline bool 163 ViewState::IsValid(uint32 bit) const 164 { 165 return valid_flags & bit; 166 } 167 168 169 inline bool 170 ViewState::IsAllValid() const 171 { 172 return (valid_flags & B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT) 173 == (B_VIEW_ALL_BITS & ~B_VIEW_CLIP_REGION_BIT); 174 } 175 176 177 } // namespace BPrivate 178 179 180 struct _array_data_{ 181 // the max number of points in the array 182 uint32 maxCount; 183 // the current number of points in the array 184 uint32 count; 185 // the array of points 186 ViewLineArrayInfo* array; 187 }; 188 189 190 #endif /* VIEW_PRIVATE_H */ 191