Пример #1
0
void GWindow::Visible(bool v)
{
	if (v)
	{
		Pour();
	}
	else
	{
		int asd=0;
	}

	if (v)
	{
		SetStyle(GetStyle() | WS_VISIBLE);

		if (_View)
		{
			GWindowZoom z = d->Show;
			char *Cmd = 0;

			WINDOWPLACEMENT *Wp = new WINDOWPLACEMENT;
			if (Wp)
			{
				ZeroObj(*Wp);
				Wp->length = sizeof(*Wp);
				Wp->flags = 2;
				Wp->ptMaxPosition.x = -1;
				Wp->ptMaxPosition.y = -1;

				if (d->Show == GZoomMax)
				{
					Wp->showCmd = SW_MAXIMIZE;
					Cmd = "SW_MAXIMIZE";
				}
				else if (d->Show == GZoomMin)
				{
					Wp->showCmd = SW_MINIMIZE;
					Cmd = "SW_MINIMIZE";
				}
				else
				{
					Wp->showCmd = SW_NORMAL;
					Cmd = "SW_NORMAL";
				}

				Wp->rcNormalPosition = Pos;
				#if DEBUG_WINDOW_PLACEMENT
				LgiTrace("%s:%i - SetWindowPlacement, pos=%s, show=%i\n", __FILE__, __LINE__, Pos.GetStr(), Wp->showCmd);
				#endif
				SetWindowPlacement(_View, Wp);

				if (d->InCreate)
				{
					DeleteObj(d->Wp);
					d->Wp = Wp;
				}
				else
				{
					DeleteObj(Wp);
				}
			}
		}
	}
	else
	{
		#if DEBUG_WINDOW_PLACEMENT
		LgiTrace("%s:%i - Visible(%i)\n", __FILE__, __LINE__, v);
		#endif
		GView::Visible(v);
	}

	if (v)
	{
		OnZoom(d->Show);
	}
}
Пример #2
0
bool GWindow::SerializeState(GDom *Store, const char *FieldName, bool Load)
{
	if (!Store || !FieldName)
		return false;

	#if DEBUG_SERIALIZE_STATE
	LgiTrace("GWindow::SerializeState(%p, %s, %i)\n", Store, FieldName, Load);
	#endif
	if (Load)
	{
		GVariant v;
		if (Store->GetValue(FieldName, v) && v.Str())
		{
			GRect Position(0, 0, -1, -1);
			GWindowZoom State = GZoomNormal;

			#if DEBUG_SERIALIZE_STATE
			LgiTrace("\t::SerializeState:%i v=%s\n", __LINE__, v.Str());
			#endif

			GToken t(v.Str(), ";");
			for (int i=0; i<t.Length(); i++)
			{
				char *Var = t[i];
				char *Value = strchr(Var, '=');
				if (Value)
				{
					*Value++ = 0;

					if (stricmp(Var, "State") == 0)
						State = (GWindowZoom)atoi(Value);
					else if (stricmp(Var, "Pos") == 0)
					{
					    GRect r;
					    r.SetStr(Value);
					    if (r.Valid())
						    Position = r;
					}
				}
				else return false;
			}

			#if DEBUG_SERIALIZE_STATE
			LgiTrace("\t::SerializeState:%i State=%i, Pos=%s\n", __LINE__, State, Position.GetStr());
			#endif

			// Apply any shortcut override
			int Show = LgiApp->GetShow();
			if (Show == SW_SHOWMINIMIZED ||
				Show == SW_SHOWMINNOACTIVE ||
				Show == SW_MINIMIZE)
			{
				State = GZoomMin;
			}
			else if (Show == SW_SHOWMAXIMIZED ||
					 Show == SW_MAXIMIZE)
			{
				State = GZoomMax;
			}

			WINDOWPLACEMENT *Wp = new WINDOWPLACEMENT;
			if (Wp)
			{
				ZeroObj(*Wp);
				Wp->length = sizeof(*Wp);
				if (Visible())
				{
					if (State == GZoomMax)
					{
						Wp->showCmd = SW_SHOWMAXIMIZED;
					}
					else if (State == GZoomMin)
					{
						Wp->showCmd = SW_MINIMIZE;
					}
					else
					{
						Wp->showCmd = SW_NORMAL;
					}
				}
				else
				{
					Wp->showCmd = SW_HIDE;
					d->Show = State;
				}

				if (Position.Valid() &&
					Position.x1 >= 0 &&
					Position.y1 >= 0)
				    Pos = Position;
				else
					Pos.ZOff(800, 600);
				Wp->rcNormalPosition = Pos;
				#if DEBUG_SERIALIZE_STATE
				LgiTrace("%s:%i - SetWindowPlacement, pos=%s, show=%i\n", __FILE__, __LINE__, Pos.GetStr(), Wp->showCmd);
				#endif
				SetWindowPlacement(Handle(), Wp);

				if (d->InCreate)
				{
					DeleteObj(d->Wp);
					d->Wp = Wp;
				}
				else
				{
					DeleteObj(Wp);
				}
			}
		}
		else return false;
	}
	else
	{
		char s[256];
		GWindowZoom State = GetZoom();
		GRect Position;
		
		if (Handle())
		{
		    WINDOWPLACEMENT Wp;
		    ZeroObj(Wp);
		    Wp.length = sizeof(Wp);
		    GetWindowPlacement(Handle(), &Wp);
		    Position = Wp.rcNormalPosition;
		}
		else
		{
		    // A reasonable fall back if we don't have a window...
		    Position = GetPos();
		}
		
		sprintf_s(s, sizeof(s), "State=%i;Pos=%s", State, Position.GetStr());

		#if DEBUG_SERIALIZE_STATE
		LgiTrace("\t::SerializeState:%i s='%s'\n", __LINE__, s);
		#endif

		GVariant v = s;
		if (!Store->SetValue(FieldName, v))
			return false;
	}

	return true;
}
Пример #3
0
	~GWindowPrivate()
	{
		DeleteObj(Wp);
	}
