diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-09-27 18:24:54 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-09-27 18:24:54 +0000 |
commit | 8eb1030c56d6a1228d3145b247f75c733576e511 (patch) | |
tree | b07af847fe22e6ea153e1c0088a257f72dd9f02f /src/corelib/gfx_msgqueue.inc | |
parent | 1c50f4279f89d41dd1d85964645217860f5c0b9c (diff) | |
download | fpGUI-8eb1030c56d6a1228d3145b247f75c733576e511.tar.xz |
* Rename all corelib units to the new naming convention.
* Updated the UI Designer to use the new unit names.
Diffstat (limited to 'src/corelib/gfx_msgqueue.inc')
-rw-r--r-- | src/corelib/gfx_msgqueue.inc | 229 |
1 files changed, 0 insertions, 229 deletions
diff --git a/src/corelib/gfx_msgqueue.inc b/src/corelib/gfx_msgqueue.inc deleted file mode 100644 index 20fed3ff..00000000 --- a/src/corelib/gfx_msgqueue.inc +++ /dev/null @@ -1,229 +0,0 @@ -{%mainunit fpgfx.pas} - -// fpGFX internal message queue implementation - -type - // a simlpe linked list implementation - TMessageListElement = class(TObject) - protected - Next: TMessageListElement; - Prev: TMessageListElement; - public - msg: TfpgMessageRec; - end; - -var - // to make things easier we have a few global variable that will get set - UsedFirstMessage: TMessageListElement; - UsedLastMessage: TMessageListElement; - FreeFirstMessage: TMessageListElement; - FreeLastMessage: TMessageListElement; - -procedure MsgListInsertElement(Elem: TMessageListElement; var First: TMessageListElement; var Last: TMessageListElement); -begin - Elem.Prev := nil; - Elem.Next := nil; - - if First = nil then - begin - First := Elem; - Last := Elem; - end - else - begin - Last.Next := Elem; - Elem.Prev := Last; - Last := Elem; - end; -end; - -procedure MsgListRemoveElement(Elem: TMessageListElement; var First: TMessageListElement; var Last: TMessageListElement); -begin - if Elem = First then - First := Elem.Next; - - if Elem = Last then - Last := Elem.Prev; - - if Elem.Next <> nil then - Elem.Next.Prev := Elem.Prev; - - if Elem.Prev <> nil then - Elem.Prev.Next := Elem.Next; -end; - -function fpgAllocateMessage: PfpgMessageRec; -var - e: TMessageListElement; -begin - e := FreeFirstMessage; - if e <> nil then - begin - MsgListRemoveElement(e, FreeFirstMessage, FreeLastMessage); - MsgListInsertElement(e, UsedFirstMessage, UsedLastMessage); - result := @(e.msg); - end - else - result := nil; -end; - -procedure fpgDeleteFirstMessage; -var - e: TMessageListElement; -begin - e := UsedFirstMessage; - if e <> nil then - begin - MsgListRemoveElement(e, UsedFirstMessage, UsedLastMessage); - MsgListInsertElement(e, FreeFirstMessage, FreeLastMessage); - end; -end; - -function fpgGetFirstMessage: PfpgMessageRec; -begin - if UsedFirstMessage <> nil then - Result := @(UsedFirstMessage.msg) - else - Result := nil; -end; - -procedure fpgInitMsgQueue; -var - n: integer; - e: TMessageListElement; -begin - UsedFirstMessage := nil; - UsedLastMessage := nil; - FreeFirstMessage := nil; - FreeLastMessage := nil; - - uMsgQueueList := TList.Create; - - for n := 1 to cMessageQueueSize do - begin - e := TMessageListElement.Create; - uMsgQueueList.Add(e); // so we can free it off later - MsgListInsertElement(e,FreeFirstMessage,FreeLastMessage); - end; -end; - -procedure fpgPostMessage(Sender, Dest: TObject; MsgCode: integer; var aparams: TfpgMessageParams); overload; -var - p: PfpgMessageRec; -begin - if Dest = nil then - Exit; //==> - - p := fpgAllocateMessage; - if p <> nil then - begin - p^.MsgCode := MsgCode; - p^.Sender := Sender; - p^.Dest := Dest; - p^.Params := aparams; - end - else - Writeln('THE MESSAGE QUEUE IS FULL.'); -end; - -procedure fpgPostMessage(Sender, Dest: TObject; MsgCode: integer); overload; -var - p: PfpgMessageRec; -begin - if Dest = nil then - Exit; //==> - - p := fpgAllocateMessage; - if p <> nil then - begin - p^.MsgCode := MsgCode; - p^.Sender := Sender; - p^.Dest := Dest; - p^.Stop := False; - end - else - Writeln('THE MESSAGE QUEUE IS FULL.'); -end; - -procedure fpgSendMessage(Sender, Dest: TObject; MsgCode: integer; var aparams: TfpgMessageParams); overload; -var - m: TfpgMessageRec; -begin - if Dest = nil then - Exit; //==> - - m.MsgCode := MsgCode; - m.Sender := Sender; - m.Dest := Dest; - m.Params := aparams; - -// try - m.Dest.Dispatch(m) -// except -// on E: Exception do -// {$IFDEF DEBUG}writeln('fpgSendMessage Caught Exception: ' + E.Message){$ENDIF}; -// end; -end; - -procedure fpgSendMessage(Sender, Dest: TObject; MsgCode: integer); overload; -var - m: TfpgMessageRec; -begin - if Dest = nil then - Exit; //==> - - m.MsgCode := MsgCode; - m.Sender := Sender; - m.Dest := Dest; - -// try - m.Dest.Dispatch(m) -// except -// on E: Exception do -// {$IFDEF DEBUG}writeln('fpgSendMessage Caught Exception: ' + E.Message){$ENDIF}; -// end; -end; - -procedure fpgDeliverMessage(var msg: TfpgMessageRec); -var - oItem: TMsgHookItem; - i: integer; -begin - if msg.MsgCode = FPGM_KILLME then - msg.Dest.Free - else - begin -// try - msg.Dest.Dispatch(msg); - if fpgApplication.FMessageHookList.Count > 0 then - begin - for i := 0 to fpgApplication.FMessageHookList.Count - 1 do - begin - oItem := TMsgHookItem(fpgApplication.FMessageHookList.Items[i]); - if (msg.Dest = oItem.Dest) and (msg.MsgCode = oItem.MsgCode) then - oItem.Listener.Dispatch(msg); - end; - end; -// except -// on E: Exception do -// {$IFDEF DEBUG}writeln('fpgDeliverMessage Caught Exception: ' + E.Message){$ENDIF}; -// end; - end; -end; - -procedure fpgDeliverMessages; -var - mp: PfpgMessageRec; - m: TfpgMessageRec; -begin - repeat - mp := fpgGetFirstMessage; - if mp <> nil then - begin - m := mp^; - fpgDeleteFirstMessage; - fpgDeliverMessage(m); - end; - until mp = nil; -end; - |