void Clear () { if (selection != null) { selection.Notify -= Notified; selection = null; } foreach (Gtk.Widget w in Children) w.Hide (); }
static void GenerateWidgetCode(CodeNamespace globalNs, GenerationOptions options, List <SteticCompilationUnit> units, Gtk.Widget w, ArrayList warnings) { // Generate the build method CodeTypeDeclaration type = CreatePartialClass(units, options, w.Name); CodeMemberMethod met = new CodeMemberMethod(); met.Name = "Build"; type.Members.Add(met); met.ReturnType = new CodeTypeReference(typeof(void)); met.Attributes = MemberAttributes.Family; Stetic.Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup(w); if (options.GenerateEmptyBuildMethod) { GenerateWrapperFields(type, wwidget); return; } met.Statements.Add( new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(new CodeTypeReference(globalNs.Name + ".Gui", CodeTypeReferenceOptions.GlobalReference)), "Initialize", new CodeThisReferenceExpression() ) ); if (wwidget.GeneratePublic) { type.TypeAttributes = TypeAttributes.Public; } else { type.TypeAttributes = TypeAttributes.NotPublic; } if (!String.IsNullOrEmpty(wwidget.UIManagerName)) { type.Members.Add(new CodeMemberField(new CodeTypeReference("Gtk.UIManager", CodeTypeReferenceOptions.GlobalReference), wwidget.UIManagerName)); } Stetic.WidgetMap map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, type, w, new CodeThisReferenceExpression(), met.Statements, options, warnings); CodeGenerator.BindSignalHandlers(new CodeThisReferenceExpression(), wwidget, map, met.Statements, options); }
void BuildContextMenu (Stetic.Wrapper.Widget parentWrapper, bool top, Widget context) { MenuItem item; item = new ImageMenuItem (Gtk.Stock.Cut, null); if (editable.CanCut) item.Activated += DoCut; else item.Sensitive = false; Add (item); item = new ImageMenuItem (Gtk.Stock.Copy, null); if (editable.CanCopy) item.Activated += DoCopy; else item.Sensitive = false; Add (item); item = new ImageMenuItem (Gtk.Stock.Paste, null); if (editable.CanPaste) item.Activated += DoPaste; else item.Sensitive = false; Add (item); if (editable.CanDelete) { item = new ImageMenuItem (Gtk.Stock.Delete, null); item.Activated += DoDelete; Add (item); } if (top) { for (; parentWrapper != null; parentWrapper = parentWrapper.ParentWrapper) { Add (new SeparatorMenuItem ()); item = LabelItem (parentWrapper.Wrapped); item.Submenu = new ContextMenu (parentWrapper, context); Add (item); } } ShowAll (); }
static void FaultDragDataReceived(object obj, Gtk.DragDataReceivedArgs args) { Stetic.Wrapper.Widget dropped = null; Stetic.Wrapper.Widget faultOwner = Stetic.Wrapper.Widget.Lookup((Gtk.Widget)obj); if (faultOwner != null) { dropped = WidgetUtils.Paste(faultOwner.Project, args.SelectionData); } Gtk.Drag.Finish(args.Context, dropped != null, dropped != null, args.Time); if (dropped != null) { Gtk.Widget targetWidget = (Gtk.Widget)obj; int px = args.X + targetWidget.Allocation.X; int py = args.Y + targetWidget.Allocation.Y; FaultDrop(dropped, px, py, targetWidget); } }
void FillChildren(TreeIter it, Wrapper.Widget wrapper) { Stetic.Wrapper.Container container = wrapper as Wrapper.Container; if (container != null) { foreach (Gtk.Widget w in container.RealChildren) { Stetic.Wrapper.Widget ww = GetVisibleWrapper(w); if (ww != null) { // Add a dummy node to allow lazy loading store.SetValue(it, ColFilled, false); store.AppendValues(it, null, "", null, false); return; } } } store.SetValue(it, ColFilled, true); }
void FillWidgets() { store.Clear(); widgets.Clear(); Stetic.Wrapper.Widget widget = Stetic.Wrapper.Widget.Lookup(obj); if (widget == null) { return; } while (!widget.IsTopLevel) { widget = widget.ParentWrapper; } store.AppendValues(null, "(None)"); FillWidgets(widget, 0); }
void FillWidgets(Stetic.Wrapper.Widget widget, int level) { if (!widget.Unselectable) { TreeIter iter = store.AppendValues(widget.ClassDescriptor.Icon, widget.Wrapped.Name); widgets [widget.Wrapped.Name] = iter; } Gtk.Container cont = widget.Wrapped as Gtk.Container; if (cont != null && widget.ClassDescriptor.AllowChildren) { foreach (Gtk.Widget child in cont.AllChildren) { Stetic.Wrapper.Widget cwidget = Stetic.Wrapper.Widget.Lookup(child); if (cwidget != null) { FillWidgets(cwidget, level + 1); } } } }
internal void GetClipboardOperations(object obj, out bool canCut, out bool canCopy, out bool canPaste) { Stetic.Wrapper.Widget wrapper = obj as Stetic.Wrapper.Widget; if (wrapper != null) { canCut = wrapper.InternalChildProperty == null && !wrapper.IsTopLevel; canCopy = !wrapper.IsTopLevel; canPaste = false; } else if (obj is Placeholder) { // FIXME: make it work for placeholders canCut = canCopy = false; canPaste = true; } else { canCut = canCopy = canPaste = false; } }
public WidgetActionBar(WidgetDesignerFrontend frontend, Stetic.Wrapper.Widget rootWidget) { this.frontend = frontend; editors = new Hashtable(); wrappers = new Hashtable(); sensitives = new Hashtable(); invisibles = new Hashtable(); toggles = new ArrayList(); IconSize = IconSize.Menu; Orientation = Orientation.Horizontal; ToolbarStyle = ToolbarStyle.BothHoriz; combo = new WidgetTreeCombo(); comboItem = new ToolItem(); comboItem.Add(combo); comboItem.ShowAll(); Insert(comboItem, -1); ShowAll(); RootWidget = rootWidget; }
public void AddWidget(Gtk.Widget widget) { if (!typeof(Gtk.Container).IsInstanceOfType(widget)) { throw new System.ArgumentException("widget", "Only containers can be top level widgets"); } topLevels.Add(new WidgetData(null, null, widget)); if (!loading) { Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup(widget); if (ww == null) { throw new InvalidOperationException("Widget not wrapped"); } if (frontend != null) { frontend.NotifyWidgetAdded(Component.GetSafeReference(ww), widget.Name, ww.ClassDescriptor.Name); } OnWidgetAdded(new Stetic.Wrapper.WidgetEventArgs(ww)); } }
public void AddNode(TreeIter iter, Gtk.Widget widget) { Stetic.Wrapper.Widget wrapper = GetVisibleWrapper(widget); if (wrapper == null) { return; } Gdk.Pixbuf icon = wrapper.ClassDescriptor.Icon.ScaleSimple(16, 16, Gdk.InterpType.Bilinear); string txt = widget.Name; if (!iter.Equals(TreeIter.Zero)) { iter = store.AppendValues(iter, icon, txt, wrapper, true); } else { iter = store.AppendValues(icon, txt, wrapper, true); } FillChildren(iter, wrapper); }
public static void GenerateProjectGuiCode(CodeNamespace globalNs, CodeTypeDeclaration globalType, GenerationOptions options, List <SteticCompilationUnit> units, ProjectBackend[] projects, ArrayList warnings) { // Generate code for each project foreach (ProjectBackend gp in projects) { // Generate top levels foreach (Gtk.Widget w in gp.Toplevels) { Stetic.Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup(w); string topLevelName = wwidget.Name; if (gp.ComponentNeedsCodeGeneration(topLevelName)) { //designer file for widget could be changed beyond stetic process //and we nead update wrapper before code generation //during reloading wrappered widget w could be changed; Gtk.Widget currentw = w; if (gp.ReloadTopLevel(topLevelName)) { currentw = gp.GetWidget(topLevelName); } GenerateWidgetCode(globalNs, options, units, currentw, warnings); } } // Generate global action groups foreach (Wrapper.ActionGroup agroup in gp.ActionGroups) { string groupName = agroup.Name; if (gp.ComponentNeedsCodeGeneration(groupName)) { //designer file for action group could be changed beyond stetic process //and we nead update wrapper gp.ReloadActionGroup(groupName); GenerateGlobalActionGroupCode(globalNs, options, units, agroup, warnings); } } } }
void AddCommands(ObjectWrapper wrapper) { foreach (ItemGroup igroup in wrapper.ClassDescriptor.ItemGroups) { foreach (ItemDescriptor desc in igroup) { if ((desc is CommandDescriptor) && desc.SupportsGtkVersion(project.TargetGtkVersion)) { AppendCommand((CommandDescriptor)desc, wrapper); } } } Stetic.Wrapper.Widget widget = wrapper as Stetic.Wrapper.Widget; if (widget != null) { Stetic.Wrapper.Container.ContainerChild packingSelection = Stetic.Wrapper.Container.ChildWrapper(widget); if (packingSelection != null) { AddCommands(packingSelection); } } }
public ContextMenu (Stetic.Wrapper.Widget wrapper, Gtk.Widget context) { MenuItem item; editable = wrapper; widget = wrapper.Wrapped; if (widget == context) { item = LabelItem (widget); item.Sensitive = false; Add (item); } item = new MenuItem (Catalog.GetString ("_Select")); item.Activated += DoSelect; Add (item); ClassDescriptor klass = wrapper.ClassDescriptor; if (klass != null) { foreach (ItemDescriptor id in klass.ContextMenu) { CommandDescriptor cmd = (CommandDescriptor)id; if (!cmd.VisibleFor (widget)) continue; item = new MenuItem (cmd.Label); if (cmd.Enabled (widget, context)) { Gtk.Widget wdup = widget, cdup = context; // FIXME bxc 75689 item.Activated += delegate (object o, EventArgs args) { cmd.Run (wdup, cdup); }; } else item.Sensitive = false; Add (item); } } BuildContextMenu (wrapper.ParentWrapper, widget == context, context); }
public static void AddFault(Stetic.Wrapper.Widget owner, object faultId, Gtk.Orientation orientation, Gdk.Rectangle fault) { AddFault(owner, faultId, orientation, fault.X, fault.Y, fault.Width, fault.Height); }
public WidgetNameChangedArgs(Stetic.Wrapper.Widget widget, string oldName, string newName) : base(widget) { this.oldName = oldName; this.newName = newName; }
void DoSelect (object obj, EventArgs args) { Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (widget); if (wrapper != null) wrapper.Select (); }
void UpdateSelection (Wrapper.Widget w) { Clear (); selection = w; if (selection == null) { combo.SetSelection (null); return; } // Look for the root widget, and only update the bar if the selected // widget is a child of the root widget while (w != null && !w.IsTopLevel) { w = Stetic.Wrapper.Container.LookupParent ((Gtk.Widget) w.Wrapped); } if (w == null || w != rootWidget) return; combo.SetSelection (selection); selection.Notify += Notified; packingSelection = Stetic.Wrapper.Container.ChildWrapper (selection); if (packingSelection != null) packingSelection.Notify += Notified; AddWidgetCommands (selection); UpdateSensitivity (); }
public void SetSelection(Stetic.Wrapper.Widget widget) { selection = widget; Update(); }
public void SetSelection (Stetic.Wrapper.Widget widget) { selection = widget; Update (); }
public void PopupContextMenu(Stetic.Wrapper.Widget wrapper) { Gtk.Menu m = new ContextMenu(wrapper); m.Popup(); }
public ContextMenu(Stetic.Wrapper.Widget wrapper) : this(wrapper, wrapper.Wrapped) { }
public override void Dispose() { if (disposed) return; disposed = true; combo.Destroy (); combo = null; RootWidget = null; Clear (); base.Dispose (); }
void Selected (object s, Wrapper.WidgetEventArgs args) { newSelection = args != null ? args.WidgetWrapper : null; GLib.Timeout.Add (50, new GLib.TimeoutHandler (SelectedHandler)); }
bool SelectedHandler () { ClassDescriptor klass; Clear (); selection = newSelection; if (selection == null || selection.Wrapped is ErrorWidget) { noSelection.Show (); return false; } header.Show (); selection.Notify += Notified; klass = selection.ClassDescriptor; header.AttachObject (selection.Wrapped); AppendItemGroups (klass, selection.Wrapped); packingSelection = Stetic.Wrapper.Container.ChildWrapper (selection); if (packingSelection != null) { klass = packingSelection.ClassDescriptor; if (klass.ItemGroups.Count > 0) { AppendItemGroups (klass, packingSelection.Wrapped); packingSelection.Notify += Notified; } } return false; }
void Clear () { if (selection != null) { selection.Notify -= Notified; if (packingSelection != null) packingSelection.Notify -= Notified; } selection = null; packingSelection = null; editors.Clear (); wrappers.Clear (); sensitives.Clear (); invisibles.Clear (); toggles.Clear (); foreach (Gtk.Widget child in Children) if (child != comboItem) { Remove (child); child.Destroy (); } }
public static void ClearFaults(Stetic.Wrapper.Widget owner) { ClearFaults(owner.Wrapped); }
public WidgetEventArgs (Stetic.Wrapper.Widget wrapper) { this.wrapper = wrapper; if (wrapper != null) this.widget = wrapper.Wrapped; }
void Selected(object s, Wrapper.WidgetEventArgs args) { newSelection = args != null ? args.WidgetWrapper : null; GLib.Timeout.Add(50, new GLib.TimeoutHandler(SelectedHandler)); }
public WidgetEventArgs (Gtk.Widget widget) { this.widget = widget; wrapper = Stetic.Wrapper.Widget.Lookup (widget); }
static void GenerateWidgetCode(SteticCompilationUnit globalUnit, CodeNamespace globalNs, GenerationOptions options, List <SteticCompilationUnit> units, Gtk.Widget w, ArrayList warnings, bool regenerateWidgetClass) { if (options.GenerateSingleFile) { regenerateWidgetClass = true; } // Don't register this unit if the class doesn't need to be regenerated if (!regenerateWidgetClass) { units = null; } CodeTypeDeclaration type = CreatePartialClass(globalUnit, units, options, w.Name); // Generate the build method CodeMemberMethod met = new CodeMemberMethod(); met.Name = "Build"; type.Members.Add(met); met.ReturnType = new CodeTypeReference(typeof(void)); met.Attributes = MemberAttributes.Family; Stetic.Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup(w); if (regenerateWidgetClass) { if (options.GenerateEmptyBuildMethod) { GenerateWrapperFields(type, wwidget); return; } met.Statements.Add( new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(new CodeTypeReference(globalNs.Name + ".Gui", CodeTypeReferenceOptions.GlobalReference)), "Initialize", new CodeThisReferenceExpression() ) ); if (wwidget.GeneratePublic) { type.TypeAttributes = TypeAttributes.Public; } else { type.TypeAttributes = TypeAttributes.NotPublic; } if (!String.IsNullOrEmpty(wwidget.UIManagerName)) { type.Members.Add(new CodeMemberField(new CodeTypeReference("Gtk.UIManager", CodeTypeReferenceOptions.GlobalReference), wwidget.UIManagerName)); } } // We need to generate the creation code even if regenerateWidgetClass is false because GenerateCreationCode // may inject support classes or methods into the global namespace, which is always generated Stetic.WidgetMap map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, type, w, new CodeThisReferenceExpression(), met.Statements, options, warnings); if (regenerateWidgetClass) { CodeGenerator.BindSignalHandlers(new CodeThisReferenceExpression(), wwidget, map, met.Statements, options); } }
internal void GetComponentInfo(object obj, out string name, out string type) { Stetic.Wrapper.Widget wrapper = obj as Stetic.Wrapper.Widget; name = wrapper.Wrapped.Name; type = wrapper.ClassDescriptor.Name; }
public WidgetEventArgs(Gtk.Widget widget) { this.widget = widget; wrapper = Stetic.Wrapper.Widget.Lookup(widget); }
public Fault(Stetic.Wrapper.Widget owner, object id, Gtk.Orientation orientation, Gdk.Window window) { Owner = owner; Id = id; Orientation = orientation; Window = window; }
internal static void BindSignalHandlers(CodeExpression targetObjectVar, ObjectWrapper wrapper, Stetic.WidgetMap map, CodeStatementCollection statements, GenerationOptions options) { foreach (Signal signal in wrapper.Signals) { SignalDescriptor descriptor = signal.SignalDescriptor; CodeExpression createDelegate; if (options.UsePartialClasses) { createDelegate = new CodeDelegateCreateExpression( new CodeTypeReference(descriptor.HandlerTypeName), new CodeThisReferenceExpression(), signal.Handler); } else { createDelegate = new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(typeof(Delegate)), "CreateDelegate", new CodeTypeOfExpression(descriptor.HandlerTypeName), targetObjectVar, new CodePrimitiveExpression(signal.Handler)); createDelegate = new CodeCastExpression(descriptor.HandlerTypeName, createDelegate); } CodeAttachEventStatement cevent = new CodeAttachEventStatement( new CodeEventReferenceExpression( map.GetWidgetExp(wrapper), descriptor.Name), createDelegate); statements.Add(cevent); } Wrapper.Widget widget = wrapper as Wrapper.Widget; if (widget != null && widget.IsTopLevel) { // Bind local action signals foreach (Wrapper.ActionGroup grp in widget.LocalActionGroups) { foreach (Wrapper.Action ac in grp.Actions) { BindSignalHandlers(targetObjectVar, ac, map, statements, options); } } } Gtk.Container cont = wrapper.Wrapped as Gtk.Container; if (cont != null) { foreach (Gtk.Widget child in cont.AllChildren) { Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup(child); if (ww != null) { BindSignalHandlers(targetObjectVar, ww, map, statements, options); } } } }