BOOL DetachOperation(ObjDescType ods)
{
	return 	DeleteObj(ods,&Op_Carrier);
}
Пример #5
0
GDocApp<OptionsFmt>::~GDocApp()
{
	DeleteObj(d);
	DeleteObj(Options);
}
Пример #6
0
void CDynamicFilenameSet::FreeObject(Filename *&pObj) const
{
	DeleteObj(pObj);
}
Пример #7
0
	~App()
	{
		DeleteObj(Tree);
	}
Пример #8
0
	virtual void FreeObject(Filename *&pObj) const { DeleteObj(pObj); }
Пример #9
0
GCssTest::~GCssTest()
{
	DeleteObj(d);
}
Пример #10
0
GCombo::~GCombo()
{
	DeleteObj(d);
}
Пример #11
0
	~GBfsDb()
	{
		DeleteObj(Db);
	}
Пример #12
0
	bool Convert(GView *Parent)
	{
		bool Status = false;
		GProgressDlg Dlg(Parent);

		if (Store1 &&
			Store2)
		{
			if (Store1->GetStatus())
			{
				Prog = Dlg.ItemAt(0);
				Dlg.SetDescription("Converting items...");
				Dlg.SetLimits(0, Store1->GetFileSize());
				Dlg.SetScale(1.0 / 1024.0);
				Dlg.SetType("K");

				StorageItem *Item1 = Store1->GetRoot();
				ReaderItem *Reader1 = new ReaderItem(Item1);
				if (Reader1)
				{
					// The storage1 code didn't set the root object's type
					// correctly, leaving it as -1. So on the way over lets
					// correct this little mistake and make it into a folder.
					Reader1->Store->SetType(0xAAFF0003); // magic # for a folder
				}

				WriterItem *Writer2 = new WriterItem(Reader1);
				StorageItem *Item2 = Store2->CreateRoot(Writer2);
				if (Writer2 && Item2)
				{
					Writer2->Store = Item2;
					Item2->Object = Writer2;
				}

				if (Reader1 && Writer2)
				{
					Status = ConvertItem(Reader1, Writer2);

					Reader1->Store->Object = 0;
					Reader1->Store = 0;
					Writer2->Store->Object = 0;
					Writer2->Store = 0;
				}
			}
			else
			{
				GStatusPane *Wnd = dynamic_cast<GStatusPane*>(Prog);
				LgiMsg(	Wnd,
						"The input folders failed to load correctly.\n"
						"Most likely because they are not v1 folders or\n"
						"are corrupt.",
						"Scribe: Folder Compact",
						MB_OK);
			}

			DeleteObj(Store1);
			DeleteObj(Store2);
		}

		return Status;
	}
