示例#1
0
        public DateMultiSelect()
        {
            DateTime now = DateTime.Now;

            this.ShadowType  = ShadowType.EtchedOut;
            this.BorderWidth = 0;

            MonthCombo = new ComboBox();
            DayCombo   = new ComboBox();
            YearCombo  = new ComboBox();
            Calendar   = new Gtk.Calendar();

            TopVbox   = new VBox();
            ComboHbox = new HBox();

            ComboHbox.Add(MonthCombo);
            ComboHbox.Add(DayCombo);
            ComboHbox.Add(YearCombo);

            TopVbox.Add(ComboHbox);

            TopVbox.Add(Calendar);

            this.Add(TopVbox);

            SetDate(DateTime.Now);

            MonthCombo.Changed   += OnComboChanged;
            DayCombo.Changed     += OnComboChanged;
            YearCombo.Changed    += OnComboChanged;
            Calendar.DaySelected += OnCalendarChanged;

            ShowAll();
        }
示例#2
0
 internal Calendar()
 {
     _calendar = new Gtk.Calendar
     {
         Date           = DateTime.Now,
         DisplayOptions = CalendarDisplayOptions.ShowHeading | CalendarDisplayOptions.ShowDayNames | CalendarDisplayOptions.ShowDetails
     };
 }
示例#3
0
		public static Calendar CreateCalendar ()
		{
			Calendar cal = new Calendar();
			cal.DisplayOptions = CalendarDisplayOptions.ShowHeading    |
					     CalendarDisplayOptions.ShowDayNames   |
					     CalendarDisplayOptions.ShowWeekNumbers;
			return cal;
		}
示例#4
0
        public MainWindow_Widget2()
            : base("Widget2")
        {
            SetDefaultSize(800, 600);
            SetPosition(WindowPosition.Center);

            BorderWidth = 7;
            DeleteEvent += delegate
            {
                    Application.Quit();
            };

            _label = new Label("...");

            Entry entry = new Entry();
            entry.Changed += OnChangedEntry;

            // scale and image
            HScale scale = new HScale(0, 100, 1);
            {
                scale.SetSizeRequest(160, 35);
                scale.ValueChanged += OnChangeScale;

                LoadImage();

                _image = new Image(img1);
            }

            // Color
            ToggleButton red = new ToggleButton("red");
            {
                red.SetSizeRequest(80, 35);
                red.Clicked += OnRed;

                _area = new DrawingArea();
                _area.SetSizeRequest(150, 150);
            }

            Calendar calendar = new Calendar();
            {
                calendar.DaySelected += OnDaySelected;
            }

            Fixed fix = new Fixed();
            fix.Put(entry, 60, 100);
            fix.Put(_label, 60, 40);
            fix.Put(scale, 60, 200);
            fix.Put(_image, 10, 240);
            fix.Put(red, 300, 250);
            fix.Put(_area, 300, 500);
            fix.Put(calendar, 500, 300);

            Add(fix);

            ShowAll();
        }
示例#5
0
        private void Build()
        {
            this.calendarTitle  = new Gtk.Label("Calendar");
            this.calendarWidget = new Gtk.Calendar();

            PackStart(this.calendarTitle, false, true, 5);
            PackStart(this.calendarWidget, true, true, 5);

            this.OnViewBuilt();
        }
示例#6
0
        private void ShowPopup()
        {
            win              = new Gtk.Window(Gtk.WindowType.Popup);
            win.Screen       = this.Screen;
            win.WidthRequest = this.Allocation.Width;

            cal = new Gtk.Calendar();
            win.Add(cal);

            if (validDate)
            {
                cal.Date = date;
            }

            // events
            win.ButtonPressEvent       += OnWinButtonPressEvent;
            cal.DaySelectedDoubleClick += OnCalDaySelectedDoubleClick;
            cal.KeyPressEvent          += OnCalKeyPressEvent;
            cal.ButtonPressEvent       += OnCalButtonPressEvent;

            int x, y;

            GetWidgetPos(this, out x, out y);
            win.Move(x, y + Allocation.Height + 2);
            win.ShowAll();
            win.GrabFocus();

            Grab.Add(win);

            Gdk.GrabStatus grabStatus;

            grabStatus = Gdk.Pointer.Grab(win.GdkWindow, true, EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask, null, null, Gtk.Global.CurrentEventTime);
            if (grabStatus == Gdk.GrabStatus.Success)
            {
                grabStatus = Gdk.Keyboard.Grab(win.GdkWindow, true, Gtk.Global.CurrentEventTime);
                if (grabStatus != Gdk.GrabStatus.Success)
                {
                    Grab.Remove(win);
                    win.Destroy();
                    win = null;
                }
            }
            else
            {
                Grab.Remove(win);
                win.Destroy();
                win = null;
            }
        }
