Require backends to actually implement the interface they are registered for

This commit is contained in:
Alex Corrado 2013-02-05 14:25:29 -05:00
Родитель 612020a039
Коммит b652747170
5 изменённых файлов: 120 добавлений и 117 удалений

Просмотреть файл

@ -42,68 +42,68 @@ namespace Xwt.GtkBackend
public override void InitializeBackends ()
{
RegisterBackend (typeof(ICustomWidgetBackend), typeof(CustomWidgetBackend));
RegisterBackend (typeof(IWindowBackend), typeof(WindowBackend));
RegisterBackend (typeof(ILabelBackend), typeof(LabelBackend));
RegisterBackend (typeof(IBoxBackend), typeof(BoxBackend));
RegisterBackend (typeof(IButtonBackend), typeof(ButtonBackend));
RegisterBackend (typeof(INotebookBackend), typeof(NotebookBackend));
RegisterBackend (typeof(ITreeViewBackend), typeof(TreeViewBackend));
RegisterBackend (typeof(ITreeStoreBackend), typeof(TreeStoreBackend));
RegisterBackend (typeof(IListViewBackend), typeof(ListViewBackend));
RegisterBackend (typeof(IListStoreBackend), typeof(ListStoreBackend));
RegisterBackend (typeof(ICanvasBackend), typeof(CanvasBackend));
RegisterBackend (typeof(ImageBackendHandler), typeof(ImageHandler));
RegisterBackend<ICustomWidgetBackend, CustomWidgetBackend> ();
RegisterBackend<IWindowBackend, WindowBackend> ();
RegisterBackend<ILabelBackend, LabelBackend> ();
RegisterBackend<IBoxBackend, BoxBackend> ();
RegisterBackend<IButtonBackend, ButtonBackend> ();
RegisterBackend<INotebookBackend, NotebookBackend> ();
RegisterBackend<ITreeViewBackend, TreeViewBackend> ();
RegisterBackend<ITreeStoreBackend, TreeStoreBackend> ();
RegisterBackend<IListViewBackend, ListViewBackend> ();
RegisterBackend<IListStoreBackend, ListStoreBackend> ();
RegisterBackend<ICanvasBackend, CanvasBackend> ();
RegisterBackend<ImageBackendHandler, ImageHandler> ();
#if USE_PANGO
RegisterBackend (typeof(Xwt.Backends.ContextBackendHandler), typeof(ContextBackendHandlerWithPango));
RegisterBackend (typeof(TextLayoutBackendHandler), typeof(GtkTextLayoutBackendHandler));
RegisterBackend<Xwt.Backends.ContextBackendHandler, ContextBackendHandlerWithPango> ();
RegisterBackend<TextLayoutBackendHandler, GtkTextLayoutBackendHandler> ();
#else
WidgetRegistry.RegisterBackend (typeof(ContextBackendHandler), typeof(ContextBackendHandler));
WidgetRegistry.RegisterBackend (typeof(TextLayoutBackendHandler), typeof(CairoTextLayoutBackendHandler));
WidgetRegistry.RegisterBackend<ContextBackendHandler, ContextBackendHandler> ();
WidgetRegistry.RegisterBackend<TextLayoutBackendHandler, CairoTextLayoutBackendHandler> ();
#endif
RegisterBackend (typeof(DrawingPathBackendHandler), typeof(CairoContextBackendHandler));
RegisterBackend (typeof(GradientBackendHandler), typeof(CairoGradientBackendHandler));
RegisterBackend (typeof(FontBackendHandler), typeof(GtkFontBackendHandler));
RegisterBackend (typeof(IMenuBackend), typeof(MenuBackend));
RegisterBackend (typeof(IMenuItemBackend), typeof(MenuItemBackend));
RegisterBackend (typeof(ICheckBoxMenuItemBackend), typeof(CheckBoxMenuItemBackend));
RegisterBackend (typeof(IRadioButtonMenuItemBackend), typeof(RadioButtonMenuItemBackend));
RegisterBackend (typeof(ISeparatorMenuItemBackend), typeof(SeparatorMenuItemBackend));
RegisterBackend (typeof(IScrollViewBackend), typeof(ScrollViewBackend));
RegisterBackend (typeof(IComboBoxBackend), typeof(ComboBoxBackend));
RegisterBackend (typeof(IDesignerSurfaceBackend), typeof(DesignerSurfaceBackend));
RegisterBackend (typeof(IMenuButtonBackend), typeof(MenuButtonBackend));
RegisterBackend (typeof(ITextEntryBackend), typeof(TextEntryBackend));
RegisterBackend (typeof(IToggleButtonBackend), typeof(ToggleButtonBackend));
RegisterBackend (typeof(IImageViewBackend), typeof(ImageViewBackend));
RegisterBackend (typeof(IAlertDialogBackend), typeof(AlertDialogBackend));
RegisterBackend (typeof(ICheckBoxBackend), typeof(CheckBoxBackend));
RegisterBackend (typeof(IFrameBackend), typeof(FrameBackend));
RegisterBackend (typeof(ISeparatorBackend), typeof(SeparatorBackend));
RegisterBackend (typeof(IDialogBackend), typeof(DialogBackend));
RegisterBackend (typeof(IComboBoxEntryBackend), typeof(ComboBoxEntryBackend));
RegisterBackend (typeof(ClipboardBackend), typeof(GtkClipboardBackend));
RegisterBackend (typeof(ImagePatternBackendHandler), typeof(GtkImagePatternBackendHandler));
RegisterBackend (typeof(ImageBuilderBackendHandler), typeof(ImageBuilderBackend));
RegisterBackend (typeof(IScrollAdjustmentBackend), typeof(ScrollAdjustmentBackend));
RegisterBackend (typeof(IOpenFileDialogBackend), typeof(OpenFileDialogBackend));
RegisterBackend (typeof(ISaveFileDialogBackend), typeof(SaveFileDialogBackend));
RegisterBackend (typeof(ISelectFolderDialogBackend), typeof(SelectFolderDialogBackend));
RegisterBackend (typeof(IPanedBackend), typeof(PanedBackend));
RegisterBackend (typeof(ISelectColorDialogBackend), typeof(SelectColorDialogBackend));
RegisterBackend (typeof(IListBoxBackend), typeof(ListBoxBackend));
RegisterBackend (typeof(IStatusIconBackend), typeof(StatusIconBackend));
RegisterBackend (typeof(IProgressBarBackend), typeof(ProgressBarBackend));
RegisterBackend (typeof(IPopoverBackend), typeof (PopoverBackend));
RegisterBackend (typeof(ISpinButtonBackend), typeof (SpinButtonBackend));
RegisterBackend (typeof(IDatePickerBackend), typeof (DatePickerBackend));
RegisterBackend (typeof(ILinkLabelBackend), typeof (LinkLabelBackend));
RegisterBackend (typeof(ISpinnerBackend), typeof (SpinnerBackend));
RegisterBackend (typeof(IRichTextViewBackend), typeof (RichTextViewBackend));
RegisterBackend (typeof(IExpanderBackend), typeof (ExpanderBackend));
RegisterBackend (typeof(DesktopBackend), typeof(GtkDesktopBackend));
RegisterBackend (typeof(IEmbeddedWidgetBackend), typeof(EmbeddedWidgetBackend));
RegisterBackend (typeof(ISegmentedButtonBackend), typeof(SegmentedButtonBackend));
RegisterBackend<DrawingPathBackendHandler, CairoContextBackendHandler> ();
RegisterBackend<GradientBackendHandler, CairoGradientBackendHandler> ();
RegisterBackend<FontBackendHandler, GtkFontBackendHandler> ();
RegisterBackend<IMenuBackend, MenuBackend> ();
RegisterBackend<IMenuItemBackend, MenuItemBackend> ();
RegisterBackend<ICheckBoxMenuItemBackend, CheckBoxMenuItemBackend> ();
RegisterBackend<IRadioButtonMenuItemBackend, RadioButtonMenuItemBackend> ();
RegisterBackend<ISeparatorMenuItemBackend, SeparatorMenuItemBackend> ();
RegisterBackend<IScrollViewBackend, ScrollViewBackend> ();
RegisterBackend<IComboBoxBackend, ComboBoxBackend> ();
RegisterBackend<IDesignerSurfaceBackend, DesignerSurfaceBackend> ();
RegisterBackend<IMenuButtonBackend, MenuButtonBackend> ();
RegisterBackend<ITextEntryBackend, TextEntryBackend> ();
RegisterBackend<IToggleButtonBackend, ToggleButtonBackend> ();
RegisterBackend<IImageViewBackend, ImageViewBackend> ();
RegisterBackend<IAlertDialogBackend, AlertDialogBackend> ();
RegisterBackend<ICheckBoxBackend, CheckBoxBackend> ();
RegisterBackend<IFrameBackend, FrameBackend> ();
RegisterBackend<ISeparatorBackend, SeparatorBackend> ();
RegisterBackend<IDialogBackend, DialogBackend> ();
RegisterBackend<IComboBoxEntryBackend, ComboBoxEntryBackend> ();
RegisterBackend<ClipboardBackend, GtkClipboardBackend> ();
RegisterBackend<ImagePatternBackendHandler, GtkImagePatternBackendHandler> ();
RegisterBackend<ImageBuilderBackendHandler, ImageBuilderBackend> ();
RegisterBackend<IScrollAdjustmentBackend, ScrollAdjustmentBackend> ();
RegisterBackend<IOpenFileDialogBackend, OpenFileDialogBackend> ();
RegisterBackend<ISaveFileDialogBackend, SaveFileDialogBackend> ();
RegisterBackend<ISelectFolderDialogBackend, SelectFolderDialogBackend> ();
RegisterBackend<IPanedBackend, PanedBackend> ();
RegisterBackend<ISelectColorDialogBackend, SelectColorDialogBackend> ();
RegisterBackend<IListBoxBackend, ListBoxBackend> ();
RegisterBackend<IStatusIconBackend, StatusIconBackend> ();
RegisterBackend<IProgressBarBackend, ProgressBarBackend> ();
RegisterBackend<IPopoverBackend, PopoverBackend> ();
RegisterBackend<ISpinButtonBackend, SpinButtonBackend> ();
RegisterBackend<IDatePickerBackend, DatePickerBackend> ();
RegisterBackend<ILinkLabelBackend, LinkLabelBackend> ();
RegisterBackend<ISpinnerBackend, SpinnerBackend> ();
RegisterBackend<IRichTextViewBackend, RichTextViewBackend> ();
RegisterBackend<IExpanderBackend, ExpanderBackend> ();
RegisterBackend<DesktopBackend, GtkDesktopBackend> ();
RegisterBackend<IEmbeddedWidgetBackend, EmbeddedWidgetBackend> ();
RegisterBackend<ISegmentedButtonBackend, SegmentedButtonBackend> ();
}
public override void RunApplication ()

