Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

AK

 

The definition and use of redefinable key accelerators

 

 

 

 

 

AK.h

 

#ifndef _AK_AK_h

#define _AK_AK_h

 

#include <CtrlLib/CtrlLib.h>

 

using namespace Upp;

 

#define KEYGROUPNAME "AK"

#define KEYNAMESPACE AKKeys

#define KEYFILE      <AK/AK.key>

#include             <CtrlLib/key_header.h>

 

#define KEYGROUPNAME "Setup"

#define KEYFILE      <AK/Setup.key>

#include             <CtrlLib/key_header.h>

 

class App : public TopWindow {

    MenuBar menubar;

 

    void Fn(String text);

    void AkMenu(Bar& menu);

    void SetupMenu(Bar& menu);

    void MainMenu(Bar& menu);

    void SetBar();

    void SetLang(int lang);

 

public:

    typedef App CLASSNAME;

    App();

};

 

#endif

 

 

 

main.cpp

 

#include "AK.h"

 

#define KEYGROUPNAME "AK"

#define KEYNAMESPACE AKKeys

#define KEYFILE      <AK/AK.key>

#include             <CtrlLib/key_source.h>

 

using namespace AKKeys;

 

void App::Fn(String text)

{

    PromptOK(text);

}

 

void App::AkMenu(Bar& menu)

{

    menu.Add(AK_FN1, [=] { Fn("1"); });

    menu.Add(AK_FN2, [=] { Fn("2"); });

    menu.Add(AK_EXIT, [=] { Close(); });

}

 

void App::MainMenu(Bar& menu)

{

    menu.Sub("AK", [=](Bar& bar) { AkMenu(bar); });

    menu.Sub(t_("Setup"), [=](Bar& bar) { SetupMenu(bar); });

}

 

App::App()

{

    SetLang(LNGC_('E','N','U','S', CHARSET_UTF8));

    AddFrame(menubar);

    menubar.Set(THISFN(MainMenu));

    Sizeable();

}

 

GUI_APP_MAIN

{

    String keyfile = ConfigFile("keys.key");

    RestoreKeys(LoadFile(keyfile));

    App().Run();

    SaveFile(keyfile, StoreKeys());

}

 

 

 

setup.cpp

 

#include "AK.h"

 

#define KEYGROUPNAME "Setup"

#define KEYFILE      <AK/Setup.key>

#include             <CtrlLib/key_source.h>

 

void App::SetLang(int lang)

{

    SetLanguage(lang);

    menubar.Set([=] (Bar& bar) { MainMenu(bar); });

}

 

void App::SetupMenu(Bar& menu)

{

    menu.Add(AK_ENGLISH, [=] { SetLang(LNGC_('E','N','U','S', CHARSET_UTF8)); })

        .Radio(GetCurrentLanguage() == LNGC_('E','N','U','S', CHARSET_UTF8));

    menu.Add(AK_CZECH, [=] { SetLang(LNGC_('C','S','C','Z', CHARSET_UTF8)); })

        .Radio(GetCurrentLanguage() == LNGC_('C','S','C','Z', CHARSET_UTF8));

    menu.Separator();

    menu.Add(AK_KEYS, [=] { EditKeys(); });

}

 

 

 

ak.icpp

 

#include "AK.h"

 

#define  TFILE <AK/ak.t>

#include <Core/t.h>

 

 

 

Group1.key

 

KEY(UNTRANSLATED, "Untranslated", K_CTRL_U)

KEY(TRANSLATED, t_("Translated"), K_CTRL_S)

 

 

 

Setup.key

 

KEY(ENGLISH, t_("English"), K_CTRL_E)

KEY(CZECH, t_("Czech"), K_CTRL_R)

KEY(KEYS, t_("Setup keys"), K_CTRL_K)

 

 

 

AK.key

 

KEY(FN1, "First function", K_CTRL_M)

KEY(FN2, t_("Second function"), K_CTRL_W)

KEY(EXIT, t_("Exit"), K_CTRL_Q)

 

 

 

 

Do you want to contribute?