示例#7
0
        private void BuildDialog()
        {
            this.Modal = true;

            var row1 = new HBox(false, 5);
            var row2 = new HBox(false, 5);
            var row3 = new HBox(false, 5);

            this.VBox.PackStart(row1);
            this.VBox.Add(row2);
            this.VBox.PackEnd(row3);

            var lbl1 = new Label("Weight");
            var lbl2 = new Label("Barriga Perimeter");
            var lbl3 = new Label("Date");

            this.weightEntry = new Entry();
            this.acEntry     = new Entry();
            this.dateEntry   = new Gtk.Calendar();

            row1.PackStart(lbl1, false, false, 5);
            row1.Add(this.weightEntry);

            row2.PackStart(lbl2, false, false, 5);
            row2.Add(this.acEntry);

            row3.PackStart(lbl3, false, false, 5);
            row3.Add(this.dateEntry);

            this.AddButton(Stock.Save, ResponseType.Accept);
            this.AddButton(Stock.Cancel, ResponseType.Cancel);

            this.Response += this.OnDialogResponse;

            this.VBox.ShowAll();

            this.OnViewBuilt();


            this.Run();
            this.Destroy();
        }
示例#8
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public WeatherDownloadDialog()
        {
            Builder builder = ViewBase.BuilderFromResource("ApsimNG.Resources.Glade.WeatherDownload.glade");

            dialog1             = (Dialog)builder.GetObject("dialog1");
            vbox1               = (VBox)builder.GetObject("vbox1");
            dialogVBox          = (Box)builder.GetObject("dialog-vbox1");
            scroller            = (ScrolledWindow)builder.GetObject("scrolledwindow1");
            radioAus            = (RadioButton)builder.GetObject("radioAus");
            radioWorld          = (RadioButton)builder.GetObject("radioWorld");
            entryLatitude       = (Entry)builder.GetObject("entryLatitude");
            entryLongitude      = (Entry)builder.GetObject("entryLongitude");
            entryPlacename      = (Entry)builder.GetObject("entryPlacename");
            radioSiloDataDrill  = (RadioButton)builder.GetObject("radioSiloDataDrill");
            radioSiloPatchPoint = (RadioButton)builder.GetObject("radioSiloPatchPoint");
            radioNASA           = (RadioButton)builder.GetObject("radioNASA");
            btnOk               = (Button)builder.GetObject("btnOk");
            btnCancel           = (Button)builder.GetObject("btnCancel");
            btnGetPlacename     = (Button)builder.GetObject("btnGetPlacename");
            btnGetLocation      = (Button)builder.GetObject("btnGetLocation");
            calendarStart       = (Gtk.Calendar)builder.GetObject("calendarStart");
            calendarEnd         = (Gtk.Calendar)builder.GetObject("calendarEnd");
            entryFilePath       = (Entry)builder.GetObject("entryFilePath");
            btnBrowse           = (Button)builder.GetObject("btnBrowse");
            entryEmail          = (Entry)builder.GetObject("entryEmail");

            // fixme: once we move to gtk3, we can just use a scrolled
            // window with natural height/width propagation to get a
            // sensible initial size. Until then, we need to use this
            // hack in the SizeAllocated event.
            scroller.SizeAllocated += OnSizeAllocated;

            calendarEnd.Date         = DateTime.Today.AddDays(-1.0);
            radioAus.Clicked        += RadioAus_Clicked;
            radioWorld.Clicked      += RadioAus_Clicked;
            btnOk.Clicked           += BtnOk_Clicked;
            btnCancel.Clicked       += BtnCancel_Clicked;
            btnGetLocation.Clicked  += BtnGetLocation_Clicked;
            btnGetPlacename.Clicked += BtnGetPlacename_Clicked;
            btnBrowse.Clicked       += BtnBrowse_Clicked;
        }
