Skip to content

Commit

Permalink
smooth release 0.8.69.1
Browse files Browse the repository at this point in the history
  • Loading branch information
enzo1982 committed Feb 6, 2007
1 parent edb42ed commit 726d587
Show file tree
Hide file tree
Showing 108 changed files with 5,083 additions and 6,378 deletions.
6 changes: 5 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
ChangeLog for smooth

xx.01.07 xx:xx - smooth alpha 0.8.69.1
06.02.07 13:18 - smooth alpha 0.8.69.1

- list.cpp - Speed optimizations
- buffer.cpp - Fixed problems when using const Buffer<>
- icon.cpp - Added an image loader for Windows icon resources
- widget.cpp - Renamed RegisterObject to Add
- Renamed UnregisterObject to Remove
- app..tion.cpp - Moved main loop to Application

- simplified Array<> API
- converted project to MSVC 8.0
Expand Down
23 changes: 19 additions & 4 deletions Makefile-objects
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ $(OBJECTDIR)/size.o: $(GRAPHICSCLASSESDIR)/forms/size.cpp $(SMOOTHINCLUDEDIR)/gr
$(COMPILER) $(COMPILER_OPTS) $(GRAPHICSCLASSESDIR)/forms/size.cpp -o $(OBJECTDIR)/size.o
$(ECHO) done.

$(OBJECTDIR)/imageloader_icon.o: $(GRAPHICSCLASSESDIR)/imageloader/icon.cpp $(SMOOTHINCLUDEDIR)/graphics/imageloader/icon.h
$(ECHO) -n Compiling $(GRAPHICSCLASSESDIR)/imageloader/icon.cpp...
$(COMPILER) $(COMPILER_OPTS) $(GRAPHICSCLASSESDIR)/imageloader/icon.cpp -o $(OBJECTDIR)/imageloader_icon.o
$(ECHO) done.

$(OBJECTDIR)/imageloader.o: $(GRAPHICSCLASSESDIR)/imageloader/imageloader.cpp $(SMOOTHINCLUDEDIR)/graphics/imageloader/imageloader.h
$(ECHO) -n Compiling $(GRAPHICSCLASSESDIR)/imageloader/imageloader.cpp...
$(COMPILER) $(COMPILER_OPTS) $(GRAPHICSCLASSESDIR)/imageloader/imageloader.cpp -o $(OBJECTDIR)/imageloader.o
Expand Down Expand Up @@ -540,6 +545,16 @@ $(OBJECTDIR)/stream.o: $(IOCLASSESDIR)/stream.cpp $(SMOOTHINCLUDEDIR)/io/stream.
$(COMPILER) $(COMPILER_OPTS) $(IOCLASSESDIR)/stream.cpp -o $(OBJECTDIR)/stream.o
$(ECHO) done.

$(OBJECTDIR)/base64.o: $(MISCCLASSESDIR)/encoding/base64.cpp $(SMOOTHINCLUDEDIR)/misc/encoding/base64.h
$(ECHO) -n Compiling $(MISCCLASSESDIR)/encoding/base64.cpp...
$(COMPILER) $(COMPILER_OPTS) $(MISCCLASSESDIR)/encoding/base64.cpp -o $(OBJECTDIR)/base64.o
$(ECHO) done.

$(OBJECTDIR)/crc32.o: $(MISCCLASSESDIR)/hash/crc32.cpp $(SMOOTHINCLUDEDIR)/misc/hash/crc32.h
$(ECHO) -n Compiling $(MISCCLASSESDIR)/hash/crc32.cpp...
$(COMPILER) $(COMPILER_OPTS) $(MISCCLASSESDIR)/hash/crc32.cpp -o $(OBJECTDIR)/crc32.o
$(ECHO) done.