Пример #13
0
GPrintDC::~GPrintDC()
{
	DeleteObj(d);
}
Пример #14
0
GScreenDC::~GScreenDC()
{
	DeleteObj(d);
}
Пример #15
0
GMessage::Result GWindow::OnEvent(GMessage *Msg)
{
	int Status = 0;

	switch (MsgCode(Msg))
	{
		case M_SET_WINDOW_PLACEMENT:
		{
			/*	
				Apparently if you use SetWindowPlacement inside the WM_CREATE handler,
				then the restored rect doesn't "stick", it gets stomped on by windows.
				So this code... RESETS it to be what we set earlier. Windows sucks.
			*/
			if (d->Wp)
			{
				if (_View)
				{
					GRect r = d->Wp->rcNormalPosition;

					if (!GView::Visible())
					{
						d->Wp->showCmd = SW_HIDE;
					}

					#if DEBUG_WINDOW_PLACEMENT
					LgiTrace("%s:%i - SetWindowPlacement, pos=%s, show=%i\n", __FILE__, __LINE__, r.GetStr(), d->Wp->showCmd);
					#endif

					SetWindowPlacement(_View, d->Wp);
				}
				DeleteObj(d->Wp);
			}
			break;
		}
		case WM_SYSCOLORCHANGE:
		{
			LgiInitColours();
			break;
		}
		case WM_WINDOWPOSCHANGING:
		{
			bool Icon = IsIconic(Handle());
			bool Zoom = IsZoomed(Handle());

			if (!Icon && (_Dialog || !Zoom))
			{
				WINDOWPOS *Info = (LPWINDOWPOS) Msg->b;
				if (!Info)
				    break;
				    
				if (Info->flags == (SWP_NOSIZE | SWP_NOMOVE) && _Dialog)
				{
				    // Info->flags |= SWP_NOZORDER;
				    Info->hwndInsertAfter = _Dialog->Handle();
				}

				if (GetMinimumSize().x &&
					GetMinimumSize().x > Info->cx)
				{
					Info->cx = GetMinimumSize().x;
				}

				if (GetMinimumSize().y &&
					GetMinimumSize().y > Info->cy)
				{
					Info->cy = GetMinimumSize().y;
				}

				RECT Rc;
				if (d->SnapToEdge &&
					SystemParametersInfo(SPI_GETWORKAREA, 0, &Rc, SPIF_SENDCHANGE))
				{
					GRect r = Rc;
					GRect p(Info->x,
					        Info->y,
					        Info->x + Info->cx - 1,
					        Info->y + Info->cy - 1);
					
					if (r.Valid() && p.Valid())
					{
						int Snap = 12;

						if (abs(p.x1 - r.x1) <= Snap)
						{
							// Snap left edge
							Info->x = r.x1;
						}
						else if (abs(p.x2 - r.x2) <= Snap)
						{
							// Snap right edge
							Info->x = r.x2 - Info->cx + 1;
						}

						if (abs(p.y1 - r.y1) <= Snap)
						{
							// Snap top edge
							Info->y = r.y1;
						}
						else if (abs(p.y2 - r.y2) <= Snap)
						{
							// Snap bottom edge
							Info->y = r.y2 - Info->cy + 1;
						}
					}
				}
			}
			break;
		}
		case WM_SIZE:
		{
			if (Visible())
			{
				GWindowZoom z = d->Show;
				switch (Msg->a)
				{
					case SIZE_MINIMIZED:
					{
						z = GZoomMin;
						break;
					}
					case SIZE_MAXIMIZED:
					{
						z = GZoomMax;
						break;
					}
					case SIZE_RESTORED:
					{
						z = GZoomNormal;
						break;
					}
				}
				if (z != d->Show)
				{
					OnZoom(d->Show = z);
				}
			}

			Status = GView::OnEvent(Msg);
			break;
		}
		case WM_ACTIVATE:
		{
			// This is a hack to make Windows set the focus of a child
			// control when you Alt-Tab in and out of a top level window
			if (LOWORD(Msg->a) != WA_INACTIVE)
			{
				/*
				// gaining focus
				if (LastFocus)
				{
					if (In_SetWindowPos)
					{
						assert(0);
						LgiTrace("%s:%i - %s->SetFocus()\n", __FILE__, __LINE__, GetClass());
					}
					SetFocus(LastFocus);
					LastFocus = 0;
				}
				
				if (d->Focus && d->Focus->Handle())
				{
					if (In_SetWindowPos)
					{
						assert(0);
						LgiTrace("%s:%i - %s->SetFocus()\n", __FILE__, __LINE__, GetClass());
					}
					else
					{					
						::SetFocus(d->Focus->Handle());
					}
				}
				*/
			}
			/*
			else
			{
				// losing focus
				LastFocus = 0;
				HWND f = GetFocus();
				for (HWND p = ::GetParent(f); p; p = ::GetParent(p))
				{
					if (p == Handle())
					{
						LastFocus = f;
					}
				}
			}
			*/
			break;
		}
		case WM_CREATE:
		{
			Pour();
			OnCreate();

			if (!_Default)
			{
				_Default = FindControl(IDOK);
				if (_Default)
				{
					_Default->Invalidate();
				}
			}

			d->InCreate = false;
			if (d->Wp)
			{
				PostEvent(M_SET_WINDOW_PLACEMENT);
			}
			break;
		}
		case WM_WINDOWPOSCHANGED:
		{
			DeleteObj(d->Wp);
			Status = GView::OnEvent(Msg);
			break;
		}
		case WM_QUERYENDSESSION:
	 	case WM_CLOSE:
		{
			bool QuitApp;
			if (QuitApp = OnRequestClose(MsgCode(Msg) == WM_QUERYENDSESSION))
			{
				Quit();
			}

			if (MsgCode(Msg) == WM_CLOSE)
			{
				return 0;
			}
			else
			{
				return QuitApp;
			}
			break;
		}
		case WM_SYSCOMMAND:
		{
		    if (Msg->a == SC_CLOSE)
		    {
    			if (OnRequestClose(false))
    		    {
    		        Quit();
    		    }

   		        return 0;
		    }
		    else
		    {
			    Status = GView::OnEvent(Msg);
			}
		    break;
		}
		case WM_DROPFILES:
		{
			HDROP hDrop = (HDROP) Msg->a;
			if (hDrop)
			{
				GArray<char*> FileNames;
				int Count = 0;
				
				Count = DragQueryFileW(hDrop, -1, NULL, 0);

				for (int i=0; i<Count; i++)
				{
					char16 FileName[256];
					if (DragQueryFileW(hDrop, i, FileName, sizeof(FileName)-1) > 0)
					{
						FileNames.Add(LgiNewUtf16To8(FileName));
					}
				}

				OnReceiveFiles(FileNames);
				FileNames.DeleteArrays();
			}
			break;
		}
		case M_HANDLEMOUSEMOVE:
		{
			// This receives events fired from the GMouseHookPrivate class so that
			// non-LGI windows create mouse hook events as well.
			GTempView v((OsView)MsgB(Msg));
			GMouse m;
			m.x = LOWORD(MsgA(Msg));
			m.y = HIWORD(MsgA(Msg));
			HandleViewMouse(&v, m);
			break;
		}
		case M_COMMAND:
		{
			HWND OurWnd = Handle(); // copy onto the stack, because
									// we might lose the 'this' object in the
									// OnCommand handler which would delete
									// the memory containing the handle.

			Status = OnCommand(Msg->a, 0, (HWND) Msg->b);
			if (!IsWindow(OurWnd))
			{
				// The window was deleted so break out now
				break;
			}
			// otherwise fall thru to the GView handler
		}
		default:
		{
			Status = GView::OnEvent(Msg);
			break;
		}
	}

	return Status;
}
Пример #16
0
GPrinter::~GPrinter()
{
	DeleteObj(d);
}
Пример #17
0
GDragDropSource::~GDragDropSource()
{
	DeleteObj(d);
}
Пример #18
0
void FreeDiffZipCommand()
{
	if (g_pDistriDialog)
		DeleteObj(g_pDistriDialog);
}
Пример #19
0
void CDynamicStringArray::FreeObject(String *&pObj) const
{
	DeleteObj(pObj);
}
Пример #20
0
GButton::~GButton()
{
	DeleteObj(d);
}
Пример #21
0
GDialog::~GDialog()
{
	DeleteObj(d);
}
Пример #22
0
GAnonPipe::~GAnonPipe()
{
	DeleteObj(d);
}