示例#9
0
        /// <summary>
        /// Builds the UI.
        /// </summary>
        private void Build()
        {
            SetDefaultSize (600, 600);

            var image = new Image ("./logo.png");

            this.calendarVbox = new Gtk.VBox(false, 5);
            this.bottomHBox = new Gtk.HBox (true, 5);
            this.eventDetail = new Gtk.VBox (false, 5);

            this.cal = new Gtk.Calendar ();
            calendarVbox.PackStart (image);
            calendarVbox.PackStart (this.cal, true, false, 5);

            this.bottomHBox.PackStart(this.buildStats(), true, false, 5);
            this.bottomHBox.PackStart (eventDetail, true, false, 5);

            calendarVbox.PackEnd (bottomHBox, true, false, 5);

            this.Add(calendarVbox);

            // Mark events for calendar
            this.MarkEventsForMonth (this.cal.Month);

            // Events
            this.DeleteEvent += (o, args) => this.OnClose();
            //this.btnAdd.Clicked += (o, args) => this.ShowAddTrip();
            //this.btnList.Clicked += (o, args) => this.ShowListTrips();
            this.cal.DaySelected += (o, args) => this.ShowEventsForDay ();
            this.cal.MonthChanged += (object sender, EventArgs e) => this.MarkEventsForMonth (this.cal.Month);
            this.cal.NextYear += (object sender, EventArgs e) => this.MarkEventsForMonth (this.cal.Month);
            this.cal.PrevYear += (object sender, EventArgs e) => this.MarkEventsForMonth (this.cal.Month);

            // Show current day after bootstrap
            this.ShowEventsForDay();
        }
示例#10
0
        public void ShowCalendar()
        {
            popup = new Window(WindowType.Popup);
            popup.Screen = parent.Screen;

            Frame frame = new Frame();
            frame.Shadow = ShadowType.Out;
            frame.Show();

            popup.Add(frame);

            VBox box = new VBox(false, 0);
            box.Show();
            frame.Add(box);

            cal = new Calendar();
            cal.DisplayOptions = CalendarDisplayOptions.ShowHeading
                                 | CalendarDisplayOptions.ShowDayNames
                                 | CalendarDisplayOptions.ShowWeekNumbers;

            cal.KeyPressEvent += OnCalendarKeyPressed;
            popup.ButtonPressEvent += OnButtonPressed;

            cal.Show();

            Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);
            calAlignment.Show();
            calAlignment.SetPadding(4, 4, 4, 4);
            calAlignment.Add(cal);

            box.PackStart(calAlignment, false, false, 0);

            //Requisition req = SizeRequest();

            parent.GdkWindow.GetOrigin(out xPos, out yPos);
            //			popup.Move(x + Allocation.X, y + Allocation.Y + req.Height + 3);
            popup.Move(xPos, yPos);
            popup.Show();
            popup.GrabFocus();

            Grab.Add(popup);

            Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true,
                                     Gdk.EventMask.ButtonPressMask
                                     | Gdk.EventMask.ButtonReleaseMask
                                     | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME);

            if (grabbed == Gdk.GrabStatus.Success) {
                grabbed = Gdk.Keyboard.Grab(popup.GdkWindow,
                                            true, CURRENT_TIME);

                if (grabbed != Gdk.GrabStatus.Success) {
                    Grab.Remove(popup);
                    popup.Destroy();
                    popup = null;
                }
            } else {
                Grab.Remove(popup);
                popup.Destroy();
                popup = null;
            }

            cal.DaySelected += OnCalendarDaySelected;
            cal.MonthChanged += OnCalendarMonthChanged;

            cal.Date = date;
        }
