ecere: DateBox with pulled CalendarControl fixes
authorJerome St-Louis <jerome@ecere.com>
Sat, 20 Aug 2011 06:51:42 +0000 (02:51 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sat, 20 Aug 2011 06:51:42 +0000 (02:51 -0400)
ecere/src/gui/Window.ec
ecere/src/gui/drivers/Win32Interface.ec
ecere/src/gui/drivers/XInterface.ec
ecere/src/sys/Date.ec

index fe35681..f81ecd2 100644 (file)
@@ -3569,7 +3569,7 @@ private:
                   {
                      if(rootWindow != this)
                      {
-                        if(activateParent && !parent.active /*parent != parent.parent.activeChild*/)
+                        if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
                            parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
                      }
                      else if(!guiApp.fullScreenMode)
@@ -3943,6 +3943,13 @@ private:
                   if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) || 
                      (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
                   {
+                     // Let the OnLeftButtonDown do the activating instead
+                     if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
+                     {
+                        window = null;
+                        result = true;
+                     }
+                     else
                      //if(activate)
                      {
                         incref activateWindow;
index dbcdb94..5b56824 100644 (file)
@@ -812,7 +812,7 @@ class Win32Interface : Interface
                   //case WM_NCLBUTTONDOWN:
                   case WM_LBUTTONDOWN:
                      window.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown,x,y,&code, false, 
-                                             (msg == WM_LBUTTONDBLCLK) ? false: true);
+                                             /*(msg == WM_LBUTTONDBLCLK) ? false: */true);
                      break;
                   //case WM_NCLBUTTONUP:
                   case WM_LBUTTONUP:      window.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp, x,y,&code, false, false);break;
index dc0e078..db6c243 100644 (file)
@@ -1352,7 +1352,7 @@ class XInterface : Interface
                            break;
                         }
                      }
-                     window.MouseMessage(button, event->x_root, event->y_root, &keyFlags, false, doubleClick? false : true);
+                     window.MouseMessage(button, event->x_root, event->y_root, &keyFlags, false, /*doubleClick? false : */true);
                   }
                   //*if(xGlobalDisplay) XLockDisplay(xGlobalDisplay);
                   delete window;
index 93ba12e..9ca085f 100644 (file)
@@ -301,13 +301,28 @@ public struct Date
 
 class DateDropBox : DropBox
 {
+   bool dateModified;
+   void EditNotifyUpdate(EditBox editBox)
+   {
+      if(pullDown)
+         dateModified = true;
+   }
+
+   bool OnPostCreate()
+   {
+      editBox.NotifyUpdate = EditNotifyUpdate;
+      return true;
+   }
    bool OnKeyDown(Key key, unichar ch)
    {
-      if(pullDown && (SmartKey)key == enter)
+      SmartKey sKey = (SmartKey)key;
+      if(pullDown && sKey == enter)
       {
-         NotifyTextEntry(master, this, null, false);
+         // Because we can still edit the date text while the calendar is dropped, enter on the date box should validate it
+         NotifyTextEntry(master, this, contents /*null*/, true);//false);
          ((DataBox)master).SetData(&calendar.dateValue, false);
          ((DataBox)master).Refresh();
+         return false;
       }
       return DropBox::OnKeyDown(key, ch);
    }
@@ -316,11 +331,40 @@ class DateDropBox : DropBox
       master = this, autoCreate = false;
       interim = true;
 
+      bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
+      {
+         if(!active)
+         {
+            DateDropBox dropBox = (DateDropBox)master;
+            Destroy(0);
+            ((DataBox)dropBox.master).Refresh();
+            *goOnWithActivation = false;
+         }
+         return true;
+      }
+
       void NotifyChanged(bool close)
       {
          incref this;
-         NotifyTextEntry(master, this, null, false);
-         ((DataBox)master).SetData(&calendar.dateValue, false);
+         if(dateModified)
+         {
+            Date date = calendar.dateValue;
+            dateModified = false;
+            if(date.OnGetDataFromString(contents))
+            {
+               if(date.year || date.month || date.day)
+               {
+                  calendar.dateValue = date;
+                  calendar.shownMonth = date.month;
+                  calendar.shownYear = date.year;
+                  dateModified = true;
+               }
+            }
+         }
+         if(!dateModified)
+            NotifyTextEntry(master, this, null, false);
+         dateModified = false;
+         //((DataBox)master).SetData(&calendar.dateValue, false);
          if(close)
          {
             OnKeyDown(enter, 0);
@@ -333,6 +377,7 @@ class DateDropBox : DropBox
 
    Window OnDropDown()
    {
+      editBox.Activate();
       if(contents[0])
          NotifyTextEntry(master, this, contents, true);
       calendar.Create();
@@ -354,10 +399,10 @@ class DateDropBox : DropBox
       {
          if(date.OnGetDataFromString(string))
          {
-            // TESTING THIS COMMENTED OUT HERE:
-            /*if(date.year != calendar.dateValue.year ||
+            // TESTING THIS COMMENTED OUT HERE: (Not good -- was modifying on drop down!)
+            if(date.year != calendar.dateValue.year ||
                date.month != calendar.dateValue.month ||
-               date.day != calendar.dateValue.day)*/
+               date.day != calendar.dateValue.day)
                SetData(&date, false);
             if(date.year || date.month || date.day)
             {