You can subscribe to this list here.
2004 |
Jan
|
Feb
(48) |
Mar
(80) |
Apr
(9) |
May
(2) |
Jun
(91) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Dejan L. <le...@us...> - 2004-08-22 17:38:03
|
Update of /cvsroot/rtk/rtk/src/core/platform/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv939 Modified Files: File.cpp Log Message: Small cosmetic change... Index: File.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/linux/File.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** File.cpp 13 Jun 2004 19:40:51 -0000 1.11 --- File.cpp 22 Aug 2004 17:37:50 -0000 1.12 *************** *** 33,37 **** * Authors (chronological order): * Dejan Lekic, de...@rt... ! * Dejan Lozanovic, null§rtk.cx * Contributors (chronological order): * $fname $lname, $email --- 33,37 ---- * Authors (chronological order): * Dejan Lekic, de...@rt... ! * Dejan Lozanovic, nullrtk.cx * Contributors (chronological order): * $fname $lname, $email *************** *** 171,181 **** // Convert WCHAR -> CHAR, destination allocated in stack! (no need to free) #define W2A(src, dst) do { \ ! int src_len = rstrlen(src); \ ! int dst_len = wcstombs(NULL, src, src_len); \ ! if(dst_len==-1) break; \ ! char *_dst = (char*)alloca(dst_len+1); \ ! if(wcstombs(_dst, src, src_len)==-1) break; \ ! _dst[dst_len] = '\0'; \ ! dst = (const char*)_dst; \ } while(0) #endif --- 171,181 ---- // Convert WCHAR -> CHAR, destination allocated in stack! (no need to free) #define W2A(src, dst) do { \ ! int src_len = rstrlen(src); \ ! int dst_len = wcstombs(NULL, src, src_len); \ ! if(dst_len==-1) break; \ ! char *_dst = (char*)alloca(dst_len+1); \ ! if(wcstombs(_dst, src, src_len)==-1) break; \ ! _dst[dst_len] = '\0'; \ ! dst = (const char*)_dst; \ } while(0) #endif *************** *** 344,345 **** --- 344,348 ---- }; // Rtk namespace + /** + * $Id$ + ***************************************************************************/ |
From: Dejan L. <le...@us...> - 2004-06-22 20:14:28
|
Update of /cvsroot/rtk/rtk/uml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1278/uml Added Files: rtk.xmi Log Message: This is the initial RTK UML XMI file. We'll use this one for future RTK design. Please whenever You add something COMMIT changes. Also, whenever You want to start working on it UPDATE that file from CVS, because somebody might change it in the meantime. --- NEW FILE: rtk.xmi --- <?xml version="1.0" encoding="UTF-8"?> <XMI xmlns:UML="org.omg/standards/UML" verified="false" timestamp="" xmi.version="1.2" > <XMI.header> <XMI.documentation> <XMI.exporter>umbrello uml modeller http://uml.sf.net</XMI.exporter> <XMI.exporterVersion>1.2.0</XMI.exporterVersion> <XMI.exporterEncoding>UnicodeUTF8</XMI.exporterEncoding> </XMI.documentation> <XMI.model xmi.name="rtk" href="/home/dejan/prj/cxx/rtk/uml/rtk.xmi" /> <XMI.metamodel xmi.name="UML" href="UML.xml" xmi.version="1.3" /> </XMI.header> <XMI.content> <docsettings viewid="1" documentation="" uniqueid="35" /> <UML:Model> <UML:DataType stereotype="datatyp" visibility="public" xmi.id="2" name="int" /> <UML:DataType stereotype="datatyp" visibility="public" xmi.id="3" name="char" /> <UML:DataType stereotype="datatyp" visibility="public" xmi.id="4" name="bool" /> <UML:DataType stereotype="datatyp" visibility="public" xmi.id="5" name="float" /> <UML:DataType stereotype="datatyp" visibility="public" xmi.id="6" name="double" /> <UML:DataType stereotype="datatyp" visibility="public" xmi.id="7" name="long" /> <UML:DataType stereotype="datatyp" visibility="public" xmi.id="8" name="short" /> <UML:DataType stereotype="datatyp" visibility="public" xmi.id="9" name="string" /> <UML:Package visibility="public" xmi.id="15" name="Rtk" /> <UML:Class stereotype="klass" visibility="public" xmi.id="16" name="HashValue" /> <UML:Class stereotype="klass" comment="Root RTK Type (Class)." visibility="public" xmi.id="17" isAbstract="true" name="Object" > <UML:Operation visibility="public" xmi.id="20" type="void" isAbstract="true" name="Put" > <UML:Parameter comment="Standard I/O (Console) object." visibility="public" xmi.id="1" value="" type="Console" name="arg_console" /> </UML:Operation> <UML:Operation visibility="public" xmi.id="21" type="HashValue" isAbstract="true" name="Hash" /> </UML:Class> <UML:Class stereotype="klass" visibility="public" xmi.id="19" name="Console" /> <UML:Class stereotype="klass" comment="Abstract RTK class that gives RTK objects basic persistence (ie. serialisation/deserialisation)." visibility="public" xmi.id="24" isAbstract="true" name="Persistent" > <UML:Operation comment="The only important method in this class. It is used both for serialization and de-serialization. Type of process is determined by second argument." visibility="public" xmi.id="27" type="int" isAbstract="true" name="Serialize" > <UML:Parameter comment="Pointer to IO object that will be used for serialization." visibility="public" xmi.id="1" value="" type="IO" name="arg_io" /> <UML:Parameter comment="bool parameter that determines wheather we'll serialize (true) or de-serialize (false) object." visibility="public" xmi.id="2" value="true" type="bool" name="arg_serialize" /> </UML:Operation> </UML:Class> <UML:Class stereotype="klass" visibility="public" xmi.id="26" name="IO" /> <UML:Class stereotype="klass" visibility="public" xmi.id="35" name="ny_klass" /> <UML:Generalization child="24" visibility="public" xmi.id="25" parent="17" /> </UML:Model> <diagrams> <diagram snapgrid="1" showattsig="1" fillcolor="#ffffc0" zoom="100" showgrid="1" showopsig="1" usefillcolor="1" snapx="10" canvaswidth="1010" snapy="10" showatts="1" xmi.id="1" documentation="$Id: rtk.xmi,v 1.1 2004/06/22 20:14:19 leka Exp $" type="402" showops="1" showpackage="0" name="Rtk" localid="30000" showstereotype="0" showscope="1" snapcsgrid="0" font="Sans,11,-1,5,50,0,0,0,0,0" linecolor="#ff0000" canvasheight="857" > <widgets> <UML:ClassWidget usesdiagramfillcolour="1" width="84" showattsigs="601" usesdiagramusefillcolour="1" x="30" linecolour="none" y="350" showopsigs="601" instancename="" usesdiagramlinecolour="1" fillcolour="none" height="40" usefillcolor="1" showattributes="1" isinstance="0" xmi.id="16" showoperations="1" showpackage="0" showscope="1" showstereotype="0" font="Sans,11,-1,5,75,0,0,0,0,0" /> <UML:ClassWidget usesdiagramfillcolour="0" width="257" showattsigs="601" usesdiagramusefillcolour="0" x="220" linecolour="#ff0000" y="240" showopsigs="601" instancename="" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="70" usefillcolor="1" showattributes="1" isinstance="0" xmi.id="17" showoperations="1" showpackage="0" showscope="1" showstereotype="0" font="Sans,11,-1,5,75,1,0,0,0,0" /> <UML:ClassWidget usesdiagramfillcolour="1" width="68" showattsigs="601" usesdiagramusefillcolour="1" x="30" linecolour="none" y="400" showopsigs="601" instancename="" usesdiagramlinecolour="1" fillcolour="none" height="40" usefillcolor="1" showattributes="1" isinstance="0" xmi.id="19" showoperations="1" showpackage="0" showscope="1" showstereotype="0" font="Sans,11,-1,5,75,0,0,0,0,0" /> <UML:ClassWidget usesdiagramfillcolour="0" width="383" showattsigs="601" usesdiagramusefillcolour="0" x="520" linecolour="#ff0000" y="240" showopsigs="601" instancename="" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="50" usefillcolor="1" showattributes="1" isinstance="0" xmi.id="24" showoperations="1" showpackage="0" showscope="1" showstereotype="0" font="Sans,11,-1,5,75,1,0,0,0,0" /> <UML:ClassWidget usesdiagramfillcolour="1" width="62" showattsigs="601" usesdiagramusefillcolour="1" x="30" linecolour="none" y="450" showopsigs="601" instancename="" usesdiagramlinecolour="1" fillcolour="none" height="40" usefillcolor="1" showattributes="1" isinstance="0" xmi.id="26" showoperations="1" showpackage="0" showscope="1" showstereotype="0" font="Sans,11,-1,5,75,0,0,0,0,0" /> <UML:NoteWidget usesdiagramfillcolour="1" width="556" usesdiagramusefillcolour="1" x="10" linecolour="none" y="10" instancename="" usesdiagramlinecolour="1" fillcolour="none" height="99" usefillcolor="1" isinstance="0" xmi.id="31" text="RTK http://www.rtk.cx $Source: /cvsroot/rtk/rtk/uml/rtk.xmi,v $ $Id: rtk.xmi,v 1.1 2004/06/22 20:14:19 leka Exp $" font="Sans,11,-1,5,50,0,0,0,0,0" /> </widgets> <messages/> <associations> <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="2" indexb="1" widgetbid="17" widgetaid="24" xmi.id="25" > <linepath> <startpoint startx="520" starty="265" /> <endpoint endx="477" endy="275" /> </linepath> </UML:AssocWidget> </associations> </diagram> </diagrams> <listview> <listitem open="1" type="800" id="-1" label="Vyer" > <listitem open="1" type="801" id="-1" label="Logisk vy" > <listitem open="0" type="807" id="1" label="Rtk" /> <listitem open="1" type="813" id="19" label="Console" /> <listitem open="1" type="813" id="16" label="HashValue" /> <listitem open="1" type="813" id="26" label="IO" /> <listitem open="1" type="813" id="17" label="Object" > <listitem open="0" type="815" id="21" label="Hash" /> <listitem open="0" type="815" id="20" label="Put" /> </listitem> <listitem open="1" type="813" id="24" label="Persistent" > <listitem open="0" type="815" id="27" label="Serialize" /> </listitem> <listitem open="1" type="813" id="35" label="ny_klass" /> <listitem open="1" type="818" id="15" label="Rtk" /> <listitem open="1" type="830" id="-1" label="Datatyper" > <listitem open="1" type="829" id="4" label="bool" /> <listitem open="1" type="829" id="3" label="char" /> <listitem open="1" type="829" id="6" label="double" /> <listitem open="1" type="829" id="5" label="float" /> <listitem open="1" type="829" id="2" label="int" /> <listitem open="1" type="829" id="7" label="long" /> <listitem open="1" type="829" id="8" label="short" /> <listitem open="1" type="829" id="9" label="string" /> </listitem> </listitem> <listitem open="1" type="802" id="-1" label="Användningsfallsvy" /> <listitem open="1" type="821" id="-1" label="Komponentvy" /> <listitem open="1" type="827" id="-1" label="Utplaceringsvy" /> </listitem> </listview> <codegeneration/> </XMI.content> </XMI> |
From: Mikko L. <laz...@us...> - 2004-06-19 15:12:34
|
Update of /cvsroot/rtk/rtk/src/gui/VDAL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12106/gui/VDAL Added Files: Win32_VDAL.cpp Log Message: Added first GUI files. NOTE: Nothing usable yet, just sandbox for developing :) --- NEW FILE: Win32_VDAL.cpp --- // VDAL.cpp: implementation of the VDAL class. // ////////////////////////////////////////////////////////////////////// #include <rtk/Gui.h> #include <rtk/WMAL.h> #include <rtk/Win32_VDAL.h> #include <rtk/Win32_GD.h> #include <rtk/rchar.h> #include <stdlib.h> namespace Rtk { // // WM_SYNCPAINT is an "undocumented" message, which is finally defined in // VC++ 6.0. // #ifndef WM_SYNCPAINT # define WM_SYNCPAINT 0x0088 #endif #ifndef WM_MOUSELEAVE # define WM_MOUSELEAVE 0x02a3 #endif #ifndef WM_MOUSEWHEEL # define WM_MOUSEWHEEL 0x020a #endif #ifndef WHEEL_DELTA # define WHEEL_DELTA 120 // according to MSDN. #endif #ifndef ENUM_CURRENT_SETTINGS # define ENUM_CURRENT_SETTINGS ((DWORD)-1) #endif struct WIN32_VDAL_DATA : public VDAL_DATA { HWND wnd; HBITMAP offscr; HDC dc; HRGN region; Win32GD *gd; unsigned flags; }; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// Win32VDAL::Win32VDAL() { owndc = false; //owndc = true; } Win32VDAL::~Win32VDAL() { } static RCHAR class_name[] = _R("RTK DEFAULT WINDOW CLASS"); int Win32VDAL::Init() { instance = ::GetModuleHandle(NULL); WNDCLASSEX wc; // Documentation states a device context consumes about 800 bytes // of memory... so who cares? If 800 bytes per window is what it // takes to speed things up, I'm game. //wc.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC | CS_DBLCLKS; wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; if(owndc) wc.style |= CS_OWNDC; wc.lpfnWndProc = (WNDPROC)Win32VDAL::WndProc; wc.cbClsExtra = wc.cbWndExtra = 0; wc.hInstance = instance; //if (!w->icon()) //w->icon((void *)LoadIcon(NULL, IDI_APPLICATION)); wc.hIcon = wc.hIconSm = 0;//(HICON)w->icon(); wc.hCursor = LoadCursor(NULL, IDC_ARROW); //uchar r,g,b; Fl::get_color(FL_GRAY,r,g,b); //wc.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(178,178,178)); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = class_name; wc.cbSize = sizeof(WNDCLASSEX); RegisterClassEx(&wc); if( !(WMAL::Instance()->GetCaps() & WMAL::MANAGED) ) { // Create desktop window! // CreateWin(-1, -1, 320, 240, 0, 0, 0); } procid = ::GetCurrentThreadId(); return 1; } int borders(int& dx,int& dy,int& dw,int& dh) { dx = dy = dw = dh = 0; #if 0 if (!window->border() || window->override() || window->parent()) { dx = dy = dw = dh = 0; return WS_POPUP; } // resizable else if (window->m_maxw != window->m_minw || window->m_maxh != window->m_minh) #endif { dx = GetSystemMetrics(SM_CXSIZEFRAME); dw = 2*dx; int bt = GetSystemMetrics(SM_CYCAPTION); int by = GetSystemMetrics(SM_CYSIZEFRAME); dy = bt+by; dh = bt+2*by; return WS_THICKFRAME | WS_MAXIMIZEBOX | WS_CAPTION; } #if 0 else { dx = GetSystemMetrics(SM_CXFIXEDFRAME); dw = 2*dx; int bt = GetSystemMetrics(SM_CYCAPTION); int by = GetSystemMetrics(SM_CYFIXEDFRAME); dy = bt+by; dh = bt+2*by; return WS_DLGFRAME | WS_CAPTION; } #endif } VDALHandle Win32VDAL::CreateWin(int x, int y, int w, int h, unsigned flags, void *data, VDALCallback cb) { DWORD dwStyle = WS_OVERLAPPEDWINDOW /*WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPED | WS_SIZEBOX */| WS_VISIBLE; DWORD dwStyleEx = WS_EX_LEFT; int dx,dy,dw,dh; borders(dx,dy,dw,dh); HWND wnd = ::CreateWindowEx(dwStyleEx, class_name, _R("VDAL Window"), dwStyle, (x==-1) ? CW_USEDEFAULT : (x+dx), (y==-1) ? CW_USEDEFAULT : (y+dy), w+dw, h+dh, NULL, NULL, instance, this); WIN32_VDAL_DATA *ret = (WIN32_VDAL_DATA*)calloc(1, sizeof(WIN32_VDAL_DATA)); ret->wnd = wnd; if(owndc) ret->dc = GetDC(wnd); SetWindowLong(wnd, GWL_USERDATA, (LONG)ret); ret->userdata = data; ret->cb = cb; return ret; } bool Win32VDAL::DestroyWin(VDALHandle win) { WIN32_VDAL_DATA *handle = (WIN32_VDAL_DATA *)win; if(handle->dc) ReleaseDC(handle->wnd, handle->dc); DestroyWindow(handle->wnd); free(handle); return true; } static HDC maindc = NULL; VDALHandle Win32VDAL::CreateOffscreen(int w, int h) { WIN32_VDAL_DATA *ret = (WIN32_VDAL_DATA*)calloc(1, sizeof(WIN32_VDAL_DATA)); if(!maindc) maindc = GetDC(NULL); ret->flags = 1; ret->offscr = CreateCompatibleBitmap(maindc, w, h); ret->dc = CreateCompatibleDC(maindc); SelectObject(ret->dc, ret->offscr); return ret; } bool Win32VDAL::ResizeOffscreen(VDALHandle offscr, int w, int h) { WIN32_VDAL_DATA *handle = (WIN32_VDAL_DATA *)offscr; if(!handle->offscr) return false; DeleteObject(handle->offscr); handle->offscr = CreateCompatibleBitmap(maindc, w, h); SelectObject(handle->dc, handle->offscr); return true; } bool Win32VDAL::DestroyOffscreen(VDALHandle offscr) { WIN32_VDAL_DATA *handle = (WIN32_VDAL_DATA *)offscr; if(!handle->offscr) return false; DeleteDC(handle->dc); DeleteObject(handle->offscr); free(handle); return true; } bool Win32VDAL::Copy(VDALHandle dst, int x, int y, int w, int h, VDALHandle src, int srcx, int srcy) { WIN32_VDAL_DATA *dhandle = (WIN32_VDAL_DATA *)dst; WIN32_VDAL_DATA *shandle = (WIN32_VDAL_DATA *)src; HDC dstdc; HDC srcdc = shandle->dc; if(dhandle->dc) dstdc = dhandle->dc; else { dstdc = GetDC(dhandle->wnd); } BitBlt(dstdc, x, y, w, h, srcdc, srcx, srcy, SRCCOPY); if(!dhandle->dc) { ReleaseDC(dhandle->wnd, dstdc); } return true; } GD *Win32VDAL::CreateGD(VDALHandle win) { WIN32_VDAL_DATA *handle = (WIN32_VDAL_DATA *)win; Win32GD *gd = new Win32GD(); if(!owndc) gd->SetHWND(handle->wnd); else gd->SetHDC(handle->dc); return gd; } GD *Win32VDAL::PrepareGD(VDALHandle win) { WIN32_VDAL_DATA *handle = (WIN32_VDAL_DATA *)win; Win32GD *gd = handle->gd; if(!gd) gd = new Win32GD(); if(handle->dc) gd->SetHDC(handle->dc); else gd->SetHWND(handle->wnd); gd->BeginDraw(); handle->gd = gd; if(handle->region) ::SelectClipRgn(gd->GetHDC(), handle->region); return gd; } void Win32VDAL::UnprepareGD(VDALHandle win, GD *gd) { WIN32_VDAL_DATA *handle = (WIN32_VDAL_DATA *)win; if(gd != handle->gd) { printf("OOPS!! Strange GD..\n"); } else { if(handle->region) ::SelectClipRgn(((Win32GD *)gd)->GetHDC(), NULL); gd->EndDraw(); } } MSG win_msg; // WM_MAKEWAITRETURN is the user-defined message that is used to try // to make WaitEvent() return to the main loop so the windows version acts // like GUI programs on more sensible operating systems #define WM_MAKEWAITRETURN (WM_USER+0x456) int Win32VDAL::WaitEvent(int timeout) { int have_message = 0; int timerid; if(timeout < INFINITE) { have_message = PeekMessage(&win_msg, NULL, 0, 0, PM_REMOVE); if(!have_message) { if(timeout > 0) { // Got some time to wait timerid = SetTimer(NULL, 0, timeout, NULL); have_message = GetMessage(&win_msg, NULL, 0, 0); KillTimer(NULL, timerid); if(win_msg.message == WM_TIMER) have_message = 0; // TIMEOUT! } } } else { have_message = GetMessage(&win_msg, NULL, 0, 0); } if(!have_message) { // No messages in given time (if not infinite), // Return 0 to notify that timeout exceed. return 0; } // Execute the message we got, and all other pending messages: while (have_message) { if(win_msg.message != WM_MAKEWAITRETURN) { TranslateMessage(&win_msg); DispatchMessage(&win_msg); } have_message = PeekMessage(&win_msg, NULL, 0, 0, PM_REMOVE); } // Return 1, since there's some events we have handled. return 1; } void Win32VDAL::Wakeup() { PostThreadMessage(procid, WM_MAKEWAITRETURN, 0, 0); } LRESULT CALLBACK Win32VDAL::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WIN32_VDAL_DATA *handle = (WIN32_VDAL_DATA *)GetWindowLong(hWnd, GWL_USERDATA); if(!handle) goto RETURN; switch (uMsg) { case WM_SYNCPAINT : case WM_NCPAINT : case WM_ERASEBKGND : // Andreas Weitl - WM_SYNCPAINT needs to be passed to DefWindowProc // so that Windows can generate the proper paint messages... // Similarly, WM_NCPAINT and WM_ERASEBKGND need this, too... break; case WM_CAPTURECHANGED: break; case WM_QUIT: // this should not happen? //Fl::fatal(_T("WM_QUIT message")); break; case WM_CLOSE: if(handle->cb) (handle->cb)(handle, WIN_CLOSE, 0); return 1; case WM_PAINT: { #if 1 // Merge the region into whatever is accumulated by RTK. I do this // by merging the RTK region to the hWnd and reading the resulting region // back: if(handle->region) InvalidateRgn(hWnd, handle->region, FALSE); else handle->region = CreateRectRgn(0,0,0,0); GetUpdateRgn(hWnd, handle->region, 0); // This convinces MSWindows we have painted whatever they wanted // us to paint, and stops it from sending WM_PAINT messages: ValidateRgn(hWnd, handle->region); if(handle->cb) { (handle->cb)(handle, WIN_FLUSH, 0); } ::DeleteObject(handle->region); handle->region = 0; #else PAINTSTRUCT paint; // Save DC HDC saved_dc = handle->dc; // Merge RTK window clip region if(handle->region) { InvalidateRgn(hWnd, handle->region, FALSE); DeleteObject(handle->region); handle->region = 0; } // Begin handles clipping and validating handle->dc = BeginPaint(hWnd, &paint); GD *gd = VDAL::vdal_instance->PrepareGD(handle); Rtk::FlushWindow(handle, gd); VDAL::vdal_instance->UnprepareGD(handle, gd); // Done! EndPaint(hWnd, &paint); // Restore DC handle->dc = saved_dc; #endif break; } case WM_SIZE: { if (wParam == SIZE_MINIMIZED || wParam == SIZE_MAXHIDE) { // iconize } else { if(handle->cb) { long args[3] = { LOWORD(lParam), HIWORD(lParam), 0 }; (handle->cb)(handle, WIN_RESIZE, args); } } break; } default: break; } RETURN: return DefWindowProc(hWnd, uMsg, wParam, lParam); } }; // namespace Rtk |
From: Mikko L. <laz...@us...> - 2004-06-19 15:12:34
|
Update of /cvsroot/rtk/rtk/src/gui/WMAL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12106/gui/WMAL Added Files: Dummy_WMAL.cpp Fake_WMAL.cpp Win32_WMAL.cpp Log Message: Added first GUI files. NOTE: Nothing usable yet, just sandbox for developing :) --- NEW FILE: Fake_WMAL.cpp --- #include <rtk/Fake_WMAL.h> using namespace Rtk; FakeWMAL::FakeWMAL() { } FakeWMAL::~FakeWMAL() { } int FakeWMAL::Init() { return 1; } WMALHandle FakeWMAL::CreateWin(int x, int y, int w, int h, unsigned flags) { return 0; } bool FakeWMAL::DestroyWin(WMALHandle win) { return false; } bool FakeWMAL::SetWindowSize(WMALHandle win, int x, int y, int w, int h, unsigned flags) { return false; } bool FakeWMAL::GetWindowSize(WMALHandle win, int &x, int &y, int &w, int &h) { return false; } bool FakeWMAL::SetWindowCaption(WMALHandle win, const RCHAR *caption) { return false; } bool FakeWMAL::GetWindowCaption(WMALHandle win, RCHAR *caption, int size) { return false; } bool FakeWMAL::ShowWin(WMALHandle win, unsigned flags) { return false; } bool FakeWMAL::HideWin(WMALHandle win) { return false; } bool FakeWMAL::SetForeground(WMALHandle win) { return false; } --- NEW FILE: Win32_WMAL.cpp --- #include <rtk/Win32_VDAL.h> #include <rtk/Win32_WMAL.h> #include <rtk/Gui.h> #include <rtk/Window.h> #include <stdlib.h> #include <windows.h> using namespace Rtk; struct WIN32_WMAL_DATA : public WMAL_DATA { VDALHandle wnd; VDALHandle backbuffer; int W,H; }; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// Win32WMAL::Win32WMAL() { } Win32WMAL::~Win32WMAL() { } int Win32WMAL::Init() { return 1; } WMALHandle Win32WMAL::CreateWin(int x, int y, int w, int h, unsigned flags, void *data, WMALCallback cb) { WIN32_WMAL_DATA *ret = (WIN32_WMAL_DATA*)calloc(1, sizeof(WIN32_WMAL_DATA)); ret->wnd = VDAL::Instance()->CreateWin( x, y, w, h, flags, ret, WMAL::StaticVdalCb ); ret->W = w; ret->H = h; ret->userdata = data; ret->cb = cb; if(flags==1) { ret->backbuffer = VDAL::Instance()->CreateOffscreen(w, h); } return ret; } bool Win32WMAL::DestroyWin(WMALHandle win) { WIN32_WMAL_DATA *handle = (WIN32_WMAL_DATA*)win; if(handle->wnd) VDAL::Instance()->DestroyWin(handle->wnd); if(handle->backbuffer) VDAL::Instance()->DestroyOffscreen(handle->backbuffer); return true; } bool Win32WMAL::SetWindowSize(WMALHandle win, int x, int y, int w, int h, unsigned flags) { return 0; } bool Win32WMAL::GetWindowSize(WMALHandle win, int &x, int &y, int &w, int &h) { return 0; } bool Win32WMAL::SetWindowCaption(WMALHandle win, const RCHAR *caption) { return 0; } bool Win32WMAL::GetWindowCaption(WMALHandle win, RCHAR *caption, int size) { return 0; } bool Win32WMAL::ShowWin(WMALHandle win, unsigned flags) { return 0; } bool Win32WMAL::HideWin(WMALHandle win) { return 0; } bool Win32WMAL::SetForeground(WMALHandle win) { return 0; } GD *Win32WMAL::PrepareGD(WMALHandle win) { WIN32_WMAL_DATA *handle = (WIN32_WMAL_DATA*)win; GD *gd; if(handle->backbuffer) { gd = VDAL::Instance()->PrepareGD(handle->backbuffer); } else { gd = VDAL::Instance()->PrepareGD(handle->wnd); } return gd; } void Win32WMAL::UnprepareGD(WMALHandle win, GD *gd) { WIN32_WMAL_DATA *handle = (WIN32_WMAL_DATA*)win; if(handle->backbuffer) { VDAL::Instance()->UnprepareGD(handle->backbuffer, gd); } else { VDAL::Instance()->UnprepareGD(handle->wnd, gd); } } void Win32WMAL::FlushWindow(WMALHandle win) { WIN32_WMAL_DATA *handle = (WIN32_WMAL_DATA*)win; if(handle->backbuffer) { VDAL::Instance()->Copy(handle->wnd, 0,0,handle->W,handle->H,handle->backbuffer,0,0); } } /* Called by VDAL */ void Win32WMAL::VdalCb(VDALHandle h, int event, long *args) { WIN32_WMAL_DATA *handle = (WIN32_WMAL_DATA*)h->userdata; switch(event) { case WIN_FLUSH: if(handle->cb) { (*handle->cb)(handle, event, args); } break; case WIN_RESIZE: handle->W = args[0]; handle->H = args[1]; if(handle->backbuffer) { VDAL::Instance()->ResizeOffscreen(handle->backbuffer, handle->W, handle->H); } if(handle->cb) { (*handle->cb)(handle, event, args); } break; case WIN_CLOSE: if(handle->cb) { (*handle->cb)(handle, event, args); } break; default: // Incorrect event! break; }; } --- NEW FILE: Dummy_WMAL.cpp --- #include <rtk/Dummy_WMAL.h> using namespace Rtk; DummyWMAL::DummyWMAL() { } DummyWMAL::~DummyWMAL() { } |
From: Mikko L. <laz...@us...> - 2004-06-19 15:12:34
|
Update of /cvsroot/rtk/rtk/src/gui/GD In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12106/gui/GD Added Files: GD.cpp Win32_GD.cpp Log Message: Added first GUI files. NOTE: Nothing usable yet, just sandbox for developing :) --- NEW FILE: Win32_GD.cpp --- #include <rtk/Win32_GD.h> #include <stdio.h> using namespace Rtk; Win32GD::Win32GD() { _wnd = 0; _dc = 0; _pen = 0; _brush = 0; } Win32GD::~Win32GD() { EndDraw(); } bool Win32GD::BeginDraw() { if(!_dc && _wnd) { _dc = GetDC(_wnd); } GD::BeginDraw(); return (_dc != 0); } bool Win32GD::EndDraw() { bool ret = true; if(_dc && _wnd) { ret = (ReleaseDC(_wnd, _dc) == 1); _dc = 0; } if(_pen) DeleteObject(_pen); if(_brush) DeleteObject(_brush); _pen = 0; _brush = 0; GD::EndDraw(); return ret; } #define GET_COLORREF(x) RGB( (x>>24), (x>>16), (x>>8) ) static HPEN GetNullPen() { static HPEN null_pen = 0; if(!null_pen) null_pen = CreatePen(PS_NULL, 1, 1); return null_pen; } void Win32GD::UpdatePen(Pen &pen) { Color clr = pen.GetColor(); HPEN oldpen = _pen; HPEN newpen; if(clr == Color::NoColor) { _pen = GetNullPen(); } else { int width = pen.GetWidth(); bool geom = (width > 1); int style = (geom ? PS_GEOMETRIC : PS_COSMETIC); LOGBRUSH penbrush = { BS_SOLID, GET_COLORREF(clr), 0 }; newpen = ExtCreatePen(style, width, &penbrush, 0, 0); } SelectObject(_dc, newpen); _pen = newpen; if(oldpen && oldpen != GetNullPen()) DeleteObject(oldpen); } static HBRUSH GetNullBrush() { static HBRUSH null_brush = 0; if(!null_brush) null_brush = (HBRUSH)GetStockObject(NULL_BRUSH); return null_brush; } void Win32GD::UpdateBrush(Brush &br) { Color clr = br.GetColor(); HBRUSH oldbrush = _brush; HBRUSH newbrush; if(clr == Color::NoColor) { newbrush = GetNullBrush(); } else { newbrush = CreateSolidBrush(GET_COLORREF(clr)); } SelectObject(_dc, newbrush); _brush = newbrush; if(oldbrush && oldbrush != GetNullBrush()) { // Do not delete NULL_BRUSH stock object DeleteObject(oldbrush); } } void Win32GD::DrawRect(int x, int y, int w, int h) { Rectangle(_dc, x, // x-coord of upper-left corner of rectangle y, // y-coord of upper-left corner of rectangle x+w, // x-coord of lower-right corner of rectangle y+h // y-coord of lower-right corner of rectangle ); } void Win32GD::DrawLine(int x1, int y1, int x2, int y2) { //transform(x1,y1); //transform(x2,y2); MoveToEx(_dc, x1, y1, NULL); LineTo(_dc, x2, y2); } --- NEW FILE: GD.cpp --- #include <rtk/GD.h> using namespace Rtk; void GD::SetPen(const Pen &pen) { if(_pen != pen) { _pen = pen; UpdatePen(_pen); } } void GD::SetBrush(const Brush &br) { if(_brush != br) { _brush = br; UpdateBrush(_brush); } } bool GD::BeginDraw() { return true; } bool GD::EndDraw() { _pen.SetColor(Color::NoColor); _brush.SetColor(Color::NoColor); return true; } |
From: Mikko L. <laz...@us...> - 2004-06-19 15:12:34
|
Update of /cvsroot/rtk/rtk/src/core/platform/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12106/core/platform/win32 Modified Files: File.cpp Log Message: Added first GUI files. NOTE: Nothing usable yet, just sandbox for developing :) Index: File.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/win32/File.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** File.cpp 13 Jun 2004 10:38:34 -0000 1.4 --- File.cpp 19 Jun 2004 15:12:22 -0000 1.5 *************** *** 49,58 **** #include <stdlib.h> //free - namespace Rtk - { - #include <windows.h> #include <io.h> #ifndef INVALID_SET_FILE_POINTER # define INVALID_SET_FILE_POINTER 0xFFFFFFFF --- 49,58 ---- #include <stdlib.h> //free #include <windows.h> #include <io.h> + namespace Rtk + { + #ifndef INVALID_SET_FILE_POINTER # define INVALID_SET_FILE_POINTER 0xFFFFFFFF |
From: Mikko L. <laz...@us...> - 2004-06-19 15:11:16
|
Update of /cvsroot/rtk/rtk/src/gui/VDAL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11093/VDAL Log Message: Directory /cvsroot/rtk/rtk/src/gui/VDAL added to the repository |
From: Mikko L. <laz...@us...> - 2004-06-19 15:11:03
|
Update of /cvsroot/rtk/rtk/src/gui/WMAL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10817/WMAL Log Message: Directory /cvsroot/rtk/rtk/src/gui/WMAL added to the repository |
From: Mikko L. <laz...@us...> - 2004-06-19 15:10:48
|
Update of /cvsroot/rtk/rtk/src/gui/GD In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10600/GD Log Message: Directory /cvsroot/rtk/rtk/src/gui/GD added to the repository |
From: Mikko L. <laz...@us...> - 2004-06-19 15:10:24
|
Update of /cvsroot/rtk/rtk/src/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10377 Added Files: Brush.cpp Color.cpp Group.cpp Gui.cpp Pen.cpp Rect.cpp Widget.cpp Window.cpp Log Message: Added first GUI files. NOTE: Nothing usable yet, just sandbox for developing :) --- NEW FILE: Color.cpp --- // Color.cpp: implementation of the Color class. // ////////////////////////////////////////////////////////////////////// #include "RTK\Color.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// --- NEW FILE: Pen.cpp --- #include <rtk/Pen.h> #include <rtk/GD.h> using namespace Rtk; Pen::Pen() { _width = 1; } Pen::Pen(const Color &clr, int width) { _clr = clr; _width = width; } Pen::~Pen() { } void Pen::CopyFrom(const Pen &p) { _clr = p._clr; _width = p._width; } void Pen::SetColor(const Color &clr) { _clr = clr; } void Pen::SetWidth(int w) { _width = w; } --- NEW FILE: Rect.cpp --- #include <rtk/Rect.h> #undef MIN #undef MAX #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) const Rect Rect::operator+( const Rect &r ) const { Rect ret; ret._x1 = MIN(_x1, r._x1); ret._x2 = MAX(_x2, r._x2); ret._y1 = MIN(_y1, r._y1); ret._y2 = MAX(_y2, r._y2); return ret; } Rect Rect::Intersect(Rect &r) { Rect ret; ret._x1 = MAX(_x1, r._x1); ret._x2 = MIN(_x2, r._x2); ret._y1 = MAX(_y1, r._y1); ret._y2 = MIN(_y2, r._y2); return ret; } bool Rect::Overlap(Rect &r) { return ( MAX( _x1, r._x1 ) <= MIN( _x2, r._x2 ) && MAX( _y1, r._y1 ) <= MIN( _y2, r._y2 ) ); } --- NEW FILE: Window.cpp --- #include <rtk/Window.h> #include <rtk/VDAL.h> #include <rtk/Rect.h> #include <rtk/error.h> using namespace Rtk; static SList window_list; SList *Window::GetWindowList() { return &window_list; } Window::Window() : Group() { window_list.Append(this); _wnd = 0; _create_flags = 0; } Window::Window(int w, int h) : Group() { window_list.Append(this); _wnd = 0; _create_flags = 0; W = w; H = h; } Window::~Window() { window_list.Remove(this); Destroy(); } void Window::Flush() { if(_wnd) { // Prepare GD for flushing, this sets clip region & friends GD *gd = WMAL::Instance()->PrepareGD(_wnd); if(_damage) { // Draw only if there's something to draw DoDraw(gd); } // This is only does something if window is double buffered: WMAL::Instance()->FlushWindow(_wnd); // We're done, free clip region and release window GD WMAL::Instance()->UnprepareGD(_wnd, gd); } } int Window::Create() { _wnd = CreateWin(_create_flags); if(!_wnd) ERROR_RETURN(OPERATION_FAILED); RETURN_SUCCESS; } int Window::Destroy() { if(_wnd) { DestroyWin(_wnd); _wnd = 0; RETURN_SUCCESS; } ERROR_RETURN(OPERATION_FAILED); } WMALHandle Window::CreateWin(unsigned flags) { WMALHandle ret = WMAL::Instance()->CreateWin(X, Y, W, H, flags, this, Window::StaticWmalCb); return ret; } void Window::DestroyWin(WMALHandle hwnd) { WMAL::Instance()->DestroyWin(hwnd); } void Window::WmalCb(WMALHandle h, int event, long *args) { switch(event) { case WIN_FLUSH: if((_create_flags & DOUBLEBUFFER) == 0) { // Window is not double buffered, we must draw everything. // This will not blink, since WIN_FLUSH is called only // when window exposed by underlying system and dirty area // is merged to window GD clip region. _damage = DAMAGE_ALL; } Flush(); break; case WIN_RESIZE: _damage = DAMAGE_ALL; W = args[0]; H = args[1]; break; case WIN_CLOSE: Destroy(); default: break; }; } --- NEW FILE: Widget.cpp --- #include <rtk\Widget.h> using namespace Rtk; Widget::Widget() { X = Y = 0; W = H = 0; _damage = DAMAGE_ALL; } Widget::Widget(int x, int y, int w, int h) { X = x; Y = y; W = w; H = h; _damage = DAMAGE_ALL; } Widget::~Widget() { } void Widget::Resize(int x, int y, int w, int h) { X = x; Y = y; W = w; H = h; } void Widget::DoLayout() { } void Widget::DoDraw(GD *gd) { // NOTE TESTING // Do some ugly drawing to see flickering :) if(_damage & DAMAGE_ALL) { gd->SetPen(Color::Red); gd->SetBrush(Color::Blue); gd->DrawRect(0,0,W,H); for(int n=0; n<W; n+=2) { if(n%4==0) gd->SetPen(Color::Red); else gd->SetPen(Color::Green); gd->DrawLine(n, 0, 0, n); } } _damage = 0; } --- NEW FILE: Brush.cpp --- #include <rtk/Brush.h> using namespace Rtk; Brush::Brush() { } Brush::Brush(const Color &clr) { _clr = clr; } Brush::~Brush() { } void Brush::CopyFrom(const Brush &br) { _clr = br._clr; } --- NEW FILE: Gui.cpp --- #include <rtk/Gui.h> #include <rtk/Window.h> #include <rtk/SList.h> namespace Rtk { VDAL *VDAL::vdal_instance = 0; WMAL *WMAL::wmal_instance = 0; // Noone.. }; --- NEW FILE: Group.cpp --- #include <rtk/Group.h> using namespace Rtk; Group::Group() { } Group::~Group() { } |
From: Mikko L. <laz...@us...> - 2004-06-19 15:08:41
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8951 Added Files: Brush.h Color.h Dummy_WMAL.h Fake_WMAL.h GD.h Group.h Gui.h Pen.h Rect.h VDAL.h WMAL.h Widget.h Win32_GD.h Win32_VDAL.h Win32_WMAL.h Window.h Log Message: Added first GUI files. NOTE: Nothing usable yet, just sandbox for developing :) --- NEW FILE: GD.h --- #ifndef _GD_H_ #define _GD_H_ #include "Pen.h" #include "Brush.h" #include "Matrix.h" namespace Rtk { class GD { public: GD() { _caps = 0; } virtual ~GD() { } unsigned int GetCaps() { return _caps; } void SetPen(const Color &clr, int width=1) { Pen c(clr, width); SetPen(c); } void SetPen(const Pen &pen); const Pen &GetPen() const { return _pen; } void SetBrush(const Color &clr) { Brush br(clr); SetBrush(br); } void SetBrush(const Brush &br); const Brush &GetBrush() const { return _brush; } /* Virtual functions */ virtual bool BeginDraw(); virtual bool EndDraw(); /* Drawing primitives */ virtual void DrawRect(int x, int y, int w, int h) = 0; virtual void DrawLine(int x1, int y1, int x2, int y2) = 0; /* GD specific */ virtual void UpdatePen(Pen &pen) { } virtual void UpdateBrush(Brush &br) { } virtual void UpdateMatrix(Matrix &m) { } protected: unsigned int _caps; Pen _pen; Brush _brush; Matrix _matrix; }; }; #endif /* _GD_H_ */ --- NEW FILE: Widget.h --- #ifndef _WIDGET_H_ #define _WIDGET_H_ #include "GD.h" namespace Rtk { enum { DAMAGE_ALL = (1<<0), DAMAGE_CHILD = (1<<1) }; class Widget { public: Widget(); Widget(int x, int y, int w, int h); virtual ~Widget(); void Redraw(unsigned flags = 0); void Resize(int x, int y, int w, int h); int x() const { return X; } int y() const { return Y; } int w() const { return W; } int h() const { return H; } virtual void DoLayout(); virtual void DoDraw(GD *gd); unsigned GetDamage() const { return _damage; } protected: int X,Y,W,H; unsigned _damage; }; }; #endif // _WIDGET_H_ --- NEW FILE: Group.h --- #ifndef _GROUP_H_ #define _GROUP_H_ #include "Widget.h" namespace Rtk { class Group : public Widget { public: Group(); virtual ~Group(); }; }; #endif // _GROUP_H_ --- NEW FILE: Fake_WMAL.h --- #ifndef _FAKE_WMAL_H_ #define _FAKE_WMAL_H_ #include "WMAL.h" namespace Rtk { class FakeWMAL : public WMAL { public: FakeWMAL(); virtual ~FakeWMAL(); unsigned GetCaps() { return WMAL::MANAGED; } int Init(); WMALHandle CreateWin(int x, int y, int w, int h, unsigned flags); bool DestroyWin(WMALHandle win); bool SetWindowSize(WMALHandle win, int x, int y, int w, int h, unsigned flags); bool GetWindowSize(WMALHandle win, int &x, int &y, int &w, int &h); bool SetWindowCaption(WMALHandle win, const RCHAR *caption); bool GetWindowCaption(WMALHandle win, RCHAR *caption, int size); bool ShowWin(WMALHandle win, unsigned flags); bool HideWin(WMALHandle win); bool SetForeground(WMALHandle win); }; }; #endif --- NEW FILE: Rect.h --- #ifndef _RECT_H_ #define _RECT_H_ class Rect { public: Rect() : _x1(0), _y1(0), _x2(-1), _y2(-1) { } Rect(int x, int y, int w, int h) : _x1(x), _y1(y), _x2(x+w-1), _y2(y+h-1) { } Rect(const Rect &r) { _x1=r._x1; _y1=r._y1; _x2=r._x2; _y2=r._y2; } Rect &operator=( const Rect &r ) { _x1=r._x1; _y1=r._y1; _x2=r._x2; _y2=r._y2; return *this; } const Rect operator+( const Rect &r ) const; bool Overlap(Rect &r); Rect Intersect(Rect &r); bool Contains(int xs, int ys) { return (xs >= _x1 && xs <= _x2 && ys >= _y1 && ys <= _y2); } int x1() const { return _x1; } int y1() const { return _y1; } int x2() const { return _x2; } int y2() const { return _y2; } int GetLeft() const { return _x1; } int GetTop() const { return _y1; } int GetRight() const { return _x2; } int GetBottom() const { return _y2; } int SetLeft(int v) { return (_x1=v); } int SetTop(int v) { return (_y1=v); } int SetRight(int v) { return (_x2=v); } int SetBottom(int v) { return (_y2=v); } int x() const { return _x1; } int y() const { return _y1; } void x(int x) { _x1 = x; } void y(int y) { _y1 = y; } int GetWidth() const { return (_x2-_x1+1); } void SetWidth(int w) { _x2 = (_x1+w-1); } int w() const { return (_x2-_x1+1); } void w(int w) { _x2 = (_x1+w-1); } int GetHeight() const { return (_y2-_y1+1); } void SetHeight(int h) { _y2 = (_y1+h-1); } int h() const { return (_y2-_y1+1); } void h(int h) { _y2 = (_y1+h-1); } void MoveBy(int dx, int dy) { _x1+=dx; _x2+=dx; _y1+=dy; _y2+=dy; } void SetBox(int x, int y, int w, int h) { _x1=x; _y1=y; _x2=x+w-1; _y2=y+h-1; } void Set(int x1, int y1, int x2, int y2) { _x1=x1; _y1=y1; _x2=x2; _y2=y2; } private: int _x1, _y1, _x2, _y2; }; #endif // _RECT_H_ --- NEW FILE: Gui.h --- #ifndef _GUI_H_ #define _GUI_H_ #include "GD.h" #include "WMAL.h" #include "Rect.h" namespace Rtk { // Noone }; #endif --- NEW FILE: Color.h --- #ifndef _COLOR_H_ #define _COLOR_H_ namespace Rtk { class GD; typedef unsigned int RCOLOR; class Color { public: enum { Red = 0xFF000000, Green = 0x00FF0000, Blue = 0x0000FF00, NoColor = 0x000000FF }; Color() { _clr = 0; } Color(RCOLOR clr) { _clr = clr; } ~Color() { } operator const RCOLOR &() const { return _clr; } //operator RCOLOR &() { return _clr; } private: RCOLOR _clr; }; }; #endif // _COLOR_H_ --- NEW FILE: Win32_WMAL.h --- #ifndef _WIN32_WMAL_H_ #define _WIN32_WMAL_H_ #include "WMAL.h" namespace Rtk { class Win32WMAL : public WMAL { public: Win32WMAL(); ~Win32WMAL(); unsigned GetCaps() { return MANAGED; } int Init(); WMALHandle CreateWin(int x, int y, int w, int h, unsigned flags, void *data, WMALCallback cb); bool DestroyWin(WMALHandle win); bool SetWindowSize(WMALHandle win, int x, int y, int w, int h, unsigned flags); bool GetWindowSize(WMALHandle win, int &x, int &y, int &w, int &h); bool SetWindowCaption(WMALHandle win, const RCHAR *caption); bool GetWindowCaption(WMALHandle win, RCHAR *caption, int size); bool ShowWin(WMALHandle win, unsigned flags); bool HideWin(WMALHandle win); bool SetForeground(WMALHandle win); GD *PrepareGD(WMALHandle win); void UnprepareGD(WMALHandle win, GD *gd); void FlushWindow(WMALHandle win); protected: /* Called by VDAL */ void VdalCb(VDALHandle h, int event, long *args); }; }; #endif // _WIN32_WMAL_H_ --- NEW FILE: Window.h --- #ifndef _WINDOW_H_ #define _WINDOW_H_ #include "Group.h" #include "WMAL.h" #include "SList.h" namespace Rtk { class Window : public Group { public: static SList *GetWindowList(); enum CreateFlags { DOUBLEBUFFER = (1<<0) }; Window(); Window(int w, int h); virtual ~Window(); virtual void Flush(); int Create(); int Destroy(); WMALHandle GetHandle() const { return _wnd; } void SetCreateFlags(unsigned flags) { _create_flags = flags; } unsigned GetCreateFlags() const { return _create_flags; } protected: virtual WMALHandle CreateWin(unsigned flags); virtual void DestroyWin(WMALHandle hwnd); void WmalCb(WMALHandle h, int event, long *args); static void StaticWmalCb(WMALHandle h, int event, long *args) { ((Window*)h->userdata)->WmalCb(h, event, args); } private: WMALHandle _wnd; unsigned _create_flags; }; }; /* namespace Rtk */ #endif // _WINDOW_H_ --- NEW FILE: Win32_VDAL.h --- #ifndef _WIN32_VDAL_H_ #define _WIN32_VDAL_H_ #include "VDAL.h" #include <windows.h> namespace Rtk { class Win32VDAL : public VDAL { public: Win32VDAL(); virtual ~Win32VDAL(); VDALHandle CreateWin(int x, int y, int w, int h, unsigned flags, void *data, VDALCallback cb); bool DestroyWin(VDALHandle win); VDALHandle CreateOffscreen(int w, int h); bool ResizeOffscreen(VDALHandle offscr, int w, int h); bool DestroyOffscreen(VDALHandle offscr); bool Copy(VDALHandle dst, int x, int y, int w, int h, VDALHandle src, int srcx, int srcy); GD *CreateGD(VDALHandle win); GD *PrepareGD(VDALHandle win); void UnprepareGD(VDALHandle win, GD *gd); unsigned GetCaps() { return 0; } int Init(); int WaitEvent(int timeout); void Wakeup(); HINSTANCE Instance() const { return instance; } private: static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); HINSTANCE instance; bool owndc; DWORD procid; }; }; #endif // _VDAL_H_ --- NEW FILE: Pen.h --- #ifndef _PEN_H_ #define _PEN_H_ #include "Color.h" namespace Rtk { class GD; class Pen { public: Pen(); Pen(const Color &clr, int width = 1); Pen(const Pen &pen) { CopyFrom(pen); } virtual ~Pen(); Pen& operator = (const Pen& p) { CopyFrom(p); return *this; } Pen& operator = (const Color& c) { SetColor(c); return *this; } bool operator != (const Pen &p) const { return (_clr != p._clr || _width != p._width); } bool operator == (const Pen &p) const { return (_clr == p._clr && _width == p._width); } const Color &GetColor() const { return _clr; } void SetColor(const Color &clr); int GetWidth() const { return _width; } void SetWidth(int w); private: void CopyFrom(const Pen &p); Color _clr; int _width; }; }; #endif // _PEN_H_ --- NEW FILE: WMAL.h --- #ifndef _WMAL_H_ #define _WMAL_H_ #include "rchar.h" #include "VDAL.h" #include "GD.h" namespace Rtk { /* Forward declarations */ struct WMAL_DATA; /* Type definitions */ typedef WMAL_DATA *WMALHandle; typedef void (*WMALCallback)(WMALHandle h, int event, long *args); struct WMAL_DATA { void *userdata; WMALCallback cb; }; /** WMAL - Window Management Abstraction Layer * * @note This is just preliminary description * * WMAL controls all RTK windows. * WMAL is one level higher than VDAL, and is used by Rtk::Window class. * It's purpose is control window movement, stacking, caption, style and flushing. * * WMAL will manage window double buffering, if VDAL does not support it. * It uses VDAL offscreens to handle double buffering, if needed. * * WMAL uses VDAL to create WM specific windows. * However, WMAL does not have to use VDAL to create WM windows. * For example, when VDAL does not support that (framebuffer) * In that case, WMAL will create offscreen handles and manage windows it self (FakeWMAL) * * @note This is just preliminary description * * Most likely the flow is: * Rtk::Window -> WMAL -> VDAL -> OS * And other way around: * OS -> VDAL -> WMAL ->Rtk::Window * * In case there's no OS WM environment available (such as framebuffer) * Will VDAL report events for whole display and WMAL (FameWMAL) sends them to correct * Rtk::Window's. * * WMAL is responsible to pass events (such as KEYDOWN) to Rtk evetn subsystem. * */ class WMAL { public: enum { MANAGED = (1<<1) ///< OS WM managed windows }; WMAL() { wmal_instance = this; } virtual ~WMAL() { } static WMAL *Instance() { return wmal_instance; } void SetUserData(WMALHandle win, void *data) { win->userdata = data; } void *GetUserData(WMALHandle win) const { return win->userdata; } void SetCallback(WMALHandle win, WMALCallback cb) { win->cb = cb; } WMALCallback GetCallback(WMALHandle win) const { return win->cb; } virtual unsigned GetCaps() = 0; virtual int Init() = 0; virtual WMALHandle CreateWin(int x, int y, int w, int h, unsigned flags, void *data, WMALCallback cb) = 0; virtual bool DestroyWin(WMALHandle win) = 0; virtual bool SetWindowSize(WMALHandle win, int x, int y, int w, int h, unsigned flags) = 0; virtual bool GetWindowSize(WMALHandle win, int &x, int &y, int &w, int &h) = 0; virtual bool SetWindowCaption(WMALHandle win, const RCHAR *caption) = 0; virtual bool GetWindowCaption(WMALHandle win, RCHAR *caption, int size) = 0; virtual bool ShowWin(WMALHandle win, unsigned flags) = 0; virtual bool HideWin(WMALHandle win) = 0; virtual bool SetForeground(WMALHandle win) = 0; virtual GD *PrepareGD(WMALHandle win) = 0; virtual void UnprepareGD(WMALHandle win, GD *gd) = 0; /** Flush window to the screen. This does only something if window is double buffered */ virtual void FlushWindow(WMALHandle win) = 0; protected: static WMAL *wmal_instance; /* Called by VDAL */ virtual void VdalCb(VDALHandle h, int event, long *args) = 0; static void StaticVdalCb(VDALHandle h, int event, long *args) { wmal_instance->VdalCb(h, event, args); } }; }; #endif // _WMAL_H_ --- NEW FILE: Brush.h --- #ifndef _BRUSH_H_ #define _BRUSH_H_ #include "Color.h" namespace Rtk { class Brush { public: Brush(); Brush(const Color &clr); ~Brush(); const Color &GetColor() const { return _clr; } void SetColor(const Color &clr) { _clr = clr; } Brush& operator = (const Brush& b) { CopyFrom(b); return *this; } bool operator != (const Brush &b) const { return (_clr != b._clr); } bool operator == (const Brush &b) const { return (_clr == b._clr); } private: void CopyFrom(const Brush &br); Color _clr; }; }; #endif // _BRUSH_H_ --- NEW FILE: VDAL.h --- #ifndef _VDAL_H_ #define _VDAL_H_ namespace Rtk { class GD; /* Forward declarations */ struct VDAL_DATA; /* Type definitions */ typedef VDAL_DATA* VDALHandle; typedef void (*VDALCallback)(VDALHandle h, int event, long *args); struct VDAL_DATA { void *userdata; VDALCallback cb; }; enum { /** Called when window needs to be flushed by the underlying windowing environment, * such as X11 or Win32. * Args: * NONE */ WIN_FLUSH = 0, /** Called when window size has changed by the underlying windowing environment. * This happends, for example, when user drag the window corner to change size. * Args: * args[0]: New width * args[1]: New height * args[2]: Flags */ WIN_RESIZE, /** Called when user clicks the "X" (close) button in window titlebar or tries to close * some other way from underlying windowing environment. * Args: * NONE */ WIN_CLOSE, VDAL_LAST_EVENT }; /** VDAL - Video Device Abstraction Layer * * @note This is just preliminary description * * VDAL is the lowest level on RTK video system. * It is supposed to create instances underlying windowing system * handles, such as windows or offscreens. * * VDAL does not necessarily need underlying windowing system. * If no windowing system available, VDAL::CreateWin will return NULL. * VDAL::Init will create main display for RTK, for example, framebuffer access. * VDAL::CreateGD with NULL argument creates GD instance to main display. * In order to use such VDAL as a normal windowing environment "FakeWMAL" must be used (default) * * Events: * VDAL is not supposed to post anything to RTK internal event subsystem. * Instead VDAL passes ALL events to window handle associated callback, * which usually is WMAL internal callback. All events passed to RTK evet subsystem, * are passed from WMAL if needed. * * @note This is just preliminary description * * VDAL functions should not be called directly ever. * It is used only by WMAL and some RTK internal components. * */ class VDAL { public: VDAL() { vdal_instance = this; } virtual ~VDAL() { } /** Return pointer to current instance of VDAL */ static VDAL *Instance() { return vdal_instance; } void SetUserData(VDALHandle win, void *data) { win->userdata = data; } void *GetUserData(VDALHandle win) const { return win->userdata; } void SetCallback(VDALHandle win, VDALCallback cb) { win->cb = cb; } VDALCallback GetCallback(VDALHandle win) const { return win->cb; } /** Create window instance * If this is native VDAL implementation (such as framebuffer), * this function will return NULL. * * @param x X position of windowin screen, if -1 default position is used * @param y Y position of windowin screen, if -1 default position is used * @param w Width of the window * @param h Height of the window * @param flags Creation flags (TBD) * @param data Userdata to associate with window handle * @param cb Callback function to receive VDAL events * * @return VDALHandle to created window, or NULL on error. */ virtual VDALHandle CreateWin(int x, int y, int w, int h, unsigned flags, void *data, VDALCallback cb) = 0; /** Destroys the window */ virtual bool DestroyWin(VDALHandle win) = 0; /** Create offscreen instance * @param w Width of the offscreen image * @param h Height of the offscreen image * * @return VDALHandle to created offscreen, or NULL on error. */ virtual VDALHandle CreateOffscreen(int w, int h) = 0; /** Resize offscreen to specific size. */ virtual bool ResizeOffscreen(VDALHandle offscr, int w, int h) = 0; /** Destroy offscreen */ virtual bool DestroyOffscreen(VDALHandle offscr) = 0; /** Copy bits from handle to other. * @note High subject to change in future * * @param dst Handle to destination window or offscreen * @param x destination X position * @param y destination Y position * @param w destination width * @param h destination height * @param src Handle to source window or offscreen * @param srcx source X position * @param srcy source Y position */ virtual bool Copy(VDALHandle hdst, int x, int y, int w, int h, VDALHandle hsrc, int srcx, int srcy) = 0; /** Create new GD for window or offscreen. * Returned GD must be deleted with 'delete' operator after use */ virtual GD *CreateGD(VDALHandle handle) = 0; /** Prepare GD for use with specific window. * This sets underlying WM clip region if there's one. */ virtual GD *PrepareGD(VDALHandle handle) = 0; /** End GD drawing started by PrepareGD and free clipping region */ virtual void UnprepareGD(VDALHandle handle, GD *gd) = 0; /** Get capabilities of VDAL (TBD) */ virtual unsigned GetCaps() = 0; /** Init VDAL (TBD) */ virtual int Init() = 0; /** Wait for event * @param timeout Max time to wait in milliseconds * * @return Number of events received */ virtual int WaitEvent(int timeout) = 0; /** Make VDAL::WaitEvent return immediately. */ virtual void Wakeup() = 0; protected: static VDAL *vdal_instance; }; }; /* namespace Rtk */ #endif // _VDAL_H_ --- NEW FILE: Dummy_WMAL.h --- #ifndef _DUMMY_WMAL_H_ #define _DUMMY_WMAL_H_ #include "WMAL.h" namespace Rtk { class DummyWMAL : public WMAL { public: DummyWMAL(); ~DummyWMAL(); unsigned GetCaps() { return 0; } int Init() { return 1; } WMALHandle CreateWin(int x, int y, int w, int h, unsigned flags) { return 0; } bool DestroyWin(WMALHandle win) { return false; } bool SetWindowSize(WMALHandle win, int x, int y, int w, int h, unsigned flags) { return false; } bool GetWindowSize(WMALHandle win, int &x, int &y, int &w, int &h) { return false; } bool SetWindowCaption(WMALHandle win, const RCHAR *caption) { return false; } bool GetWindowCaption(WMALHandle win, RCHAR *caption, int size) { return false; } bool ShowWin(WMALHandle win, unsigned flags) { return false; } bool HideWin(WMALHandle win) { return false; } bool SetForeground(WMALHandle win) { return false; } }; }; #endif // _DUMMY_WMAL_H_ --- NEW FILE: Win32_GD.h --- #ifndef _WIN32_GD_H_ #define _WIN32_GD_H_ #include "Pen.h" #include "GD.h" #include <windows.h> namespace Rtk { class Win32GD : public GD { public: Win32GD(); virtual ~Win32GD(); void SetHWND(HWND wnd) { _wnd = wnd; } HWND GetHWND() const { return _wnd; } void SetHDC(HDC dc) { _dc = dc; } HDC GetHDC() const { return _dc; } /***********************/ /* Virtual functions */ unsigned GetCaps() { return 0; } bool BeginDraw(); bool EndDraw(); void DrawRect(int x, int y, int w, int h); void DrawLine(int x1, int y1, int x2, int y2); void UpdatePen(Pen &pen); void UpdateBrush(Brush &br); private: HWND _wnd; HDC _dc; HPEN _pen; HBRUSH _brush; }; }; #endif // _WIN32_GD_H_ |
From: Dejan L. <de...@us...> - 2004-06-15 23:16:55
|
Update of /cvsroot/rtk/rtk/ide/devcxx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11521/ide/devcxx Modified Files: librtk.dev librtk_private.h librtk_private.rc Log Message: Latest Dev-C++ project files with error, Queue and debug. Index: librtk_private.h =================================================================== RCS file: /cvsroot/rtk/rtk/ide/devcxx/librtk_private.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** librtk_private.h 12 Jun 2004 22:48:29 -0000 1.15 --- librtk_private.h 15 Jun 2004 23:16:46 -0000 1.16 *************** *** 6,14 **** // VERSION DEFINITIONS ! #define VER_STRING "0.1.1.101" #define VER_MAJOR 0 #define VER_MINOR 1 #define VER_RELEASE 1 ! #define VER_BUILD 101 #define COMPANY_NAME "RTK Team" #define FILE_VERSION "" --- 6,14 ---- // VERSION DEFINITIONS ! #define VER_STRING "0.1.1.110" #define VER_MAJOR 0 #define VER_MINOR 1 #define VER_RELEASE 1 ! #define VER_BUILD 110 #define COMPANY_NAME "RTK Team" #define FILE_VERSION "" Index: librtk_private.rc =================================================================== RCS file: /cvsroot/rtk/rtk/ide/devcxx/librtk_private.rc,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** librtk_private.rc 12 Jun 2004 22:48:29 -0000 1.15 --- librtk_private.rc 15 Jun 2004 23:16:46 -0000 1.16 *************** *** 9,14 **** // 1 VERSIONINFO ! FILEVERSION 0,1,1,101 ! PRODUCTVERSION 0,1,1,101 FILETYPE VFT_DLL { --- 9,14 ---- // 1 VERSIONINFO ! FILEVERSION 0,1,1,110 ! PRODUCTVERSION 0,1,1,110 FILETYPE VFT_DLL { Index: librtk.dev =================================================================== RCS file: /cvsroot/rtk/rtk/ide/devcxx/librtk.dev,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** librtk.dev 12 Jun 2004 22:48:29 -0000 1.14 --- librtk.dev 15 Jun 2004 23:16:46 -0000 1.15 *************** *** 2,6 **** FileName=librtk.dev Name=librtk ! UnitCount=38 Type=3 Ver=1 --- 2,6 ---- FileName=librtk.dev Name=librtk ! UnitCount=43 Type=3 Ver=1 *************** *** 47,51 **** Build=35 ======= ! Build=101 >>>>>>> 1.8 LanguageID=1033 --- 47,51 ---- Build=35 ======= ! Build=110 >>>>>>> 1.8 LanguageID=1033 *************** *** 432,433 **** --- 432,483 ---- BuildCmd= + [Unit40] + FileName=..\..\src\core\Queue.cpp + CompileCpp=1 + Folder=librtk + Compile=1 + Link=1 + Priority=1000 + OverrideBuildCmd=0 + BuildCmd= + + [Unit41] + FileName=..\..\rtk\Queue.h + CompileCpp=1 + Folder=librtk + Compile=1 + Link=1 + Priority=1000 + OverrideBuildCmd=0 + BuildCmd= + + [Unit39] + FileName=..\..\src\core\PriorityQueue.cpp + CompileCpp=1 + Folder=librtk + Compile=1 + Link=1 + Priority=1000 + OverrideBuildCmd=0 + BuildCmd= + + [Unit42] + FileName=..\..\src\core\debug.cpp + CompileCpp=1 + Folder=librtk + Compile=1 + Link=1 + Priority=1000 + OverrideBuildCmd=0 + BuildCmd= + + [Unit43] + FileName=..\..\src\core\error.cpp + CompileCpp=1 + Folder=librtk + Compile=1 + Link=1 + Priority=1000 + OverrideBuildCmd=0 + BuildCmd= + |
From: Mikko L. <laz...@us...> - 2004-06-15 19:30:22
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17438 Modified Files: Matrix.h Log Message: minor changes in method names Index: Matrix.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/Matrix.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Matrix.h 15 Jun 2004 19:12:45 -0000 1.1 --- Matrix.h 15 Jun 2004 19:30:12 -0000 1.2 *************** *** 57,75 **** { public: ! Matrix() { set_identity(); } ! Matrix(float M11, float M12, float M21, float M22, float X, float Y) { set_matrix(M11, M12, M21, M22, X, Y); } Matrix(const Matrix &m) { ! copy(m); } Matrix& operator=(const Matrix &m) { ! return copy(m); } ! Matrix& copy(const Matrix &m); ! void set_matrix(float M11, float M12, float M21, float M22, float X, float Y, bool trivial = false); /// X scaling factor --- 57,75 ---- { public: ! Matrix() { SetIdentity(); } ! Matrix(float M11, float M12, float M21, float M22, float X, float Y) { SetMatrix(M11, M12, M21, M22, X, Y); } Matrix(const Matrix &m) { ! CopyFrom(m); } Matrix& operator=(const Matrix &m) { ! return CopyFrom(m); } ! Matrix& CopyFrom(const Matrix &m); ! void SetMatrix(float M11, float M12, float M21, float M22, float X, float Y, bool trivial = false); /// X scaling factor *************** *** 98,118 **** * All elements are set to zero, except m[0][0] and m[1][1] (scaling) which are set to 1. */ ! void set_identity() { set_matrix(1, 0, 0, 1, 0, 0, true); } ! void translate(float dx, float dy); ! void translate(int dx, int dy); ! void transform(float &dx, float &dy) const; ! void transform(int &dx, int &dy) const; ! void transform_distance(float &dx, float &dy) const; ! void rotate(float degrees); ! void scale(float factor_x, float factor_y); ! void scale(float factor) { scale(factor, factor); } ! void shear(float factor_h, float factor_v); /** Multiply this matrix by given values. */ ! void multiply(float M11, float M12, float M21, float M22, float X, float Y); ! void multiply(const Matrix &m) { multiply(m.m11, m.m12, m.m21, m.m22, m.x, m.y); } ! Matrix &operator *= (const Matrix &m) { multiply(m); return *this; } bool operator == (const Matrix &m) const { --- 98,118 ---- * All elements are set to zero, except m[0][0] and m[1][1] (scaling) which are set to 1. */ ! void SetIdentity() { SetMatrix(1, 0, 0, 1, 0, 0, true); } ! void Translate(float dx, float dy); ! void Translate(int dx, int dy); ! void Transform(float &dx, float &dy) const; ! void Transform(int &dx, int &dy) const; ! void Transform_distance(float &dx, float &dy) const; ! void Rotate(float degrees); ! void Scale(float factor_x, float factor_y); ! void Scale(float factor) { Scale(factor, factor); } ! void Shear(float factor_h, float factor_v); /** Multiply this matrix by given values. */ ! void Multiply(float M11, float M12, float M21, float M22, float X, float Y); ! void Multiply(const Matrix &m) { Multiply(m.m11, m.m12, m.m21, m.m22, m.x, m.y); } ! Matrix &operator *= (const Matrix &m) { Multiply(m); return *this; } bool operator == (const Matrix &m) const { |
From: Mikko L. <laz...@us...> - 2004-06-15 19:29:57
|
Update of /cvsroot/rtk/rtk/src/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17052 Modified Files: Matrix.cpp Log Message: minor changes in method names Index: Matrix.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/gui/Matrix.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Matrix.cpp 15 Jun 2004 19:13:59 -0000 1.1 --- Matrix.cpp 15 Jun 2004 19:29:44 -0000 1.2 *************** *** 56,60 **** #endif ! Matrix& Matrix::copy(const Matrix &m) { m11 = m.m11; m12 = m.m12; --- 56,60 ---- #endif ! Matrix& Matrix::CopyFrom(const Matrix &m) { m11 = m.m11; m12 = m.m12; *************** *** 66,70 **** } ! void Matrix::set_matrix(float M11, float M12, float M21, float M22, float X, float Y, bool trivial) { m11 = M11; m12 = M12; --- 66,70 ---- } ! void Matrix::SetMatrix(float M11, float M12, float M21, float M22, float X, float Y, bool trivial) { m11 = M11; m12 = M12; *************** *** 76,80 **** } ! void Matrix::translate(float dx, float dy) { if(trivial) { --- 76,80 ---- } ! void Matrix::Translate(float dx, float dy) { if(trivial) { *************** *** 92,96 **** } ! void Matrix::translate(int dx, int dy) { if(trivial) { --- 92,96 ---- } ! void Matrix::Translate(int dx, int dy) { if(trivial) { *************** *** 107,111 **** } ! void Matrix::transform(float &dx, float &dy) const { if(!trivial) { --- 107,111 ---- } ! void Matrix::Transform(float &dx, float &dy) const { if(!trivial) { *************** *** 119,123 **** } ! void Matrix::transform(int &dx, int &dy) const { if(!trivial) { --- 119,123 ---- } ! void Matrix::Transform(int &dx, int &dy) const { if(!trivial) { *************** *** 131,135 **** } ! void Matrix::transform_distance(float &dx, float &dy) const { if(trivial) return; --- 131,135 ---- } ! void Matrix::Transform_distance(float &dx, float &dy) const { if(trivial) return; *************** *** 139,143 **** } ! void Matrix::rotate(float degrees) { float s, c; // sin & cos --- 139,143 ---- } ! void Matrix::Rotate(float degrees) { float s, c; // sin & cos *************** *** 161,165 **** } ! void Matrix::scale(float factor_x, float factor_y) { if(factor_x != 1.0f) { --- 161,165 ---- } ! void Matrix::Scale(float factor_x, float factor_y) { if(factor_x != 1.0f) { *************** *** 175,179 **** } ! void Matrix::shear(float factor_h, float factor_v) { float t11 = factor_v * m21; --- 175,179 ---- } ! void Matrix::Shear(float factor_h, float factor_v) { float t11 = factor_v * m21; *************** *** 187,191 **** // Multiply this matrix by given values. ! void Matrix::multiply(float M11, float M12, float M21, float M22, float X, float Y) { if(trivial) { --- 187,191 ---- // Multiply this matrix by given values. ! void Matrix::Multiply(float M11, float M12, float M21, float M22, float X, float Y) { if(trivial) { |
From: Mikko L. <laz...@us...> - 2004-06-15 19:14:08
|
Update of /cvsroot/rtk/rtk/src/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5378 Added Files: Matrix.cpp Log Message: Added 3x3 (2D) Matrix class --- NEW FILE: Matrix.cpp --- /** * * RTK * Fast and easy cross-platform GUI ToolKit. * * Copyright (C) 2001-200x RTK Development Team * * This library is free software; you can redistribute it and/or modify it * under the terms of the slightly modified (see the "EXCEPTION NOTICE" part * of RTK Library License) GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * and along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA . * * Also you should have received a copy of RTK Library License, if not please * write an e-mail to some of RTK authors (listed in file AUTHORS). * * Bug reports: bu...@rt... * Suggestions: rf...@rt... ***************************************************************************/ /** * $Source: /cvsroot/rtk/rtk/src/gui/Matrix.cpp,v $ ***** * Authors (chronological order): * Mikko Lahteenmaki, mikko§rtk.cx * Contributors (chronological order): * $fname $lname, $email ***** * T0D0 List: * - ***************************************************************************/ /** * @file * Implementation of the 3x3 (2D) Matrix */ #include <rtk/Matrix.h> #include <math.h> namespace Rtk { #ifndef floorf # define floorf(x) ((float)floor((double)(x))) #endif Matrix& Matrix::copy(const Matrix &m) { m11 = m.m11; m12 = m.m12; m21 = m.m21; m22 = m.m22; x = m.x; y = m.y; ix = m.ix; iy = m.iy; trivial = m.trivial; return *this; } void Matrix::set_matrix(float M11, float M12, float M21, float M22, float X, float Y, bool trivial) { m11 = M11; m12 = M12; m21 = M12; m22 = M22; x = X; y = Y; ix = int(floorf(X+.5f)); iy = int(floorf(Y+.5f)); trivial = trivial; } void Matrix::translate(float dx, float dy) { if(trivial) { x += dx; y += dy; ix = int(floorf(x+.5f)); iy = int(floorf(y+.5f)); trivial = (ix==x && iy==y); } else { x += dx * m11 + dy * m21; y += dy * m22 + dx * m12; ix = int(floorf(x+.5f)); iy = int(floorf(y+.5f)); } } void Matrix::translate(int dx, int dy) { if(trivial) { ix += dx; iy += dy; x = float(ix); y = float(iy); } else { x += dx * m11 + dy * m21; y += dy * m22 + dx * m12; ix = int(floorf(x+.5f)); iy = int(floorf(y+.5f)); } } void Matrix::transform(float &dx, float &dy) const { if(!trivial) { float nx = m11*dx + m21*dy + x; float ny = m12*dx + m22*dy + y; dx = nx; dy = ny; } else { dx += x; dy += y; } } void Matrix::transform(int &dx, int &dy) const { if(!trivial) { int nx = int(floorf(m11*dx + m21*dy + x + .5f)); int ny = int(floorf(m12*dx + m22*dy + y + .5f)); dx = nx; dy = ny; } else { dx += ix; dy += iy; } } void Matrix::transform_distance(float &dx, float &dy) const { if(trivial) return; float nx = m11*dx + m21*dy; float ny = m12*dx + m22*dy; dx = nx; dy = ny; } void Matrix::rotate(float degrees) { float s, c; // sin & cos if(degrees==0) { s = 0; c = 1; } else if(degrees==90) { s = 1; c = 0; } else if(degrees==180) { s = 0; c = -1; } else if(degrees==270 || degrees==-90) { s = -1; c = 0; } else { float rad = DEG2RAD * degrees; // Convert to radians s = sinf(rad); c = cosf(rad); } //multiply(c, -s, s, c, 0, 0); float t00 = c * m11 + -s * m21; float t01 = c * m12 + -s * m22; float t10 = s * m11 + c * m21; float t11 = s * m12 + c * m22; m11 = t00; m12 = t01; m21 = t10; m22 = t11; trivial = false; } void Matrix::scale(float factor_x, float factor_y) { if(factor_x != 1.0f) { m11 *= factor_x; m12 *= factor_x; trivial = false; } if(factor_y != 1.0f) { m21 *= factor_y; m22 *= factor_y; trivial = false; } } void Matrix::shear(float factor_h, float factor_v) { float t11 = factor_v * m21; float t12 = factor_v * m22; float t21 = factor_h * m11; float t22 = factor_h * m12; m11 += t11; m12 += t12; m21 += t21; m22 += t22; trivial = false; } // Multiply this matrix by given values. void Matrix::multiply(float M11, float M12, float M21, float M22, float X, float Y) { if(trivial) { m11 = M11; m12 = M12; m21 = M21; m22 = M22; x += X; y += Y; ix = int(floor(x+.5f)); iy = int(floor(y+.5f)); trivial = false; } else { float t00 = M11 * m11 + M12 * m21; float t01 = M11 * m12 + M12 * m22; float t10 = M21 * m11 + M22 * m21; float t11 = M21 * m12 + M22 * m22; if(X!=0) { x = X * m11 + Y * m21 + x; ix = int(floor(x+.5f)); } if(Y!=0) { y = X * m12 + Y * m22 + y; iy = int(floor(y+.5f)); } m11 = t00; m12 = t01; m21 = t10; m22 = t11; trivial = false; } } }; // namespace Rtk |
From: Mikko L. <laz...@us...> - 2004-06-15 19:13:20
|
Update of /cvsroot/rtk/rtk/src/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4809/gui Log Message: Directory /cvsroot/rtk/rtk/src/gui added to the repository |
From: Mikko L. <laz...@us...> - 2004-06-15 19:12:53
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4432 Added Files: Matrix.h Log Message: Added 3x3 (2D) Matrix class --- NEW FILE: Matrix.h --- /** * * RTK * Fast and easy cross-platform GUI ToolKit. * * Copyright (C) 2001-200x RTK Development Team * * This library is free software; you can redistribute it and/or modify it * under the terms of the slightly modified (see the "EXCEPTION NOTICE" part * of RTK Library License) GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * and along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA . * * Also you should have received a copy of RTK Library License, if not please * write an e-mail to some of RTK authors (listed in file AUTHORS). * * Bug reports: bu...@rt... * Suggestions: rf...@rt... ***************************************************************************/ /** * $Source: /cvsroot/rtk/rtk/rtk/Matrix.h,v $ ***** * Authors (chronological order): * Mikko Lahteenmaki, mi...@rt... * Contributors (chronological order): * $fname $lname, $email ***** * T0D0 List: * - ***************************************************************************/ #ifndef _RTK_MATRIX_H_ #define _RTK_MATRIX_H_ namespace Rtk { #define DEG2RAD (0.017453292519943295769f) // PI/180 /** The 3x3 Matrix: * .-----------------------. * | m[0][0] | m[0][1] | 0 | * | m[1][0] | m[1][1] | 0 | * | X | Y | 1 | * '-----------------------' */ class Matrix { public: Matrix() { set_identity(); } Matrix(float M11, float M12, float M21, float M22, float X, float Y) { set_matrix(M11, M12, M21, M22, X, Y); } Matrix(const Matrix &m) { copy(m); } Matrix& operator=(const Matrix &m) { return copy(m); } Matrix& copy(const Matrix &m); void set_matrix(float M11, float M12, float M21, float M22, float X, float Y, bool trivial = false); /// X scaling factor float m11; /// Vertical shearing factor. float m12; /// Horizontal shearing factor. float m21; /// Y scaling factor. float m22; /// Horizontal translation. float x; /// Vertical translation. float y; /// Horizontal translation. rounded nearest integer. int ix; /// Vertical translation. rounded nearest integer. int iy; /// Is this matrix trivial? I.e. no scaling or rotating bool trivial; /** * Set the matrix to an identity matrix. * All elements are set to zero, except m[0][0] and m[1][1] (scaling) which are set to 1. */ void set_identity() { set_matrix(1, 0, 0, 1, 0, 0, true); } void translate(float dx, float dy); void translate(int dx, int dy); void transform(float &dx, float &dy) const; void transform(int &dx, int &dy) const; void transform_distance(float &dx, float &dy) const; void rotate(float degrees); void scale(float factor_x, float factor_y); void scale(float factor) { scale(factor, factor); } void shear(float factor_h, float factor_v); /** Multiply this matrix by given values. */ void multiply(float M11, float M12, float M21, float M22, float X, float Y); void multiply(const Matrix &m) { multiply(m.m11, m.m12, m.m21, m.m22, m.x, m.y); } Matrix &operator *= (const Matrix &m) { multiply(m); return *this; } bool operator == (const Matrix &m) const { return ( x==m.x && y==m.y && m11==m.m11 && m12==m.m12 && m21==m.m21 && m22==m.m22 ); } bool operator != (const Matrix &m) const { return ( x!=m.x || y!=m.y || m11!=m.m11 && m12!=m.m12 && m21!=m.m21 && m22!=m.m22 ); } }; }; #endif // _MATRIX_H_ |
From: Mikko L. <laz...@us...> - 2004-06-15 19:01:16
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28535 Modified Files: Queue.cpp Log Message: minor changes, added few missing consts. Added cmp param to Contains Index: Queue.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/Queue.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Queue.cpp 14 Jun 2004 17:44:37 -0000 1.3 --- Queue.cpp 15 Jun 2004 19:01:05 -0000 1.4 *************** *** 58,68 **** bool Queue::Enqueue(void *data) { ! if ((_max_size!=0) && (_max_size<_count+1)) return false; ! if (_mutex) _mutex->Lock(); // Allocate space for new element QueueNode* new_element = (QueueNode*)malloc(sizeof(QueueNode)); ! if (new_element == (QueueNode*)0) // NULL ! return false; new_element->data = data; --- 58,71 ---- bool Queue::Enqueue(void *data) { ! if ((_max_size!=0) && (_max_size<_count+1)) return false; ! if (_mutex) _mutex->Lock(); ! // Allocate space for new element QueueNode* new_element = (QueueNode*)malloc(sizeof(QueueNode)); ! if (new_element == (QueueNode*)0) { // NULL ! if(_mutex) _mutex->Unlock(); ! return false; ! } new_element->data = data; *************** *** 116,129 **** //--------------------------------------------------------------------------- ! int Queue::Contains(void* data) const { ! int count=0; ! QueueNode* node=_head; ! while (node) ! { ! if ( node->data == data ) count++; ! node=node->next; ! } ! return count; } --- 119,136 ---- //--------------------------------------------------------------------------- ! int Queue::Contains(void* data, CmpFunction cmp) const { ! int count=0; ! QueueNode* node=_head; ! while (node) ! { ! if(cmp) { ! if( cmp(node->data, data)==0 ) count++; ! } else { ! if( node->data == data ) count++; ! } ! node=node->next; ! } ! return count; } |
From: Mikko L. <laz...@us...> - 2004-06-15 19:00:49
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28196 Modified Files: Queue.h Log Message: minor changes, added few missing consts. Added cmp param to Contains Index: Queue.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/Queue.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Queue.h 14 Jun 2004 11:44:18 -0000 1.3 --- Queue.h 15 Jun 2004 19:00:39 -0000 1.4 *************** *** 80,109 **** /** ! * Returns number of items in the list. */ int GetCount() const { return _count; } /** ! * Returns pointer to _head node in Queue. ! * @return QueueNode pointer to first node in Queue. */ ! void* GetFirst() const { return _head->data; } /** * Get free data function. */ ! FreeDataFunc GetFreeDataFunc() { return _free_func; } /** * Get Mutex from Queue */ ! ! Mutex* GetMutex() { return _mutex; } /** * GetMaxSize, Maximum size of Queue, if return value is 0 ! * then Queue have no maximum size. */ ! int GetMaxSize() {return _max_size; } // --------- SET METHODS ----------------------------------- --- 80,115 ---- /** ! * Returns number of items in the queue. */ int GetCount() const { return _count; } /** ! * Returns a pointer to the head item in the queue. ! * The queue is not changed. Returns 0 if the queue is empty. */ ! void* GetFirst() const { return (_head ? _head->data : 0); } ! ! /** ! * Returns a pointer to the head item in the queue. ! * The queue is not changed. Returns 0 if the queue is empty. ! */ ! void* GetHead() const { return (_head ? _head->data : 0); } /** * Get free data function. */ ! FreeDataFunc GetFreeDataFunc() const { return _free_func; } /** * Get Mutex from Queue */ ! Mutex* GetMutex() const { return _mutex; } /** * GetMaxSize, Maximum size of Queue, if return value is 0 ! * then Queue size is unlimited. */ ! int GetMaxSize() const { return _max_size; } ! // --------- SET METHODS ----------------------------------- *************** *** 124,132 **** */ void SetMaxSize(int max_size) { _max_size = max_size; } // --------- OTHER METHODS --------------------------------- /** ! * Clears the Queue. This wi ! ll call 'Free Data Handler' */ void Clear(); --- 130,138 ---- */ void SetMaxSize(int max_size) { _max_size = max_size; } + // --------- OTHER METHODS --------------------------------- /** ! * Clears the Queue. This will call 'Free Data Handler' */ void Clear(); *************** *** 142,146 **** * Remove first element from Queue * This will call 'Free Data Handler' ! * @return Data assigned to removed element, or NULL on error */ void *Dequeue(); --- 148,152 ---- * Remove first element from Queue * This will call 'Free Data Handler' ! * @return Data assigned to removed element, or NULL on error */ void *Dequeue(); *************** *** 148,166 **** /** * Get number of items containing given data. * @param data Search for this data * @return Number of elements found, that contains given data. */ ! int Contains(void *data) const; protected: // Members ! int _count; /// Size of the list object (how many elements are stored inside) ! int _max_size; /// Max size of Queue ! bool _sort; /// How priority queue is sorted ! QueueNode* _head; /// Pointer to _head element of the List. ! QueueNode* _tail; /// Pointer to _tail element of the List. FreeDataFunc _free_func; /// Free data function ! Mutex* _mutex; /// Thread safe }; // Queue --- 154,174 ---- /** * Get number of items containing given data. + * * @param data Search for this data + * @param cmp Uses this function to compare items, if NULL (default) then pointer comparing is used. + * * @return Number of elements found, that contains given data. */ ! int Contains(void *data, CmpFunction cmp = 0) const; protected: // Members ! int _count; /// Size of the list object (how many elements are stored inside) ! int _max_size; /// Max size of Queue ! QueueNode* _head; /// Pointer to _head element of the List. ! QueueNode* _tail; /// Pointer to _tail element of the List. FreeDataFunc _free_func; /// Free data function ! Mutex* _mutex; /// Thread safe }; // Queue |
From: Dejan L. <dlo...@us...> - 2004-06-14 17:44:46
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8561 Modified Files: Queue.cpp Log Message: Index: Queue.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/Queue.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Queue.cpp 14 Jun 2004 11:44:18 -0000 1.2 --- Queue.cpp 14 Jun 2004 17:44:37 -0000 1.3 *************** *** 76,79 **** --- 76,80 ---- { _tail->next=new_element; + _tail=new_element; } |
From: Dejan L. <dlo...@us...> - 2004-06-14 12:59:27
|
Update of /cvsroot/rtk/rtk/test/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20569 Modified Files: CMakeLists.txt Log Message: added queue0 Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/CMakeLists.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CMakeLists.txt 12 Jun 2004 22:49:42 -0000 1.8 --- CMakeLists.txt 14 Jun 2004 12:59:17 -0000 1.9 *************** *** 41,45 **** FOREACH(NAME vector0 dlist0 debug0 list0 variant0 array0 dict0 error0 ! string0 file0 buffer0) ADD_EXECUTABLE(test_core_${NAME} ${NAME}.cpp) TARGET_LINK_LIBRARIES(test_core_${NAME} ${RTK_LIBRTK}) --- 41,45 ---- FOREACH(NAME vector0 dlist0 debug0 list0 variant0 array0 dict0 error0 ! string0 file0 buffer0 queue0) ADD_EXECUTABLE(test_core_${NAME} ${NAME}.cpp) TARGET_LINK_LIBRARIES(test_core_${NAME} ${RTK_LIBRTK}) |
From: Dejan L. <dlo...@us...> - 2004-06-14 12:58:33
|
Update of /cvsroot/rtk/rtk/test/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19990 Added Files: queue0.cpp Log Message: test for queue class --- NEW FILE: queue0.cpp --- /***************************************************************************** Example file for the Array class *****************************************************************************/ #include "../test.h" #ifdef _WIN32 #include <windows.h> #endif #include <stdio.h> #include <rtk/Queue.h> #include <rtk/Rtk.h> #include <rtk/rchar.h> #include <rtk/debug.h> #include <rtk/rchar.h> using namespace Rtk; int main(int argc, char* argv[]) { TITLE(_R("Test file for the Queue class(es)")); STEP(Queue qu); // Append some single values STEP(qu.SetMaxSize(4)); STEP(qu.Enqueue((void*)2)); STEP(qu.Enqueue((void*)5)); STEP(qu.Enqueue((void*)7)); STEP(qu.Enqueue((void*)11)); STEP(qu.Enqueue((void*)32)); STEP(qu.Enqueue((void*)1)); STEP(rprintf(_R("Size is: %d\n\n\n\n\n"),qu.GetCount())); while(qu.GetCount()) { rprintf(_R("element: %d\n"),(int)qu.GetFirst()); STEP(qu.Dequeue()); rprintf(_R("new size: %d\n\n\n"),(int)qu.GetCount()); } return 0; } |
From: Dejan L. <le...@us...> - 2004-06-14 12:07:16
|
Update of /cvsroot/rtk/rtk/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9162/doc Modified Files: CMakeLists.txt Log Message: Small change - now doxygen generates docs... Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/rtk/rtk/doc/CMakeLists.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CMakeLists.txt 27 May 2004 14:16:58 -0000 1.2 --- CMakeLists.txt 14 Jun 2004 12:07:02 -0000 1.3 *************** *** 1 **** ! ADD_CUSTOM_TARGET(docs "cd .. && doxygen rtk.doxygen") --- 1 ---- ! ADD_CUSTOM_TARGET(docs "doxygen ${RTK_SOURCE_DIR}/rtk.doxygen") |
From: Dejan L. <dlo...@us...> - 2004-06-14 11:44:42
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21007/rtk Modified Files: Queue.h PriorityQueue.h Log Message: Added GetMaxSize and SetMaxSize, also GetFirst now return void *data instead of QueueNode Index: Queue.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/Queue.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Queue.h 14 Jun 2004 11:00:26 -0000 1.2 --- Queue.h 14 Jun 2004 11:44:18 -0000 1.3 *************** *** 88,92 **** * @return QueueNode pointer to first node in Queue. */ ! QueueNode* GetFirst() const { return _head; } /** --- 88,92 ---- * @return QueueNode pointer to first node in Queue. */ ! void* GetFirst() const { return _head->data; } /** Index: PriorityQueue.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/PriorityQueue.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PriorityQueue.h 10 Jun 2004 22:09:03 -0000 1.3 --- PriorityQueue.h 14 Jun 2004 11:44:18 -0000 1.4 *************** *** 72,76 **** /** ! * Queue or FIFO(first in, first out) class */ class RTK_API PriorityQueue --- 72,76 ---- /** ! * PriorityQueue */ class RTK_API PriorityQueue *************** *** 83,87 **** */ PriorityQueue(bool sort=SORT_ASC): _sort(sort),_priority_head(0) ! ,_count(0), _head(0), _tail(0), _free_func(0), _mutex(0) { } // --------- DESTRUCTORS ----------------------------------- --- 83,87 ---- */ PriorityQueue(bool sort=SORT_ASC): _sort(sort),_priority_head(0) ! ,_count(0), _max_size(0), _head(0), _tail(0), _free_func(0), _mutex(0) { } // --------- DESTRUCTORS ----------------------------------- *************** *** 102,106 **** * @return QueueNode pointer to first node in Queue. */ ! QueueNode* GetFirst() const { return this->_head; } /** --- 102,106 ---- * @return QueueNode pointer to first node in Queue. */ ! void* GetFirst() const { return _head->data; } /** *************** *** 114,117 **** --- 114,124 ---- Mutex* GetMutex() { return _mutex; } + + /** + * GetMaxSize, Maximum size of PriorityQueue, if return value is 0 + * then PriorityQueue have no maximum size. + */ + int GetMaxSize() {return _max_size; } + // --------- SET METHODS ----------------------------------- *************** *** 127,130 **** --- 134,143 ---- void SetMutex(Mutex* mutex) { _mutex = mutex; } + /** + * Set maximum size for PriorityQueue if max_size is 0 then Queue have + * no max size + */ + void SetMaxSize(int max_size) { _max_size = max_size; } + // --------- OTHER METHODS --------------------------------- *************** *** 158,178 **** int Contains(void *data) const; - /** - * Returns TRUE if given node is _head node in Queue. - * @param element QueueNode* Node that should be checked. - * @return TRUE if given node is _head node in Queue, FALSE otherwize. - */ - bool IsFirst(const QueueNode* element) const { return ((element == this->_head) ? true : false); } - - /** - * Returns TRUE if given node is _tail node in Queue. - * @param element QueueNode* Node that should be checked. - * @return TRUE if given node oElement is _tail node in Queue, FALSE otherwize. - */ - bool IsLast(const QueueNode* element) const { return ((element->next == 0) ? true : false); } protected: // Members int _count; /// Size of the list object (how many elements are stored inside) bool _sort; /// How priority queue is sorted QueueNode* _head; /// Pointer to _head element of the List. --- 171,179 ---- int Contains(void *data) const; protected: // Members int _count; /// Size of the list object (how many elements are stored inside) + int _max_size; /// Maximum Size for Priority Queue bool _sort; /// How priority queue is sorted QueueNode* _head; /// Pointer to _head element of the List. *************** *** 180,183 **** --- 181,185 ---- PriorityNode* _priority_head; /// Pointer to priority head_element of the list + FreeDataFunc _free_func; /// Free data function Mutex* _mutex; |
From: Dejan L. <dlo...@us...> - 2004-06-14 11:44:34
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21007/src/core Modified Files: PriorityQueue.cpp Queue.cpp Log Message: Added GetMaxSize and SetMaxSize, also GetFirst now return void *data instead of QueueNode Index: Queue.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/Queue.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Queue.cpp 13 Jun 2004 13:50:10 -0000 1.1 --- Queue.cpp 14 Jun 2004 11:44:18 -0000 1.2 *************** *** 58,62 **** bool Queue::Enqueue(void *data) { ! if(_mutex) _mutex->Lock(); // Allocate space for new element QueueNode* new_element = (QueueNode*)malloc(sizeof(QueueNode)); --- 58,63 ---- bool Queue::Enqueue(void *data) { ! if ((_max_size!=0) && (_max_size<_count+1)) return false; ! if (_mutex) _mutex->Lock(); // Allocate space for new element QueueNode* new_element = (QueueNode*)malloc(sizeof(QueueNode)); *************** *** 114,117 **** --- 115,131 ---- //--------------------------------------------------------------------------- + int Queue::Contains(void* data) const + { + int count=0; + QueueNode* node=_head; + while (node) + { + if ( node->data == data ) count++; + node=node->next; + } + return count; + } + + //--------------------------------------------------------------------------- void *Queue::Dequeue() { Index: PriorityQueue.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/PriorityQueue.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PriorityQueue.cpp 10 Jun 2004 22:10:35 -0000 1.2 --- PriorityQueue.cpp 14 Jun 2004 11:44:18 -0000 1.3 *************** *** 58,61 **** --- 58,62 ---- bool PriorityQueue::Enqueue(void *data, unsigned char priority ) { + if ((_max_size!=0) && (_max_size<_count+1)) return false; if(_mutex) _mutex->Lock(); // Allocate space for new element *************** *** 164,167 **** --- 165,180 ---- //--------------------------------------------------------------------------- + int PriorityQueue::Contains(void* data) const + { + int count=0; + QueueNode* node=_head; + while (node) + { + if ( node->data == data ) count++; + node=node->next; + } + return count; + } + //--------------------------------------------------------------------------- void *PriorityQueue::Dequeue() |