$(OBJECTDIR)/args.o: $(MISCCLASSESDIR)/args.cpp $(SMOOTHINCLUDEDIR)/misc/args.h
$(ECHO) -n Compiling $(MISCCLASSESDIR)/args.cpp...
$(COMPILER) $(COMPILER_OPTS) $(MISCCLASSESDIR)/args.cpp -o $(OBJECTDIR)/args.o
Expand Down Expand Up @@ -775,9 +790,9 @@ $(OBJECTDIR)/codecs.o: $(MISCDIR)/codecs.cpp $(SMOOTHINCLUDEDIR)/codecs.h
$(COMPILER) $(COMPILER_OPTS) $(MISCDIR)/codecs.cpp -o $(OBJECTDIR)/codecs.o
$(ECHO) done.

$(OBJECTDIR)/loop.o: $(MISCDIR)/loop.cpp $(SMOOTHINCLUDEDIR)/loop.h
$(ECHO) -n Compiling $(MISCDIR)/loop.cpp...
$(COMPILER) $(COMPILER_OPTS) $(MISCDIR)/loop.cpp -o $(OBJECTDIR)/loop.o
$(OBJECTDIR)/init.o: $(MISCDIR)/init.cpp $(SMOOTHINCLUDEDIR)/init.h
$(ECHO) -n Compiling $(MISCDIR)/init.cpp...
$(COMPILER) $(COMPILER_OPTS) $(MISCDIR)/init.cpp -o $(OBJECTDIR)/init.o
$(ECHO) done.

$(OBJECTDIR)/pciio.o: $(MISCDIR)/pciio.cpp $(SMOOTHINCLUDEDIR)/pciio.h
Expand Down Expand Up @@ -817,7 +832,7 @@ $(OBJECTDIR)/translator_translator.o: $(TRANSLATORDIR)/translator.cpp $(DLLNAME)

$(OBJECTDIR)/translator_resources.o: $(TRANSLATORDIR)/translator.rc
$(ECHO) -n Compiling $(TRANSLATORDIR)/translator.rc...
$(RESCOMP) $(RESCOMP_OPTS) $(TRANSLATORDIR)/translator.rc -o $(OBJECTDIR)/translator_resources.o
$(RESCOMP) $(RESCOMP_OPTS) -D__SMOOTH_DLL__ $(TRANSLATORDIR)/translator.rc -o $(OBJECTDIR)/translator_resources.o
$(ECHO) done.

$(OBJECTDIR)/fribidi2_fribidi.o: $(FRIBIDI2DIR)/fribidi.c
Expand Down
78 changes: 39 additions & 39 deletions ToDo.xml

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions classes/graphics/backends/gdi/bitmapgdi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,18 @@ S::Bool S::GUI::BitmapGDI::SetSystemBitmap(Void *nBitmap)

CreateBitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmBitsPixel);

HDC ddc = GetWindowDC(NIL);
HDC cdc1 = CreateCompatibleDC(ddc);
HDC cdc2 = CreateCompatibleDC(ddc);
HBITMAP backup1 = (HBITMAP) SelectObject(cdc1, nBitmap);
HBITMAP backup2 = (HBITMAP) SelectObject(cdc2, bitmap);
HDC dc1 = CreateCompatibleDC(NIL);
HDC dc2 = CreateCompatibleDC(NIL);
HBITMAP backup1 = (HBITMAP) SelectObject(dc1, nBitmap);
HBITMAP backup2 = (HBITMAP) SelectObject(dc2, bitmap);

BitBlt(cdc2, 0, 0, size.cx, size.cy, cdc1, 0, 0, SRCCOPY);
BitBlt(dc2, 0, 0, size.cx, size.cy, dc1, 0, 0, SRCCOPY);

nBitmap = (HBITMAP) SelectObject(cdc1, backup1);
bitmap = (HBITMAP) SelectObject(cdc2, backup2);
nBitmap = (HBITMAP) SelectObject(dc1, backup1);
bitmap = (HBITMAP) SelectObject(dc2, backup2);

DeleteDC(cdc1);
DeleteDC(cdc2);
ReleaseDC(NIL, ddc);
DeleteDC(dc1);
DeleteDC(dc2);
}

