<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dockable palette - is it possible? in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116441#M6654</link>
    <description>Thanks. That's a big help.</description>
    <pubDate>Tue, 18 Nov 2014 03:18:00 GMT</pubDate>
    <dc:creator>ReignBough</dc:creator>
    <dc:date>2014-11-18T03:18:00Z</dc:date>
    <item>
      <title>[SOLVED] Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116417#M6630</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Is it possible to create a &lt;STRONG&gt;dockable&lt;/STRONG&gt; custom palette like Info Box - in the other words, is it possible to create a window, which can be made floating or docked to some side of the working area?&lt;BR /&gt;Thanks.&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Jul 2023 14:20:19 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116417#M6630</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-13T14:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116418#M6631</link>
      <description>Hi Vladimir,&lt;BR /&gt;
&lt;BR /&gt;
There is some "docking" support.  May be it is not like you expect.&lt;BR /&gt;
And I think a palette is dockable by default.&lt;BR /&gt;
&lt;BR /&gt;
There are two functions related :&lt;BR /&gt;
&lt;BR /&gt;
DGDisablePaletteDock&lt;BR /&gt;
DGIsPaletteDocked&lt;BR /&gt;
&lt;BR /&gt;
Same for C++ DG implementations (I use it)&lt;BR /&gt;
&lt;BR /&gt;
DG::Palette::DisableDock&lt;BR /&gt;
DG::Palette::IsDocked&lt;BR /&gt;
&lt;BR /&gt;
It is all of I know. I have one dockable palette and it is docks. &lt;BR /&gt;
So try and test.&lt;BR /&gt;
&lt;BR /&gt;
Oleg</description>
      <pubDate>Sat, 11 Apr 2009 08:37:30 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116418#M6631</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2009-04-11T08:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116419#M6632</link>
      <description>Hi, Oleg, and thanks for comprehensive reply!&lt;BR /&gt;
&lt;BR /&gt;
I guess, the point is the ArchiCAD SDK I am using (version 10) have no function your mention.. Does this mean that support for dockable palettes had been introduced in later versions (11 or 12)? I would like to have the same addon UI and behavior for as much ArchiCAD versions as possible..</description>
      <pubDate>Sat, 11 Apr 2009 14:18:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116419#M6632</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-04-11T14:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116420#M6633</link>
      <description>AFAIR it is available from at last AC 9. &lt;BR /&gt;
It seems, this functions are not documented so look in headers.&lt;BR /&gt;
But this functions are not "enable" docking, so it is not so important actually. &lt;BR /&gt;
I think, a docking works by default for any palette. (But I am not sure). Currently I have only one palette and it works.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Oleg.</description>
      <pubDate>Sat, 11 Apr 2009 16:06:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116420#M6633</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2009-04-11T16:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116421#M6634</link>
      <description>&lt;BLOCKQUOTE&gt;It seems, this functions are not documented so look in headers.&lt;/BLOCKQUOTE&gt; &lt;BR /&gt;
Found them with your prompt in Support\Modules\DGLib\DG.h -thanks!  &lt;BR /&gt;

&lt;BLOCKQUOTE&gt;I think, a docking works by default for any palette. (But I am not sure). &lt;/BLOCKQUOTE&gt;
But I cannot have the "dock" effect until applying DGCreateDockablePalette()..</description>
      <pubDate>Sat, 11 Apr 2009 16:32:18 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116421#M6634</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-04-11T16:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116422#M6635</link>
      <description>Hmm, DGCreateDockablePalette was the main reason.&lt;BR /&gt;
I didnt know it, as I use DG::Palette. &lt;BR /&gt;
I think all palletes is dockable by default, but it was not true.&lt;BR /&gt;
&lt;BR /&gt;
Good luck&lt;BR /&gt;
&lt;BR /&gt;
Oleg</description>
      <pubDate>Sat, 11 Apr 2009 17:07:55 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116422#M6635</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2009-04-11T17:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116423#M6636</link>
      <description>Oleg, a few more questions, if you don't mind.&lt;BR /&gt;
