{"id":13547634,"url":"https://github.com/mono/xwt","last_synced_at":"2025-02-21T23:31:11.552Z","repository":{"id":39525869,"uuid":"2650621","full_name":"mono/xwt","owner":"mono","description":"A cross-platform UI toolkit for creating desktop applications with .NET and Mono","archived":false,"fork":false,"pushed_at":"2023-03-14T14:29:26.000Z","size":9950,"stargazers_count":1360,"open_issues_count":160,"forks_count":238,"subscribers_count":101,"default_branch":"main","last_synced_at":"2024-05-29T12:31:26.286Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mono.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2011-10-26T12:13:39.000Z","updated_at":"2024-05-20T02:39:59.000Z","dependencies_parsed_at":"2022-07-12T19:30:46.398Z","dependency_job_id":"ea05d94b-3f60-4c6b-99a1-b7aab72ab45f","html_url":"https://github.com/mono/xwt","commit_stats":{"total_commits":3100,"total_committers":124,"mean_commits":25.0,"dds":0.705483870967742,"last_synced_commit":"8108d5603f141f19129f4b0ee2a7bfca0127b65f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono%2Fxwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono%2Fxwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono%2Fxwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono%2Fxwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mono","download_url":"https://codeload.github.com/mono/xwt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219847440,"owners_count":16556385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:00:59.000Z","updated_at":"2024-10-14T11:05:16.176Z","avatar_url":"https://github.com/mono.png","language":"C#","readme":"This document is an introduction to XWT, a cross-platform UI toolkit\nfor creating desktop applications.\n\nIf you have any question about XWT or do you want to contribute\na discussion group for XWT is available here:\n\nhttp://groups.google.com/group/xwt-list\n\nIntroduction\n============\n\nXwt is a new .NET framework for creating desktop applications that run\non multiple platforms from the same codebase.   Xwt works by exposing\none unified API across all environments that is mapped to a set of\nnative controls on each platform.\n\nThis means that Xwt tends to focus on providing controls that will\nwork across all platforms. However, that doesn't mean that the\nfunctionality available is a common denominator of all platforms.\nIf a specific feature or widget is not available in the\nnative framework of a platform, it will be emulated or implemented\nas a set of native widgets.\n\nXwt can be used as a standalone framework to power the entire application\nor it can be embedded into an existing host.  This allows developers\nto develop their \"shell\" using native components (for example a Ribbon\non Windows, toolbars on Linux) and use Xwt for specific bits of the\napplication, like dialog boxes or cross platform surfaces. \n\nXwt works by creating an engine at runtime that will map to the\nunderlying platform.   These are the engines that are supported on\neach platform:\n\n* Windows: WPF engine, Gtk engine (using Gtk#)\n* MacOS X: Cocoa engine (using Xamarin.Mac) and Gtk engine (using Gtk#)\n* Linux: Gtk engine (using Gtk#)\n\nThis means for example that you can write code for Xwt on Windows that\ncan be hosted on an existing WPF application (like Visual Studio) or\nan existing Gtk# application (like MonoDevelop).   Or on Mac, you can\nhost Xwt on an existing Cocoa/Xamarin.Mac application or you can host it\nin our own MonoDevelop IDE.\n\nGetting Started\n---------------\n\nOpen the Xwt.sln with MonoDevelop (or VisualStudio on Windows) and\nbuild the solution.   You should end up with the libraries that you\ncan use in your project and a couple of sample applications.\n\nUsing Xwt in your app\n---------------------\n\nBased on your platform and the backend that you want to use, you need\nto pick the libraries that you want to use in your project.\n\n* Windows+WPF: Xwt.dll + Xwt.WPF.dll (requires WPF)\n* Windows+Gtk: Xwt.dll + Xwt.Gtk.dll (requires Gtk#)\n* Linux+Gtk: Xwt.dll + Xwt.Gtk.dll (requires Gtk#)\n* Mac+Gtk: Xwt.dll + Xwt.Gtk.dll (requires Gtk#)\n* Mac+Cocoa: Xwt.dll + Xwt.XamMac.dll (requires Xamarin.Mac.dll)\n\nHello World\n-----------\n\nTo write your first application, create an empty .NET project in your\nfavorite language in MonoDevelop or Visual Studio and reference the\nXwt.dll library. This is the only library that you need to reference\nat compile time.\n\nThis is the simplest Xwt program you can write:\n\n```cs\nusing System;\nusing Xwt;\n\nclass XwtDemo\n{\n    [STAThread]\n    static void Main()\n    {\n        Application.Initialize(ToolkitType.Gtk);\n        var mainWindow = new Window()\n        {\n            Title = \"Xwt Demo Application\",\n            Width = 500,\n            Height = 400\n        };\n        mainWindow.Show();\n        Application.Run();\n        mainWindow.Dispose();\n    }\n}\n```\n\nYou use the `Application.Initialize()` method to get the backend\ninitialized. In this example we are using the Gtk backend. If you\nwant to use another backend, just change the parameter provided\nto the `Initialize()` method. Also make sure the appropiate backend\nDLL is available in the application directory.\n\nThen we create an instance of the Window class, this class exposes two\ninteresting properties, MainMenu which can be used to set the Window's\nmain menu and \"Content\" which is of type \"Widget\" and allows you to\nadd some content to the window.\n\nFinally, the Application.Run method is called to get the UI events\nprocessing going.\n\nWidget Class Hierarchy\n======================\n\nYou will be using widgets to create the contents for your\napplication.   Xwt.Widget is the abstract base class from which all\nthe other components are created.  \n\nSome Widgets can contain other widgets, these are container widgets,\nand in Xwt those are Canvas, Paned, HBox, VBox and Table.  The first\ntwo implement a box layout system, while the last one implements a\nTable layout that allows widgets to be attached to different\nanchor-points in a grid.\n\nThe layout system uses an auto-sizing system similar to what is\navailble in Gtk and HTML allowing the user interface to grow or shrink\nbased on the contents of the childrens on it.\n\n* XwtComponent \n    * Menu\n    * MenuItem\n    * Widget\n        * Box (Container)\n            * HBox (Container)\n            * VBox (Container)\n        * Button\n            * MenuButton\n            * ToggleButton\n        * Calendar\n        * Canvas (Container)\n        * Checkbox\n        * ComboBox\n        * Frame\n        * ImageView\n        * Label\n        * ListView\n        * NoteBook\n        * Paned (Container)\n            * HPaned (Container)\n            * VPaned (Container)\n        * ProgressBar\n        * ScrollView\n        * Separator\n            * VSeparator\n            * HSeparator\n        * Table (Container)\n        * TextEntry\n        * TreeView\n    * WindowFrame\n        * Window\n            * Dialog\n\nFor example, the following attaches various labels and data entries to\na Table:\n\n```cs\nvar table = new Table();\ntable.Attach(new Label (\"One:\"), 0, 1, 0, 1);\ntable.Attach(new TextEntry (), 1, 2, 0, 1);\ntable.Attach(new Label (\"Two:\"), 0, 1, 1, 2);\ntable.Attach(new TextEntry (), 1, 2, 1, 2);\ntable.Attach(new Label (\"Three:\"), 0, 1, 2, 3);\ntable.Attach(new TextEntry (), 1, 2, 2, 3);\n```\n\nThe Application Class\n=====================\n\nThe Application class is a static class that provides services to run\nyour application.  \n\nInitialization \n--------------\n\nThe Application.Initialize API will instruct Xwt to initialize its\nbinding to the native toolkit. You can pass an optional parameter to\nthis method that specifies the full type name to load as the backend.\n\nFor example, you can force the initialization of the backend to be\nspecifically Gtk+ or specifically Xamarin.Mac based on MacOS.   This is\ncurrently done like this:\n\n\tApplication.Initialize(\"Xwt.GtkBackend.GtkEngine, Xwt.Gtk, Version=1.0.0.0\");\n\nor:\n\n\tApplication.Initialize(\"Xwt.Mac.MacEngine, Xwt.XamMac, Version=1.0.0.0\");\n\nAs you saw from the Hello World sample, toplevel windows are created\nby creating an instance of the \"Xwt.Window\" class.   This class\nexposes a couple of properties that you can use to spice it up.   The\nMainMenu property is used to control the contents of the application\nmenus while the \"Content\" property is used to hold a Widget.\n\nTimers\n------\n\nThe Application.TimeoutInvoke method takes a timespan and a Func\u003cbool\u003e\naction method and invokes that method in the main user interface\nloop.  \n\nIf the provided function returns true, then the timer is restarted,\notherwise the timer ends.\n\nBackground Threads\n------------------\n\nIt is very common to perform tasks in the background and for those\ntasks in the background to later update the user interface.   The Xwt\nAPI is not thread safe, which means that calls to the Xwt API must\nonly be done from the main user interface thread.\n\nThis is a trait from the underlying toolkits used by Xwt.\n\nIf you want a background thread to run some code on the main loop, you\nuse the Application.Invoke (Action action) method.   The provided\n\"action\" method is guaranteed to run on the main loop.\n\n","funding_links":[],"categories":["C# #","GUI"],"sub_categories":["GUI - Framework"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmono%2Fxwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmono%2Fxwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmono%2Fxwt/lists"}