* Control.cs : ContextMenu, CanSelect, force parent to perform layout when Dock property changes
* GroupBox.cs
* Label.cs
* Panel.cs
* PictureBox.cs
* Splitter.cs
* ProgressBar.cs : remove Selectable style
* RadioButton.cs : set TextAlign to MiddleLeft by default
* tooltip.cs : override Dispose method
* win32Enums.cs
* win32functions.cs : flags and function for context menu
svn path=/trunk/mcs/; revision=15319
+2003-06-09 Aleksey Ryabchuk <ryabchuk@yahoo.com>
+ * ContextMenu.cs : SourceControl, Show method
+ * Control.cs : ContextMenu, CanSelect, force parent to perform layout when Dock property changes
+ * GroupBox.cs
+ * Label.cs
+ * Panel.cs
+ * PictureBox.cs
+ * Splitter.cs
+ * ProgressBar.cs : remove Selectable style
+ * RadioButton.cs : set TextAlign to MiddleLeft by default
+ * tooltip.cs : override Dispose method
+ * win32Enums.cs
+ * win32functions.cs : flags and function for context menu
+
2003-06-09 Aleksey Ryabchuk <ryabchuk@yahoo.com>
* Conrols.cs : Disposing property, Dispose method
* Cursor.cs : Show, Hide, Copy cursor
namespace System.Windows.Forms {
/// <summary>
- /// Represents a Windows combo box control.
+ /// Represents a shortcut menu
/// </summary>
[MonoTODO]
// private fields
RightToLeft rightToLeft;
+ Control sourceControl;
// --- Constructor ---
[MonoTODO]
public ContextMenu() : base(null)
{
rightToLeft = RightToLeft.Inherit;
+ sourceControl = null;
}
[MonoTODO]
set { rightToLeft=value; }
}
- [MonoTODO]
public Control SourceControl {
- get { throw new NotImplementedException (); }
+ get { return sourceControl; }
}
/// --- Methods ---
/// internal .NET framework supporting methods, not stubbed out:
/// - protected internal virtual void OnPopup(EventArgs e);
[MonoTODO]
- public void Show(Control control,Point pos)
+ public void Show(Control control, Point pos)
{
- //FIXME:
+ if ( Handle == IntPtr.Zero )
+ return;
+
+ sourceControl = control;
+
+ POINT pt = new POINT ();
+ pt.x = pos.X;
+ pt.y = pos.Y;
+
+ Win32.ClientToScreen ( control.Handle, ref pt );
+ Win32.TrackPopupMenu ( Handle, ( uint ) ( TrackPopupMenuFlags.TPM_LEFTALIGN | TrackPopupMenuFlags.TPM_RIGHTBUTTON ),
+ pt.x, pt.y, 0, control.Handle , IntPtr.Zero );
}
/// events
Rectangle oldBounds;
bool causesValidation;
- //ContextMenu contextMenu;
+ ContextMenu contextMenu;
DockStyle dock;
bool enabled;
Font font;
oldBounds = new Rectangle();
// bindingContext = null;
causesValidation = true;
- // contextMenu = null;
+ contextMenu = null;
dock = DockStyle.None;
enabled = true;
// font = Control.DefaultFont;
[MonoTODO]
public bool CanSelect {
get {
- // if (ControlStyles.Selectable &&
- // isContainedInAnotherControl &&
- // parentIsVisiable && isVisialbe &&
- // parentIsEnabled && isEnabled) {
- // return true;
- // }
- // return false;
-
- throw new NotImplementedException ();
+ if ( !GetStyle ( ControlStyles.Selectable ) )
+ return false;
+
+ if ( Parent == null )
+ return false;
+
+ Control parent = Parent;
+ while ( parent != null ) {
+ if ( !parent.Visible || !parent.Enabled )
+ return false;
+ parent = parent.Parent;
+ }
+
+ return true;
}
}
[MonoTODO]
public virtual ContextMenu ContextMenu {
get {
- //return contextMenu;
- throw new NotImplementedException ();
+ return contextMenu;
}
set {
- //contextMenu=value;
- throw new NotImplementedException ();
+ if ( contextMenu != value ) {
+ contextMenu = value;
+ OnContextMenuChanged ( EventArgs.Empty );
+ }
}
}
protected virtual void OnDockChanged (EventArgs e)
{
- PerformLayout ( this, "Dock" );
+ // changing this property does not affect the control directly
+ // so have its parent to calculate new layout
+ if ( Parent != null )
+ Parent.PerformLayout ( this, "Dock" );
if (DockChanged != null)
DockChanged (this, e);
}
} else
CallControlWndProc( ref m );
break;
+ case Msg.WM_RBUTTONDOWN:
+ if ( contextMenu != null ) {
+ contextMenu.Show ( this,
+ new Point ( Win32.HIGH_ORDER ( m.LParam.ToInt32() ),
+ Win32.LOW_ORDER ( m.LParam.ToInt32() ) ) );
+ }
+ CallControlWndProc( ref m );
+ break;
default:
CallControlWndProc(ref m);
/*
[MonoTODO]
public GroupBox() {
SetStyle ( ControlStyles.UserPaint, true);
+ SetStyle ( ControlStyles.Selectable, false );
TabStop = false;
flatStyle = FlatStyle.Standard;
}
autoSize = false;\r
borderStyle = BorderStyle.None;\r
base.TabStop = false;\r
- //Defaults not in the spec\r
- Image backgroundImage;\r
- Image image;\r
- ContentAlignment imageAlign;\r
- ImeMode defaultImeMode;\r
- bool renderTransparent;\r
- FlatStyle flatStyle;\r
- int preferredHeight;\r
- int preferredWidth;\r
- bool tabStop;\r
- ContentAlignment textAlign;\r
- bool useMnemonic;\r
-\r
+ \r
SubClassWndProc_ = true;\r
+ SetStyle ( ControlStyles.Selectable, false );
}\r
\r
//\r
//
[MonoTODO]
public Panel() {
- controlStyles_ |= ControlStyles.UserPaint;
+ SetStyle ( ControlStyles.Selectable, false );
+ SetStyle ( ControlStyles.UserPaint, true );
}
//
sizeMode = PictureBoxSizeMode.Normal;
borderStyle = BorderStyle.None;
SetStyle ( ControlStyles.UserPaint, true );
+ SetStyle ( ControlStyles.Selectable, false );
}
public BorderStyle BorderStyle {
#region Constructor
public ProgressBar() {
+ SetStyle ( ControlStyles.Selectable, false );
}
#endregion
autoCheck = true;
checkAlign = ContentAlignment.MiddleLeft;
checked_ = false;
+ TextAlign = ContentAlignment.MiddleLeft;
}
public Appearance Appearance {
[MonoTODO]
public Splitter()
{
-
+ SetStyle ( ControlStyles.Selectable, false );
}
//
Marshal.FreeHGlobal ( ptr );
}
}
+
+ protected override void Dispose( bool disposing )
+ {
+ lock ( this ) {
+ try {
+ if ( disposing ) {
+ tooltipWnd.DestroyHandle ( );
+ }
+ }
+ finally {
+ base.Dispose ( disposing );
+ }
+ }
+ }
}
}
CDN_TYPECHANGE = (CDN_FIRST - 0x0006),
CDN_INCLUDEITEM = (CDN_FIRST - 0x0007)
}
+
+ [Flags]
+ internal enum TrackPopupMenuFlags : int {
+ TPM_LEFTBUTTON = 0x0000,
+ TPM_RIGHTBUTTON = 0x0002,
+ TPM_LEFTALIGN = 0x0000,
+ TPM_CENTERALIGN = 0x0004,
+ TPM_RIGHTALIGN = 0x0008,
+ TPM_TOPALIGN = 0x0000,
+ TPM_VCENTERALIGN = 0x0010,
+ TPM_BOTTOMALIGN = 0x0020,
+ TPM_HORIZONTAL = 0x0000,
+ TPM_VERTICAL = 0x0040,
+ TPM_NONOTIFY = 0x0080,
+ TPM_RETURNCMD = 0x0100,
+ TPM_RECURSE = 0x0001
+ }
}
internal static extern IntPtr GetActiveWindow ( );
[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
internal static extern IntPtr GetForegroundWindow ( );
+
+ [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
+ internal static extern bool TrackPopupMenu( IntPtr hMenu, uint uFlags, int x, int y, int nReserved,
+ IntPtr hWnd, IntPtr prcRect );
+
#endregion
#region Shell32.dll functions