&lt;BR /&gt;
1. As far as I understand from your answers, AC SDK has a set of handy C++ classes, which are an alternative to the pure API calls. &lt;BR /&gt;
Is there exists any documentation or examples of using of this classes - besides headers in the SDK's Support\Modules folder? &lt;BR /&gt;
&lt;BR /&gt;
2. I have tried to use the DG::Palette like this:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;// Declare global variable to hold a palette object reference
DG::Palette* g_pPalette = NULL; 
...
// Inintialize the reference in menu command handler
// and show the palette
if (!g_pPalette) 
  g_pPalette = new DG::Palette(32420);
g_pPalette-&amp;gt;BeginEventProcessing();
g_pPalette-&amp;gt;Show();
&lt;/PRE&gt;

But it does not work: the panel became visible just for a bit of second and then disappears &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;  &lt;BR /&gt;
What's wrong with this code?</description>
      <pubDate>Sun, 12 Apr 2009 16:01:59 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116423#M6636</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-04-12T16:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116424#M6637</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Unfortunately I have no time for more detailed answers.&lt;BR /&gt;
This week will very hard.&lt;BR /&gt;
&lt;BR /&gt;
1. Class Library is documented briefly in the DialogManager.chm&lt;BR /&gt;
(may be it is in html docs too, I dont install it, so I dont know)&lt;BR /&gt;
Examples...I dont remember well, but it seems there was example DGTest (not DG_Test)..may be it was in AC 9 API only.&lt;BR /&gt;
But anyway I often use method - "try,test and guess"&lt;BR /&gt;
&lt;BR /&gt;
2. I dont know what is wrong exactly. May be you need use this functions also.&lt;BR /&gt;
ACAPI_RegisterModelessWindow&lt;BR /&gt;
ACAPI_UnregisterModelessWindow&lt;BR /&gt;
&lt;BR /&gt;
Also, I dont remember details, but I use constructor with Guid.&lt;BR /&gt;
&lt;BR /&gt;
Oleg.</description>
      <pubDate>Mon, 13 Apr 2009 03:45:57 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116424#M6637</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2009-04-13T03:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116425#M6638</link>
      <description>&lt;BLOCKQUOTE&gt;Vladimir wrote:&lt;BR /&gt;1. As far as I understand from your answers, AC SDK has a set of handy C++ classes, which are an alternative to the pure API calls. &lt;BR /&gt;
Is there exists any documentation or examples of using of this classes - besides headers in the SDK's &lt;FONT color="#00FFC8"&gt;Support\Modules folder? &lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;&lt;COLOR color="#00FFC8"&gt;&lt;BR /&gt;
&lt;BR /&gt;
These do not seem to be well-documented.  The document called "DG Namespace" in the help file DG.html may be helpful.&lt;BR /&gt;
&lt;BR /&gt;
The example project Automate_Functions has some of the DG:: namespace calls as an example.&lt;BR /&gt;
&lt;BR /&gt;
I don't know much beyond that!&lt;BR /&gt;
&lt;BR /&gt;
Cheers,&lt;BR /&gt;
Karl&lt;/COLOR&gt;</description>
      <pubDate>Mon, 13 Apr 2009 04:25:41 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116425#M6638</guid>
      <dc:creator>Karl Ottenstein</dc:creator>
      <dc:date>2009-04-13T04:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116426#M6639</link>
      <description>Oleg, Karl, a hearty thank you for help!&lt;BR /&gt;
&lt;BR /&gt;
All I need was the ACAPI_KeepInMemory(1) calls to prevent the addon from unloading from memory - as was explained by Ralph Wessel &lt;A href="http://195.144.20.106/viewtopic.php?p=106317&amp;amp;sid=16b959a8b97e5764f3d75dafa6ae3f0b" target="_blank"&gt;here&lt;/A&gt;.&lt;BR /&gt;
&lt;BR /&gt;
Now I have a nice dockable palette which can live her own life -&lt;BR /&gt;
and all this by due of a small piece of code - thanks for DG::Palette and DG::PanelObserver - miracle! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
The only question: is it possible to make the palette name to appear in the &lt;B&gt;Window &amp;gt; Palettes&lt;/B&gt; list, so the user can toggle the palette visibility by clicking the corresponding menu item?</description>
      <pubDate>Tue, 14 Apr 2009 21:02:33 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116426#M6639</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-04-14T21:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116427#M6640</link>
      <description>&lt;BLOCKQUOTE&gt;The only question: is it possible to make the palette name to appear in the Window &amp;gt; Palettes list, so the user can toggle the palette visibility by clicking the corresponding menu item?&lt;/BLOCKQUOTE&gt;

