public Graphic(IntPtr display, TInt screenNumber, X11Graphic.StockIcon stock, X11Graphic image) { Display = display; ScreenNumber = screenNumber; Stock = stock; Image = image; }
/// <summary> Set right bitmap and bitmap shared flag. </summary> /// <param name="rightBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="rightShared"> Indicate wether the rightBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public void SetRightBitmap(X11Graphic rightBitmap, bool rightShared) { if (_rightBitmap != null && _rightBitmapShared == false) { _rightBitmap.Dispose(); _rightBitmap = null; } _rightBitmap = rightBitmap; _rightBitmapShared = rightShared; }
/// <summary> Set left bitmap and bitmap shared flag. </summary> /// <param name="leftBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="leftShared"> Indicate wether the leftBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public void SetLeftBitmap(X11Graphic leftBitmap, bool leftShared) { if (_leftBitmap != null && _leftBitmapShared == false) { _leftBitmap.Dispose(); _leftBitmap = null; } _leftBitmap = leftBitmap; _leftBitmapShared = leftShared; }
/// <summary> Set on bitmap. </summary> /// <param name="onBitmap"> The on bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="onShared"> Indicate wether the onBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public void SetOnBitmap(X11Graphic onBitmap, bool onShared) { if (_onBitmap != null && _onBitmapShared == false) { _onBitmap.Dispose(); _onBitmap = null; } _onBitmap = onBitmap; _onBitmapShared = onShared; }
/// <summary> Initializing constructor. </summary> /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param> /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param> /// <param name="parentWindow"> The X11 *** parent *** window for X11 calls. This widget has no X11 *** own *** window. <see cref="System.IntPtr"/> </param> /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). Passed as reference to avoid structure copy constructor calls. <see cref="TPoint"/> </param> /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TIntSize"/> </param> /// <param name="label"> The label to display. <see cref="System.String"/> </param> /// <param name="leftBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="leftShared"> Indicate wether the leftBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> /// <param name="rightBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="rightShared"> Indicate wether the rightBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public XrwLabel(IntPtr display, X11.TInt screenNumber, IntPtr parentWindow, ref TPoint assignedPosition, ref TSize fixedSize, string label, X11Graphic leftBitmap, bool leftShared, X11Graphic rightBitmap, bool rightShared) : base(display, screenNumber, parentWindow, ref assignedPosition, ref fixedSize) { _label = label; _lines = new Multiline(this, _label); _leftBitmap = leftBitmap; _leftBitmapShared = leftShared; _rightBitmap = rightBitmap; _rightBitmapShared = rightShared; InitializeLabelRessources(); }
/// <summary> Dispose by parent. </summary> public override void DisposeByParent() { if (_offBitmap != null && _offBitmapShared == false) { _offBitmap.Dispose(); _offBitmap = null; } if (_onBitmap != null && _onBitmapShared == false) { _onBitmap.Dispose(); _onBitmap = null; } base.DisposeByParent(); }
/// <summary> Dispose by parent. </summary> public override void DisposeByParent() { if (_leftBitmap != null && _leftBitmapShared == false) { _leftBitmap.Dispose(); _leftBitmap = null; } if (_rightBitmap != null && _rightBitmapShared == false) { _rightBitmap.Dispose(); _rightBitmap = null; } base.DisposeByParent(); }
// ############################################################################### // ### M E T H O D S // ############################################################################### #region Methods /// <summary> Load the icon from indicated path and set it as shell icon. </summary> /// <returns> <c>true</c>, if icon was set, <c>false</c> otherwise. </returns> /// <param name='iconPath'> The icon path. </param> public bool SetShellIcon(string iconPath) { bool result = false; if (_shell == IntPtr.Zero) { Console.WriteLine(CLASS_NAME + "::SetShellIcon() ERROR: Member attribute '_shell' null."); return(result); } if (string.IsNullOrEmpty(iconPath)) { Console.WriteLine(CLASS_NAME + "::SetShellIcon() ERROR: Paramerter 'iconPath' null or empty."); return(result); } IntPtr display = Xtlib.XtDisplay(_shell); IntPtr window = Xtlib.XtWindow(_shell); TInt screenNumber = Xtlib.XDefaultScreen(display); using (X11Graphic appIcon = new X11Graphic(display, (int)screenNumber, IntPtr.Zero, X11lib.XDefaultDepth(display, screenNumber), iconPath)) { _appIconPixMap = appIcon.CreateIndependentGraphicPixmap(display, window); _appMaskPixMap = appIcon.CreateIndependentMaskPixmap(display, window); if (_appIconPixMap != IntPtr.Zero && _appMaskPixMap != IntPtr.Zero) { X11lib.XWMHints wmHints = new X11lib.XWMHints(); IntPtr wmAddr = X11lib.XAllocWMHints(ref wmHints); wmHints.flags = X11lib.XWMHintMask.IconPixmapHint | X11lib.XWMHintMask.IconPositionHint | X11lib.XWMHintMask.IconMaskHint; wmHints.icon_pixmap = _appIconPixMap; wmHints.icon_mask = _appMaskPixMap; wmHints.icon_x = 0; wmHints.icon_y = 0; X11lib.XSetWMHints(display, window, ref wmHints); X11lib.XFree(wmAddr); result = true; } else { Console.WriteLine(CLASS_NAME + "::SetShellIcon () ERROR: Can not create application icon."); } } return(result); }
/// <summary> Initializing constructor. </summary> /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param> /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param> /// <param name="parentWindow"> The X11 *** parent *** window for X11 calls. This widget has no X11 *** own *** window. <see cref="System.IntPtr"/> </param> /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). Passed as reference to avoid structure copy constructor calls. <see cref="TPoint"/> </param> /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TIntSize"/> </param> /// <param name="label"> The label to display. <see cref="System.String"/> </param> /// <param name="offBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="offShared"> Indicate wether the offBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> /// <param name="onBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="onShared"> Indicate wether the onBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public XrwToggle(IntPtr display, X11.TInt screenNumber, IntPtr parentWindow, ref TPoint assignedPosition, ref TSize fixedSize, string label, X11Graphic offBitmap, bool offShared, X11Graphic onBitmap, bool onShared) : base(display, screenNumber, parentWindow, ref assignedPosition, ref fixedSize) { _label = label; _lines = new Multiline(this, _label); _offBitmap = offBitmap; _offBitmapShared = offShared; _onBitmap = onBitmap; _onBitmapShared = onShared; // Create a *** own *** window and exchange the *** parent *** window against it. base.InitializeOwnWindow(); InitializeToggleRessources(); }
// --------------------------------------------------------------------------- // --- M E T H O D S // --------------------------------------------------------------------------- #region Methods public X11Graphic Graphic(IntPtr display, TInt screenNumber, X11Graphic.StockIcon stock) { for (int count = 0; count < this.Count; count++) { Graphic gr1 = this[count]; if (gr1.Stock == stock && gr1.Display == display && gr1.ScreenNumber == screenNumber) { return(gr1.Image); } } X11Graphic image = new X11Graphic(display, screenNumber, stock); if (image == null) { return(null); } Graphic gr2 = new Graphic(display, screenNumber, stock, image); this.Add(gr2); return(image); }
/// <summary> Set the shell icon for a WM shell. </summary> /// <param name="application"> The WM shell to set the icon for. <see cref="XrwWmShell"/> </param> /// <param name="iconPath"> The path (relative, if applicable) to the icon to set. <see cref="System.String"/> </param> /// <returns> Returns true on success, or false otherwise. <see cref="System.Boolean"/> </returns> public static bool SetWmShellIcon(XrwWmShell application, string iconPath) { bool result = false; if (application == null) { Console.WriteLine(CLASS_NAME + "::SetWmShellIcon() ERROR: Paramerter 'application' null."); return(result); } if (string.IsNullOrEmpty(iconPath)) { Console.WriteLine(CLASS_NAME + "::SetWmShellIcon() ERROR: Paramerter 'iconPath' null or empty."); return(result); } using (X11Graphic appIcon = new X11Graphic(application.Display, application.Screen, iconPath)) { IntPtr appGraphicPixMap = appIcon.CreateIndependentGraphicPixmap(application.Display, application.Window); IntPtr appMaskPixMap = appIcon.CreateIndependentMaskPixmap(application.Display, application.Window); if (appGraphicPixMap != IntPtr.Zero && appMaskPixMap != IntPtr.Zero) { X11lib.XWMHints wmHints = X11lib.XAllocWMHints(); wmHints.flags = X11lib.XWMHintMask.IconPixmapHint | X11lib.XWMHintMask.IconPositionHint | X11lib.XWMHintMask.IconMaskHint; wmHints.icon_pixmap = appGraphicPixMap; wmHints.icon_mask = appMaskPixMap; wmHints.icon_x = 0; wmHints.icon_y = 0; X11lib.XSetWMHints(application.Display, application.Window, ref wmHints); result = true; } else { Console.WriteLine(CLASS_NAME + "::SetWmShellIcon () ERROR: Can not create application icon."); } } return(result); }
/// <summary> Initializing constructor. </summary> /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param> /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param> /// <param name="parentWindow"> The X11 *** parent *** window for X11 calls. This widget has no X11 *** own *** window. <see cref="System.IntPtr"/> </param> /// <param name="label"> The label to display. <see cref="System.String"/> </param> /// <param name="leftBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="leftShared"> Indicate wether the leftBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> /// <param name="rightBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="rightShared"> Indicate wether the rightBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public XrwSme(IntPtr display, X11.TInt screenNumber, IntPtr parentWindow, string label, X11Graphic leftBitmap, bool leftShared, X11Graphic rightBitmap, bool rightShared) : base(display, screenNumber, parentWindow, label, leftBitmap, leftShared, rightBitmap, rightShared) { InitializeSmeRessources(); }
/// <summary> Initializing constructor. </summary> /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param> /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param> /// <param name="parentWindow"> The X11 *** parent *** window for X11 calls. This widget has no X11 *** own *** window. <see cref="System.IntPtr"/> </param> /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). Passed as reference to avoid structure copy constructor calls. <see cref="TPoint"/> </param> /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TIntSize"/> </param> /// <param name="label"> The label to display. <see cref="System.String"/> </param> /// <param name="leftBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="leftShared"> Indicate wether the leftBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> /// <param name="rightBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="rightShared"> Indicate wether the rightBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public XrwCommand(IntPtr display, X11.TInt screenNumber, IntPtr parentWindow, ref TPoint assignedPosition, ref TSize fixedSize, string label, X11Graphic leftBitmap, bool leftShared, X11Graphic rightBitmap, bool rightShared) : base(display, screenNumber, parentWindow, ref assignedPosition, ref fixedSize, label, leftBitmap, leftShared, rightBitmap, rightShared) { // Create a *** own *** window and exchange the *** parent *** window against it. base.InitializeOwnWindow(); InitializeCommandRessources(); }
/// <summary> Initializing constructor. </summary> /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="IntPtr"/> </param> /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param> /// <param name="parentWindow"> The X11 *** parent *** window that will be the parent for an X11 *** own ** window. <see cref="IntPtr"/> </param> /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. <see cref="TIntSize"/> </param> /// <param name="label"> The label to display. <see cref="System.String"/> </param> /// <param name="offBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="offShared"> Indicate wether the offBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> /// <param name="onBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="onShared"> Indicate wether the onBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public XrwRadio(IntPtr display, X11.TInt screen, IntPtr parentWindow, ref TSize fixedSize, string label, X11Graphic offBitmap, bool offShared, X11Graphic onBitmap, bool onShared) : base(display, screen, parentWindow, ref fixedSize, label, offBitmap, offShared, onBitmap, onShared) { }
/// <summary> Initializing constructor. </summary> /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="IntPtr"/> </param> /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param> /// <param name="parentWindow"> The X11 *** parent *** window that will be the parent for an X11 *** own ** window. <see cref="IntPtr"/> </param> /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). <see cref="TPoint"/> </param> /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. <see cref="TIntSize"/> </param> /// <param name="label"> The label to display. <see cref="System.String"/> </param> /// <param name="offBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="offShared"> Indicate wether the offBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> /// <param name="onBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="onShared"> Indicate wether the onBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public XrwRadio(IntPtr display, X11.TInt screenNumber, IntPtr parentWindow, ref TPoint assignedPosition, ref TSize fixedSize, string label, X11Graphic offBitmap, bool offShared, X11Graphic onBitmap, bool onShared) : base(display, screenNumber, parentWindow, ref assignedPosition, ref fixedSize, label, offBitmap, offShared, onBitmap, onShared) { }
/// <summary> Initialize local ressources for all constructors. </summary> public void InitializeMessageBoxResources() { XrwBox vboxMain = XrwBox.NewVBox(_display, _screenNumber, _window); vboxMain.BorderWidth = 0; vboxMain.VertSpacing = 0; AddChild(vboxMain); vboxMain.Show(); XrwBox hboxContentArea = XrwBox.NewHBox(_display, _screenNumber, _window); hboxContentArea.ExpandToAvailableHeight = true; vboxMain.AddChild(hboxContentArea); hboxContentArea.Show(); X11Graphic graphic = null; if (_image != X11Graphic.StockIcon.None) { graphic = new X11Graphic(_display, _screenNumber, _image); } XrwLabel _labelMessage = new XrwLabel(_display, _screenNumber, _window, _message, graphic, false, null, false); _labelMessage.FrameType = TFrameType.Sunken; _labelMessage.FrameWidth = XrwTheme.InteractingFrameWidth; _labelMessage.HorzTextAlign = 0.0F; _labelMessage.ExpandToAvailableHeight = true; hboxContentArea.AddChild(_labelMessage); _labelMessage.Show(); XrwBox hboxActionArea = XrwBox.NewHBox(_display, _screenNumber, _window); hboxActionArea.BorderWidth = 2; hboxActionArea.ChildAlign = 1.0F; hboxActionArea.BorderColor = hboxActionArea.BackgroundColor; vboxMain.AddChild(hboxActionArea); hboxActionArea.Show(); X11Graphic cancelGraphic = XrwTheme.GetGraphic(_display, _screenNumber, X11Graphic.StockIcon.Cancel16TrueColor); XrwCommand cbCancel = new XrwCommand(_display, _screenNumber, _window, "Cancel", cancelGraphic, true, null, false); cbCancel.ExpandToMaxSiblingWidth = true; cbCancel.HorzTextAlign = 0.5F; cbCancel.ButtonRelease += HandleCbCancelButtonRelease; hboxActionArea.AddChild(cbCancel); cbCancel.Show(); X11Graphic okGraphic = XrwTheme.GetGraphic(_display, _screenNumber, X11Graphic.StockIcon.Ok16TrueColor); XrwCommand cbOk = new XrwCommand(_display, _screenNumber, _window, "OK", okGraphic, true, null, false); cbOk.ExpandToMaxSiblingWidth = true; cbOk.HorzTextAlign = 0.5F; cbOk.ButtonRelease += HandleCbOkButtonRelease; hboxActionArea.AddChild(cbOk); cbOk.Show(); CalculateChildLayout(); _assignedSize = vboxMain.AssignedSize; _assignedSize.Width += 2 * _borderWidth; _assignedSize.Height += 2 * _borderWidth; TPoint position = new TPoint(0, 0); MoveResize(ref position, ref _assignedSize); X11lib.XSetWMName(_display, _window, _title); }
/// <summary> Initializing constructor. </summary> /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param> /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param> /// <param name="parentWindow"> The X11 *** parent *** window for X11 calls. This widget has no X11 *** own *** window. <see cref="System.IntPtr"/> </param> /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). Passed as reference to avoid structure copy constructor calls. <see cref="TPoint"/> </param> /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TIntSize"/> </param> /// <param name="label"> The label to display. <see cref="System.String"/> </param> /// <param name="leftBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="leftShared"> Indicate wether the leftBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> /// <param name="rightBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param> /// <param name="rightShared"> Indicate wether the rightBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param> public XrwSme(IntPtr display, X11.TInt screenNumber, IntPtr parentWindow, ref TPoint assignedPosition, ref TSize fixedSize, string label, X11Graphic leftBitmap, bool leftShared, X11Graphic rightBitmap, bool rightShared) : base(display, screenNumber, parentWindow, ref assignedPosition, ref fixedSize, label, leftBitmap, leftShared, rightBitmap, rightShared) { InitializeSmeRessources(); }