Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Window without title bar
Re: Window without title bar [message #14142 is a reply to message #14139] |
Thu, 14 February 2008 22:06 |
Werner
Messages: 234 Registered: May 2006 Location: Cologne / Germany
|
Experienced Member |
|
|
Ok. Just to reconcile those singleton-haters I have created a tiny demo, featuring multiple main windows and multiple subwindows (at most 1 subwindow in 1 main window lest Windows (!) crashes ) with slide effect and fade effect - it goes without saying: WITHOUT using "Single", to say nothing of "singleton".
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class PopUpWin : public LineEdit
{
private:
bool poppedUp_;
void RightDown(Point p, dword keyFlags)
{
Close();
poppedUp_ = false;
}
public:
PopUpWin() : poppedUp_(false) { }
void SetPoppedUp(bool yesNo) { poppedUp_ = yesNo; }
bool IsPoppedUp() const { return poppedUp_; }
};
class MainWin : public TopWindow
{
private:
typedef MainWin CLASSNAME;
static int mainWinCount;
PopUpWin popUp;
virtual void Paint(Draw& w)
{
w.DrawRect(GetSize(), WhiteGray);
w.DrawText(0, 0, "Click left for context menu");
}
virtual void Close()
{
delete this; // window is on the heap
}
void AddMainWin()
{
(new MainWin)->OpenMain();
}
void NoEffect()
{
if (popUp.IsPoppedUp())
return;
popUp.SetPoppedUp(true);
Rect mainRect = GetScreenRect();
popUp.SetRect(mainRect.left + 20, mainRect.top + 20, 300, 225);
popUp.SetColor(TextCtrl::PAPER_NORMAL, LtBlue);
popUp.SetColor(TextCtrl::INK_NORMAL, Yellow);
popUp.Set(String("no effect\nclick right to close"));
popUp.PopUp
(
this, // Ctrl* owner = NULL
true, // bool savebits = true
true, // bool activate = true
true, // bool dropshadow = false
false // bool topmost = false
);
}
void SlideEffect()
{
if (popUp.IsPoppedUp())
return;
popUp.SetPoppedUp(true);
Rect mainRect = GetScreenRect();
popUp.SetRect(mainRect.left + 20, mainRect.top + 20, 4, 3);
popUp.SetColor(TextCtrl::PAPER_NORMAL, LtRed);
popUp.SetColor(TextCtrl::INK_NORMAL, White);
popUp.Set(String("slide effect\nclick right to close"));
popUp.PopUp
(
this, // Ctrl* owner = NULL
true, // bool savebits = true
true, // bool activate = true
true, // bool dropshadow = false
false // bool topmost = false
);
Ctrl::ProcessEvents();
Animate(popUp, RectC(mainRect.left + 20, mainRect.top + 20, 300, 225), GUIEFFECT_SLIDE);
}
void FadeEffect()
{
if (popUp.IsPoppedUp())
return;
popUp.SetPoppedUp(true);
Rect mainRect = GetScreenRect();
popUp.SetRect(mainRect.left + 20, mainRect.top + 20, 300, 225);
popUp.SetColor(TextCtrl::PAPER_NORMAL, LtGreen);
popUp.SetColor(TextCtrl::INK_NORMAL, Blue);
popUp.Set(String("fade effect\nclick right to close"));
popUp.PopUp
(
this, // Ctrl* owner = NULL
true, // bool savebits = true
true, // bool activate = true
true, // bool dropshadow = false
false // bool topmost = false
);
Ctrl::ProcessEvents();
Animate(popUp, RectC(mainRect.left + 20, mainRect.top + 20, 300, 225), GUIEFFECT_FADE);
}
void local_menu(Bar& bar)
{
MenuBar local_menu;
bar.Add("new main window", THISBACK(AddMainWin));
bar.Add("subwindow with no effect", THISBACK(NoEffect));
bar.Add("subwindow with slide effect", THISBACK(SlideEffect));
bar.Add("subwindow with fade effect", THISBACK(FadeEffect));
local_menu.Execute();
}
void LeftDown(Point p, dword keyFlags)
{
MenuBar::Execute(THISBACK(local_menu));
}
public:
MainWin()
{
++mainWinCount;
String title("Multi-windowed App with Subwindow: Window # ");
Title(title + AsString(mainWinCount));
SetRect(40 * mainWinCount, 40 * mainWinCount, 400, 300);
NoCenter();
}
~MainWin()
{
--mainWinCount;
}
};
int MainWin::mainWinCount = 0;
GUI_APP_MAIN
{
(new MainWin)->OpenMain(); // anytime deleteable
Ctrl::EventLoop();
}
Enjoy!
Werner
|
|
|
|
|
Window without title bar
By: DoggyDog on Tue, 12 February 2008 16:48
|
|
|
Re: Window without title bar
By: DoggyDog on Wed, 13 February 2008 12:37
|
|
|
Re: Window without title bar
|
|
|
Re: Window without title bar
By: DoggyDog on Wed, 13 February 2008 13:02
|
|
|
Re: Window without title bar
By: DoggyDog on Wed, 13 February 2008 13:54
|
|
|
Re: Window without title bar
By: Werner on Wed, 13 February 2008 16:41
|
|
|
Re: Window without title bar
By: DoggyDog on Wed, 13 February 2008 17:16
|
|
|
Re: Window without title bar
By: Werner on Wed, 13 February 2008 21:06
|
|
|
Re: Window without title bar
By: DoggyDog on Thu, 14 February 2008 13:15
|
|
|
Re: Window without title bar
By: Werner on Thu, 14 February 2008 13:38
|
|
|
Re: Window without title bar
By: mr_ped on Thu, 14 February 2008 16:15
|
|
|
Re: Window without title bar
By: mrjt on Thu, 14 February 2008 16:18
|
|
|
Re: Window without title bar
|
|
|
Re: Window without title bar
By: Werner on Thu, 14 February 2008 18:54
|
|
|
Re: Window without title bar
By: Werner on Thu, 14 February 2008 22:06
|
|
|
Re: Window without title bar
By: mr_ped on Thu, 14 February 2008 18:07
|
Goto Forum:
Current Time: Sun Apr 28 12:14:08 CEST 2024
Total time taken to generate the page: 0.04562 seconds
|