Solve this by using MenuCode_Palettes indentifier in ACAPI_Register_Menu(). Oh, silly me :oops:</description>
      <pubDate>Wed, 15 Apr 2009 10:57:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116427#M6640</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-04-15T10:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116428#M6641</link>
      <description>Can't make palette dockable. Tried using pure API calls and DG::Palette class.&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;static CntlDlgData cntlDlgData;
static GS::Guid dialogGUID = GS::Guid( "sDock1" );
static short dialogID = 0;
&lt;/PRE&gt;


&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;GSErrCode InitPalette()
{
	GSErrCode err = NoError;
	
	// Inintialize the reference in menu command handler
	// and show the palette
	if ( dialogID == 0 ) {
		dialogGUID.ConvertFromString( "sDock1" );
		GSResModule actResModule = ACAPI_UseOwnResModule();
		dialogID = DGCreateDockablePalette( 32400, CntlDlgCallBack, (long)(void*)&amp;amp;cntlDlgData, dialogGUID );
		ACAPI_ResetResModule( actResModule );
	}

	DGBeginProcessEvents( dialogID );
	DGShowModelessDialog( dialogID );
	return err;
}
&lt;/PRE&gt;

After calling the InitPalette() function the panel appears, but it is not dockable. What's the trick?</description>
      <pubDate>Tue, 25 Aug 2009 17:24:52 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116428#M6641</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-25T17:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116429#M6642</link>
      <description>Did you try to add ACAPI_RegisterModelessWindow()?</description>
      <pubDate>Tue, 25 Aug 2009 18:09:05 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116429#M6642</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-25T18:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116430#M6643</link>
      <description>No, I didn't.</description>
      <pubDate>Tue, 25 Aug 2009 18:12:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116430#M6643</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-25T18:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116431#M6644</link>
      <description>Just added a call to ACAPI_RegisterModelessWindow() and implemented the APIPaletteControlCallBackProc callback function. The docking is still not working.</description>
      <pubDate>Tue, 25 Aug 2009 18:26:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116431#M6644</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-25T18:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116432#M6645</link>
      <description>Here is what I have now:&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;GSErrCode InitPalette()
{
	GSErrCode err = NoError;
	
	// Initialize the reference in menu command handler
	// and show the palette
	if ( dialogID == 0 ) {
		dialogGUID.ConvertFromString( "sPanel1" );
		GSResModule actResModule = ACAPI_UseOwnResModule();
		dialogID = DGCreateDockablePalette( 32400, CntlDlgCallBack, (long)(void*)&amp;amp;cntlDlgData, dialogGUID );
		ACAPI_ResetResModule( actResModule );
	}

	DGBeginProcessEvents( dialogID );
	DGShowModelessDialog( dialogID );
	return err;
}

// -----------------------------------------------------------------------------
// Callback function for the palette
// -----------------------------------------------------------------------------
short DGCALLBACK CntlDlgCallBack( short message, short dialID, short item, long userData, long /*msgData*/ )
{
	CntlDlgData *dlgData = (CntlDlgData*)userData;

	switch( message ) {
		case DG_MSG_INIT:
			if ( ACAPI_RegisterModelessWindow( dialogID, PaletteAPIControlCallBack, API_PalEnabled_FloorPlan + API_PalEnabled_Section + API_PalEnabled_Elevation + API_PalEnabled_InteriorElevation + API_PalEnabled_Detail + API_PalEnabled_Worksheet + API_PalEnabled_3D + API_PalEnabled_Layout) != NoError )
				WriteReport( "Test::ACAPI_RegisterModelessWindow failed" );
			break;

		case DG_MSG_ACTIVATE:
			break;

		case DG_MSG_UPDATE:
			break;

		case DG_MSG_CLOSE:
			DGDestroyPalette( dialogID );
			dialogID = 0;
			break;
	}
	// Save preferences :
	ACAPI_SetPreferences( 1, sizeof(CntlDlgData), &amp;amp;cntlDlgData );
	return (0);
}