Просмотреть файл

@ -24,11 +24,12 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using Xwt.Backends;
using MonoMac.AppKit;
namespace Xwt.Mac
{
public class SeparatorMenuItemBackend: MenuItemBackend
public class SeparatorMenuItemBackend: MenuItemBackend, ISeparatorMenuItemBackend
{
public SeparatorMenuItemBackend (): base (NSMenuItem.SeparatorItem)
{

Просмотреть файл

@ -24,11 +24,18 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using MonoMac.AppKit;
using Xwt.Backends;
namespace Xwt.Mac
{
public class ToggleButtonBackend: ButtonBackend
public class ToggleButtonBackend: ButtonBackend, IToggleButtonBackend
{
public bool Active {
get { return Widget.State == NSCellStateValue.On; }
set { Widget.State = value? NSCellStateValue.On : NSCellStateValue.Off; }
}
public ToggleButtonBackend ()
{
}

Просмотреть файл

@ -49,54 +49,54 @@ namespace Xwt.WPFBackend
if (application == null)
application = new System.Windows.Application ();
RegisterBackend (typeof (IWindowBackend), typeof (WindowBackend));
RegisterBackend (typeof (IDialogBackend), typeof (DialogBackend));
RegisterBackend (typeof (INotebookBackend), typeof (NotebookBackend));
RegisterBackend (typeof (IMenuBackend), typeof (MenuBackend));
RegisterBackend (typeof (IMenuItemBackend), typeof (MenuItemBackend));
RegisterBackend (typeof (ICheckBoxMenuItemBackend), typeof (CheckboxMenuItemBackend));
RegisterBackend (typeof (IRadioButtonMenuItemBackend), typeof (RadioButtonMenuItemBackend));
RegisterBackend (typeof (ISeparatorMenuItemBackend), typeof (SeparatorMenuItemBackend));
RegisterBackend (typeof (IBoxBackend), typeof (BoxBackend));
RegisterBackend (typeof (ILabelBackend), typeof (LabelBackend));
RegisterBackend (typeof (ITextEntryBackend), typeof (TextEntryBackend));
RegisterBackend (typeof (IButtonBackend), typeof (ButtonBackend));
RegisterBackend (typeof (IToggleButtonBackend), typeof (ToggleButtonBackend));
RegisterBackend (typeof (IMenuButtonBackend), typeof (MenuButtonBackend));
RegisterBackend (typeof (ICheckBoxBackend), typeof (CheckBoxBackend));
RegisterBackend (typeof (ITreeViewBackend), typeof (TreeViewBackend));
RegisterBackend (typeof (ITreeStoreBackend), typeof (TreeStoreBackend));
RegisterBackend (typeof (IImageViewBackend), typeof (ImageViewBackend));
RegisterBackend (typeof (ISeparatorBackend), typeof (SeparatorBackend));
RegisterBackend (typeof (ImageBackendHandler), typeof (ImageHandler));
RegisterBackend (typeof (FontBackendHandler), typeof (WpfFontBackendHandler));
RegisterBackend (typeof (ClipboardBackend), typeof (WpfClipboardBackend));
RegisterBackend (typeof (IComboBoxBackend), typeof (ComboBoxBackend));
RegisterBackend (typeof (IComboBoxEntryBackend), typeof (ComboBoxEntryBackend));
RegisterBackend (typeof (IScrollViewBackend), typeof (ScrollViewBackend));
RegisterBackend (typeof (IFrameBackend), typeof (FrameBackend));
RegisterBackend (typeof (ICanvasBackend), typeof (CanvasBackend));
RegisterBackend (typeof (ContextBackendHandler), typeof (WpfContextBackendHandler));
RegisterBackend (typeof (DrawingPathBackendHandler), typeof (WpfContextBackendHandler));
RegisterBackend (typeof (GradientBackendHandler), typeof (WpfGradientBackendHandler));
RegisterBackend (typeof (TextLayoutBackendHandler), typeof (WpfTextLayoutBackendHandler));
RegisterBackend (typeof (ICustomWidgetBackend), typeof (CustomWidgetBackend));
RegisterBackend (typeof (IPanedBackend), typeof (PanedBackend));
RegisterBackend (typeof (IScrollAdjustmentBackend), typeof (ScrollAdjustmentBackend));
RegisterBackend (typeof (IOpenFileDialogBackend), typeof (OpenFileDialogBackend));
RegisterBackend (typeof (ISelectFolderDialogBackend), typeof (SelectFolderDialogBackend));
RegisterBackend (typeof (IAlertDialogBackend), typeof (AlertDialogBackend));
RegisterBackend (typeof (ImageBuilderBackendHandler), typeof (WpfImageBuilderBackendHandler));
RegisterBackend (typeof (ImagePatternBackendHandler), typeof (WpfImagePatternBackendHandler));
RegisterBackend (typeof (IListViewBackend), typeof (ListViewBackend));
RegisterBackend (typeof (IListStoreBackend), typeof (ListDataSource));
RegisterBackend (typeof (IListBoxBackend), typeof (ListBoxBackend));
RegisterBackend (typeof (IPopoverBackend), typeof (PopoverBackend));
RegisterBackend (typeof (IProgressBarBackend), typeof (ProgressBarBackend));
RegisterBackend (typeof (IRichTextViewBackend), typeof (RichTextViewBackend));
RegisterBackend (typeof (ILinkLabelBackend), typeof (LinkLabelBackend));
RegisterBackend (typeof (ISpinnerBackend), typeof (SpinnerBackend));
RegisterBackend (typeof (DesktopBackend), typeof (WpfDesktopBackend));
RegisterBackend<IWindowBackend, WindowBackend> ();
RegisterBackend<IDialogBackend, DialogBackend> ();
RegisterBackend<INotebookBackend, NotebookBackend> ();
RegisterBackend<IMenuBackend, MenuBackend> ();
RegisterBackend<IMenuItemBackend, MenuItemBackend> ();
RegisterBackend<ICheckBoxMenuItemBackend, CheckboxMenuItemBackend> ();
RegisterBackend<IRadioButtonMenuItemBackend, RadioButtonMenuItemBackend> ();
RegisterBackend<ISeparatorMenuItemBackend, SeparatorMenuItemBackend> ();
RegisterBackend<IBoxBackend, BoxBackend> ();
RegisterBackend<ILabelBackend, LabelBackend> ();
RegisterBackend<ITextEntryBackend, TextEntryBackend> ();
RegisterBackend<IButtonBackend, ButtonBackend> ();
RegisterBackend<IToggleButtonBackend, ToggleButtonBackend> ();
RegisterBackend<IMenuButtonBackend, MenuButtonBackend> ();
RegisterBackend<ICheckBoxBackend, CheckBoxBackend> ();
RegisterBackend<ITreeViewBackend, TreeViewBackend> ();
RegisterBackend<ITreeStoreBackend, TreeStoreBackend> ();
RegisterBackend<IImageViewBackend, ImageViewBackend> ();
RegisterBackend<ISeparatorBackend, SeparatorBackend> ();
RegisterBackend<ImageBackendHandler, ImageHandler> ();
RegisterBackend<FontBackendHandler, WpfFontBackendHandler> ();
RegisterBackend<ClipboardBackend, WpfClipboardBackend> ();
RegisterBackend<IComboBoxBackend, ComboBoxBackend> ();
RegisterBackend<IComboBoxEntryBackend, ComboBoxEntryBackend> ();
RegisterBackend<IScrollViewBackend, ScrollViewBackend> ();
RegisterBackend<IFrameBackend, FrameBackend> ();
RegisterBackend<ICanvasBackend, CanvasBackend> ();
RegisterBackend<ContextBackendHandler, WpfContextBackendHandler> ();
RegisterBackend<DrawingPathBackendHandler, WpfContextBackendHandler> ();
RegisterBackend<GradientBackendHandler, WpfGradientBackendHandler> ();
RegisterBackend<TextLayoutBackendHandler, WpfTextLayoutBackendHandler> ();
RegisterBackend<ICustomWidgetBackend, CustomWidgetBackend> ();
RegisterBackend<IPanedBackend, PanedBackend> ();
RegisterBackend<IScrollAdjustmentBackend, ScrollAdjustmentBackend> ();
RegisterBackend<IOpenFileDialogBackend, OpenFileDialogBackend> ();
RegisterBackend<ISelectFolderDialogBackend, SelectFolderDialogBackend> ();
RegisterBackend<IAlertDialogBackend, AlertDialogBackend> ();
RegisterBackend<ImageBuilderBackendHandler, WpfImageBuilderBackendHandler> ();
RegisterBackend<ImagePatternBackendHandler, WpfImagePatternBackendHandler> ();
RegisterBackend<IListViewBackend, ListViewBackend> ();
RegisterBackend<IListStoreBackend, ListDataSource> ();
RegisterBackend<IListBoxBackend, ListBoxBackend> ();
RegisterBackend<IPopoverBackend, PopoverBackend> ();
RegisterBackend<IProgressBarBackend, ProgressBarBackend> ();
RegisterBackend<IRichTextViewBackend, RichTextViewBackend> ();
RegisterBackend<ILinkLabelBackend, LinkLabelBackend> ();
RegisterBackend<ISpinnerBackend, SpinnerBackend> ();
RegisterBackend<DesktopBackend, WpfDesktopBackend> ();
}
public override void DispatchPendingEvents()

Просмотреть файл

@ -247,17 +247,12 @@ namespace Xwt.Backends
return (T) CreateBackend (typeof(T));
}
public void RegisterBackend<Backend, Implementation> ()
{
RegisterBackend (typeof(Backend), typeof(Implementation));
}
public void RegisterBackend (Type backendType, Type implementationType)
public void RegisterBackend<Backend, Implementation> () where Implementation: Backend
{
CheckInitialized ();
backendTypes [backendType] = implementationType;
backendTypes [typeof(Backend)] = typeof(Implementation);
}
public T CreateFrontend<T> (object backend)
{
return (T) Activator.CreateInstance (typeof(T), backend);