示例#11
0
        private void ShowCalendar()
        {
            popup = new Window(WindowType.Popup);
            popup.Screen = tree.Screen;

            Frame frame = new Frame();
            frame.Shadow = ShadowType.Out;
            frame.Show();

            popup.Add(frame);

            VBox box = new VBox(false, 0);
            box.Show();
            frame.Add(box);

            cal = new Calendar();
            cal.DisplayOptions = CalendarDisplayOptions.ShowHeading
                                 | CalendarDisplayOptions.ShowDayNames
                                 | CalendarDisplayOptions.ShowWeekNumbers;

            cal.KeyPressEvent += OnCalendarKeyPressed;
            popup.ButtonPressEvent += OnButtonPressed;

            cal.Show();

            Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);
            calAlignment.Show();
            calAlignment.SetPadding(4, 4, 4, 4);
            calAlignment.Add(cal);

            box.PackStart(calAlignment, false, false, 0);

            // FIXME: Make the popup appear directly below the date
            Gdk.Rectangle allocation = tree.Allocation;
            //   Gtk.Requisition req = tree.SizeRequest ();
            int x = 0, y = 0;
            tree.GdkWindow.GetOrigin(out x, out y);
            //   popup.Move(x + allocation.X, y + allocation.Y + req.Height + 3);
            popup.Move(x + allocation.X, y + allocation.Y);
            popup.Show();
            popup.GrabFocus();

            Grab.Add(popup);

            Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true,
                                     Gdk.EventMask.ButtonPressMask
                                     | Gdk.EventMask.ButtonReleaseMask
                                     | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME);

            if (grabbed == Gdk.GrabStatus.Success) {
                grabbed = Gdk.Keyboard.Grab(popup.GdkWindow,
                                            true, CURRENT_TIME);

                if (grabbed != Gdk.GrabStatus.Success) {
                    Grab.Remove(popup);
                    popup.Destroy();
                    popup = null;
                }
            } else {
                Grab.Remove(popup);
                popup.Destroy();
                popup = null;
            }

            cal.DaySelectedDoubleClick += OnCalendarDaySelected;
            cal.ButtonPressEvent += OnCalendarButtonPressed;

            cal.Date = date == DateTime.MinValue ? DateTime.Now : date;
        }
        protected void OnButtonPickDatePeriodClicked(object sender, EventArgs e)
        {
            #region Widget creation
            Window parentWin = (Window)Toplevel;
            var selectDate = new Dialog ("Укажите период", parentWin, DialogFlags.DestroyWithParent);
            selectDate.Modal = true;
            selectDate.AddButton ("Отмена", ResponseType.Cancel);
            selectDate.AddButton ("Ok", ResponseType.Ok);

            periodSummary = new Label();
            selectDate.VBox.Add(periodSummary);

            HBox hbox = new HBox (true, 6);

            StartDateCalendar = new Calendar ();
            StartDateCalendar.DisplayOptions = DisplayOptions;
            StartDateCalendar.Date = StartDateOrNull ?? DateTime.Today;
            StartDateCalendar.DaySelected += StartDateCalendar_DaySelected;

            EndDateCalendar = new Calendar ();
            EndDateCalendar.DisplayOptions = DisplayOptions;
            EndDateCalendar.Date = EndDateOrNull ?? DateTime.Today;
            EndDateCalendar.DaySelected += EndDateCalendar_DaySelected;

            hbox.Add (StartDateCalendar);
            hbox.Add (EndDateCalendar);

            selectDate.VBox.Add (hbox);
            selectDate.ShowAll ();
            #endregion

            int response = selectDate.Run ();
            if (response == (int)ResponseType.Ok) {
                startDate = StartDateCalendar.GetDate ();
                endDate = EndDateCalendar.GetDate ();
                OnPeriodChanged ();
            }

            #region Destroy
            EndDateCalendar.Destroy ();
            StartDateCalendar.Destroy ();
            hbox.Destroy ();
            selectDate.Destroy ();
            #endregion
        }
示例#13
0
        protected void OnButtonEditDateClicked(object sender, EventArgs e)
        {
            Gtk.Window parentWin = (Gtk.Window) this.Toplevel;
            editDate = new Dialog(WithTime ? "Укажите дату и время" : "Укажите дату",
                parentWin, Gtk.DialogFlags.DestroyWithParent);
            editDate.Modal = true;
            editDate.AddButton ("Отмена", ResponseType.Cancel);
            editDate.AddButton ("Ok", ResponseType.Ok);
            TimeEntry timeEntry = null;
            if(WithTime)
            {
                HBox timeBox = new HBox();
                Label timeLabel = new Label("Время:");
                timeLabel.Angle = 1;
                timeBox.Add(timeLabel);
                timeEntry = new TimeEntry();
                timeEntry.DateTime = date ?? DateTime.Now.Date;
                timeEntry.AutocompleteStep = 5;
                timeBox.Add(timeEntry);
                editDate.VBox.Add(timeBox);
            }
            Calendar SelectDate = new Calendar ();
            SelectDate.DisplayOptions = CalendarDisplayOptions.ShowHeading  |
                CalendarDisplayOptions.ShowDayNames |
                    CalendarDisplayOptions.ShowWeekNumbers;
            SelectDate.DaySelectedDoubleClick += OnCalendarDaySelectedDoubleClick;
            SelectDate.Date = date ?? DateTime.Now.Date;

            editDate.VBox.Add(SelectDate);
            editDate.ShowAll();
            int response = editDate.Run ();
            if(response == (int)ResponseType.Ok)
            {
                DateOrNull = WithTime ? SelectDate.GetDate() + timeEntry.Time : SelectDate.GetDate();
            }
            SelectDate.Destroy();
            editDate.Destroy ();
        }