GSErrCode __ACENV_CALL PaletteAPIControlCallBack( long referenceID, API_PaletteMessageID messageID )
{
	if (referenceID == dialogID) {
		switch (messageID) {
			case APIPalMsg_ClosePalette:
				DGModelessClose( dialogID );
				break;
		}
	}

	return NoError;
}
&lt;/PRE&gt;

The docking is not working.</description>
      <pubDate>Tue, 25 Aug 2009 18:42:14 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116432#M6645</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-25T18:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116433#M6646</link>
      <description>Sorry, EzPresso, have no time to test your code.&lt;BR /&gt;
I am using DG::Palette and DG::PanelObserver. Here is an extracts. Hope it helps..&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;////////////////////////////////////////////////////////////////////////
// Addon.cpp


// --- Addon ------------------------------------------------------------

...

#include "Palette.h"

...

GSErrCode __ACENV_CALL	Initialize (void)
{
	GSErrCode err = NoError;

	// Prevent the add-on auto-unloading 
        ACAPI_KeepInMemory(1);

	// Install menu handler
	err = ACAPI_Install_MenuHandler (32500, APIMenuCommandProc_32500);

	...


	return err;
}		/* Initialize */


GSErrCode __ACENV_CALL	FreeData (void)
{
	...	

	Palette::DeleteInstance();

	return NoError;
}		/* FreeData */



GSErrCode __ACENV_CALL APIMenuCommandProc_32500 (const API_MenuParams *menuParams)
{
   DBPrintf ("Test::APIMenuCommandProc_32500() %d/%d\n", menuParams-&amp;gt;menuItemRef.menuResID, menuParams-&amp;gt;menuItemRef.itemIndex);
   ACAPI_KeepInMemory(1);
   Palette::ToggleVisibility();
   return NoError;
}



////////////////////////////////////////////////////////////////////////
// Palette.h

#pragma once;

// --- Palette ------------------------------------------------------------

class Palette: public DG::Palette
{
  friend class PaletteObserver;

private:
	static Palette* m_pPalette;
  static PaletteObserver* m_pPaletteObserver;

  enum {
     CloseButtonId      = 1
  };

DG::Button closeButton;  

private:
  Palette(short resId);

public:
  ~Palette();
  void SelectionChanged(const API_Neig *selElemNeig);


static Palette&amp;amp; GetInstance(); 
static bool HasInstance(); 
static void DeleteInstance(); 
static void ToggleVisibility();

};

// --- PaletteObserver ------------------------------------------------------------

class PaletteObserver: private DG::PanelObserver,
  public  DG::ButtonItemObserver,
  public  DG::CompoundItemObserver
{
private:
  Palette*   m_palette;
public:
  PaletteObserver (Palette* palette);
  ~PaletteObserver();
  virtual void   SourceDestroyed (GS::EventSource* evSource);
  virtual void   PanelOpened (const DG::PanelOpenEvent&amp;amp; ev);
  virtual void   PanelCloseRequested (const DG::PanelCloseRequestEvent&amp;amp; ev, bool* accepted);
  virtual void   PanelClosed (const DG::PanelCloseEvent&amp;amp; ev);
  virtual void   PanelResized (const DG::PanelResizeEvent&amp;amp; ev);
  virtual void   ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev);
};


////////////////////////////////////////////////////////////////////////
// Palette.cpp

#if !defined (ACExtension)
#define	ACExtension
#endif

#if defined (_MSC_VER)
	#if !defined (WINDOWS)
		#define WINDOWS
	#endif
#endif

#if defined (WINDOWS)
	#include "Win32Interface.hpp"
	#pragma warning (disable: 4068)
#endif

// ------------------------------ Includes -------------------------------------

