#region Public Constructors
public Button() {
dialog_result = DialogResult.None;
+ SetStyle(ControlStyles.StandardDoubleClick, false);
}
#endregion // Public Constructors
FontChanged+=new EventHandler(RedrawEvent);
SizeChanged+=new EventHandler(RedrawEvent);
- SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SetStyle(ControlStyles.ResizeRedraw, true);
- SetStyle(ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false);
+ SetStyle(ControlStyles.ResizeRedraw |
+ ControlStyles.Opaque |
+ ControlStyles.UserMouse |
+ ControlStyles.SupportsTransparentBackColor |
+ ControlStyles.CacheText |
+ ControlStyles.DoubleBuffer, true);
+ SetStyle(ControlStyles.StandardClick, false);
}
#endregion // Public Constructors
+2005-10-12 Peter Dennis Bartok <pbartok@novell.com>
+
+ * XplatUI.cs, XplatUIDriver.cs: Removed EraseWindowBackground
+ and SetWindowBackground methods
+ * Control.cs:
+ - Setting proper ControlStyles
+ - We no longer call XplatUI.SetWindowBackground and XplatUI.
+ EraseWindowBackground, instead we draw the window background
+ ourselves in PaintControlBackground. This behaviour is
+ required to match MS, where, when OnPaintBackground is not
+ called, the background is not drawn.
+ - Removed unneeded Refresh() in set_Text
+ * Hwnd.cs: Dropped the ErasePending support. No longer needed
+ * XplatUIX11.cs:
+ - Created DeriveStyles method to translate from CreateParams to
+ FormBorderStyle and TitleStyle, also handles BorderStyle (which
+ matches FormBorderStyle enum values)
+ - Consolidated SetHwndStyles and CalculateWindowRect border/title
+ style calculations into single DeriveStyles method
+ - Fixed CreateWindow to (finally) use Gravity. This prevents X11
+ from redrawing the whole window on any resize or expose.
+ - Fixed CreateWindow usage of SetWindowValuemask. Before not
+ all styles were applied to our whole/client window appropriately
+ - Removed EraseWindowBackground() and SetWindowBackground() methods
+ - Removed handling of WM_ERASEBKGND message from DefWndProc, we
+ no longer clear/redraw the background through X
+ - Removed handling of erase_pending bit, we have no use for it (or
+ so it seems)
+ * XplatUIOSX.cs:
+ - Removed generation and handling of WM_ERASEBKGND message
+ - Removed EraseWindowBackground() and SetWindowBackground() methods
+ - Removed handling of hwnd.ErasePending flag
+ * XplatUIWin32.cs:
+ - Removed EraseWindowBackground() and SetWindowBackground() methods
+ - We no longer call EraseWindowBackground on PaintEventStart, we
+ ignore the fErase flag, erasing is handled in Control in the
+ background handler
+ * Button.cs, GroupBox.cs, Label.cs, CheckBox.cs, ProgressBar.cs,
+ LinkLabel.cs, ListControl.cs, TabPage.cs, UpDownBase.cs,
+ TextBoxBase.cs, TextBox.cs, ListView.cs, ButtonBase.cs,
+ CheckedListBox.cs, MdiClient.cs, Panel.cs, DataGrid.cs,
+ DataGridTextBox.cs, ScrollBar.cs, ListBox.cs, TrackBar.cs,
+ TabControl.cs, ScrollableControl.cs, ToolBar.cs, PictureBox.cs,
+ DateTimePicker.cs, StatusBar.cs, MonthCalendar.cs: Setting proper ControlStyles
+
2005-10-12 Jonathan Chambers <jonathan.chambers@ansys.com>
* PropertyGrids.cs: Get sub properties
auto_check = true;
check_alignment = ContentAlignment.MiddleLeft;
text_alignment = ContentAlignment.MiddleLeft;
+ SetStyle(ControlStyles.StandardDoubleClick, false);
}
#endregion // Public Constructors
check_onclick = false;
three_dcheckboxes = false;
listbox_info.item_height = FontHeight + 2;
+ SetStyle (ControlStyles.ResizeRedraw, true);
}
#region events
border_style = BorderStyle.None;
background_color = Color.Empty;
- control_style = ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick;
+ control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
+ ControlStyles.Selectable | ControlStyles.StandardClick |
+ ControlStyles.StandardDoubleClick;
parent = null;
background_image = null;
for (int i=0; i < parent.child_controls.Count; i++) {
child=parent.child_controls[i];
- if (child.IsHandleCreated) {
- if (!child.GetStyle (ControlStyles.UserPaint)) {
- XplatUI.SetWindowBackground(child.window.Handle, child.BackColor);
- }
- }
if (child.child_controls.Count>0) {
SetChildColor(child);
}
// This method exists so controls overriding OnPaintBackground can have default background painting done
internal virtual void PaintControlBackground (PaintEventArgs pevent)
{
- if (background_image == null)
+ if (background_image == null) {
+ pevent.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(BackColor), new Rectangle(pevent.ClipRectangle.X - 1, pevent.ClipRectangle.Y - 1, pevent.ClipRectangle.Width + 2, pevent.ClipRectangle.Height + 2));
return;
+ }
DrawBackgroundImage (pevent.Graphics);
}
set {
background_color=value;
- if (this.IsHandleCreated && !GetStyle (ControlStyles.UserPaint)) {
- XplatUI.SetWindowBackground(this.window.Handle, value);
- }
SetChildColor(this);
OnBackColorChanged(EventArgs.Empty);
Invalidate();
[BindableAttribute(true)]
public virtual string Text {
get {
+ // Our implementation ignores ControlStyles.CacheText - we always cache
return this.text;
}
text=value;
if (IsHandleCreated) {
XplatUI.Text(Handle, text);
- } else {
- // FIXME: Do we need a Refresh() here?
- Refresh();
}
OnTextChanged (EventArgs.Empty);
}
creator_thread = Thread.CurrentThread;
- if (!GetStyle (ControlStyles.UserPaint)) {
- XplatUI.SetWindowBackground(window.Handle, this.BackColor);
- }
-
OnHandleCreated(EventArgs.Empty);
}
}
Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
OnPaintBackground (eraseEventArgs);
}
- } else {
- XplatUI.EraseWindowBackground(m.HWnd, m.WParam);
}
// The DefWndProc will never have to handle this, we don't ever set hbr on the window
m.Result = (IntPtr)1;
vert_scrollbar.Scroll += new ScrollEventHandler (GridVScrolled);
KeyUp += new KeyEventHandler (OnKeyUpDG);
- SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.UserMouse, true);
}
{
isedit = true;
grid = null;
+
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false);
+ SetStyle (ControlStyles.FixedHeight, true);
}
#endregion
MouseDown += new MouseEventHandler (MouseDownHandler);
Paint += new PaintEventHandler (PaintHandler);
- SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
+ SetStyle (ControlStyles.FixedHeight, true);
}
#endregion
TabStop = false;
flat_style = FlatStyle.Standard;
- SetStyle(ControlStyles.ContainerControl, true);
+ SetStyle(ControlStyles.ContainerControl | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Selectable, false);
- SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
}
#region Public Properties
internal bool visible;
internal Rectangle invalid;
internal bool expose_pending;
- internal bool erase_pending;
internal bool nc_expose_pending;
internal bool configure_pending;
internal Graphics client_dc;
expose_pending = false;
nc_expose_pending = false;
client_rectangle = Rectangle.Empty;
- erase_pending = true;
marshal_free_list = new ArrayList(2);
}
}
}
- public bool ErasePending {
- get {
- return erase_pending;
- }
-
- set {
- erase_pending = value;
- }
- }
-
public bool ExposePending {
get {
return expose_pending;
AutoSizeChanged = null;
TextAlignChanged = null;
- SetStyle (ControlStyles.ResizeRedraw, true);
SetStyle (ControlStyles.Selectable, false);
- SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.ResizeRedraw |
+ ControlStyles.UserPaint |
+ ControlStyles.AllPaintingInWmPaint |
+ ControlStyles.SupportsTransparentBackColor |
+ ControlStyles.DoubleBuffer, true);
HandleCreated += new EventHandler (OnHandleCreatedLB);
}
DisabledLinkColor = ThemeEngine.Current.ColorGrayText;
LinkColor = Color.FromArgb (255, 0, 0, 255);
VisitedLinkColor = Color.FromArgb (255, 128, 0, 128);
- SetStyle (ControlStyles.Selectable, true);
+ SetStyle (ControlStyles.Selectable, false);
+ SetStyle (ControlStyles.Opaque, true);
}
#region Public Properties
GotFocus += new EventHandler (OnGotFocus);
LostFocus += new EventHandler (OnLostFocus);
- SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.UserPaint, false);
}
#region Events
value_member = new BindingMemberInfo (string.Empty);
display_member = string.Empty;
data_manager = null;
+ SetStyle (ControlStyles.StandardClick | ControlStyles.UserPaint, false);
}
#region Events
base.Paint += new PaintEventHandler (ListView_Paint);
SizeChanged += new EventHandler (ListView_SizeChanged);
- this.SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
}
#endregion // Public Constructors
public MdiClient() {
BackColor = SystemColors.AppWorkspace;
Dock = DockStyle.Fill;
+ SetStyle (ControlStyles.Selectable, false);
}
#endregion // Public Constructors
public MonthCalendar () {
// set up the control painting
- SetStyle (ControlStyles.UserPaint, true);
- SetStyle (ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
// mouse down timer
timer = new Timer ();
public Panel () {
base.TabStop = false;
SetStyle(ControlStyles.Selectable, false);
- SetStyle(ControlStyles.UserPaint, true);
+ SetStyle (ControlStyles.SupportsTransparentBackColor, true);
}
#endregion // Constructors & Destructors
redraw = true;
recalc = true;
allow_drop = false;
+ SetStyle (ControlStyles.Selectable, false);
+ SetStyle (ControlStyles.DoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
}
[DefaultValue(PictureBoxSizeMode.Normal)]
base.Paint += new PaintEventHandler (OnPaintPB);
base.Resize += new EventHandler (OnResizeTB);
- SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
- SetStyle (ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);
+ SetStyle (ControlStyles.UserPaint |
+ ControlStyles.Selectable |
+ ControlStyles.ResizeRedraw |
+ ControlStyles.Opaque, false);
}
#endregion // Public Constructors
base.Resize += new EventHandler (OnResizeSB);
base.TabStop = false;
- SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
- SetStyle (ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
}
#region Internal & Private Properties
#region Public Constructors
public ScrollableControl() {
SetStyle(ControlStyles.ContainerControl, true);
+ SetStyle(ControlStyles.AllPaintingInWmPaint, false);
auto_scroll = false;
auto_hscroll = false;
auto_vscroll = false;
base.Dock = DockStyle.Bottom;
Anchor = AnchorStyles.Top | AnchorStyles.Left;
this.TabStop = false;
- this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(ControlStyles.UserPaint | ControlStyles.Selectable, false);
}
#endregion // Public Constructors
public TabControl ()
{
tab_pages = new TabPageCollection (this);
- SetStyle (ControlStyles.UserPaint, true);
+ SetStyle (ControlStyles.UserPaint, false);
padding = ThemeEngine.Current.TabControlDefaultPadding;
item_size = ThemeEngine.Current.TabControlDefaultItemSize;
public TabPage ()
{
Visible = true;
+
+ SetStyle (ControlStyles.CacheText, true);
}
public TabPage (string text) : base ()
this.LostFocus +=new EventHandler(TextBox_LostFocus);
this.BackColor = ThemeEngine.Current.ColorWindow;
this.ForeColor = ThemeEngine.Current.ColorWindowText;
+
+ SetStyle (ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false);
+ SetStyle (ControlStyles.FixedHeight, true);
}
#endregion // Public Constructors
ResumeLayout ();
//SetStyle(ControlStyles.ResizeRedraw, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SetStyle(ControlStyles.UserPaint, true);
+ SetStyle(ControlStyles.UserPaint | ControlStyles.StandardClick, false);
canvas_width = ClientSize.Width;
canvas_height = ClientSize.Height;
this.MouseMove += new MouseEventHandler (ToolBar_MouseMove);
this.MouseUp += new MouseEventHandler (ToolBar_MouseUp);
base.Paint += new PaintEventHandler (ToolBar_Paint);
+
+ SetStyle (ControlStyles.UserPaint, false);
+ SetStyle (ControlStyles.FixedHeight, true);
}
#endregion Constructor
MouseMove += new MouseEventHandler (OnMouseMoveTB);
holdclick_timer.Elapsed += new ElapsedEventHandler (OnFirstClickTimer);
- SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
- SetStyle (ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);
+ SetStyle (ControlStyles.UserPaint | ControlStyles.Opaque, false);
}
#region Private & Internal Properties
MouseMove += new MouseEventHandler(MouseMoveHandler);
SizeChanged += new EventHandler (SizeChangedHandler);
- SetStyle (ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
- SetStyle (ControlStyles.UserPaint | ControlStyles.Selectable, true);
+ SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick, false);
dash = new Pen (SystemColors.ControlLight, 1);
dash.DashStyle = DashStyle.Dash;
txtView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
this.Paint +=new PaintEventHandler(UpDownBase_Paint);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SetStyle(ControlStyles.DoubleBuffer, true);
- SetStyle(ControlStyles.Opaque, true);
- SetStyle(ControlStyles.ResizeRedraw, true);
- SetStyle(ControlStyles.UserPaint, true);
+ SetStyle(ControlStyles.FixedHeight, true);
UpdateEditText();
}
driver.Exit();
}
- internal static void EraseWindowBackground(IntPtr handle, IntPtr wParam) {
- driver.EraseWindowBackground(handle, wParam);
- }
-
internal static IntPtr GetActive() {
#if DriverDebug
Console.WriteLine("GetActive(): Called");
driver.SetWindowStyle(handle, cp);
}
- internal static void SetWindowBackground(IntPtr handle, Color color) {
- #if DriverDebug
- Console.WriteLine("SetWindowBackground({0:X}, {1}): Called", handle.ToInt32(), color);
- #endif
- driver.SetWindowBackground(handle, color);
- }
-
internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom) {
#if DriverDebug
Console.WriteLine("SetZOrder({0:X}, {1:X}, {2}, {3}): Called", handle.ToInt32(), AfterhWnd.ToInt32(), Top, Bottom);
internal abstract IntPtr GetParent(IntPtr handle);
internal abstract void UpdateWindow(IntPtr handle);
- internal abstract void SetWindowBackground(IntPtr handle, Color color);
internal abstract PaintEventArgs PaintEventStart(IntPtr handle, bool client);
internal abstract void PaintEventEnd(IntPtr handle, bool client);
internal abstract void SetIcon(IntPtr handle, Icon icon);
- internal abstract void EraseWindowBackground(IntPtr handle, IntPtr wParam);
-
internal abstract void ClipboardClose(IntPtr handle);
internal abstract IntPtr ClipboardOpen();
internal abstract int ClipboardGetID(IntPtr handle, string format);
internal override IntPtr DefWndProc(ref Message msg) {
Hwnd hwnd = Hwnd.ObjectFromHandle (msg.HWnd);
switch ((Msg)msg.Msg) {
- case Msg.WM_ERASEBKGND: {
- HIViewSetNeedsDisplay (hwnd.whole_window, true);
- return (IntPtr)1;
- }
case Msg.WM_DESTROY: {
if (WindowMapping [hwnd.Handle] != null)
//Like X11 we need not do anything here
}
- internal override void EraseWindowBackground(IntPtr handle, IntPtr wParam) {
- Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
- HIViewSetNeedsDisplay (hwnd.whole_window, true);
- }
-
-
internal override void Exit() {
GetMessageResult = false;
ExitToShell ();
internal override void Invalidate (IntPtr handle, Rectangle rc, bool clear) {
Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
- if (clear)
- hwnd.erase_pending = true;
if (hwnd.visible && HIViewIsVisible (handle)) {
MSG msg = new MSG ();
msg.hwnd = hwnd.Handle;
HideCaret();
}
- if (hwnd.erase_pending) {
- NativeWindow.WndProc (hwnd.client_window, Msg.WM_ERASEBKGND, IntPtr.Zero, IntPtr.Zero);
- hwnd.erase_pending = false;
- }
-
hwnd.client_dc = Graphics.FromHwnd (hwnd.client_window);
paint_event = new PaintEventArgs(hwnd.client_dc, hwnd.invalid);
return true;
}
- internal override void SetWindowBackground(IntPtr handle, Color color) {
- Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
-
- if (WindowMapping [hwnd.Handle] != null) {
- RGBColor backColor = new RGBColor ();
- backColor.red = (short)(color.R * 257);
- backColor.green = (short)(color.G * 257);
- backColor.blue = (short)(color.B * 257);
-
- CheckError (SetWindowContentColor ((IntPtr) WindowMapping [hwnd.Handle], ref backColor));
- } else {
- WindowBackgrounds [hwnd] = color;
- }
- }
-
internal override void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
Hwnd hwnd;
Win32UpdateWindow(handle);
}
- internal override void SetWindowBackground(IntPtr handle, Color color) {
- Win32SetWindowLong(handle, WindowLong.GWL_USERDATA, (uint)color.ToArgb());
- }
-
[MonoTODO("FIXME - Add support for internal table of windows/DCs for cleanup; handle client=false to draw in NC area")]
internal override PaintEventArgs PaintEventStart(IntPtr handle, bool client) {
IntPtr hdc;
hwnd.user_data = (object)ps;
- // FIXME: Figure out why the rectangle is always 0 size
clip_rect = new Rectangle(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right-ps.rcPaint.left, ps.rcPaint.bottom-ps.rcPaint.top);
-// clip_rect = new Rectangle(rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top);
-
- if (ps.fErase != 0) {
- EraseWindowBackground(handle, hdc);
- }
} else {
hdc = Win32GetDC(handle);
// FIXME: Add the DC to internal list
Win32SendMessage(hwnd, Msg.WM_SETICON, (IntPtr)1, icon.Handle); // 1 = large icon (0 would be small)
}
- internal override void EraseWindowBackground(IntPtr hWnd, IntPtr hDc) {
- IntPtr hbr;
- LOGBRUSH lb;
- uint argb;
- RECT rect;
-
- //msg.wParam
- argb = Win32GetWindowLong(hWnd, WindowLong.GWL_USERDATA);
- lb = new LOGBRUSH();
-
- lb.lbColor.B = (byte)((argb & 0xff0000)>>16);
- lb.lbColor.G = (byte)((argb & 0xff00)>>8);
- lb.lbColor.R = (byte)(argb & 0xff);
-
- lb.lbStyle = LogBrushStyle.BS_SOLID;
- hbr = Win32CreateBrushIndirect(ref lb);
- Win32GetClientRect(hWnd, out rect);
- Win32FillRect(hDc, ref rect, hbr);
- Win32DeleteObject(hbr);
- }
-
internal override void ClipboardClose(IntPtr handle) {
if (handle != clip_magic) {
throw new ArgumentException("handle is not a valid clipboard handle");
XSendEvent(DisplayHandle, window, false, EventMask.NoEventMask, ref xev);
}
- private void SetHwndStyles(Hwnd hwnd, CreateParams cp) {
- hwnd.border_style = FormBorderStyle.None;
- if ((cp.ExStyle & (int)WindowStyles.WS_EX_WINDOWEDGE) != 0) {
- if ((cp.ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
- if ((cp.Style & (int)WindowStyles.WS_THICKFRAME) != 0) {
- hwnd.border_style = FormBorderStyle.SizableToolWindow;
- } else {
- hwnd.border_style = FormBorderStyle.FixedToolWindow;
- }
- } else if ((cp.ExStyle & (int)WindowStyles.WS_EX_DLGMODALFRAME) != 0) {
- hwnd.border_style = FormBorderStyle.FixedDialog;
- } else if ((cp.ExStyle & (int)WindowStyles.WS_THICKFRAME) != 0) {
- hwnd.border_style = FormBorderStyle.Sizable;
+
+ private void DeriveStyles(IntPtr handle, int Style, int ExStyle, out FormBorderStyle border_style, out TitleStyle title_style) {
+ Control control;
+
+ control = Control.FromHandle(handle);
+
+ if ( !(control is Form)) {
+ if (control != null) {
+ border_style = (FormBorderStyle)control.border_style;
} else {
- hwnd.border_style = FormBorderStyle.FixedSingle;
+ border_style = FormBorderStyle.None;
}
+ title_style = TitleStyle.None;
} else {
- hwnd.border_style = FormBorderStyle.Fixed3D;
- }
-
+ title_style = TitleStyle.None;
+ if ((Style & (int)WindowStyles.WS_CAPTION) != 0) {
+ if ((ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
+ title_style = TitleStyle.Tool;
+ } else {
+ title_style = TitleStyle.Normal;
+ }
+ }
- if ((cp.Style & (int)WindowStyles.WS_CAPTION) != 0) {
- if ((cp.ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
- hwnd.title_style = TitleStyle.Tool;
+ border_style = FormBorderStyle.None;
+ if ((ExStyle & (int)WindowStyles.WS_EX_WINDOWEDGE) != 0) {
+ if ((ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
+ if ((Style & (int)WindowStyles.WS_THICKFRAME) != 0) {
+ border_style = FormBorderStyle.SizableToolWindow;
+ } else {
+ border_style = FormBorderStyle.FixedToolWindow;
+ }
+ } else if ((ExStyle & (int)WindowStyles.WS_EX_DLGMODALFRAME) != 0) {
+ border_style = FormBorderStyle.FixedDialog;
+ } else if ((ExStyle & (int)WindowStyles.WS_THICKFRAME) != 0) {
+ border_style = FormBorderStyle.Sizable;
+ } else {
+ border_style = FormBorderStyle.FixedSingle;
+ }
} else {
- hwnd.title_style = TitleStyle.Normal;
+ border_style = FormBorderStyle.Fixed3D;
}
}
}
+ private void SetHwndStyles(Hwnd hwnd, CreateParams cp) {
+ DeriveStyles(hwnd.Handle, cp.Style, cp.ExStyle, out hwnd.border_style, out hwnd.title_style);
+ }
+
private void SetWMStyles(Hwnd hwnd, CreateParams cp) {
MotifWmHints mwmHints;
MotifFunctions functions;
FormBorderStyle border_style;
TitleStyle title_style;
- title_style = TitleStyle.None;
- if ((Style & (int)WindowStyles.WS_CAPTION) != 0) {
- if ((ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
- title_style = TitleStyle.Tool;
- } else {
- title_style = TitleStyle.Normal;
- }
- }
-
- border_style = FormBorderStyle.None;
- if ((ExStyle & (int)WindowStyles.WS_EX_WINDOWEDGE) != 0) {
- if ((ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
- if ((Style & (int)WindowStyles.WS_THICKFRAME) != 0) {
- border_style = FormBorderStyle.SizableToolWindow;
- } else {
- border_style = FormBorderStyle.FixedToolWindow;
- }
- } else if ((ExStyle & (int)WindowStyles.WS_EX_DLGMODALFRAME) != 0) {
- border_style = FormBorderStyle.FixedDialog;
- } else if ((ExStyle & (int)WindowStyles.WS_THICKFRAME) != 0) {
- border_style = FormBorderStyle.Sizable;
- } else {
- border_style = FormBorderStyle.FixedSingle;
- }
- } else {
- border_style = FormBorderStyle.Fixed3D;
- }
-
+ DeriveStyles(handle, Style, ExStyle, out border_style, out title_style);
WindowRect = Hwnd.GetWindowRectangle(border_style, MenuHandle, title_style, ClientRect);
return true;
hwnd = new Hwnd();
- SetHwndStyles(hwnd, cp);
-
Attributes = new XSetWindowAttributes();
X = cp.X;
Y = cp.Y;
}
}
+ ValueMask = SetWindowValuemask.BitGravity | SetWindowValuemask.WinGravity;
+
+ Attributes.bit_gravity = Gravity.NorthWestGravity;
+ Attributes.win_gravity = Gravity.NorthWestGravity;
+
// Save what's under the toolwindow
if ((cp.ExStyle & (int)WindowStyles.WS_EX_TOOLWINDOW) != 0) {
Attributes.save_under = true;
+ ValueMask |= SetWindowValuemask.SaveUnder;
}
if ((cp.Style & ((int)WindowStyles.WS_POPUP)) != 0) {
if ((cp.Style & (int)WindowStyles.WS_CAPTION) == 0) {
Attributes.override_redirect = true;
+ ValueMask |= SetWindowValuemask.OverrideRedirect;
}
}
- Attributes.bit_gravity = Gravity.NorthWestGravity;
- Attributes.win_gravity = Gravity.NorthWestGravity;
-
hwnd.x = X;
hwnd.y = Y;
hwnd.width = Width;
ClientWindow = IntPtr.Zero;
lock (XlibLock) {
- WholeWindow = XCreateWindow(DisplayHandle, ParentHandle, X, Y, Width, Height, 0, (int)CreateWindowArgs.CopyFromParent, (int)CreateWindowArgs.InputOutput, IntPtr.Zero, SetWindowValuemask.BitGravity | SetWindowValuemask.WinGravity | SetWindowValuemask.SaveUnder | SetWindowValuemask.OverrideRedirect, ref Attributes);
+ WholeWindow = XCreateWindow(DisplayHandle, ParentHandle, X, Y, Width, Height, 0, (int)CreateWindowArgs.CopyFromParent, (int)CreateWindowArgs.InputOutput, IntPtr.Zero, ValueMask, ref Attributes);
if (WholeWindow != IntPtr.Zero) {
- if (CustomVisual == IntPtr.Zero || CustomColormap == IntPtr.Zero) {
- ValueMask = SetWindowValuemask.Nothing;
- } else {
+ ValueMask &= ~(SetWindowValuemask.OverrideRedirect | SetWindowValuemask.SaveUnder);
+
+ if (CustomVisual != IntPtr.Zero && CustomColormap != IntPtr.Zero) {
ValueMask = SetWindowValuemask.ColorMap;
Attributes.colormap = CustomColormap;
}
-
ClientWindow = XCreateWindow(DisplayHandle, WholeWindow, ClientRect.X, ClientRect.Y, ClientRect.Width, ClientRect.Height, 0, (int)CreateWindowArgs.CopyFromParent, (int)CreateWindowArgs.InputOutput, CustomVisual, ValueMask, ref Attributes);
}
}
hwnd.WholeWindow = WholeWindow;
hwnd.ClientWindow = ClientWindow;
+ SetHwndStyles(hwnd, cp);
+
#if DriverDebug
Console.WriteLine("Created window {0:X} / {1:X} parent {2:X}", ClientWindow.ToInt32(), WholeWindow.ToInt32(), hwnd.parent != null ? hwnd.parent.Handle.ToInt32() : 0);
#endif
}
internal override IntPtr DefWndProc(ref Message msg) {
- switch((Msg)msg.Msg) {
- case Msg.WM_ERASEBKGND: {
- Hwnd hwnd;
-
- hwnd = Hwnd.ObjectFromHandle(msg.HWnd);
- XClearArea(DisplayHandle, hwnd.client_window, hwnd.invalid.X, hwnd.invalid.Y, hwnd.invalid.Width, hwnd.invalid.Height, false);
-
- return (IntPtr)1;
- }
- }
return IntPtr.Zero;
}
// We do nothing; On X11 SetModal is used to create modal dialogs, on Win32 this function is used (see comment there)
}
- internal override void EraseWindowBackground(IntPtr handle, IntPtr wParam) {
- Hwnd hwnd;
-
- hwnd = Hwnd.ObjectFromHandle(handle);
-
- lock (XlibLock) {
- XClearArea (DisplayHandle, hwnd.client_window, hwnd.invalid.Left, hwnd.invalid.Top, hwnd.invalid.Width, hwnd.invalid.Height, false);
- }
- }
-
internal override void Exit() {
GetMessageResult = false;
}
xevent.ExposeEvent.window = hwnd.client_window;
if (clear) {
- hwnd.erase_pending = true;
xevent.ExposeEvent.x = hwnd.X;
xevent.ExposeEvent.y = hwnd.Y;
xevent.ExposeEvent.width = hwnd.Width;
}
if (client) {
- if (hwnd.erase_pending) {
- // In our implementation WM_ERASEBKGND always returns 1; otherwise we'd check the result and only call clear if it returned 0
- NativeWindow.WndProc(hwnd.client_window, Msg.WM_ERASEBKGND, IntPtr.Zero, IntPtr.Zero);
- hwnd.erase_pending = false;
- }
-
hwnd.client_dc = Graphics.FromHwnd (hwnd.client_window);
hwnd.client_dc.SetClip(hwnd.invalid);
paint_event = new PaintEventArgs(hwnd.client_dc, hwnd.invalid);
return true;
}
- internal override void SetWindowBackground(IntPtr handle, Color color) {
- XColor xcolor;
- Hwnd hwnd;
-
- hwnd = Hwnd.ObjectFromHandle(handle);
- xcolor = new XColor();
-
- xcolor.red = (ushort)(color.R * 257);
- xcolor.green = (ushort)(color.G * 257);
- xcolor.blue = (ushort)(color.B * 257);
-
- lock (XlibLock) {
- XAllocColor(DisplayHandle, DefaultColormap, ref xcolor);
- XSetWindowBackground(DisplayHandle, hwnd.client_window, xcolor.pixel);
- XClearWindow(DisplayHandle, hwnd.client_window);
- }
- }
-
internal override void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
Hwnd hwnd;
Rectangle client_rect;