示例#14
0
        /// <summary>
        /// Handles the click on the datetag:
        /// Opens up a calendar dialog
        /// </summary>
        /// <param name="editor">
        /// A <see cref="NoteEditor"/>
        /// </param>
        /// <param name="start">
        /// A <see cref="Gtk.TextIter"/>
        /// </param>
        /// <param name="end">
        /// A <see cref="Gtk.TextIter"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        protected override bool OnActivate(NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end)
        {
            calendar = new Calendar ();
            range = new TextRange (start, end);
            this.editor = editor;

            Dialog dialog = new Dialog ();
            dialog.Modal = true;
            dialog.VBox.Add (calendar);
            dialog.VBox.ShowAll ();
            dialog.AddButton ("OK", ResponseType.Ok);
            dialog.AddButton ("Cancel", ResponseType.Cancel);

            dialog.Response += new ResponseHandler (OnDialogResponse);
            dialog.Run ();
            dialog.Destroy ();

            return true;
        }
示例#15
0
文件: GridView.cs 项目: hol353/ApsimX
 /// <summary>
 /// User is about to edit a cell.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event arguments</param>
 private void OnCellBeginEdit(object sender, EditingStartedArgs e)
 {
     this.userEditingCell = true;
     IGridCell where = GetCurrentCell;
     if (where.RowIndex >= DataSource.Rows.Count)
     {
         for (int i = DataSource.Rows.Count; i <= where.RowIndex; i++)
         {
             DataRow row = DataSource.NewRow();
             DataSource.Rows.Add(row);
         }
     }
     this.valueBeforeEdit = this.DataSource.Rows[where.RowIndex][where.ColumnIndex];
     Type dataType = this.valueBeforeEdit.GetType();
     if (dataType == typeof(DateTime))
     {
         Dialog dialog = new Dialog("Select date", gridview.Toplevel as Window, DialogFlags.DestroyWithParent);
         dialog.SetPosition(WindowPosition.None);
         VBox topArea = dialog.VBox;
         topArea.PackStart(new HBox());
         Calendar calendar = new Calendar();
         calendar.DisplayOptions = CalendarDisplayOptions.ShowHeading |
                              CalendarDisplayOptions.ShowDayNames |
                              CalendarDisplayOptions.ShowWeekNumbers;
         calendar.Date = (DateTime)this.valueBeforeEdit;
         topArea.PackStart(calendar, true, true, 0);
         dialog.ShowAll();
         dialog.Run();
         // What SHOULD we do here? For now, assume that if the user modified the date in the calendar dialog,
         // the resulting date is what they want. Otherwise, keep the text-editing (Entry) widget active, and
         // let the user enter a value manually.
         if (calendar.Date != (DateTime)this.valueBeforeEdit)
         {
             DateTime date = calendar.GetDate();
             this.DataSource.Rows[where.RowIndex][where.ColumnIndex] = date;
             CellRendererText render = sender as CellRendererText;
             if (render != null)
             {
                 render.Text = String.Format("{0:d}", date);
                 if (e.Editable is Entry)
                 {
                     (e.Editable as Entry).Text = render.Text;
                     (e.Editable as Entry).Destroy();
                     this.userEditingCell = false;
                     if (this.CellsChanged != null)
                     {
                         GridCellsChangedArgs args = new GridCellsChangedArgs();
                         args.ChangedCells = new List<IGridCell>();
                         args.ChangedCells.Add(this.GetCell(where.ColumnIndex, where.RowIndex));
                         this.CellsChanged(this, args);
                     }
                 }
             }
         }
         dialog.Destroy();
     }
 }
        void CreateWidget()
        {
            Homogeneous = false;
            Spacing = 1;

            Add (date_entry = new Entry () {WidthChars = 10, IsEditable = true});
            date_entry.Changed += HandleDateEntryChanged;
            date_entry.Show ();
            var bbox = new HBox ();
            Widget w;
            bbox.Add (w = calendar_label = new Label (Catalog.GetString ("Calendar")));
            w.Show ();
            bbox.Add (w = new Arrow (ArrowType.Down, ShadowType.Out));
            w.Show ();
            bbox.Show ();
            Add (date_button = new Button (bbox));
            date_button.Clicked += HandleCalendarButtonClicked;
            date_button.Show ();
            Add (time_entry = new Entry () {WidthChars = 12, IsEditable = true});
            time_entry.Changed += HandleTimeEntryChanged;
            time_entry.Show ();
            Add (offset_entry = new Entry () {WidthChars = 6, IsEditable = true});
            offset_entry.Changed += HandleOffsetEntryChanged;
            offset_entry.Show ();

            calendar = new Calendar ();
            calendar.DaySelected += HandleCalendarDaySelected;
            calendar.DaySelectedDoubleClick += HandleCalendarDaySelectedDoubleClick;
            var frame = new Frame ();
            frame.Add (calendar);
            calendar.Show ();
            calendar_popup = new Window (WindowType.Popup) {DestroyWithParent = true, Resizable = false};
            calendar_popup.Add (frame);
            calendar_popup.DeleteEvent += HandlePopupDeleted;
            calendar_popup.KeyPressEvent += HandlePopupKeyPressed;
            calendar_popup.ButtonPressEvent += HandlePopupButtonPressed;
            frame.Show ();

            UpdateWidget ();
        }