#include	&amp;lt;stdio.h&amp;gt;
#include	&amp;lt;math.h&amp;gt;
#include	&amp;lt;string.h&amp;gt;

#if defined (macintosh)
#include	&amp;lt;MacTypes.h&amp;gt;
#endif

#include	"DG.h"
#include	"DGModule.hpp"

#include	"ACAPinc.h"
#include	"APICommon.h"	// also includes GSRoot.hpp


#include "Palette.h"

static GS::Guid   PaletteGuid  ("{9597C98D-95BD-48d9-9999-C2297834806B}");

static GSErrCode __ACENV_CALL   ModelessWindowCallBack (long referenceID, API_PaletteMessageID messageID)
{
	if (Palette::HasInstance() &amp;amp;&amp;amp; referenceID == Palette::GetInstance().GetId()) {
		switch (messageID) {
      case APIPalMsg_ClosePalette:   
       	Palette::GetInstance().SendCloseRequest();  
	      break;
      case APIPalMsg_HidePalette_Begin:   
	      break;
      case APIPalMsg_HidePalette_End:   
	      break;
      case APIPalMsg_DisableItems_Begin:   
	      break;
      case APIPalMsg_DisableItems_End:   
      	      break;
	  }
	}
	return NoError;
}

// --- Palette ------------------------------------------------------------

/*static*/ Palette* Palette::m_pPalette = NULL;
/*static*/ PaletteObserver* Palette::m_pPaletteObserver = NULL;

///////////////////////////////////////////

/*static*/ Palette&amp;amp; Palette::GetInstance() 
{
	if (!m_pPalette) {
     GSResModule actResModule = ACAPI_UseOwnResModule ();
	   m_pPalette = new Palette(32420);  
     ACAPI_ResetResModule (actResModule);
		 m_pPaletteObserver = new PaletteObserver(m_pPalette);
	}
	return *m_pPalette;
}

/*static*/ bool Palette::HasInstance() 
{
	return m_pPalette != NULL;
}

/*static*/ void Palette::DeleteInstance() 
{
	DBASSERT(m_pPalette != NULL);
	if (m_pPalette != NULL) {
		delete m_pPalette;
		m_pPalette = NULL;
	}
	if (m_pPaletteObserver != NULL) {
		delete m_pPaletteObserver;
		m_pPaletteObserver = NULL;
	}
}

/*static*/ void Palette::ToggleVisibility() {
	if (m_pPalette != NULL &amp;amp;&amp;amp; m_pPalette-&amp;gt;IsVisible()) {
	   m_pPalette-&amp;gt;EndEventProcessing();
	   m_pPalette-&amp;gt;Hide();
	} else {
          Palette::GetInstance().BeginEventProcessing();
          m_pPalette-&amp;gt;Show(); 
	}
}

//////////////////////////////////////////////////////////

Palette::Palette(short resId) : DG::Palette(resId, PaletteGuid),
 closeButton (GetReference (), CloseButtonId)
{
   ACAPI_RegisterModelessWindow (GetId(), ModelessWindowCallBack,
          API_PalEnabled_FloorPlan + 
					API_PalEnabled_Section + 
					API_PalEnabled_Detail + 
					API_PalEnabled_Layout + 
					API_PalEnabled_3D
	 );
}


Palette::~Palette ()
{
	ACAPI_UnregisterModelessWindow (GetId());
}

void Palette::SelectionChanged(const API_Neig *selElemNeig)
{
  if (selElemNeig-&amp;gt;neigID != APINeig_None) 
	{
      DBPrintf("Last selected element: NeigID %d; guid: %s, inIndex: %d\n",
               selElemNeig-&amp;gt;neigID, (const char *) APIGuid2GSGuid (selElemNeig-&amp;gt;guid).ToUniString ().ToCStr (),
               selElemNeig-&amp;gt;inIndex);
			closeButton.Enable();
	} else {
      DBPrintf("All elements deselected\n");
			closeButton.Disable();
	}
}





// --- PaletteObserver ------------------------------------------------------------

PaletteObserver::PaletteObserver (Palette* palette)
: m_palette (palette)
{
   if (DBVERIFY (m_palette != NULL)) {
      palette-&amp;gt;Attach (*this);
      AttachToAllItems (*m_palette);
   }
}