return True;
Expand Down
4 changes: 2 additions & 2 deletions classes/graphics/backends/gdi/surfacegdi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ S::Int S::GUI::SurfaceGDI::SetText(const String &string, const Rect &iRect, cons

for (Int j = 0; j < txtsize; j++) if (string[j] == 10) lines++;

if (Setup::enableUnicode) hfont = CreateFontW(-Math::Round(font.GetSize() * 128.0 / GetDeviceCaps(gdi_dc, LOGPIXELSY)), 0, 0, 0, (font.GetWeight() == Font::Bold) ? FW_BOLD : FW_NORMAL, font.GetStyle() & Font::Italic, font.GetStyle() & Font::Underline, font.GetStyle() & Font::StrikeOut, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, font.GetName());
else hfont = CreateFontA(-Math::Round(font.GetSize() * 128.0 / GetDeviceCaps(gdi_dc, LOGPIXELSY)), 0, 0, 0, (font.GetWeight() == Font::Bold) ? FW_BOLD : FW_NORMAL, font.GetStyle() & Font::Italic, font.GetStyle() & Font::Underline, font.GetStyle() & Font::StrikeOut, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, font.GetName());
if (Setup::enableUnicode) hfont = CreateFontW(-Math::Round(font.GetSize() * 128.0 / GetDeviceCaps(gdi_dc, LOGPIXELSY)), 0, 0, 0, font.GetWeight(), font.GetStyle() & Font::Italic, font.GetStyle() & Font::Underline, font.GetStyle() & Font::StrikeOut, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, font.GetName());
else hfont = CreateFontA(-Math::Round(font.GetSize() * 128.0 / GetDeviceCaps(gdi_dc, LOGPIXELSY)), 0, 0, 0, font.GetWeight(), font.GetStyle() & Font::Italic, font.GetStyle() & Font::Underline, font.GetStyle() & Font::StrikeOut, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, font.GetName());

if (!painting)
{
Expand Down
37 changes: 21 additions & 16 deletions classes/graphics/font.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* The smooth Class Library
* Copyright (C) 1998-2006 Robert Kausch <robert.kausch@gmx.net>
* Copyright (C) 1998-2007 Robert Kausch <robert.kausch@gmx.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of "The Artistic License, Version 2.0".
Expand All @@ -14,8 +14,15 @@
S::String S::GUI::Font::Default = "default";
S::Int S::GUI::Font::DefaultSize = 8;

S::Int S::GUI::Font::Normal = 0;
S::Int S::GUI::Font::Bold = 1;
S::Int S::GUI::Font::Thin = 100;
S::Int S::GUI::Font::ExtraLight = 200;
S::Int S::GUI::Font::Light = 300;
S::Int S::GUI::Font::Normal = 400;
S::Int S::GUI::Font::Medium = 500;
S::Int S::GUI::Font::SemiBold = 600;
S::Int S::GUI::Font::Bold = 700;
S::Int S::GUI::Font::ExtraBold = 800;
S::Int S::GUI::Font::Black = 900;

S::Int S::GUI::Font::Italic = 2;
S::Int S::GUI::Font::Underline = 4;
Expand Down Expand Up @@ -185,27 +192,25 @@ S::Int S::GUI::Font::GetLineSizeX(const String &text, Int nOfChars) const
if (nOfChars == 0) return 0;

#ifdef __WIN32__
HDC ddc = GetWindowDC(0);
HDC cdc = CreateCompatibleDC(ddc);
Int size = -Math::Round(fontSize * 128.0 / GetDeviceCaps(cdc, LOGPIXELSY));
HDC dc = CreateCompatibleDC(NIL);
Int size = -Math::Round(fontSize * 128.0 / GetDeviceCaps(dc, LOGPIXELSY));
HFONT hFont;
HFONT hOldFont;

if (Setup::enableUnicode) hFont = CreateFontW(size, 0, 0, 0, (fontWeight == Font::Bold) ? FW_BOLD : FW_NORMAL, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, fontName);
else hFont = CreateFontA(size, 0, 0, 0, (fontWeight == Font::Bold) ? FW_BOLD : FW_NORMAL, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, fontName);
if (Setup::enableUnicode) hFont = CreateFontW(size, 0, 0, 0, fontWeight, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, fontName);
else hFont = CreateFontA(size, 0, 0, 0, fontWeight, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, fontName);

hOldFont = (HFONT) SelectObject(cdc, hFont);
hOldFont = (HFONT) SelectObject(dc, hFont);

SIZE tSize;

if (Setup::enableUnicode) GetTextExtentPoint32W(cdc, text, nOfChars, &tSize);
else GetTextExtentPoint32A(cdc, text, nOfChars, &tSize);
if (Setup::enableUnicode) GetTextExtentPoint32W(dc, text, nOfChars, &tSize);
else GetTextExtentPoint32A(dc, text, nOfChars, &tSize);

SelectObject(cdc, hOldFont);
SelectObject(dc, hOldFont);
::DeleteObject(hFont);

DeleteDC(cdc);
ReleaseDC(0, ddc);
DeleteDC(dc);

return tSize.cx;
#else
Expand Down Expand Up @@ -239,8 +244,8 @@ S::Int S::GUI::Font::GetLineSizeY(const String &text) const
HFONT hFont;
HFONT hOldFont;

if (Setup::enableUnicode) hFont = CreateFontW(size, 0, 0, 0, (fontWeight == Font::Bold) ? FW_BOLD : FW_NORMAL, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, fontName);
else hFont = CreateFontA(size, 0, 0, 0, (fontWeight == Font::Bold) ? FW_BOLD : FW_NORMAL, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, fontName);
if (Setup::enableUnicode) hFont = CreateFontW(size, 0, 0, 0, fontWeight, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, fontName);
else hFont = CreateFontA(size, 0, 0, 0, fontWeight, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, FF_ROMAN, fontName);

hOldFont = (HFONT) SelectObject(cdc, hFont);

Expand Down
57 changes: 57 additions & 0 deletions classes/graphics/imageloader/icon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* The smooth Class Library
* Copyright (C) 1998-2007 Robert Kausch <robert.kausch@gmx.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of "The Artistic License, Version 2.0".
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */

#include <smooth/graphics/imageloader/icon.h>
#include <smooth/init.h>

S::GUI::ImageLoaderIcon::ImageLoaderIcon(const String &iFileName) : ImageLoader(iFileName)
{
}

S::GUI::ImageLoaderIcon::~ImageLoaderIcon()
{
}

const S::GUI::Bitmap &S::GUI::ImageLoaderIcon::Load()
{
Int iconID = fileName.Tail(fileName.Length() - 5).ToInt();

if (iconID != 0)
{
HICON icon = NIL;

if (iconID >= 32512 && iconID <= 32517)
{
if (Setup::enableUnicode) icon = (HICON) LoadImageW(NIL, MAKEINTRESOURCEW(iconID), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS | LR_SHARED);
else icon = (HICON) LoadImageA(NIL, MAKEINTRESOURCEA(iconID), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS | LR_SHARED);
}
else
{
if (Setup::enableUnicode) icon = (HICON) LoadImageW(hInstance, MAKEINTRESOURCEW(iconID), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS | LR_SHARED);
else icon = (HICON) LoadImageA(hInstance, MAKEINTRESOURCEA(iconID), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS | LR_SHARED);
}

Bitmap nBitmap(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 24);

HDC dc = CreateCompatibleDC(NIL);
HBRUSH brush = CreateSolidBrush(Setup::BackgroundColor);
HBITMAP backup = (HBITMAP) SelectObject(dc, nBitmap.GetSystemBitmap());

DrawIconEx(dc, 0, 0, icon, 0, 0, 0, brush, DI_DEFAULTSIZE | DI_IMAGE | DI_MASK);

bitmap.SetSystemBitmap((HBITMAP) SelectObject(dc, backup));

::DeleteObject(brush);

DeleteDC(dc);
}

return bitmap;
}
6 changes: 4 additions & 2 deletions classes/graphics/imageloader/imageloader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* The smooth Class Library
* Copyright (C) 1998-2006 Robert Kausch <robert.kausch@gmx.net>
* Copyright (C) 1998-2007 Robert Kausch <robert.kausch@gmx.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of "The Artistic License, Version 2.0".
Expand All @@ -10,6 +10,7 @@

#include <smooth/graphics/imageloader/imageloader.h>
#include <smooth/graphics/imageloader/pci.h>
#include <smooth/graphics/imageloader/icon.h>
#include <smooth/gui/application/application.h>

S::GUI::ImageLoader::ImageLoader(const String &iFileName)
Expand All @@ -25,7 +26,8 @@ S::GUI::Bitmap S::GUI::ImageLoader::Load(const String &fileName)
{
ImageLoader *loader = NIL;

if (fileName.ToLower().Find(".pci:") != -1) loader = new ImageLoaderPCI(fileName);
if (fileName.ToLower().Find(".pci:") != -1) loader = new ImageLoaderPCI(fileName);
else if (fileName.StartsWith("Icon:")) loader = new ImageLoaderIcon(fileName);

if (loader == NIL) return NIL;

Expand Down
89 changes: 88 additions & 1 deletion classes/gui/application/application.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* The smooth Class Library
* Copyright (C) 1998-2006 Robert Kausch <robert.kausch@gmx.net>
* Copyright (C) 1998-2007 Robert Kausch <robert.kausch@gmx.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of "The Artistic License, Version 2.0".
Expand All @@ -9,7 +9,14 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */

#include <smooth/gui/application/application.h>
#include <smooth/gui/window/window.h>
#include <smooth/threads/thread.h>
#include <smooth/i18n/i18n.h>
#include <smooth/system/event.h>
#include <smooth/init.h>

S::Bool S::loopActive = S::False;
S::Int S::peekLoop = 0;

const S::Int S::GUI::Application::classID = S::Object::RequestClassID();

Expand All @@ -25,6 +32,86 @@ S::GUI::Application::Application(const String &name) : Widget(Point(0, 0), Size(
text = name == NIL ? String("smooth Application") : name;
}


S::Int S::GUI::Application::Loop()
{
if (!loopActive)
{
initializing = false;
loopActive = true;

for (Int i = 0; i < Object::GetNOfObjects(); i++)
{
Object *object = Object::GetNthObject(i);

if (object != NIL)
{
if (object->GetObjectType() == GUI::Window::classID)
{
if (!((GUI::Window *) object)->initshow) ((GUI::Window *) object)->Show();
}
}
}

// start waiting threads here

for (Int j = 0; j < Object::GetNOfObjects(); j++)
{
Object *object = Object::GetNthObject(j);

if (object != NIL)
{
if (object->GetObjectType() == Threads::Thread::classID)
{
if (((Threads::Thread *) object)->GetStatus() == Threads::THREAD_STARTME) ((Threads::Thread *) object)->Start();
}
}
}
}

#ifdef __WIN32__
if (GUI::Window::nOfActiveWindows == 0) PostQuitMessage(0);
#endif

System::EventProcessor *event = new System::EventProcessor();
Bool quit = False;

while (!quit)
{
Int result = Success();

if (peekLoop > 0) result = event->ProcessNextEvent(False);
else result = event->ProcessNextEvent(True);

if (result == Break) quit = True;
if (GUI::Window::nOfActiveWindows == 0) quit = True;
}

delete event;

loopActive = false;

for (int i = 0; i < Object::GetNOfObjects(); i++)
{
Object *object = Object::GetNthObject(i);

if (object != NIL)
{
if (object->GetObjectType() == Threads::Thread::classID)
{
if (!(((Threads::Thread *) object)->GetFlags() & Threads::THREAD_KILLFLAG_WAIT)) ((Threads::Thread *) object)->Stop();
}
}
}

/* This is the same as NonBlocking::WaitForRunningCalls(),
so we don't need to call that. */

while (Threads::Thread::GetNOfRunningThreads() > 0) LiSASleep(10);

return Success();
}

S::String S::GUI::Application::GetStartupDirectory()
{
if (startupDirectory != NIL) return startupDirectory;
Expand Down
2 changes: 1 addition & 1 deletion classes/gui/application/background.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* The smooth Class Library
* Copyright (C) 1998-2006 Robert Kausch <robert.kausch@gmx.net>
* Copyright (C) 1998-2007 Robert Kausch <robert.kausch@gmx.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of "The Artistic License, Version 2.0".
Expand Down
Loading

0 comments on commit 726d587

Please sign in to comment.