示例#17
0
		public DateEdit (System.DateTime time, DateEditFlags flags)
		{
			datetime = new DateTimeZone (time);
			datetime.Changed += HandleDateTimeZoneChanged;
			this.flags = flags;

			date_entry = new Gtk.Entry ();
			date_entry.WidthChars = 10;
			date_entry.Changed += HandleDateEntryChanged;
			PackStart (date_entry, true, true, 0);
		
			Gtk.HBox b_box = new Gtk.HBox ();
			b_box.PackStart (new Gtk.Label (Catalog.GetString ("Calendar")), true, true, 0);
			b_box.PackStart (new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), true, false, 0);
			date_button = new Gtk.Button (b_box);
			date_button.Clicked += HandleCalendarButtonClicked;
			PackStart (date_button, false, false, 0);

			calendar = new Gtk.Calendar ();
			calendar.DaySelected += HandleCalendarDaySelected;
			Gtk.Frame frame = new Gtk.Frame ();
			frame.Add (calendar);
			cal_popup = new Gtk.Window (Gtk.WindowType.Popup);
			cal_popup.DestroyWithParent = true;
			cal_popup.Add (frame);
			cal_popup.Shown += HandleCalendarPopupShown;
			cal_popup.GrabNotify += HandlePopupGrabNotify;
			frame.Show ();
			calendar.Show ();

			time_entry = new Gtk.Entry ();
			time_entry.WidthChars = 8;
			time_entry.Changed += HandleTimeEntryChanged;
			PackStart (time_entry, true, true, 0);

			Gtk.CellRendererText timecell = new Gtk.CellRendererText ();
			time_combo = new Gtk.ComboBox ();
			time_store = new Gtk.TreeStore (typeof (string), typeof (int), typeof (int)); 
			time_combo.Model = time_store;
			time_combo.PackStart (timecell, true);
			time_combo.SetCellDataFunc (timecell, new CellLayoutDataFunc (TimeCellFunc));
			time_combo.Realized += FillTimeCombo;
			time_combo.Changed += HandleTimeComboChanged;
			PackStart (time_combo, false, false, 0);

			zone_entry = new Gtk.Entry ();
			zone_entry.IsEditable = false;
			zone_entry.MaxLength = 6;
			zone_entry.WidthChars = 6;
			PackStart (zone_entry, true, true, 0);

			Gtk.CellRendererText offsetcell = new Gtk.CellRendererText ();
			offset_combo = new Gtk.ComboBox ();
			offset_combo.Model = new Gtk.TreeStore (typeof (string), typeof (int));
			offset_combo.PackStart (offsetcell, true);
			offset_combo.SetCellDataFunc (offsetcell, new CellLayoutDataFunc (OffsetCellFunc));
			FillOffsetCombo ();
			offset_combo.Changed += HandleOffsetComboChanged;
			PackStart (offset_combo, false, false, 0);

			Update ();
			ShowAll ();
		}