PaletteObserver::~PaletteObserver ()
{
   if (m_palette != NULL) {
      m_palette-&amp;gt;Detach (*this);
      DetachFromAllItems (*m_palette);
   }
}


// ... Public methods ..........................................................

void PaletteObserver::SourceDestroyed (GS::EventSource* evSource)
{
   if (evSource == m_palette) {
      //MarkAsFinished ();
      //notesObserver-&amp;gt;FindPaletteDestroyed ();
      //palette = NULL;
   }
}


// ... Dialog notifications ....................................................

void PaletteObserver::PanelOpened (const DG::PanelOpenEvent&amp;amp; /*ev*/)
{
   SetMenuItemMark(32500, 1, true);

   /*palette-&amp;gt;findEdit.SetText (palette-&amp;gt;findData-&amp;gt;findText);
   palette-&amp;gt;replaceEdit.SetText (palette-&amp;gt;findData-&amp;gt;replaceText);
   FindValidate ();

   if (palette-&amp;gt;findData-&amp;gt;findWholeWord)
      palette-&amp;gt;wholeWordCheck.Check ();
   if (palette-&amp;gt;findData-&amp;gt;findMatchCase)
      palette-&amp;gt;matchCaseCheck.Check ();
   if (palette-&amp;gt;findData-&amp;gt;findWrap)
      palette-&amp;gt;wrapCheck.Check ();

   if (palette-&amp;gt;findData-&amp;gt;findUp)
      palette-&amp;gt;upRadio.Select ();
   else
      palette-&amp;gt;downRadio.Select ();

   palette-&amp;gt;findEdit.SetFocus ();*/
}


void PaletteObserver::PanelCloseRequested (const DG::PanelCloseRequestEvent&amp;amp; /*ev*/, bool* /*accepted*/)
{
   m_palette-&amp;gt;EndEventProcessing ();
}

void PaletteObserver::PanelClosed (const DG::PanelCloseEvent&amp;amp; /*ev*/)
{
   SetMenuItemMark(32500, 1, false);
}

void PaletteObserver::PanelResized (const DG::PanelResizeEvent&amp;amp; ev)
{
   short dh = ev.GetHorizontalChange ();
   short dv = ev.GetVerticalChange ();

   m_palette-&amp;gt;BeginMoveResizeItems();

   //dialog-&amp;gt;separator.Move (dh, 0);

   m_palette-&amp;gt;closeButton.Move (dh, dv);

   m_palette-&amp;gt;EndMoveResizeItems();
}

// ... Dialog item notifications ...............................................

void   PaletteObserver::ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev)
{
   if (ev.GetSource () == &amp;amp;m_palette-&amp;gt;closeButton) {
      m_palette-&amp;gt;SendCloseRequest ();
   }
}
&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Aug 2009 18:52:17 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116433#M6646</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-25T18:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116434#M6647</link>
      <description>Oh, Vladimir, Thank you a lot!&lt;BR /&gt;
It works now! The Guid was the trick, I just changed &lt;PRE&gt;static GS::Guid dialogGUID = GS::Guid( "sDock1" );&lt;/PRE&gt; to yours &lt;PRE&gt;static GS::Guid dialogGUID( "{9597C98D-95BD-48d9-9999-C2297834806B}" );&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Aug 2009 19:06:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116434#M6647</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-25T19:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116435#M6648</link>
      <description>Great, EzPresso, glad for you! But, please, dont use my guid, otherwise our addons cannot live together (just joking)  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;</description>
      <pubDate>Tue, 25 Aug 2009 19:16:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116435#M6648</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-25T19:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dockable palette - is it possible?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116436#M6649</link>
      <description>Yes &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_razz.gif" style="display : inline;" /&gt;, I have generated another one for myself. Thank you!</description>
      <pubDate>Tue, 25 Aug 2009 19:19:27 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Dockable-palette-is-it-possible/m-p/116436#M6649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-25T19:19:27Z</dc:date>
    </item>
  </channel>
</rss>

