I'm looking for a way how I can change the font of the title in the actionbar before starting the main activity.
My current approach to change the font is the following:
int titleId = getResources().getIdentifier("action_bar_title", "id","android");
TextView textView = (TextView) findViewById(titleId);
textView .setTypeface(Typeface.createFromAsset(getAssets(), "my_font.ttf"));
This block of code is executed at the beginning of the onCreate method of the main activity. Actually, this works pretty well.
However, the small imperfection is only that when the application is launched, the title appears for a very short time in the default font before it changes. In my activity I use the DrawerLayout.
How can I change this behavior so that the text is displayed from the start in the right font?
Thank you for your help.
This is probably not possible. At least I have not found a way to accomplish this.
But I found a workaround that provides the same effect: You can design an image with the title and then define it in the styles.xml as the logo, for example:
...
<item name="android:logo">#drawable/ic_logo</item>
...
When the application is started up, the logo with the title can be removed again. As far as I've seen other apps (eg runtastic) use this technique as well.
Related
I am new to qt and I have an issue I cannot understand.
I have created my own QDialog and now I want to add it to an existing application.
In QT creator, everything works fine but when I add either my custom dialogue or even a
message box to the existing code, something odd happens.
The dialogue works just fine but when I hover over the main area of the dialogue
the icon changes to a Qt::BusyCursor the busy wait icon.
At first I assumed this must be a threading issue but then isn't .exec() suppose to block?
Also when I hover over the title bar or the message box / dialogue, it seems fine i.e it shows a Qt::ArrowCursor, in both cases the dialogue functionally works fine also.
I have tried to set the .setCursor() on both and it did not work still a busy icon.
can anyone give me some hints as to what I might look at to investigate this more.
Thanks a lot!!!
I can suggest you to use
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
and reset it with
QApplication::restoreOverrideCursor();.
I'm rather new to C++, I have a bit of experience with MCV programming in Java. im using GTKmm on C++
What I'm trying to do is writing an application for teaching assistants to submit and edit applications to various positions, and administrators to come in view, and accept these applications.
What I'm trying to do at the begging is create 3 'frames' (I'm working on the submitting application for students only at the moment)
This first will have 2 buttons 1 for selecting if you're a student/admin
Upon clicking you're a student I want to hide this frame and show my second frame
The second frame will have another 2 buttons one for creating an application, and the other for editing applications
My core problem is that I don't understand how to switch between the frames, I've written all the code for my Model, and understand everything I want it to do however I cant seem to find how to do this...
My only idea would be to create windows for each of these, make them look all nice w/e, then when a button is pressed have that window close and a string written to file I can access to see which button has been pressed, then open a new window accordingly. Should I do it like this or is there a better way?
I think I can suggest a better/more idiomatic option for any version >= GTK+ 3.10 - which, to be fair, arrived about half a year after the accepted answer.
If you want to switch between widgets one-at-a-time without any accessories like tabs, then a Gtk::Stack seems like a better option. Because it's specifically geared for one-at-a-time presentation, without any redundancy and (theoretical) overhead from a Notebook's manual tabbing features, which you'd just be disabling straight away! It's a container with multiple children, with one visible at any given moment, and of course methods to change the active child.
You can hook up your own widgets and/or events to manage which of the Stack's children is shown. Alternatively - albeit possibly just restoring the redundancy in this case - there's a StackSwitcher companion widget, which is pretty much a vertical tab-bar as seen in the GTK+ demo and GNOME Tweak Tool.
Easiest way is to use a Notebook widget. You can hide the tabs since you will be controlling which page is showing, using method set_show_tabs(false). Put the top level widget for each of your frames in a pane using method append_page(), and switch between them using set_current_page(). You might want to hide the notebook's bevel if it's distracting, using method set_show_bevel(false).
Use signals to make a widget (e.g. "I'm a student" button) on one page do something (e.g. go to the second page). If you don't know what this means or how to do it, go through the gtkmm tutorial, it will explain this and more.
A bit too late ! But here is my try :
Gtk::Notebook is great but it is not ideal in switching between app frames on menu item clicks. Gtk::Stack, since gtkmm 3.10, exists to mitigate this. Assuming you're using glade and Gtk::Builder :
class
class AppName : public Gtk::ApplicationWindow
{
public:
//...Your app methods and callbacks
void on_mb_itemname_selected(); // The call back for our menu item click/select
private:
//Builder which will help build the app from a .glade file
Glib::RefPtr<Gtk::Builder> _builder;
//...
//Your menu item to activate a particular frame
Gtk::MenuItem * _mb_itemname;
//Your handle to Gtk::Stack which is usually the stack for the whole app
Gtk::Stack * _app_stack;
//...
}
constructor
AppName::AppName(BaseObjectType *cobj,
Glib::RefPtr<Gtk::Builder>& ref_builder)
:Gtk::ApplicationWindow(cobj),_builder(ref_builder)
{
//.. Other setup
_builder->get_widget("your_glade_id_to_stack",_app_stack);
_builder->get_widget("your_glade_id_to_menu_item",_mb_itemname);
// Connect signal_select of our menu item to appropriate signal handler.
mb_itemname->signal_select().connect(
sigc::mem_fun(*this,&AppName::on_mb_itemname_selected));
}
our callback
void AppName::on_mb_itemname_selected()
{
// Change the visible child of the stack concerned.
Gtk::StackTransitionType ttype = STACK_TRANSITION_TYPE_NONE;
_app_stack->set_visible_child("your_widget_name",ttype);
// Note that widget name is not widget glade id.
// You can set your widget under name Packing -> Name
return;
}
I'm trying to build a c++ program that customizes another window title bar, adding colored text and icons. The window I need to customize is in a closed source program.
Right now I can only change the text with SetWindowText, but was unable no find a way to get that level of customization:
Razor Ultima Online Customized Titlebar
The image is from Ultima Online title bar being customized by Razor, a closed source helper program.
Thanks for reading.
Custom drawing and subclassing of other process windows requires DLL injection and hooking to detect the windows creation with subclassing to handle the non client drawing and click/hittest messages..
You should inject you DLL into client.exe process, then override main window function (WndProc), or create new window and make original client's window to be the child of your window.
Writing colored text on the caption is non-trivial task itself, especially if you want support Win7\Vista (however it's doable with GDI).
I'm able to customize the controls of a Qt app in a Qt stylesheet. However, I couldn't find a way to customize the title bar. I found some solutions but that requires modifying the code of the app itself. Is there anyway you could customize it using just the Qt stylesheet?
Title bar isn't a part of your application or Qt and it cannot be configured with stylesheet. Title bar is provided by Window manager. In some WMs there is no title bar at all. Most WMs support customisable themes for window decoration. Usualy you can configure you WM to display specific window with specific theme.
In Qt only QDockWidget's title bar can be configured by stylesheet.
P.S. Some applications disable decoration from window manager and draw title bar itself (example Chromium).
Qt has no control over the appearance of the title bar and border of an application. This is the realm of the Window Manager (WM) in use. Qt can ask the WM to turn it off or only display certain buttons, but that's the extent of it.
The standard procedure for a customized title bar is to remove it, and then create and style your own take on the title bar in its place. To anyone watching, please note that this isn't as cool as you think it is. Some people like to customize their titlebar, most people like it when their application blends in with the rest of their operating environment (which it won't when you're done with it).
Short answer: there's no way to do this to an existing application using Qt stylesheets without changing the application's source code.
How do I have a CEdit control display placeholder text when it's empty, similar to the behavior of NSTextFields in Cocoa?
Ages ago, I wrote a custom paint routine to do it, seemed to work fine.
Sometime after, they introduced SetCueBanner to CEdit, but I can remember it:
a) not working correctly
or -
b) not behaving the way I wanted
Perhaps it will work fine for you. If not, I can see if I can find my old code and post what I did in the custom paint routine.
EDIT
I just checked the Win32 docs, I think this is why I abandoned it:
You cannot set a cue banner on a multiline edit control
you could create a small window over the top of it that contains the placeholder text. Then when the user sets the keyboard focus to it hide the window and if the focus is removed and nothing is in the box then show it.
The SetCueBanner banner function is now working.