示例#18
0
        private void ShowPopup()
        {
            win = new Gtk.Window(Gtk.WindowType.Popup);
            win.Screen = this.Screen;
            win.WidthRequest = this.Allocation.Width;

            cal = new Gtk.Calendar();
            win.Add(cal);

            if (validDate)
                cal.Date = date;

            // events
            win.ButtonPressEvent		+= OnWinButtonPressEvent;
            cal.DaySelectedDoubleClick	+= OnCalDaySelectedDoubleClick;
            cal.KeyPressEvent			+= OnCalKeyPressEvent;
            cal.ButtonPressEvent		+= OnCalButtonPressEvent;

            int x, y;
            GetWidgetPos(this, out x, out y);
            win.Move(x, y + Allocation.Height + 2);
            win.ShowAll();
            win.GrabFocus();

            Grab.Add(win);

            Gdk.GrabStatus grabStatus;

            grabStatus = Gdk.Pointer.Grab(win.GdkWindow, true, EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask, null, null, Gtk.Global.CurrentEventTime);
            if (grabStatus == Gdk.GrabStatus.Success) {
                grabStatus = Gdk.Keyboard.Grab(win.GdkWindow, true, Gtk.Global.CurrentEventTime);
                if (grabStatus != Gdk.GrabStatus.Success) {
                    Grab.Remove(win);
                    win.Destroy();
                    win = null;
                }
            } else {
                Grab.Remove(win);
                win.Destroy();
                win = null;
            }
        }
        public DateEdit(System.DateTime time, DateEditFlags flags)
        {
            datetime          = new DateTimeZone(time);
            datetime.Changed += HandleDateTimeZoneChanged;
            this.flags        = flags;

            date_entry            = new Gtk.Entry();
            date_entry.WidthChars = 10;
            date_entry.Changed   += HandleDateEntryChanged;
            PackStart(date_entry, true, true, 0);

            Gtk.HBox b_box = new Gtk.HBox();
            b_box.PackStart(new Gtk.Label(Catalog.GetString("Calendar")), true, true, 0);
            b_box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), true, false, 0);
            date_button          = new Gtk.Button(b_box);
            date_button.Clicked += HandleCalendarButtonClicked;
            PackStart(date_button, false, false, 0);

            calendar              = new Gtk.Calendar();
            calendar.DaySelected += HandleCalendarDaySelected;
            Gtk.Frame frame = new Gtk.Frame();
            frame.Add(calendar);
            cal_popup = new Gtk.Window(Gtk.WindowType.Popup);
            cal_popup.DestroyWithParent = true;
            cal_popup.Add(frame);
            cal_popup.Shown      += HandleCalendarPopupShown;
            cal_popup.GrabNotify += HandlePopupGrabNotify;
            frame.Show();
            calendar.Show();

            time_entry            = new Gtk.Entry();
            time_entry.WidthChars = 8;
            time_entry.Changed   += HandleTimeEntryChanged;
            PackStart(time_entry, true, true, 0);

            Gtk.CellRendererText timecell = new Gtk.CellRendererText();
            time_combo       = new Gtk.ComboBox();
            time_store       = new Gtk.TreeStore(typeof(string), typeof(int), typeof(int));
            time_combo.Model = time_store;
            time_combo.PackStart(timecell, true);
            time_combo.SetCellDataFunc(timecell, new CellLayoutDataFunc(TimeCellFunc));
            time_combo.Realized += FillTimeCombo;
            time_combo.Changed  += HandleTimeComboChanged;
            PackStart(time_combo, false, false, 0);

            zone_entry            = new Gtk.Entry();
            zone_entry.IsEditable = false;
            zone_entry.MaxLength  = 6;
            zone_entry.WidthChars = 6;
            PackStart(zone_entry, true, true, 0);

            Gtk.CellRendererText offsetcell = new Gtk.CellRendererText();
            offset_combo       = new Gtk.ComboBox();
            offset_combo.Model = new Gtk.TreeStore(typeof(string), typeof(int));
            offset_combo.PackStart(offsetcell, true);
            offset_combo.SetCellDataFunc(offsetcell, new CellLayoutDataFunc(OffsetCellFunc));
            FillOffsetCombo();
            offset_combo.Changed += HandleOffsetComboChanged;
            PackStart(offset_combo, false, false, 0);

            Update();
            ShowAll();
        }